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 "tx_vlan set vlan_id (port_id)\n"
289 " Set hardware insertion of VLAN ID in packets sent"
292 "tx_vlan set pvid port_id vlan_id (on|off)\n"
293 " Set port based TX VLAN insertion.\n\n"
295 "tx_vlan reset (port_id)\n"
296 " Disable hardware insertion of a VLAN header in"
297 " packets sent on a port.\n\n"
299 "tx_checksum set mask (port_id)\n"
300 " Enable hardware insertion of checksum offload with"
301 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
302 " bit 0 - insert ip checksum offload if set\n"
303 " bit 1 - insert udp checksum offload if set\n"
304 " bit 2 - insert tcp checksum offload if set\n"
305 " bit 3 - insert sctp checksum offload if set\n"
306 " Please check the NIC datasheet for HW limits.\n\n"
309 " Set packet forwarding mode.\n\n"
311 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
312 " Add a MAC address on port_id.\n\n"
314 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
315 " Remove a MAC address from port_id.\n\n"
317 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
318 " Add a MAC address for a VF on the port.\n\n"
320 "set port (port_id) uta (mac_address|all) (on|off)\n"
321 " Add/Remove a or all unicast hash filter(s)"
324 "set promisc (port_id|all) (on|off)\n"
325 " Set the promiscuous mode on port_id, or all.\n\n"
327 "set allmulti (port_id|all) (on|off)\n"
328 " Set the allmulti mode on port_id, or all.\n\n"
330 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
331 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
332 " (on|off) autoneg (on|off) (port_id)\n"
333 "set flow_ctrl rx (on|off) (portid)\n"
334 "set flow_ctrl tx (on|off) (portid)\n"
335 "set flow_ctrl high_water (high_water) (portid)\n"
336 "set flow_ctrl low_water (low_water) (portid)\n"
337 "set flow_ctrl pause_time (pause_time) (portid)\n"
338 "set flow_ctrl send_xon (send_xon) (portid)\n"
339 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
340 "set flow_ctrl autoneg (on|off) (port_id)\n"
341 " Set the link flow control parameter on a port.\n\n"
343 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
344 " (low_water) (pause_time) (priority) (port_id)\n"
345 " Set the priority flow control parameter on a"
348 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
349 " Set statistics mapping (qmapping 0..15) for RX/TX"
351 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
352 " on port 0 to mapping 5.\n\n"
354 "set port (port_id) vf (vf_id) rx|tx on|off \n"
355 " Enable/Disable a VF receive/tranmit from a port\n\n"
357 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
359 " AUPE:accepts untagged VLAN;"
360 "ROPE:accept unicast hash\n\n"
361 " BAM:accepts broadcast packets;"
362 "MPE:accepts all multicast packets\n\n"
363 " Enable/Disable a VF receive mode of a port\n\n"
365 "set port (port_id) queue (queue_id) rate (rate_num)\n"
366 " Set rate limit for a queue of a port\n\n"
368 "set port (port_id) vf (vf_id) rate (rate_num) "
369 "queue_mask (queue_mask_value)\n"
370 " Set rate limit for queues in VF of a port\n\n"
372 "set port (port_id) mirror-rule (rule_id)"
373 "(pool-mirror|vlan-mirror)\n"
374 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
375 " Set pool or vlan type mirror rule on a port.\n"
376 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
377 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
380 "set port (port_id) mirror-rule (rule_id)"
381 " (uplink-mirror|downlink-mirror) dst-pool"
382 " (pool_id) (on|off)\n"
383 " Set uplink or downlink type mirror rule on a port.\n"
384 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
385 " 0 on' enable mirror income traffic to pool 0.\n\n"
387 "reset port (port_id) mirror-rule (rule_id)\n"
388 " Reset a mirror rule.\n\n"
390 "set flush_rx (on|off)\n"
391 " Flush (default) or don't flush RX streams before"
392 " forwarding. Mainly used with PCAP drivers.\n\n"
394 #ifdef RTE_NIC_BYPASS
395 "set bypass mode (normal|bypass|isolate) (port_id)\n"
396 " Set the bypass mode for the lowest port on bypass enabled"
399 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
400 "mode (normal|bypass|isolate) (port_id)\n"
401 " Set the event required to initiate specified bypass mode for"
402 " the lowest port on a bypass enabled NIC where:\n"
403 " timeout = enable bypass after watchdog timeout.\n"
404 " os_on = enable bypass when OS/board is powered on.\n"
405 " os_off = enable bypass when OS/board is powered off.\n"
406 " power_on = enable bypass when power supply is turned on.\n"
407 " power_off = enable bypass when power supply is turned off."
410 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
411 " Set the bypass watchdog timeout to 'n' seconds"
412 " where 0 = instant.\n\n"
414 "show bypass config (port_id)\n"
415 " Show the bypass configuration for a bypass enabled NIC"
416 " using the lowest port on the NIC.\n\n"
418 #ifdef RTE_LIBRTE_PMD_BOND
419 "create bonded device (mode) (socket)\n"
420 " Create a new bonded device with specific bonding mode and socket.\n\n"
422 "add bonding slave (slave_id) (port_id)\n"
423 " Add a slave device to a bonded device.\n\n"
425 "remove bonding slave (slave_id) (port_id)\n"
426 " Remove a slave device from a bonded device.\n\n"
428 "set bonding mode (value) (port_id)\n"
429 " Set the bonding mode on a bonded device.\n\n"
431 "set bonding primary (slave_id) (port_id)\n"
432 " Set the primary slave for a bonded device.\n\n"
434 "show bonding config (port_id)\n"
435 " Show the bonding config for port_id.\n\n"
437 "set bonding mac_addr (port_id) (address)\n"
438 " Set the MAC address of a bonded device.\n\n"
440 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
441 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
444 , list_pkt_forwarding_modes()
449 if (show_all || !strcmp(res->section, "flowdir")) {
454 "Flow director mode:\n"
455 "-------------------\n\n"
457 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
458 " src (src_ip_address) (src_port)"
459 " dst (dst_ip_address) (dst_port)"
460 " flexbytes (flexbytes_values) vlan (vlan_id)"
461 " queue (queue_id)\n"
462 " Add a signature filter.\n\n"
464 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
465 " src (src_ip_address) (src_port)"
466 " dst (dst_ip_address) (dst_port)"
467 " flexbytes (flexbytes_values) vlan (vlan_id)"
468 " queue (queue_id)\n"
469 " Update a signature filter.\n\n"
471 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
472 " src (src_ip_address) (src_port)"
473 " dst (dst_ip_address) (dst_port)"
474 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
475 " Remove a signature filter.\n\n"
477 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
478 " src (src_ip_address) (src_port)"
479 " dst (dst_ip_address) (dst_port)"
480 " flexbytes (flexbytes_values) vlan (vlan_id)"
481 " queue (queue_id) soft (soft_id)\n"
482 " Add a perfect filter.\n\n"
484 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
485 " src (src_ip_address) (src_port)"
486 " dst (dst_ip_address) (dst_port)"
487 " flexbytes (flexbytes_values) vlan (vlan_id)"
488 " queue (queue_id)\n"
489 " Update a perfect filter.\n\n"
491 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
492 " src (src_ip_address) (src_port)"
493 " dst (dst_ip_address) (dst_port)"
494 " flexbytes (flexbytes_values) vlan (vlan_id)"
496 " Remove a perfect filter.\n\n"
498 "set_masks_filter (port_id) only_ip_flow (0|1)"
499 " src_mask (ip_src_mask) (src_port_mask)"
500 " dst_mask (ip_dst_mask) (dst_port_mask)"
501 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
502 " Set IPv4 filter masks.\n\n"
504 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
505 " src_mask (ip_src_mask) (src_port_mask)"
506 " dst_mask (ip_dst_mask) (dst_port_mask)"
507 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
508 " compare_dst (0|1)\n"
509 " Set IPv6 filter masks.\n\n"
513 if (show_all || !strcmp(res->section, "ports")) {
519 "----------------\n\n"
521 "port start (port_id|all)\n"
522 " Start all ports or port_id.\n\n"
524 "port stop (port_id|all)\n"
525 " Stop all ports or port_id.\n\n"
527 "port close (port_id|all)\n"
528 " Close all ports or port_id.\n\n"
530 "port config (port_id|all)"
531 " speed (10|100|1000|10000|40000|auto)"
532 " duplex (half|full|auto)\n"
533 " Set speed and duplex for all ports or port_id\n\n"
535 "port config all (rxq|txq|rxd|txd) (value)\n"
536 " Set number for rxq/txq/rxd/txd.\n\n"
538 "port config all max-pkt-len (value)\n"
539 " Set the max packet length.\n\n"
541 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
543 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
546 "port config all rss (ip|udp|none)\n"
547 " Set the RSS mode.\n\n"
549 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
550 " Set the RSS redirection table.\n\n"
552 "port config (port_id) dcb vt (on|off) (traffic_class)"
554 " Set the DCB mode.\n\n"
556 "port config all burst (value)\n"
557 " Set the number of packets per burst.\n\n"
559 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
561 " Set the ring prefetch/host/writeback threshold"
562 " for tx/rx queue.\n\n"
564 "port config all (txfreet|txrst|rxfreet) (value)\n"
565 " Set free threshold for rx/tx, or set"
566 " tx rs bit threshold.\n\n"
567 "port config mtu X value\n"
568 " Set the MTU of port X to a given value\n\n"
570 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
571 " Start/stop a rx/tx queue of port X. Only take effect"
572 " when port X is started\n"
576 if (show_all || !strcmp(res->section, "registers")) {
584 "read reg (port_id) (address)\n"
585 " Display value of a port register.\n\n"
587 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
588 " Display a port register bit field.\n\n"
590 "read regbit (port_id) (address) (bit_x)\n"
591 " Display a single port register bit.\n\n"
593 "write reg (port_id) (address) (value)\n"
594 " Set value of a port register.\n\n"
596 "write regfield (port_id) (address) (bit_x) (bit_y)"
598 " Set bit field of a port register.\n\n"
600 "write regbit (port_id) (address) (bit_x) (value)\n"
601 " Set single bit value of a port register.\n\n"
604 if (show_all || !strcmp(res->section, "filters")) {
612 "add_ethertype_filter (port_id) ethertype (eth_value)"
613 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
614 " add an ethertype filter.\n\n"
616 "remove_ethertype_filter (port_id) index (idx)\n"
617 " remove an ethertype filter.\n\n"
619 "get_ethertype_filter (port_id) index (idx)\n"
620 " get info of a ethertype filter.\n\n"
622 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
623 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
624 " queue (queue_id) index (idx)\n"
625 " add a 2tuple filter.\n\n"
627 "remove_2tuple_filter (port_id) index (idx)\n"
628 " remove a 2tuple filter.\n\n"
630 "get_2tuple_filter (port_id) index (idx)\n"
631 " get info of a 2tuple filter.\n\n"
633 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
634 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
635 " mask (mask_value) flags (flags_value) priority (prio_value)"
636 " queue (queue_id) index (idx)\n"
637 " add a 5tuple filter.\n\n"
639 "remove_5tuple_filter (port_id) index (idx)\n"
640 " remove a 5tuple filter.\n\n"
642 "get_5tuple_filter (port_id) index (idx)\n"
643 " get info of a 5tuple filter.\n\n"
645 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
646 " add syn filter.\n\n"
648 "remove_syn_filter (port_id)"
649 " remove syn filter.\n\n"
651 "get_syn_filter (port_id) "
652 " get syn filter info.\n\n"
654 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
655 " priority (prio_value) queue (queue_id) index (idx)\n"
656 " add a flex filter.\n\n"
658 "remove_flex_filter (port_id) index (idx)\n"
659 " remove a flex filter.\n\n"
661 "get_flex_filter (port_id) index (idx)\n"
662 " get info of a flex filter.\n\n"
667 cmdline_parse_token_string_t cmd_help_long_help =
668 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
670 cmdline_parse_token_string_t cmd_help_long_section =
671 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
672 "all#control#display#config#flowdir#"
673 "ports#registers#filters");
675 cmdline_parse_inst_t cmd_help_long = {
676 .f = cmd_help_long_parsed,
678 .help_str = "show help",
680 (void *)&cmd_help_long_help,
681 (void *)&cmd_help_long_section,
687 /* *** start/stop/close all ports *** */
688 struct cmd_operate_port_result {
689 cmdline_fixed_string_t keyword;
690 cmdline_fixed_string_t name;
691 cmdline_fixed_string_t value;
694 static void cmd_operate_port_parsed(void *parsed_result,
695 __attribute__((unused)) struct cmdline *cl,
696 __attribute__((unused)) void *data)
698 struct cmd_operate_port_result *res = parsed_result;
700 if (!strcmp(res->name, "start"))
701 start_port(RTE_PORT_ALL);
702 else if (!strcmp(res->name, "stop"))
703 stop_port(RTE_PORT_ALL);
704 else if (!strcmp(res->name, "close"))
705 close_port(RTE_PORT_ALL);
707 printf("Unknown parameter\n");
710 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
711 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
713 cmdline_parse_token_string_t cmd_operate_port_all_port =
714 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
716 cmdline_parse_token_string_t cmd_operate_port_all_all =
717 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
719 cmdline_parse_inst_t cmd_operate_port = {
720 .f = cmd_operate_port_parsed,
722 .help_str = "port start|stop|close all: start/stop/close all ports",
724 (void *)&cmd_operate_port_all_cmd,
725 (void *)&cmd_operate_port_all_port,
726 (void *)&cmd_operate_port_all_all,
731 /* *** start/stop/close specific port *** */
732 struct cmd_operate_specific_port_result {
733 cmdline_fixed_string_t keyword;
734 cmdline_fixed_string_t name;
738 static void cmd_operate_specific_port_parsed(void *parsed_result,
739 __attribute__((unused)) struct cmdline *cl,
740 __attribute__((unused)) void *data)
742 struct cmd_operate_specific_port_result *res = parsed_result;
744 if (!strcmp(res->name, "start"))
745 start_port(res->value);
746 else if (!strcmp(res->name, "stop"))
747 stop_port(res->value);
748 else if (!strcmp(res->name, "close"))
749 close_port(res->value);
751 printf("Unknown parameter\n");
754 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
755 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
757 cmdline_parse_token_string_t cmd_operate_specific_port_port =
758 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
759 name, "start#stop#close");
760 cmdline_parse_token_num_t cmd_operate_specific_port_id =
761 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
764 cmdline_parse_inst_t cmd_operate_specific_port = {
765 .f = cmd_operate_specific_port_parsed,
767 .help_str = "port start|stop|close X: start/stop/close port X",
769 (void *)&cmd_operate_specific_port_cmd,
770 (void *)&cmd_operate_specific_port_port,
771 (void *)&cmd_operate_specific_port_id,
776 /* *** configure speed for all ports *** */
777 struct cmd_config_speed_all {
778 cmdline_fixed_string_t port;
779 cmdline_fixed_string_t keyword;
780 cmdline_fixed_string_t all;
781 cmdline_fixed_string_t item1;
782 cmdline_fixed_string_t item2;
783 cmdline_fixed_string_t value1;
784 cmdline_fixed_string_t value2;
788 cmd_config_speed_all_parsed(void *parsed_result,
789 __attribute__((unused)) struct cmdline *cl,
790 __attribute__((unused)) void *data)
792 struct cmd_config_speed_all *res = parsed_result;
793 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
794 uint16_t link_duplex = 0;
797 if (!all_ports_stopped()) {
798 printf("Please stop all ports first\n");
802 if (!strcmp(res->value1, "10"))
803 link_speed = ETH_LINK_SPEED_10;
804 else if (!strcmp(res->value1, "100"))
805 link_speed = ETH_LINK_SPEED_100;
806 else if (!strcmp(res->value1, "1000"))
807 link_speed = ETH_LINK_SPEED_1000;
808 else if (!strcmp(res->value1, "10000"))
809 link_speed = ETH_LINK_SPEED_10G;
810 else if (!strcmp(res->value1, "40000"))
811 link_speed = ETH_LINK_SPEED_40G;
812 else if (!strcmp(res->value1, "auto"))
813 link_speed = ETH_LINK_SPEED_AUTONEG;
815 printf("Unknown parameter\n");
819 if (!strcmp(res->value2, "half"))
820 link_duplex = ETH_LINK_HALF_DUPLEX;
821 else if (!strcmp(res->value2, "full"))
822 link_duplex = ETH_LINK_FULL_DUPLEX;
823 else if (!strcmp(res->value2, "auto"))
824 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
826 printf("Unknown parameter\n");
830 for (pid = 0; pid < nb_ports; pid++) {
831 ports[pid].dev_conf.link_speed = link_speed;
832 ports[pid].dev_conf.link_duplex = link_duplex;
835 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
838 cmdline_parse_token_string_t cmd_config_speed_all_port =
839 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
840 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
841 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
843 cmdline_parse_token_string_t cmd_config_speed_all_all =
844 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
845 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
846 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
847 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
848 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
849 "10#100#1000#10000#40000#auto");
850 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
851 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
852 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
853 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
856 cmdline_parse_inst_t cmd_config_speed_all = {
857 .f = cmd_config_speed_all_parsed,
859 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
862 (void *)&cmd_config_speed_all_port,
863 (void *)&cmd_config_speed_all_keyword,
864 (void *)&cmd_config_speed_all_all,
865 (void *)&cmd_config_speed_all_item1,
866 (void *)&cmd_config_speed_all_value1,
867 (void *)&cmd_config_speed_all_item2,
868 (void *)&cmd_config_speed_all_value2,
873 /* *** configure speed for specific port *** */
874 struct cmd_config_speed_specific {
875 cmdline_fixed_string_t port;
876 cmdline_fixed_string_t keyword;
878 cmdline_fixed_string_t item1;
879 cmdline_fixed_string_t item2;
880 cmdline_fixed_string_t value1;
881 cmdline_fixed_string_t value2;
885 cmd_config_speed_specific_parsed(void *parsed_result,
886 __attribute__((unused)) struct cmdline *cl,
887 __attribute__((unused)) void *data)
889 struct cmd_config_speed_specific *res = parsed_result;
890 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
891 uint16_t link_duplex = 0;
893 if (!all_ports_stopped()) {
894 printf("Please stop all ports first\n");
898 if (res->id >= nb_ports) {
899 printf("Port id %d must be less than %d\n", res->id, nb_ports);
903 if (!strcmp(res->value1, "10"))
904 link_speed = ETH_LINK_SPEED_10;
905 else if (!strcmp(res->value1, "100"))
906 link_speed = ETH_LINK_SPEED_100;
907 else if (!strcmp(res->value1, "1000"))
908 link_speed = ETH_LINK_SPEED_1000;
909 else if (!strcmp(res->value1, "10000"))
910 link_speed = ETH_LINK_SPEED_10000;
911 else if (!strcmp(res->value1, "40000"))
912 link_speed = ETH_LINK_SPEED_40G;
913 else if (!strcmp(res->value1, "auto"))
914 link_speed = ETH_LINK_SPEED_AUTONEG;
916 printf("Unknown parameter\n");
920 if (!strcmp(res->value2, "half"))
921 link_duplex = ETH_LINK_HALF_DUPLEX;
922 else if (!strcmp(res->value2, "full"))
923 link_duplex = ETH_LINK_FULL_DUPLEX;
924 else if (!strcmp(res->value2, "auto"))
925 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
927 printf("Unknown parameter\n");
931 ports[res->id].dev_conf.link_speed = link_speed;
932 ports[res->id].dev_conf.link_duplex = link_duplex;
934 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
938 cmdline_parse_token_string_t cmd_config_speed_specific_port =
939 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
941 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
942 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
944 cmdline_parse_token_num_t cmd_config_speed_specific_id =
945 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
946 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
947 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
949 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
950 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
951 "10#100#1000#10000#40000#auto");
952 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
955 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
959 cmdline_parse_inst_t cmd_config_speed_specific = {
960 .f = cmd_config_speed_specific_parsed,
962 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
965 (void *)&cmd_config_speed_specific_port,
966 (void *)&cmd_config_speed_specific_keyword,
967 (void *)&cmd_config_speed_specific_id,
968 (void *)&cmd_config_speed_specific_item1,
969 (void *)&cmd_config_speed_specific_value1,
970 (void *)&cmd_config_speed_specific_item2,
971 (void *)&cmd_config_speed_specific_value2,
976 /* *** configure txq/rxq, txd/rxd *** */
977 struct cmd_config_rx_tx {
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t keyword;
980 cmdline_fixed_string_t all;
981 cmdline_fixed_string_t name;
986 cmd_config_rx_tx_parsed(void *parsed_result,
987 __attribute__((unused)) struct cmdline *cl,
988 __attribute__((unused)) void *data)
990 struct cmd_config_rx_tx *res = parsed_result;
992 if (!all_ports_stopped()) {
993 printf("Please stop all ports first\n");
997 if (!strcmp(res->name, "rxq")) {
998 if (res->value <= 0) {
999 printf("rxq %d invalid - must be > 0\n", res->value);
1002 nb_rxq = res->value;
1004 else if (!strcmp(res->name, "txq")) {
1005 if (res->value <= 0) {
1006 printf("txq %d invalid - must be > 0\n", res->value);
1009 nb_txq = res->value;
1011 else if (!strcmp(res->name, "rxd")) {
1012 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1013 printf("rxd %d invalid - must be > 0 && <= %d\n",
1014 res->value, RTE_TEST_RX_DESC_MAX);
1017 nb_rxd = res->value;
1018 } else if (!strcmp(res->name, "txd")) {
1019 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1020 printf("txd %d invalid - must be > 0 && <= %d\n",
1021 res->value, RTE_TEST_TX_DESC_MAX);
1024 nb_txd = res->value;
1026 printf("Unknown parameter\n");
1032 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1035 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1036 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1037 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1038 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1039 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1040 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1041 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1042 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1044 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1045 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1047 cmdline_parse_inst_t cmd_config_rx_tx = {
1048 .f = cmd_config_rx_tx_parsed,
1050 .help_str = "port config all rxq|txq|rxd|txd value",
1052 (void *)&cmd_config_rx_tx_port,
1053 (void *)&cmd_config_rx_tx_keyword,
1054 (void *)&cmd_config_rx_tx_all,
1055 (void *)&cmd_config_rx_tx_name,
1056 (void *)&cmd_config_rx_tx_value,
1061 /* *** config max packet length *** */
1062 struct cmd_config_max_pkt_len_result {
1063 cmdline_fixed_string_t port;
1064 cmdline_fixed_string_t keyword;
1065 cmdline_fixed_string_t all;
1066 cmdline_fixed_string_t name;
1071 cmd_config_max_pkt_len_parsed(void *parsed_result,
1072 __attribute__((unused)) struct cmdline *cl,
1073 __attribute__((unused)) void *data)
1075 struct cmd_config_max_pkt_len_result *res = parsed_result;
1077 if (!all_ports_stopped()) {
1078 printf("Please stop all ports first\n");
1082 if (!strcmp(res->name, "max-pkt-len")) {
1083 if (res->value < ETHER_MIN_LEN) {
1084 printf("max-pkt-len can not be less than %d\n",
1088 if (res->value == rx_mode.max_rx_pkt_len)
1091 rx_mode.max_rx_pkt_len = res->value;
1092 if (res->value > ETHER_MAX_LEN)
1093 rx_mode.jumbo_frame = 1;
1095 rx_mode.jumbo_frame = 0;
1097 printf("Unknown parameter\n");
1103 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1106 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1109 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1112 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1115 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1118 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1119 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1122 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1123 .f = cmd_config_max_pkt_len_parsed,
1125 .help_str = "port config all max-pkt-len value",
1127 (void *)&cmd_config_max_pkt_len_port,
1128 (void *)&cmd_config_max_pkt_len_keyword,
1129 (void *)&cmd_config_max_pkt_len_all,
1130 (void *)&cmd_config_max_pkt_len_name,
1131 (void *)&cmd_config_max_pkt_len_value,
1136 /* *** configure port MTU *** */
1137 struct cmd_config_mtu_result {
1138 cmdline_fixed_string_t port;
1139 cmdline_fixed_string_t keyword;
1140 cmdline_fixed_string_t mtu;
1146 cmd_config_mtu_parsed(void *parsed_result,
1147 __attribute__((unused)) struct cmdline *cl,
1148 __attribute__((unused)) void *data)
1150 struct cmd_config_mtu_result *res = parsed_result;
1152 if (res->value < ETHER_MIN_LEN) {
1153 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1156 port_mtu_set(res->port_id, res->value);
1159 cmdline_parse_token_string_t cmd_config_mtu_port =
1160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1162 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1165 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1166 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1168 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1169 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1170 cmdline_parse_token_num_t cmd_config_mtu_value =
1171 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1173 cmdline_parse_inst_t cmd_config_mtu = {
1174 .f = cmd_config_mtu_parsed,
1176 .help_str = "port config mtu value",
1178 (void *)&cmd_config_mtu_port,
1179 (void *)&cmd_config_mtu_keyword,
1180 (void *)&cmd_config_mtu_mtu,
1181 (void *)&cmd_config_mtu_port_id,
1182 (void *)&cmd_config_mtu_value,
1187 /* *** configure rx mode *** */
1188 struct cmd_config_rx_mode_flag {
1189 cmdline_fixed_string_t port;
1190 cmdline_fixed_string_t keyword;
1191 cmdline_fixed_string_t all;
1192 cmdline_fixed_string_t name;
1193 cmdline_fixed_string_t value;
1197 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1198 __attribute__((unused)) struct cmdline *cl,
1199 __attribute__((unused)) void *data)
1201 struct cmd_config_rx_mode_flag *res = parsed_result;
1203 if (!all_ports_stopped()) {
1204 printf("Please stop all ports first\n");
1208 if (!strcmp(res->name, "crc-strip")) {
1209 if (!strcmp(res->value, "on"))
1210 rx_mode.hw_strip_crc = 1;
1211 else if (!strcmp(res->value, "off"))
1212 rx_mode.hw_strip_crc = 0;
1214 printf("Unknown parameter\n");
1217 } else if (!strcmp(res->name, "rx-cksum")) {
1218 if (!strcmp(res->value, "on"))
1219 rx_mode.hw_ip_checksum = 1;
1220 else if (!strcmp(res->value, "off"))
1221 rx_mode.hw_ip_checksum = 0;
1223 printf("Unknown parameter\n");
1226 } else if (!strcmp(res->name, "hw-vlan")) {
1227 if (!strcmp(res->value, "on")) {
1228 rx_mode.hw_vlan_filter = 1;
1229 rx_mode.hw_vlan_strip = 1;
1231 else if (!strcmp(res->value, "off")) {
1232 rx_mode.hw_vlan_filter = 0;
1233 rx_mode.hw_vlan_strip = 0;
1236 printf("Unknown parameter\n");
1239 } else if (!strcmp(res->name, "drop-en")) {
1240 if (!strcmp(res->value, "on"))
1242 else if (!strcmp(res->value, "off"))
1245 printf("Unknown parameter\n");
1249 printf("Unknown parameter\n");
1255 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1258 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1259 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1260 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1263 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1265 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1266 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1267 "crc-strip#rx-cksum#hw-vlan");
1268 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1272 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1273 .f = cmd_config_rx_mode_flag_parsed,
1275 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1277 (void *)&cmd_config_rx_mode_flag_port,
1278 (void *)&cmd_config_rx_mode_flag_keyword,
1279 (void *)&cmd_config_rx_mode_flag_all,
1280 (void *)&cmd_config_rx_mode_flag_name,
1281 (void *)&cmd_config_rx_mode_flag_value,
1286 /* *** configure rss *** */
1287 struct cmd_config_rss {
1288 cmdline_fixed_string_t port;
1289 cmdline_fixed_string_t keyword;
1290 cmdline_fixed_string_t all;
1291 cmdline_fixed_string_t name;
1292 cmdline_fixed_string_t value;
1296 cmd_config_rss_parsed(void *parsed_result,
1297 __attribute__((unused)) struct cmdline *cl,
1298 __attribute__((unused)) void *data)
1300 struct cmd_config_rss *res = parsed_result;
1301 struct rte_eth_rss_conf rss_conf;
1304 if (!strcmp(res->value, "ip"))
1305 rss_conf.rss_hf = ETH_RSS_IP;
1306 else if (!strcmp(res->value, "udp"))
1307 rss_conf.rss_hf = ETH_RSS_UDP;
1308 else if (!strcmp(res->value, "none"))
1309 rss_conf.rss_hf = 0;
1311 printf("Unknown parameter\n");
1314 rss_conf.rss_key = NULL;
1315 for (i = 0; i < rte_eth_dev_count(); i++)
1316 rte_eth_dev_rss_hash_update(i, &rss_conf);
1319 cmdline_parse_token_string_t cmd_config_rss_port =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1321 cmdline_parse_token_string_t cmd_config_rss_keyword =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1323 cmdline_parse_token_string_t cmd_config_rss_all =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1325 cmdline_parse_token_string_t cmd_config_rss_name =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1327 cmdline_parse_token_string_t cmd_config_rss_value =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1330 cmdline_parse_inst_t cmd_config_rss = {
1331 .f = cmd_config_rss_parsed,
1333 .help_str = "port config all rss ip|udp|none",
1335 (void *)&cmd_config_rss_port,
1336 (void *)&cmd_config_rss_keyword,
1337 (void *)&cmd_config_rss_all,
1338 (void *)&cmd_config_rss_name,
1339 (void *)&cmd_config_rss_value,
1344 /* *** configure rss hash key *** */
1345 struct cmd_config_rss_hash_key {
1346 cmdline_fixed_string_t port;
1347 cmdline_fixed_string_t config;
1349 cmdline_fixed_string_t rss_hash_key;
1350 cmdline_fixed_string_t key;
1353 #define RSS_HASH_KEY_LENGTH 40
1355 hexa_digit_to_value(char hexa_digit)
1357 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1358 return (uint8_t) (hexa_digit - '0');
1359 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1360 return (uint8_t) ((hexa_digit - 'a') + 10);
1361 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1362 return (uint8_t) ((hexa_digit - 'A') + 10);
1363 /* Invalid hexa digit */
1368 parse_and_check_key_hexa_digit(char *key, int idx)
1372 hexa_v = hexa_digit_to_value(key[idx]);
1374 printf("invalid key: character %c at position %d is not a "
1375 "valid hexa digit\n", key[idx], idx);
1380 cmd_config_rss_hash_key_parsed(void *parsed_result,
1381 __attribute__((unused)) struct cmdline *cl,
1382 __attribute__((unused)) void *data)
1384 struct cmd_config_rss_hash_key *res = parsed_result;
1385 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1390 /* Check the length of the RSS hash key */
1391 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1392 printf("key length: %d invalid - key must be a string of %d"
1393 "hexa-decimal numbers\n", (int) strlen(res->key),
1394 RSS_HASH_KEY_LENGTH * 2);
1397 /* Translate RSS hash key into binary representation */
1398 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1399 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1402 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1405 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1407 port_rss_hash_key_update(res->port_id, hash_key);
1410 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1412 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1415 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1416 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1417 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1419 rss_hash_key, "rss-hash-key");
1420 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1423 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1424 .f = cmd_config_rss_hash_key_parsed,
1426 .help_str = "port config X rss-hash-key 80 hexa digits",
1428 (void *)&cmd_config_rss_hash_key_port,
1429 (void *)&cmd_config_rss_hash_key_config,
1430 (void *)&cmd_config_rss_hash_key_port_id,
1431 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1432 (void *)&cmd_config_rss_hash_key_value,
1437 /* *** configure port rxq/txq start/stop *** */
1438 struct cmd_config_rxtx_queue {
1439 cmdline_fixed_string_t port;
1441 cmdline_fixed_string_t rxtxq;
1443 cmdline_fixed_string_t opname;
1447 cmd_config_rxtx_queue_parsed(void *parsed_result,
1448 __attribute__((unused)) struct cmdline *cl,
1449 __attribute__((unused)) void *data)
1451 struct cmd_config_rxtx_queue *res = parsed_result;
1456 if (test_done == 0) {
1457 printf("Please stop forwarding first\n");
1461 if (port_id_is_invalid(res->portid))
1464 if (port_is_started(res->portid) != 1) {
1465 printf("Please start port %u first\n", res->portid);
1469 if (!strcmp(res->rxtxq, "rxq"))
1471 else if (!strcmp(res->rxtxq, "txq"))
1474 printf("Unknown parameter\n");
1478 if (isrx && rx_queue_id_is_invalid(res->qid))
1480 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1483 if (!strcmp(res->opname, "start"))
1485 else if (!strcmp(res->opname, "stop"))
1488 printf("Unknown parameter\n");
1492 if (isstart && isrx)
1493 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1494 else if (!isstart && isrx)
1495 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1496 else if (isstart && !isrx)
1497 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1499 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1501 if (ret == -ENOTSUP)
1502 printf("Function not supported in PMD driver\n");
1505 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1506 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1507 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1508 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1509 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1510 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1511 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1512 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1513 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1514 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1517 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1518 .f = cmd_config_rxtx_queue_parsed,
1520 .help_str = "port X rxq|txq ID start|stop",
1522 (void *)&cmd_config_speed_all_port,
1523 (void *)&cmd_config_rxtx_queue_portid,
1524 (void *)&cmd_config_rxtx_queue_rxtxq,
1525 (void *)&cmd_config_rxtx_queue_qid,
1526 (void *)&cmd_config_rxtx_queue_opname,
1531 /* *** Configure RSS RETA *** */
1532 struct cmd_config_rss_reta {
1533 cmdline_fixed_string_t port;
1534 cmdline_fixed_string_t keyword;
1536 cmdline_fixed_string_t name;
1537 cmdline_fixed_string_t list_name;
1538 cmdline_fixed_string_t list_of_items;
1542 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1549 const char *p, *p0 = str;
1556 unsigned long int_fld[_NUM_FLD];
1557 char *str_fld[_NUM_FLD];
1559 while ((p = strchr(p0,'(')) != NULL) {
1561 if((p0 = strchr(p,')')) == NULL)
1565 if(size >= sizeof(s))
1568 snprintf(s, sizeof(s), "%.*s", size, p);
1569 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1571 for (i = 0; i < _NUM_FLD; i++) {
1573 int_fld[i] = strtoul(str_fld[i], &end, 0);
1574 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1578 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1579 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1581 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1582 printf("Invalid RETA hash index=%d",hash_index);
1586 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1587 reta_conf->mask_lo |= (1ULL << hash_index);
1589 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1591 reta_conf->reta[hash_index] = nb_queue;
1598 cmd_set_rss_reta_parsed(void *parsed_result,
1599 __attribute__((unused)) struct cmdline *cl,
1600 __attribute__((unused)) void *data)
1603 struct rte_eth_rss_reta reta_conf;
1604 struct cmd_config_rss_reta *res = parsed_result;
1606 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1607 if (!strcmp(res->list_name, "reta")) {
1608 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1609 printf("Invalid RSS Redirection Table config entered\n");
1612 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1614 printf("Bad redirection table parameter, return code = %d \n",ret);
1618 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1620 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1622 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1623 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1624 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1626 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1628 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1631 cmdline_parse_inst_t cmd_config_rss_reta = {
1632 .f = cmd_set_rss_reta_parsed,
1634 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1636 (void *)&cmd_config_rss_reta_port,
1637 (void *)&cmd_config_rss_reta_keyword,
1638 (void *)&cmd_config_rss_reta_port_id,
1639 (void *)&cmd_config_rss_reta_name,
1640 (void *)&cmd_config_rss_reta_list_name,
1641 (void *)&cmd_config_rss_reta_list_of_items,
1646 /* *** SHOW PORT RETA INFO *** */
1647 struct cmd_showport_reta {
1648 cmdline_fixed_string_t show;
1649 cmdline_fixed_string_t port;
1651 cmdline_fixed_string_t rss;
1652 cmdline_fixed_string_t reta;
1657 static void cmd_showport_reta_parsed(void *parsed_result,
1658 __attribute__((unused)) struct cmdline *cl,
1659 __attribute__((unused)) void *data)
1661 struct cmd_showport_reta *res = parsed_result;
1662 struct rte_eth_rss_reta reta_conf;
1664 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1665 printf("Invalid RSS Redirection Table config entered\n");
1669 reta_conf.mask_lo = res->mask_lo;
1670 reta_conf.mask_hi = res->mask_hi;
1672 port_rss_reta_info(res->port_id,&reta_conf);
1675 cmdline_parse_token_string_t cmd_showport_reta_show =
1676 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1677 cmdline_parse_token_string_t cmd_showport_reta_port =
1678 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1679 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1680 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1681 cmdline_parse_token_string_t cmd_showport_reta_rss =
1682 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1683 cmdline_parse_token_string_t cmd_showport_reta_reta =
1684 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1685 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1686 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1687 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1688 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1690 cmdline_parse_inst_t cmd_showport_reta = {
1691 .f = cmd_showport_reta_parsed,
1693 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1694 (mask_lo and mask_hi is UINT64)",
1696 (void *)&cmd_showport_reta_show,
1697 (void *)&cmd_showport_reta_port,
1698 (void *)&cmd_showport_reta_port_id,
1699 (void *)&cmd_showport_reta_rss,
1700 (void *)&cmd_showport_reta_reta,
1701 (void *)&cmd_showport_reta_mask_lo,
1702 (void *)&cmd_showport_reta_mask_hi,
1707 /* *** Show RSS hash configuration *** */
1708 struct cmd_showport_rss_hash {
1709 cmdline_fixed_string_t show;
1710 cmdline_fixed_string_t port;
1712 cmdline_fixed_string_t rss_hash;
1713 cmdline_fixed_string_t key; /* optional argument */
1716 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1717 __attribute__((unused)) struct cmdline *cl,
1720 struct cmd_showport_rss_hash *res = parsed_result;
1722 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1725 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1726 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1727 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1728 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1729 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1730 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1731 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1732 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1734 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1735 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1737 cmdline_parse_inst_t cmd_showport_rss_hash = {
1738 .f = cmd_showport_rss_hash_parsed,
1740 .help_str = "show port X rss-hash (X = port number)\n",
1742 (void *)&cmd_showport_rss_hash_show,
1743 (void *)&cmd_showport_rss_hash_port,
1744 (void *)&cmd_showport_rss_hash_port_id,
1745 (void *)&cmd_showport_rss_hash_rss_hash,
1750 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1751 .f = cmd_showport_rss_hash_parsed,
1753 .help_str = "show port X rss-hash key (X = port number)\n",
1755 (void *)&cmd_showport_rss_hash_show,
1756 (void *)&cmd_showport_rss_hash_port,
1757 (void *)&cmd_showport_rss_hash_port_id,
1758 (void *)&cmd_showport_rss_hash_rss_hash,
1759 (void *)&cmd_showport_rss_hash_rss_key,
1764 /* *** Configure DCB *** */
1765 struct cmd_config_dcb {
1766 cmdline_fixed_string_t port;
1767 cmdline_fixed_string_t config;
1769 cmdline_fixed_string_t dcb;
1770 cmdline_fixed_string_t vt;
1771 cmdline_fixed_string_t vt_en;
1773 cmdline_fixed_string_t pfc;
1774 cmdline_fixed_string_t pfc_en;
1778 cmd_config_dcb_parsed(void *parsed_result,
1779 __attribute__((unused)) struct cmdline *cl,
1780 __attribute__((unused)) void *data)
1782 struct cmd_config_dcb *res = parsed_result;
1783 struct dcb_config dcb_conf;
1784 portid_t port_id = res->port_id;
1785 struct rte_port *port;
1787 port = &ports[port_id];
1788 /** Check if the port is not started **/
1789 if (port->port_status != RTE_PORT_STOPPED) {
1790 printf("Please stop port %d first\n",port_id);
1794 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1795 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1796 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1800 /* DCB in VT mode */
1801 if (!strncmp(res->vt_en, "on",2))
1802 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1804 dcb_conf.dcb_mode = DCB_ENABLED;
1806 if (!strncmp(res->pfc_en, "on",2)) {
1807 dcb_conf.pfc_en = 1;
1810 dcb_conf.pfc_en = 0;
1812 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1813 printf("Cannot initialize network ports\n");
1817 cmd_reconfig_device_queue(port_id, 1, 1);
1820 cmdline_parse_token_string_t cmd_config_dcb_port =
1821 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1822 cmdline_parse_token_string_t cmd_config_dcb_config =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1824 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1825 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1826 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1828 cmdline_parse_token_string_t cmd_config_dcb_vt =
1829 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1830 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1831 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1832 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1833 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1834 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1836 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1839 cmdline_parse_inst_t cmd_config_dcb = {
1840 .f = cmd_config_dcb_parsed,
1842 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1844 (void *)&cmd_config_dcb_port,
1845 (void *)&cmd_config_dcb_config,
1846 (void *)&cmd_config_dcb_port_id,
1847 (void *)&cmd_config_dcb_dcb,
1848 (void *)&cmd_config_dcb_vt,
1849 (void *)&cmd_config_dcb_vt_en,
1850 (void *)&cmd_config_dcb_num_tcs,
1851 (void *)&cmd_config_dcb_pfc,
1852 (void *)&cmd_config_dcb_pfc_en,
1857 /* *** configure number of packets per burst *** */
1858 struct cmd_config_burst {
1859 cmdline_fixed_string_t port;
1860 cmdline_fixed_string_t keyword;
1861 cmdline_fixed_string_t all;
1862 cmdline_fixed_string_t name;
1867 cmd_config_burst_parsed(void *parsed_result,
1868 __attribute__((unused)) struct cmdline *cl,
1869 __attribute__((unused)) void *data)
1871 struct cmd_config_burst *res = parsed_result;
1873 if (!all_ports_stopped()) {
1874 printf("Please stop all ports first\n");
1878 if (!strcmp(res->name, "burst")) {
1879 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1880 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1883 nb_pkt_per_burst = res->value;
1885 printf("Unknown parameter\n");
1891 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1894 cmdline_parse_token_string_t cmd_config_burst_port =
1895 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1896 cmdline_parse_token_string_t cmd_config_burst_keyword =
1897 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1898 cmdline_parse_token_string_t cmd_config_burst_all =
1899 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1900 cmdline_parse_token_string_t cmd_config_burst_name =
1901 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1902 cmdline_parse_token_num_t cmd_config_burst_value =
1903 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1905 cmdline_parse_inst_t cmd_config_burst = {
1906 .f = cmd_config_burst_parsed,
1908 .help_str = "port config all burst value",
1910 (void *)&cmd_config_burst_port,
1911 (void *)&cmd_config_burst_keyword,
1912 (void *)&cmd_config_burst_all,
1913 (void *)&cmd_config_burst_name,
1914 (void *)&cmd_config_burst_value,
1919 /* *** configure rx/tx queues *** */
1920 struct cmd_config_thresh {
1921 cmdline_fixed_string_t port;
1922 cmdline_fixed_string_t keyword;
1923 cmdline_fixed_string_t all;
1924 cmdline_fixed_string_t name;
1929 cmd_config_thresh_parsed(void *parsed_result,
1930 __attribute__((unused)) struct cmdline *cl,
1931 __attribute__((unused)) void *data)
1933 struct cmd_config_thresh *res = parsed_result;
1935 if (!all_ports_stopped()) {
1936 printf("Please stop all ports first\n");
1940 if (!strcmp(res->name, "txpt"))
1941 tx_thresh.pthresh = res->value;
1942 else if(!strcmp(res->name, "txht"))
1943 tx_thresh.hthresh = res->value;
1944 else if(!strcmp(res->name, "txwt"))
1945 tx_thresh.wthresh = res->value;
1946 else if(!strcmp(res->name, "rxpt"))
1947 rx_thresh.pthresh = res->value;
1948 else if(!strcmp(res->name, "rxht"))
1949 rx_thresh.hthresh = res->value;
1950 else if(!strcmp(res->name, "rxwt"))
1951 rx_thresh.wthresh = res->value;
1953 printf("Unknown parameter\n");
1959 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1962 cmdline_parse_token_string_t cmd_config_thresh_port =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1964 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1965 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1966 cmdline_parse_token_string_t cmd_config_thresh_all =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1968 cmdline_parse_token_string_t cmd_config_thresh_name =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1970 "txpt#txht#txwt#rxpt#rxht#rxwt");
1971 cmdline_parse_token_num_t cmd_config_thresh_value =
1972 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1974 cmdline_parse_inst_t cmd_config_thresh = {
1975 .f = cmd_config_thresh_parsed,
1977 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1979 (void *)&cmd_config_thresh_port,
1980 (void *)&cmd_config_thresh_keyword,
1981 (void *)&cmd_config_thresh_all,
1982 (void *)&cmd_config_thresh_name,
1983 (void *)&cmd_config_thresh_value,
1988 /* *** configure free/rs threshold *** */
1989 struct cmd_config_threshold {
1990 cmdline_fixed_string_t port;
1991 cmdline_fixed_string_t keyword;
1992 cmdline_fixed_string_t all;
1993 cmdline_fixed_string_t name;
1998 cmd_config_threshold_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2002 struct cmd_config_threshold *res = parsed_result;
2004 if (!all_ports_stopped()) {
2005 printf("Please stop all ports first\n");
2009 if (!strcmp(res->name, "txfreet"))
2010 tx_free_thresh = res->value;
2011 else if (!strcmp(res->name, "txrst"))
2012 tx_rs_thresh = res->value;
2013 else if (!strcmp(res->name, "rxfreet"))
2014 rx_free_thresh = res->value;
2016 printf("Unknown parameter\n");
2022 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2025 cmdline_parse_token_string_t cmd_config_threshold_port =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2027 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2030 cmdline_parse_token_string_t cmd_config_threshold_all =
2031 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2032 cmdline_parse_token_string_t cmd_config_threshold_name =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2034 "txfreet#txrst#rxfreet");
2035 cmdline_parse_token_num_t cmd_config_threshold_value =
2036 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2038 cmdline_parse_inst_t cmd_config_threshold = {
2039 .f = cmd_config_threshold_parsed,
2041 .help_str = "port config all txfreet|txrst|rxfreet value",
2043 (void *)&cmd_config_threshold_port,
2044 (void *)&cmd_config_threshold_keyword,
2045 (void *)&cmd_config_threshold_all,
2046 (void *)&cmd_config_threshold_name,
2047 (void *)&cmd_config_threshold_value,
2053 struct cmd_stop_result {
2054 cmdline_fixed_string_t stop;
2057 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2058 __attribute__((unused)) struct cmdline *cl,
2059 __attribute__((unused)) void *data)
2061 stop_packet_forwarding();
2064 cmdline_parse_token_string_t cmd_stop_stop =
2065 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2067 cmdline_parse_inst_t cmd_stop = {
2068 .f = cmd_stop_parsed,
2070 .help_str = "stop - stop packet forwarding",
2072 (void *)&cmd_stop_stop,
2077 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2080 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2081 unsigned int *parsed_items, int check_unique_values)
2083 unsigned int nb_item;
2091 * First parse all items in the list and store their value.
2096 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2098 if ((c >= '0') && (c <= '9')) {
2099 value = (unsigned int) (value * 10 + (c - '0'));
2104 printf("character %c is not a decimal digit\n", c);
2108 printf("No valid value before comma\n");
2111 if (nb_item < max_items) {
2112 parsed_items[nb_item] = value;
2118 if (nb_item >= max_items) {
2119 printf("Number of %s = %u > %u (maximum items)\n",
2120 item_name, nb_item + 1, max_items);
2123 parsed_items[nb_item++] = value;
2124 if (! check_unique_values)
2128 * Then, check that all values in the list are differents.
2129 * No optimization here...
2131 for (i = 0; i < nb_item; i++) {
2132 for (j = i + 1; j < nb_item; j++) {
2133 if (parsed_items[j] == parsed_items[i]) {
2134 printf("duplicated %s %u at index %u and %u\n",
2135 item_name, parsed_items[i], i, j);
2143 struct cmd_set_list_result {
2144 cmdline_fixed_string_t cmd_keyword;
2145 cmdline_fixed_string_t list_name;
2146 cmdline_fixed_string_t list_of_items;
2149 static void cmd_set_list_parsed(void *parsed_result,
2150 __attribute__((unused)) struct cmdline *cl,
2151 __attribute__((unused)) void *data)
2153 struct cmd_set_list_result *res;
2155 unsigned int lcorelist[RTE_MAX_LCORE];
2156 unsigned int portlist[RTE_MAX_ETHPORTS];
2158 unsigned int nb_item;
2160 res = parsed_result;
2161 if (!strcmp(res->list_name, "corelist")) {
2162 nb_item = parse_item_list(res->list_of_items, "core",
2164 parsed_items.lcorelist, 1);
2166 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2169 if (!strcmp(res->list_name, "portlist")) {
2170 nb_item = parse_item_list(res->list_of_items, "port",
2172 parsed_items.portlist, 1);
2174 set_fwd_ports_list(parsed_items.portlist, nb_item);
2178 cmdline_parse_token_string_t cmd_set_list_keyword =
2179 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2181 cmdline_parse_token_string_t cmd_set_list_name =
2182 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2183 "corelist#portlist");
2184 cmdline_parse_token_string_t cmd_set_list_of_items =
2185 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2188 cmdline_parse_inst_t cmd_set_fwd_list = {
2189 .f = cmd_set_list_parsed,
2191 .help_str = "set corelist|portlist x[,y]*",
2193 (void *)&cmd_set_list_keyword,
2194 (void *)&cmd_set_list_name,
2195 (void *)&cmd_set_list_of_items,
2200 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2202 struct cmd_setmask_result {
2203 cmdline_fixed_string_t set;
2204 cmdline_fixed_string_t mask;
2208 static void cmd_set_mask_parsed(void *parsed_result,
2209 __attribute__((unused)) struct cmdline *cl,
2210 __attribute__((unused)) void *data)
2212 struct cmd_setmask_result *res = parsed_result;
2214 if (!strcmp(res->mask, "coremask"))
2215 set_fwd_lcores_mask(res->hexavalue);
2216 else if (!strcmp(res->mask, "portmask"))
2217 set_fwd_ports_mask(res->hexavalue);
2220 cmdline_parse_token_string_t cmd_setmask_set =
2221 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2222 cmdline_parse_token_string_t cmd_setmask_mask =
2223 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2224 "coremask#portmask");
2225 cmdline_parse_token_num_t cmd_setmask_value =
2226 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2228 cmdline_parse_inst_t cmd_set_fwd_mask = {
2229 .f = cmd_set_mask_parsed,
2231 .help_str = "set coremask|portmask hexadecimal value",
2233 (void *)&cmd_setmask_set,
2234 (void *)&cmd_setmask_mask,
2235 (void *)&cmd_setmask_value,
2241 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2243 struct cmd_set_result {
2244 cmdline_fixed_string_t set;
2245 cmdline_fixed_string_t what;
2249 static void cmd_set_parsed(void *parsed_result,
2250 __attribute__((unused)) struct cmdline *cl,
2251 __attribute__((unused)) void *data)
2253 struct cmd_set_result *res = parsed_result;
2254 if (!strcmp(res->what, "nbport"))
2255 set_fwd_ports_number(res->value);
2256 else if (!strcmp(res->what, "nbcore"))
2257 set_fwd_lcores_number(res->value);
2258 else if (!strcmp(res->what, "burst"))
2259 set_nb_pkt_per_burst(res->value);
2260 else if (!strcmp(res->what, "verbose"))
2261 set_verbose_level(res->value);
2264 cmdline_parse_token_string_t cmd_set_set =
2265 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2266 cmdline_parse_token_string_t cmd_set_what =
2267 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2268 "nbport#nbcore#burst#verbose");
2269 cmdline_parse_token_num_t cmd_set_value =
2270 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2272 cmdline_parse_inst_t cmd_set_numbers = {
2273 .f = cmd_set_parsed,
2275 .help_str = "set nbport|nbcore|burst|verbose value",
2277 (void *)&cmd_set_set,
2278 (void *)&cmd_set_what,
2279 (void *)&cmd_set_value,
2284 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2286 struct cmd_set_txpkts_result {
2287 cmdline_fixed_string_t cmd_keyword;
2288 cmdline_fixed_string_t txpkts;
2289 cmdline_fixed_string_t seg_lengths;
2293 cmd_set_txpkts_parsed(void *parsed_result,
2294 __attribute__((unused)) struct cmdline *cl,
2295 __attribute__((unused)) void *data)
2297 struct cmd_set_txpkts_result *res;
2298 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2299 unsigned int nb_segs;
2301 res = parsed_result;
2302 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2303 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2305 set_tx_pkt_segments(seg_lengths, nb_segs);
2308 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2309 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2310 cmd_keyword, "set");
2311 cmdline_parse_token_string_t cmd_set_txpkts_name =
2312 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2314 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2315 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2318 cmdline_parse_inst_t cmd_set_txpkts = {
2319 .f = cmd_set_txpkts_parsed,
2321 .help_str = "set txpkts x[,y]*",
2323 (void *)&cmd_set_txpkts_keyword,
2324 (void *)&cmd_set_txpkts_name,
2325 (void *)&cmd_set_txpkts_lengths,
2330 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2331 struct cmd_rx_vlan_filter_all_result {
2332 cmdline_fixed_string_t rx_vlan;
2333 cmdline_fixed_string_t what;
2334 cmdline_fixed_string_t all;
2339 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2340 __attribute__((unused)) struct cmdline *cl,
2341 __attribute__((unused)) void *data)
2343 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2345 if (!strcmp(res->what, "add"))
2346 rx_vlan_all_filter_set(res->port_id, 1);
2348 rx_vlan_all_filter_set(res->port_id, 0);
2351 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2352 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2353 rx_vlan, "rx_vlan");
2354 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2355 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2357 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2358 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2360 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2361 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2364 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2365 .f = cmd_rx_vlan_filter_all_parsed,
2367 .help_str = "add/remove all identifiers to/from the set of VLAN "
2368 "Identifiers filtered by a port",
2370 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2371 (void *)&cmd_rx_vlan_filter_all_what,
2372 (void *)&cmd_rx_vlan_filter_all_all,
2373 (void *)&cmd_rx_vlan_filter_all_portid,
2378 /* *** VLAN OFFLOAD SET ON A PORT *** */
2379 struct cmd_vlan_offload_result {
2380 cmdline_fixed_string_t vlan;
2381 cmdline_fixed_string_t set;
2382 cmdline_fixed_string_t what;
2383 cmdline_fixed_string_t on;
2384 cmdline_fixed_string_t port_id;
2388 cmd_vlan_offload_parsed(void *parsed_result,
2389 __attribute__((unused)) struct cmdline *cl,
2390 __attribute__((unused)) void *data)
2393 struct cmd_vlan_offload_result *res = parsed_result;
2396 portid_t port_id = 0;
2400 len = strnlen(str, STR_TOKEN_SIZE);
2402 /* Get port_id first */
2410 tmp = strtoul(str, NULL, 0);
2411 /* If port_id greater that what portid_t can represent, return */
2412 if(tmp >= RTE_MAX_ETHPORTS)
2414 port_id = (portid_t)tmp;
2416 if (!strcmp(res->on, "on"))
2421 if (!strcmp(res->what, "strip"))
2422 rx_vlan_strip_set(port_id, on);
2423 else if(!strcmp(res->what, "stripq")){
2424 uint16_t queue_id = 0;
2426 /* No queue_id, return */
2428 printf("must specify (port,queue_id)\n");
2431 tmp = strtoul(str + i + 1, NULL, 0);
2432 /* If queue_id greater that what 16-bits can represent, return */
2436 queue_id = (uint16_t)tmp;
2437 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2439 else if (!strcmp(res->what, "filter"))
2440 rx_vlan_filter_set(port_id, on);
2442 vlan_extend_set(port_id, on);
2447 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2448 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2450 cmdline_parse_token_string_t cmd_vlan_offload_set =
2451 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2453 cmdline_parse_token_string_t cmd_vlan_offload_what =
2454 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2455 what, "strip#filter#qinq#stripq");
2456 cmdline_parse_token_string_t cmd_vlan_offload_on =
2457 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2459 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2460 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2463 cmdline_parse_inst_t cmd_vlan_offload = {
2464 .f = cmd_vlan_offload_parsed,
2466 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2467 " qinq(extended) for both rx/tx sides ",
2469 (void *)&cmd_vlan_offload_vlan,
2470 (void *)&cmd_vlan_offload_set,
2471 (void *)&cmd_vlan_offload_what,
2472 (void *)&cmd_vlan_offload_on,
2473 (void *)&cmd_vlan_offload_portid,
2478 /* *** VLAN TPID SET ON A PORT *** */
2479 struct cmd_vlan_tpid_result {
2480 cmdline_fixed_string_t vlan;
2481 cmdline_fixed_string_t set;
2482 cmdline_fixed_string_t what;
2488 cmd_vlan_tpid_parsed(void *parsed_result,
2489 __attribute__((unused)) struct cmdline *cl,
2490 __attribute__((unused)) void *data)
2492 struct cmd_vlan_tpid_result *res = parsed_result;
2493 vlan_tpid_set(res->port_id, res->tp_id);
2497 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2498 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2500 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2501 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2503 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2504 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2506 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2507 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2509 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2510 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2513 cmdline_parse_inst_t cmd_vlan_tpid = {
2514 .f = cmd_vlan_tpid_parsed,
2516 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2518 (void *)&cmd_vlan_tpid_vlan,
2519 (void *)&cmd_vlan_tpid_set,
2520 (void *)&cmd_vlan_tpid_what,
2521 (void *)&cmd_vlan_tpid_tpid,
2522 (void *)&cmd_vlan_tpid_portid,
2527 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2528 struct cmd_rx_vlan_filter_result {
2529 cmdline_fixed_string_t rx_vlan;
2530 cmdline_fixed_string_t what;
2536 cmd_rx_vlan_filter_parsed(void *parsed_result,
2537 __attribute__((unused)) struct cmdline *cl,
2538 __attribute__((unused)) void *data)
2540 struct cmd_rx_vlan_filter_result *res = parsed_result;
2542 if (!strcmp(res->what, "add"))
2543 rx_vft_set(res->port_id, res->vlan_id, 1);
2545 rx_vft_set(res->port_id, res->vlan_id, 0);
2548 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2549 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2550 rx_vlan, "rx_vlan");
2551 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2552 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2554 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2555 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2557 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2558 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2561 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2562 .f = cmd_rx_vlan_filter_parsed,
2564 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2565 "Identifiers filtered by a port",
2567 (void *)&cmd_rx_vlan_filter_rx_vlan,
2568 (void *)&cmd_rx_vlan_filter_what,
2569 (void *)&cmd_rx_vlan_filter_vlanid,
2570 (void *)&cmd_rx_vlan_filter_portid,
2575 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2576 struct cmd_tx_vlan_set_result {
2577 cmdline_fixed_string_t tx_vlan;
2578 cmdline_fixed_string_t set;
2584 cmd_tx_vlan_set_parsed(void *parsed_result,
2585 __attribute__((unused)) struct cmdline *cl,
2586 __attribute__((unused)) void *data)
2588 struct cmd_tx_vlan_set_result *res = parsed_result;
2589 tx_vlan_set(res->port_id, res->vlan_id);
2592 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2593 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2594 tx_vlan, "tx_vlan");
2595 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2596 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2598 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2599 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2601 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2602 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2605 cmdline_parse_inst_t cmd_tx_vlan_set = {
2606 .f = cmd_tx_vlan_set_parsed,
2608 .help_str = "enable hardware insertion of a VLAN header with a given "
2609 "TAG Identifier in packets sent on a port",
2611 (void *)&cmd_tx_vlan_set_tx_vlan,
2612 (void *)&cmd_tx_vlan_set_set,
2613 (void *)&cmd_tx_vlan_set_vlanid,
2614 (void *)&cmd_tx_vlan_set_portid,
2619 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2620 struct cmd_tx_vlan_set_pvid_result {
2621 cmdline_fixed_string_t tx_vlan;
2622 cmdline_fixed_string_t set;
2623 cmdline_fixed_string_t pvid;
2626 cmdline_fixed_string_t mode;
2630 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2631 __attribute__((unused)) struct cmdline *cl,
2632 __attribute__((unused)) void *data)
2634 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2636 if (strcmp(res->mode, "on") == 0)
2637 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2639 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2642 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2643 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2644 tx_vlan, "tx_vlan");
2645 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2646 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2648 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2649 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2651 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2652 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2654 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2655 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2657 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2658 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2661 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2662 .f = cmd_tx_vlan_set_pvid_parsed,
2664 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2666 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2667 (void *)&cmd_tx_vlan_set_pvid_set,
2668 (void *)&cmd_tx_vlan_set_pvid_pvid,
2669 (void *)&cmd_tx_vlan_set_pvid_port_id,
2670 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2671 (void *)&cmd_tx_vlan_set_pvid_mode,
2676 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2677 struct cmd_tx_vlan_reset_result {
2678 cmdline_fixed_string_t tx_vlan;
2679 cmdline_fixed_string_t reset;
2684 cmd_tx_vlan_reset_parsed(void *parsed_result,
2685 __attribute__((unused)) struct cmdline *cl,
2686 __attribute__((unused)) void *data)
2688 struct cmd_tx_vlan_reset_result *res = parsed_result;
2690 tx_vlan_reset(res->port_id);
2693 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2694 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2695 tx_vlan, "tx_vlan");
2696 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2697 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2699 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2700 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2703 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2704 .f = cmd_tx_vlan_reset_parsed,
2706 .help_str = "disable hardware insertion of a VLAN header in packets "
2709 (void *)&cmd_tx_vlan_reset_tx_vlan,
2710 (void *)&cmd_tx_vlan_reset_reset,
2711 (void *)&cmd_tx_vlan_reset_portid,
2717 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2718 struct cmd_tx_cksum_set_result {
2719 cmdline_fixed_string_t tx_cksum;
2720 cmdline_fixed_string_t set;
2726 cmd_tx_cksum_set_parsed(void *parsed_result,
2727 __attribute__((unused)) struct cmdline *cl,
2728 __attribute__((unused)) void *data)
2730 struct cmd_tx_cksum_set_result *res = parsed_result;
2732 tx_cksum_set(res->port_id, res->cksum_mask);
2735 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2736 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2737 tx_cksum, "tx_checksum");
2738 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2739 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2741 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2742 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2744 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2745 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2748 cmdline_parse_inst_t cmd_tx_cksum_set = {
2749 .f = cmd_tx_cksum_set_parsed,
2751 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2752 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2753 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2755 (void *)&cmd_tx_cksum_set_tx_cksum,
2756 (void *)&cmd_tx_cksum_set_set,
2757 (void *)&cmd_tx_cksum_set_cksum_mask,
2758 (void *)&cmd_tx_cksum_set_portid,
2763 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2764 struct cmd_set_flush_rx {
2765 cmdline_fixed_string_t set;
2766 cmdline_fixed_string_t flush_rx;
2767 cmdline_fixed_string_t mode;
2771 cmd_set_flush_rx_parsed(void *parsed_result,
2772 __attribute__((unused)) struct cmdline *cl,
2773 __attribute__((unused)) void *data)
2775 struct cmd_set_flush_rx *res = parsed_result;
2776 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2779 cmdline_parse_token_string_t cmd_setflushrx_set =
2780 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2782 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2783 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2784 flush_rx, "flush_rx");
2785 cmdline_parse_token_string_t cmd_setflushrx_mode =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2790 cmdline_parse_inst_t cmd_set_flush_rx = {
2791 .f = cmd_set_flush_rx_parsed,
2792 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2795 (void *)&cmd_setflushrx_set,
2796 (void *)&cmd_setflushrx_flush_rx,
2797 (void *)&cmd_setflushrx_mode,
2802 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2803 struct cmd_set_link_check {
2804 cmdline_fixed_string_t set;
2805 cmdline_fixed_string_t link_check;
2806 cmdline_fixed_string_t mode;
2810 cmd_set_link_check_parsed(void *parsed_result,
2811 __attribute__((unused)) struct cmdline *cl,
2812 __attribute__((unused)) void *data)
2814 struct cmd_set_link_check *res = parsed_result;
2815 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2818 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2819 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2821 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2822 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2823 link_check, "link_check");
2824 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2825 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2829 cmdline_parse_inst_t cmd_set_link_check = {
2830 .f = cmd_set_link_check_parsed,
2831 .help_str = "set link_check on|off: enable/disable link status check "
2832 "when starting/stopping a port",
2835 (void *)&cmd_setlinkcheck_set,
2836 (void *)&cmd_setlinkcheck_link_check,
2837 (void *)&cmd_setlinkcheck_mode,
2842 #ifdef RTE_NIC_BYPASS
2843 /* *** SET NIC BYPASS MODE *** */
2844 struct cmd_set_bypass_mode_result {
2845 cmdline_fixed_string_t set;
2846 cmdline_fixed_string_t bypass;
2847 cmdline_fixed_string_t mode;
2848 cmdline_fixed_string_t value;
2853 cmd_set_bypass_mode_parsed(void *parsed_result,
2854 __attribute__((unused)) struct cmdline *cl,
2855 __attribute__((unused)) void *data)
2857 struct cmd_set_bypass_mode_result *res = parsed_result;
2858 portid_t port_id = res->port_id;
2859 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2861 if (!bypass_is_supported(port_id))
2864 if (!strcmp(res->value, "bypass"))
2865 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2866 else if (!strcmp(res->value, "isolate"))
2867 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2869 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2871 /* Set the bypass mode for the relevant port. */
2872 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2873 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2877 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2878 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2880 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2881 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2883 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2884 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2886 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2887 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2888 value, "normal#bypass#isolate");
2889 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2890 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2893 cmdline_parse_inst_t cmd_set_bypass_mode = {
2894 .f = cmd_set_bypass_mode_parsed,
2895 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2896 "Set the NIC bypass mode for port_id",
2899 (void *)&cmd_setbypass_mode_set,
2900 (void *)&cmd_setbypass_mode_bypass,
2901 (void *)&cmd_setbypass_mode_mode,
2902 (void *)&cmd_setbypass_mode_value,
2903 (void *)&cmd_setbypass_mode_port,
2908 /* *** SET NIC BYPASS EVENT *** */
2909 struct cmd_set_bypass_event_result {
2910 cmdline_fixed_string_t set;
2911 cmdline_fixed_string_t bypass;
2912 cmdline_fixed_string_t event;
2913 cmdline_fixed_string_t event_value;
2914 cmdline_fixed_string_t mode;
2915 cmdline_fixed_string_t mode_value;
2920 cmd_set_bypass_event_parsed(void *parsed_result,
2921 __attribute__((unused)) struct cmdline *cl,
2922 __attribute__((unused)) void *data)
2925 struct cmd_set_bypass_event_result *res = parsed_result;
2926 portid_t port_id = res->port_id;
2927 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2928 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2930 if (!bypass_is_supported(port_id))
2933 if (!strcmp(res->event_value, "timeout"))
2934 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2935 else if (!strcmp(res->event_value, "os_on"))
2936 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2937 else if (!strcmp(res->event_value, "os_off"))
2938 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2939 else if (!strcmp(res->event_value, "power_on"))
2940 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2941 else if (!strcmp(res->event_value, "power_off"))
2942 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2944 bypass_event = RTE_BYPASS_EVENT_NONE;
2946 if (!strcmp(res->mode_value, "bypass"))
2947 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2948 else if (!strcmp(res->mode_value, "isolate"))
2949 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2951 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2953 /* Set the watchdog timeout. */
2954 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2957 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2958 (rc = rte_eth_dev_wd_timeout_store(port_id,
2959 bypass_timeout)) != 0) {
2960 printf("Failed to set timeout value %u "
2961 "for port %d, errto code: %d.\n",
2962 bypass_timeout, port_id, rc);
2966 /* Set the bypass event to transition to bypass mode. */
2967 if (0 != rte_eth_dev_bypass_event_store(port_id,
2968 bypass_event, bypass_mode)) {
2969 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2974 cmdline_parse_token_string_t cmd_setbypass_event_set =
2975 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2977 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2978 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2980 cmdline_parse_token_string_t cmd_setbypass_event_event =
2981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2983 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2985 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2986 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2989 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2991 mode_value, "normal#bypass#isolate");
2992 cmdline_parse_token_num_t cmd_setbypass_event_port =
2993 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2996 cmdline_parse_inst_t cmd_set_bypass_event = {
2997 .f = cmd_set_bypass_event_parsed,
2998 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2999 "mode (normal|bypass|isolate) (port_id): "
3000 "Set the NIC bypass event mode for port_id",
3003 (void *)&cmd_setbypass_event_set,
3004 (void *)&cmd_setbypass_event_bypass,
3005 (void *)&cmd_setbypass_event_event,
3006 (void *)&cmd_setbypass_event_event_value,
3007 (void *)&cmd_setbypass_event_mode,
3008 (void *)&cmd_setbypass_event_mode_value,
3009 (void *)&cmd_setbypass_event_port,
3015 /* *** SET NIC BYPASS TIMEOUT *** */
3016 struct cmd_set_bypass_timeout_result {
3017 cmdline_fixed_string_t set;
3018 cmdline_fixed_string_t bypass;
3019 cmdline_fixed_string_t timeout;
3020 cmdline_fixed_string_t value;
3024 cmd_set_bypass_timeout_parsed(void *parsed_result,
3025 __attribute__((unused)) struct cmdline *cl,
3026 __attribute__((unused)) void *data)
3028 struct cmd_set_bypass_timeout_result *res = parsed_result;
3030 if (!strcmp(res->value, "1.5"))
3031 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3032 else if (!strcmp(res->value, "2"))
3033 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3034 else if (!strcmp(res->value, "3"))
3035 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3036 else if (!strcmp(res->value, "4"))
3037 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3038 else if (!strcmp(res->value, "8"))
3039 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3040 else if (!strcmp(res->value, "16"))
3041 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3042 else if (!strcmp(res->value, "32"))
3043 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3045 bypass_timeout = RTE_BYPASS_TMT_OFF;
3048 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3051 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3054 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3056 timeout, "timeout");
3057 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3059 value, "0#1.5#2#3#4#8#16#32");
3061 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3062 .f = cmd_set_bypass_timeout_parsed,
3063 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3064 "Set the NIC bypass watchdog timeout",
3067 (void *)&cmd_setbypass_timeout_set,
3068 (void *)&cmd_setbypass_timeout_bypass,
3069 (void *)&cmd_setbypass_timeout_timeout,
3070 (void *)&cmd_setbypass_timeout_value,
3075 /* *** SHOW NIC BYPASS MODE *** */
3076 struct cmd_show_bypass_config_result {
3077 cmdline_fixed_string_t show;
3078 cmdline_fixed_string_t bypass;
3079 cmdline_fixed_string_t config;
3084 cmd_show_bypass_config_parsed(void *parsed_result,
3085 __attribute__((unused)) struct cmdline *cl,
3086 __attribute__((unused)) void *data)
3088 struct cmd_show_bypass_config_result *res = parsed_result;
3089 uint32_t event_mode;
3090 uint32_t bypass_mode;
3091 portid_t port_id = res->port_id;
3092 uint32_t timeout = bypass_timeout;
3095 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3096 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3097 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3098 {"UNKNOWN", "normal", "bypass", "isolate"};
3099 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3106 int num_events = (sizeof events) / (sizeof events[0]);
3108 if (!bypass_is_supported(port_id))
3111 /* Display the bypass mode.*/
3112 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3113 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3117 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3118 bypass_mode = RTE_BYPASS_MODE_NONE;
3120 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3123 /* Display the bypass timeout.*/
3124 if (!RTE_BYPASS_TMT_VALID(timeout))
3125 timeout = RTE_BYPASS_TMT_OFF;
3127 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3129 /* Display the bypass events and associated modes. */
3130 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3132 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3133 printf("\tFailed to get bypass mode for event = %s\n",
3136 if (!RTE_BYPASS_MODE_VALID(event_mode))
3137 event_mode = RTE_BYPASS_MODE_NONE;
3139 printf("\tbypass event: %-16s = %s\n", events[i],
3145 cmdline_parse_token_string_t cmd_showbypass_config_show =
3146 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3148 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3149 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3151 cmdline_parse_token_string_t cmd_showbypass_config_config =
3152 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3154 cmdline_parse_token_num_t cmd_showbypass_config_port =
3155 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3158 cmdline_parse_inst_t cmd_show_bypass_config = {
3159 .f = cmd_show_bypass_config_parsed,
3160 .help_str = "show bypass config (port_id): "
3161 "Show the NIC bypass config for port_id",
3164 (void *)&cmd_showbypass_config_show,
3165 (void *)&cmd_showbypass_config_bypass,
3166 (void *)&cmd_showbypass_config_config,
3167 (void *)&cmd_showbypass_config_port,
3173 #ifdef RTE_LIBRTE_PMD_BOND
3174 /* *** SET BONDING MODE *** */
3175 struct cmd_set_bonding_mode_result {
3176 cmdline_fixed_string_t set;
3177 cmdline_fixed_string_t bonding;
3178 cmdline_fixed_string_t mode;
3183 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3184 __attribute__((unused)) struct cmdline *cl,
3185 __attribute__((unused)) void *data)
3187 struct cmd_set_bonding_mode_result *res = parsed_result;
3188 portid_t port_id = res->port_id;
3190 /* Set the bonding mode for the relevant port. */
3191 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3192 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3195 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3196 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3198 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3199 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3200 bonding, "bonding");
3201 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3202 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3204 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3205 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3207 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3208 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3211 cmdline_parse_inst_t cmd_set_bonding_mode = {
3212 .f = cmd_set_bonding_mode_parsed,
3213 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3216 (void *) &cmd_setbonding_mode_set,
3217 (void *) &cmd_setbonding_mode_bonding,
3218 (void *) &cmd_setbonding_mode_mode,
3219 (void *) &cmd_setbonding_mode_value,
3220 (void *) &cmd_setbonding_mode_port,
3225 /* *** SET BALANCE XMIT POLICY *** */
3226 struct cmd_set_bonding_balance_xmit_policy_result {
3227 cmdline_fixed_string_t set;
3228 cmdline_fixed_string_t bonding;
3229 cmdline_fixed_string_t balance_xmit_policy;
3231 cmdline_fixed_string_t policy;
3234 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3235 __attribute__((unused)) struct cmdline *cl,
3236 __attribute__((unused)) void *data)
3238 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3239 portid_t port_id = res->port_id;
3242 if (!strcmp(res->policy, "l2")) {
3243 policy = BALANCE_XMIT_POLICY_LAYER2;
3244 } else if (!strcmp(res->policy, "l23")) {
3245 policy = BALANCE_XMIT_POLICY_LAYER23;
3246 } else if (!strcmp(res->policy, "l34")) {
3247 policy = BALANCE_XMIT_POLICY_LAYER34;
3249 printf("\t Invalid xmit policy selection");
3253 /* Set the bonding mode for the relevant port. */
3254 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3255 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3260 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3261 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3263 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3264 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3265 bonding, "bonding");
3266 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3267 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3268 balance_xmit_policy, "balance_xmit_policy");
3269 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3270 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3272 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3273 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3274 policy, "l2#l23#l34");
3276 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3277 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3278 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3281 (void *)&cmd_setbonding_balance_xmit_policy_set,
3282 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3283 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3284 (void *)&cmd_setbonding_balance_xmit_policy_port,
3285 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3290 /* *** SHOW NIC BONDING CONFIGURATION *** */
3291 struct cmd_show_bonding_config_result {
3292 cmdline_fixed_string_t show;
3293 cmdline_fixed_string_t bonding;
3294 cmdline_fixed_string_t config;
3298 static void cmd_show_bonding_config_parsed(void *parsed_result,
3299 __attribute__((unused)) struct cmdline *cl,
3300 __attribute__((unused)) void *data)
3302 struct cmd_show_bonding_config_result *res = parsed_result;
3304 uint8_t slaves[RTE_MAX_ETHPORTS];
3305 int num_slaves, num_active_slaves;
3308 portid_t port_id = res->port_id;
3310 /* Display the bonding mode.*/
3311 bonding_mode = rte_eth_bond_mode_get(port_id);
3312 if (bonding_mode < 0) {
3313 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3316 printf("\tBonding mode: %d\n", bonding_mode);
3318 if (bonding_mode == BONDING_MODE_BALANCE) {
3319 int balance_xmit_policy;
3321 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3322 if (balance_xmit_policy < 0) {
3323 printf("\tFailed to get balance xmit policy for port = %d\n",
3327 printf("\tBalance Xmit Policy: ");
3329 switch (balance_xmit_policy) {
3330 case BALANCE_XMIT_POLICY_LAYER2:
3331 printf("BALANCE_XMIT_POLICY_LAYER2");
3333 case BALANCE_XMIT_POLICY_LAYER23:
3334 printf("BALANCE_XMIT_POLICY_LAYER23");
3336 case BALANCE_XMIT_POLICY_LAYER34:
3337 printf("BALANCE_XMIT_POLICY_LAYER34");
3344 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3346 if (num_slaves < 0) {
3347 printf("\tFailed to get slave list for port = %d\n", port_id);
3350 if (num_slaves > 0) {
3351 printf("\tSlaves (%d): [", num_slaves);
3352 for (i = 0; i < num_slaves - 1; i++)
3353 printf("%d ", slaves[i]);
3355 printf("%d]\n", slaves[num_slaves - 1]);
3357 printf("\tSlaves: []\n");
3361 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3364 if (num_active_slaves < 0) {
3365 printf("\tFailed to get active slave list for port = %d\n", port_id);
3368 if (num_active_slaves > 0) {
3369 printf("\tActive Slaves (%d): [", num_active_slaves);
3370 for (i = 0; i < num_active_slaves - 1; i++)
3371 printf("%d ", slaves[i]);
3373 printf("%d]\n", slaves[num_active_slaves - 1]);
3376 printf("\tActive Slaves: []\n");
3380 primary_id = rte_eth_bond_primary_get(port_id);
3381 if (primary_id < 0) {
3382 printf("\tFailed to get primary slave for port = %d\n", port_id);
3385 printf("\tPrimary: [%d]\n", primary_id);
3389 cmdline_parse_token_string_t cmd_showbonding_config_show =
3390 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3392 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3393 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3394 bonding, "bonding");
3395 cmdline_parse_token_string_t cmd_showbonding_config_config =
3396 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3398 cmdline_parse_token_num_t cmd_showbonding_config_port =
3399 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3402 cmdline_parse_inst_t cmd_show_bonding_config = {
3403 .f = cmd_show_bonding_config_parsed,
3404 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3407 (void *)&cmd_showbonding_config_show,
3408 (void *)&cmd_showbonding_config_bonding,
3409 (void *)&cmd_showbonding_config_config,
3410 (void *)&cmd_showbonding_config_port,
3415 /* *** SET BONDING PRIMARY *** */
3416 struct cmd_set_bonding_primary_result {
3417 cmdline_fixed_string_t set;
3418 cmdline_fixed_string_t bonding;
3419 cmdline_fixed_string_t primary;
3424 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3425 __attribute__((unused)) struct cmdline *cl,
3426 __attribute__((unused)) void *data)
3428 struct cmd_set_bonding_primary_result *res = parsed_result;
3429 portid_t master_port_id = res->port_id;
3430 portid_t slave_port_id = res->slave_id;
3432 /* Set the primary slave for a bonded device. */
3433 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3434 printf("\t Failed to set primary slave for port = %d.\n",
3441 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3442 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3444 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3445 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3446 bonding, "bonding");
3447 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3449 primary, "primary");
3450 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3451 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3453 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3454 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3457 cmdline_parse_inst_t cmd_set_bonding_primary = {
3458 .f = cmd_set_bonding_primary_parsed,
3459 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3462 (void *)&cmd_setbonding_primary_set,
3463 (void *)&cmd_setbonding_primary_bonding,
3464 (void *)&cmd_setbonding_primary_primary,
3465 (void *)&cmd_setbonding_primary_slave,
3466 (void *)&cmd_setbonding_primary_port,
3471 /* *** ADD SLAVE *** */
3472 struct cmd_add_bonding_slave_result {
3473 cmdline_fixed_string_t add;
3474 cmdline_fixed_string_t bonding;
3475 cmdline_fixed_string_t slave;
3480 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3481 __attribute__((unused)) struct cmdline *cl,
3482 __attribute__((unused)) void *data)
3484 struct cmd_add_bonding_slave_result *res = parsed_result;
3485 portid_t master_port_id = res->port_id;
3486 portid_t slave_port_id = res->slave_id;
3488 /* Set the primary slave for a bonded device. */
3489 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3490 printf("\t Failed to add slave %d to master port = %d.\n",
3491 slave_port_id, master_port_id);
3497 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3498 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3500 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3501 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3502 bonding, "bonding");
3503 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3504 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3506 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3507 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3509 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3510 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3513 cmdline_parse_inst_t cmd_add_bonding_slave = {
3514 .f = cmd_add_bonding_slave_parsed,
3515 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3518 (void *)&cmd_addbonding_slave_add,
3519 (void *)&cmd_addbonding_slave_bonding,
3520 (void *)&cmd_addbonding_slave_slave,
3521 (void *)&cmd_addbonding_slave_slaveid,
3522 (void *)&cmd_addbonding_slave_port,
3527 /* *** REMOVE SLAVE *** */
3528 struct cmd_remove_bonding_slave_result {
3529 cmdline_fixed_string_t remove;
3530 cmdline_fixed_string_t bonding;
3531 cmdline_fixed_string_t slave;
3536 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3537 __attribute__((unused)) struct cmdline *cl,
3538 __attribute__((unused)) void *data)
3540 struct cmd_remove_bonding_slave_result *res = parsed_result;
3541 portid_t master_port_id = res->port_id;
3542 portid_t slave_port_id = res->slave_id;
3544 /* Set the primary slave for a bonded device. */
3545 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3546 printf("\t Failed to remove slave %d from master port = %d.\n",
3547 slave_port_id, master_port_id);
3553 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3554 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3556 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3557 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3558 bonding, "bonding");
3559 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3560 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3562 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3563 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3565 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3566 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3569 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3570 .f = cmd_remove_bonding_slave_parsed,
3571 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3574 (void *)&cmd_removebonding_slave_remove,
3575 (void *)&cmd_removebonding_slave_bonding,
3576 (void *)&cmd_removebonding_slave_slave,
3577 (void *)&cmd_removebonding_slave_slaveid,
3578 (void *)&cmd_removebonding_slave_port,
3583 /* *** CREATE BONDED DEVICE *** */
3584 struct cmd_create_bonded_device_result {
3585 cmdline_fixed_string_t create;
3586 cmdline_fixed_string_t bonded;
3587 cmdline_fixed_string_t device;
3592 static int bond_dev_num = 0;
3594 static void cmd_create_bonded_device_parsed(void *parsed_result,
3595 __attribute__((unused)) struct cmdline *cl,
3596 __attribute__((unused)) void *data)
3598 struct cmd_create_bonded_device_result *res = parsed_result;
3599 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3602 if (test_done == 0) {
3603 printf("Please stop forwarding first\n");
3607 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3610 /* Create a new bonded device. */
3611 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3613 printf("\t Failed to create bonded device.\n");
3616 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3619 /* Update number of ports */
3620 nb_ports = rte_eth_dev_count();
3622 rte_eth_promiscuous_enable(port_id);
3627 cmdline_parse_token_string_t cmd_createbonded_device_create =
3628 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3630 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3631 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3633 cmdline_parse_token_string_t cmd_createbonded_device_device =
3634 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3636 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3637 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3639 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3640 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3643 cmdline_parse_inst_t cmd_create_bonded_device = {
3644 .f = cmd_create_bonded_device_parsed,
3645 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3648 (void *)&cmd_createbonded_device_create,
3649 (void *)&cmd_createbonded_device_bonded,
3650 (void *)&cmd_createbonded_device_device,
3651 (void *)&cmd_createbonded_device_mode,
3652 (void *)&cmd_createbonded_device_socket,
3657 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3658 struct cmd_set_bond_mac_addr_result {
3659 cmdline_fixed_string_t set;
3660 cmdline_fixed_string_t bonding;
3661 cmdline_fixed_string_t mac_addr;
3663 struct ether_addr address;
3666 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3667 __attribute__((unused)) struct cmdline *cl,
3668 __attribute__((unused)) void *data)
3670 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3673 if (res->port_num >= nb_ports) {
3674 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3678 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3680 /* check the return value and print it if is < 0 */
3682 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3685 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3686 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3687 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3688 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3690 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3691 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3693 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3694 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3695 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3696 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3698 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3699 .f = cmd_set_bond_mac_addr_parsed,
3701 .help_str = "set bonding mac_addr (port_id) (address): ",
3703 (void *)&cmd_set_bond_mac_addr_set,
3704 (void *)&cmd_set_bond_mac_addr_bonding,
3705 (void *)&cmd_set_bond_mac_addr_mac,
3706 (void *)&cmd_set_bond_mac_addr_portnum,
3707 (void *)&cmd_set_bond_mac_addr_addr,
3712 #endif /* RTE_LIBRTE_PMD_BOND */
3714 /* *** SET FORWARDING MODE *** */
3715 struct cmd_set_fwd_mode_result {
3716 cmdline_fixed_string_t set;
3717 cmdline_fixed_string_t fwd;
3718 cmdline_fixed_string_t mode;
3721 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3722 __attribute__((unused)) struct cmdline *cl,
3723 __attribute__((unused)) void *data)
3725 struct cmd_set_fwd_mode_result *res = parsed_result;
3727 set_pkt_forwarding_mode(res->mode);
3730 cmdline_parse_token_string_t cmd_setfwd_set =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3732 cmdline_parse_token_string_t cmd_setfwd_fwd =
3733 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3734 cmdline_parse_token_string_t cmd_setfwd_mode =
3735 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3736 "" /* defined at init */);
3738 cmdline_parse_inst_t cmd_set_fwd_mode = {
3739 .f = cmd_set_fwd_mode_parsed,
3741 .help_str = NULL, /* defined at init */
3743 (void *)&cmd_setfwd_set,
3744 (void *)&cmd_setfwd_fwd,
3745 (void *)&cmd_setfwd_mode,
3750 static void cmd_set_fwd_mode_init(void)
3753 static char token[128];
3754 static char help[256];
3755 cmdline_parse_token_string_t *token_struct;
3757 modes = list_pkt_forwarding_modes();
3758 snprintf(help, sizeof help, "set fwd %s - "
3759 "set packet forwarding mode", modes);
3760 cmd_set_fwd_mode.help_str = help;
3762 /* string token separator is # */
3763 for (c = token; *modes != '\0'; modes++)
3768 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3769 token_struct->string_data.str = token;
3772 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3773 struct cmd_set_burst_tx_retry_result {
3774 cmdline_fixed_string_t set;
3775 cmdline_fixed_string_t burst;
3776 cmdline_fixed_string_t tx;
3777 cmdline_fixed_string_t delay;
3779 cmdline_fixed_string_t retry;
3783 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3784 __attribute__((unused)) struct cmdline *cl,
3785 __attribute__((unused)) void *data)
3787 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3789 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3790 && !strcmp(res->tx, "tx")) {
3791 if (!strcmp(res->delay, "delay"))
3792 burst_tx_delay_time = res->time;
3793 if (!strcmp(res->retry, "retry"))
3794 burst_tx_retry_num = res->retry_num;
3799 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3800 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3801 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3802 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3804 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3805 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3806 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3808 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3809 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3810 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3811 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3812 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3813 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3815 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3816 .f = cmd_set_burst_tx_retry_parsed,
3817 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3819 (void *)&cmd_set_burst_tx_retry_set,
3820 (void *)&cmd_set_burst_tx_retry_burst,
3821 (void *)&cmd_set_burst_tx_retry_tx,
3822 (void *)&cmd_set_burst_tx_retry_delay,
3823 (void *)&cmd_set_burst_tx_retry_time,
3824 (void *)&cmd_set_burst_tx_retry_retry,
3825 (void *)&cmd_set_burst_tx_retry_retry_num,
3830 /* *** SET PROMISC MODE *** */
3831 struct cmd_set_promisc_mode_result {
3832 cmdline_fixed_string_t set;
3833 cmdline_fixed_string_t promisc;
3834 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3835 uint8_t port_num; /* valid if "allports" argument == 0 */
3836 cmdline_fixed_string_t mode;
3839 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3840 __attribute__((unused)) struct cmdline *cl,
3843 struct cmd_set_promisc_mode_result *res = parsed_result;
3847 if (!strcmp(res->mode, "on"))
3854 for (i = 0; i < nb_ports; i++) {
3856 rte_eth_promiscuous_enable(i);
3858 rte_eth_promiscuous_disable(i);
3863 rte_eth_promiscuous_enable(res->port_num);
3865 rte_eth_promiscuous_disable(res->port_num);
3869 cmdline_parse_token_string_t cmd_setpromisc_set =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3871 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3872 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3874 cmdline_parse_token_string_t cmd_setpromisc_portall =
3875 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3877 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3878 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3880 cmdline_parse_token_string_t cmd_setpromisc_mode =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3884 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3885 .f = cmd_set_promisc_mode_parsed,
3887 .help_str = "set promisc all on|off: set promisc mode for all ports",
3889 (void *)&cmd_setpromisc_set,
3890 (void *)&cmd_setpromisc_promisc,
3891 (void *)&cmd_setpromisc_portall,
3892 (void *)&cmd_setpromisc_mode,
3897 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3898 .f = cmd_set_promisc_mode_parsed,
3900 .help_str = "set promisc X on|off: set promisc mode on port X",
3902 (void *)&cmd_setpromisc_set,
3903 (void *)&cmd_setpromisc_promisc,
3904 (void *)&cmd_setpromisc_portnum,
3905 (void *)&cmd_setpromisc_mode,
3910 /* *** SET ALLMULTI MODE *** */
3911 struct cmd_set_allmulti_mode_result {
3912 cmdline_fixed_string_t set;
3913 cmdline_fixed_string_t allmulti;
3914 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3915 uint8_t port_num; /* valid if "allports" argument == 0 */
3916 cmdline_fixed_string_t mode;
3919 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3920 __attribute__((unused)) struct cmdline *cl,
3923 struct cmd_set_allmulti_mode_result *res = parsed_result;
3927 if (!strcmp(res->mode, "on"))
3934 for (i = 0; i < nb_ports; i++) {
3936 rte_eth_allmulticast_enable(i);
3938 rte_eth_allmulticast_disable(i);
3943 rte_eth_allmulticast_enable(res->port_num);
3945 rte_eth_allmulticast_disable(res->port_num);
3949 cmdline_parse_token_string_t cmd_setallmulti_set =
3950 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3951 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3952 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3954 cmdline_parse_token_string_t cmd_setallmulti_portall =
3955 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3957 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3958 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3960 cmdline_parse_token_string_t cmd_setallmulti_mode =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3964 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3965 .f = cmd_set_allmulti_mode_parsed,
3967 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3969 (void *)&cmd_setallmulti_set,
3970 (void *)&cmd_setallmulti_allmulti,
3971 (void *)&cmd_setallmulti_portall,
3972 (void *)&cmd_setallmulti_mode,
3977 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3978 .f = cmd_set_allmulti_mode_parsed,
3980 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3982 (void *)&cmd_setallmulti_set,
3983 (void *)&cmd_setallmulti_allmulti,
3984 (void *)&cmd_setallmulti_portnum,
3985 (void *)&cmd_setallmulti_mode,
3990 /* *** ADD/REMOVE A PKT FILTER *** */
3991 struct cmd_pkt_filter_result {
3992 cmdline_fixed_string_t pkt_filter;
3994 cmdline_fixed_string_t protocol;
3995 cmdline_fixed_string_t src;
3996 cmdline_ipaddr_t ip_src;
3998 cmdline_fixed_string_t dst;
3999 cmdline_ipaddr_t ip_dst;
4001 cmdline_fixed_string_t flexbytes;
4002 uint16_t flexbytes_value;
4003 cmdline_fixed_string_t vlan;
4005 cmdline_fixed_string_t queue;
4007 cmdline_fixed_string_t soft;
4012 cmd_pkt_filter_parsed(void *parsed_result,
4013 __attribute__((unused)) struct cmdline *cl,
4014 __attribute__((unused)) void *data)
4016 struct rte_fdir_filter fdir_filter;
4017 struct cmd_pkt_filter_result *res = parsed_result;
4019 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4021 if (res->ip_src.family == AF_INET)
4022 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4024 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4025 &(res->ip_src.addr.ipv6),
4026 sizeof(struct in6_addr));
4028 if (res->ip_dst.family == AF_INET)
4029 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4031 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4032 &(res->ip_dst.addr.ipv6),
4033 sizeof(struct in6_addr));
4035 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4036 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4038 if (!strcmp(res->protocol, "udp"))
4039 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4040 else if (!strcmp(res->protocol, "tcp"))
4041 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4042 else if (!strcmp(res->protocol, "sctp"))
4043 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4044 else /* default only IP */
4045 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4047 if (res->ip_dst.family == AF_INET6)
4048 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4050 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4052 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4053 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4055 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4056 fdir_add_signature_filter(res->port_id, res->queue_id,
4058 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4059 fdir_update_signature_filter(res->port_id, res->queue_id,
4061 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4062 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4063 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4064 fdir_add_perfect_filter(res->port_id, res->soft_id,
4066 (uint8_t) (res->queue_id < 0),
4068 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4069 fdir_update_perfect_filter(res->port_id, res->soft_id,
4071 (uint8_t) (res->queue_id < 0),
4073 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4074 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4080 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4081 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4083 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4084 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4085 protocol, "ip#tcp#udp#sctp");
4086 cmdline_parse_token_string_t cmd_pkt_filter_src =
4087 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4089 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4090 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4092 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4093 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4095 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4096 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4098 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4099 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4101 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4102 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4104 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4105 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4106 flexbytes, "flexbytes");
4107 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4108 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4109 flexbytes_value, UINT16);
4110 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4111 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4113 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4114 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4116 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4117 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4119 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4120 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4122 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4123 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4125 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4126 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4130 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4131 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4132 pkt_filter, "add_signature_filter");
4133 cmdline_parse_inst_t cmd_add_signature_filter = {
4134 .f = cmd_pkt_filter_parsed,
4136 .help_str = "add a signature filter",
4138 (void *)&cmd_pkt_filter_add_signature_filter,
4139 (void *)&cmd_pkt_filter_port_id,
4140 (void *)&cmd_pkt_filter_protocol,
4141 (void *)&cmd_pkt_filter_src,
4142 (void *)&cmd_pkt_filter_ip_src,
4143 (void *)&cmd_pkt_filter_port_src,
4144 (void *)&cmd_pkt_filter_dst,
4145 (void *)&cmd_pkt_filter_ip_dst,
4146 (void *)&cmd_pkt_filter_port_dst,
4147 (void *)&cmd_pkt_filter_flexbytes,
4148 (void *)&cmd_pkt_filter_flexbytes_value,
4149 (void *)&cmd_pkt_filter_vlan,
4150 (void *)&cmd_pkt_filter_vlan_id,
4151 (void *)&cmd_pkt_filter_queue,
4152 (void *)&cmd_pkt_filter_queue_id,
4158 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4159 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4160 pkt_filter, "upd_signature_filter");
4161 cmdline_parse_inst_t cmd_upd_signature_filter = {
4162 .f = cmd_pkt_filter_parsed,
4164 .help_str = "update a signature filter",
4166 (void *)&cmd_pkt_filter_upd_signature_filter,
4167 (void *)&cmd_pkt_filter_port_id,
4168 (void *)&cmd_pkt_filter_protocol,
4169 (void *)&cmd_pkt_filter_src,
4170 (void *)&cmd_pkt_filter_ip_src,
4171 (void *)&cmd_pkt_filter_port_src,
4172 (void *)&cmd_pkt_filter_dst,
4173 (void *)&cmd_pkt_filter_ip_dst,
4174 (void *)&cmd_pkt_filter_port_dst,
4175 (void *)&cmd_pkt_filter_flexbytes,
4176 (void *)&cmd_pkt_filter_flexbytes_value,
4177 (void *)&cmd_pkt_filter_vlan,
4178 (void *)&cmd_pkt_filter_vlan_id,
4179 (void *)&cmd_pkt_filter_queue,
4180 (void *)&cmd_pkt_filter_queue_id,
4186 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4187 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4188 pkt_filter, "rm_signature_filter");
4189 cmdline_parse_inst_t cmd_rm_signature_filter = {
4190 .f = cmd_pkt_filter_parsed,
4192 .help_str = "remove a signature filter",
4194 (void *)&cmd_pkt_filter_rm_signature_filter,
4195 (void *)&cmd_pkt_filter_port_id,
4196 (void *)&cmd_pkt_filter_protocol,
4197 (void *)&cmd_pkt_filter_src,
4198 (void *)&cmd_pkt_filter_ip_src,
4199 (void *)&cmd_pkt_filter_port_src,
4200 (void *)&cmd_pkt_filter_dst,
4201 (void *)&cmd_pkt_filter_ip_dst,
4202 (void *)&cmd_pkt_filter_port_dst,
4203 (void *)&cmd_pkt_filter_flexbytes,
4204 (void *)&cmd_pkt_filter_flexbytes_value,
4205 (void *)&cmd_pkt_filter_vlan,
4206 (void *)&cmd_pkt_filter_vlan_id,
4212 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4213 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4214 pkt_filter, "add_perfect_filter");
4215 cmdline_parse_inst_t cmd_add_perfect_filter = {
4216 .f = cmd_pkt_filter_parsed,
4218 .help_str = "add a perfect filter",
4220 (void *)&cmd_pkt_filter_add_perfect_filter,
4221 (void *)&cmd_pkt_filter_port_id,
4222 (void *)&cmd_pkt_filter_protocol,
4223 (void *)&cmd_pkt_filter_src,
4224 (void *)&cmd_pkt_filter_ip_src,
4225 (void *)&cmd_pkt_filter_port_src,
4226 (void *)&cmd_pkt_filter_dst,
4227 (void *)&cmd_pkt_filter_ip_dst,
4228 (void *)&cmd_pkt_filter_port_dst,
4229 (void *)&cmd_pkt_filter_flexbytes,
4230 (void *)&cmd_pkt_filter_flexbytes_value,
4231 (void *)&cmd_pkt_filter_vlan,
4232 (void *)&cmd_pkt_filter_vlan_id,
4233 (void *)&cmd_pkt_filter_queue,
4234 (void *)&cmd_pkt_filter_queue_id,
4235 (void *)&cmd_pkt_filter_soft,
4236 (void *)&cmd_pkt_filter_soft_id,
4242 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4243 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4244 pkt_filter, "upd_perfect_filter");
4245 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4246 .f = cmd_pkt_filter_parsed,
4248 .help_str = "update a perfect filter",
4250 (void *)&cmd_pkt_filter_upd_perfect_filter,
4251 (void *)&cmd_pkt_filter_port_id,
4252 (void *)&cmd_pkt_filter_protocol,
4253 (void *)&cmd_pkt_filter_src,
4254 (void *)&cmd_pkt_filter_ip_src,
4255 (void *)&cmd_pkt_filter_port_src,
4256 (void *)&cmd_pkt_filter_dst,
4257 (void *)&cmd_pkt_filter_ip_dst,
4258 (void *)&cmd_pkt_filter_port_dst,
4259 (void *)&cmd_pkt_filter_flexbytes,
4260 (void *)&cmd_pkt_filter_flexbytes_value,
4261 (void *)&cmd_pkt_filter_vlan,
4262 (void *)&cmd_pkt_filter_vlan_id,
4263 (void *)&cmd_pkt_filter_queue,
4264 (void *)&cmd_pkt_filter_queue_id,
4265 (void *)&cmd_pkt_filter_soft,
4266 (void *)&cmd_pkt_filter_soft_id,
4272 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4273 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4274 pkt_filter, "rm_perfect_filter");
4275 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4276 .f = cmd_pkt_filter_parsed,
4278 .help_str = "remove a perfect filter",
4280 (void *)&cmd_pkt_filter_rm_perfect_filter,
4281 (void *)&cmd_pkt_filter_port_id,
4282 (void *)&cmd_pkt_filter_protocol,
4283 (void *)&cmd_pkt_filter_src,
4284 (void *)&cmd_pkt_filter_ip_src,
4285 (void *)&cmd_pkt_filter_port_src,
4286 (void *)&cmd_pkt_filter_dst,
4287 (void *)&cmd_pkt_filter_ip_dst,
4288 (void *)&cmd_pkt_filter_port_dst,
4289 (void *)&cmd_pkt_filter_flexbytes,
4290 (void *)&cmd_pkt_filter_flexbytes_value,
4291 (void *)&cmd_pkt_filter_vlan,
4292 (void *)&cmd_pkt_filter_vlan_id,
4293 (void *)&cmd_pkt_filter_soft,
4294 (void *)&cmd_pkt_filter_soft_id,
4299 /* *** SETUP MASKS FILTER *** */
4300 struct cmd_pkt_filter_masks_result {
4301 cmdline_fixed_string_t filter_mask;
4303 cmdline_fixed_string_t src_mask;
4304 uint32_t ip_src_mask;
4305 uint16_t ipv6_src_mask;
4306 uint16_t port_src_mask;
4307 cmdline_fixed_string_t dst_mask;
4308 uint32_t ip_dst_mask;
4309 uint16_t ipv6_dst_mask;
4310 uint16_t port_dst_mask;
4311 cmdline_fixed_string_t flexbytes;
4312 uint8_t flexbytes_value;
4313 cmdline_fixed_string_t vlan_id;
4314 uint8_t vlan_id_value;
4315 cmdline_fixed_string_t vlan_prio;
4316 uint8_t vlan_prio_value;
4317 cmdline_fixed_string_t only_ip_flow;
4318 uint8_t only_ip_flow_value;
4319 cmdline_fixed_string_t comp_ipv6_dst;
4320 uint8_t comp_ipv6_dst_value;
4324 cmd_pkt_filter_masks_parsed(void *parsed_result,
4325 __attribute__((unused)) struct cmdline *cl,
4326 __attribute__((unused)) void *data)
4328 struct rte_fdir_masks fdir_masks;
4329 struct cmd_pkt_filter_masks_result *res = parsed_result;
4331 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4333 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4334 fdir_masks.vlan_id = res->vlan_id_value;
4335 fdir_masks.vlan_prio = res->vlan_prio_value;
4336 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4337 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4338 fdir_masks.src_port_mask = res->port_src_mask;
4339 fdir_masks.dst_port_mask = res->port_dst_mask;
4340 fdir_masks.flexbytes = res->flexbytes_value;
4342 fdir_set_masks(res->port_id, &fdir_masks);
4345 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4346 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4347 filter_mask, "set_masks_filter");
4348 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4349 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4351 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4352 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4353 only_ip_flow, "only_ip_flow");
4354 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4355 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4356 only_ip_flow_value, UINT8);
4357 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4358 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4359 src_mask, "src_mask");
4360 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4361 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4362 ip_src_mask, UINT32);
4363 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4364 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4365 port_src_mask, UINT16);
4366 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4367 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4368 dst_mask, "dst_mask");
4369 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4370 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4371 ip_dst_mask, UINT32);
4372 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4373 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4374 port_dst_mask, UINT16);
4375 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4376 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4377 flexbytes, "flexbytes");
4378 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4379 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4380 flexbytes_value, UINT8);
4381 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4382 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4383 vlan_id, "vlan_id");
4384 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4385 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4386 vlan_id_value, UINT8);
4387 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4388 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4389 vlan_prio, "vlan_prio");
4390 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4391 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4392 vlan_prio_value, UINT8);
4394 cmdline_parse_inst_t cmd_set_masks_filter = {
4395 .f = cmd_pkt_filter_masks_parsed,
4397 .help_str = "setup masks filter",
4399 (void *)&cmd_pkt_filter_masks_filter_mask,
4400 (void *)&cmd_pkt_filter_masks_port_id,
4401 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4402 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4403 (void *)&cmd_pkt_filter_masks_src_mask,
4404 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4405 (void *)&cmd_pkt_filter_masks_port_src_mask,
4406 (void *)&cmd_pkt_filter_masks_dst_mask,
4407 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4408 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4409 (void *)&cmd_pkt_filter_masks_flexbytes,
4410 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4411 (void *)&cmd_pkt_filter_masks_vlan_id,
4412 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4413 (void *)&cmd_pkt_filter_masks_vlan_prio,
4414 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4420 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4421 __attribute__((unused)) struct cmdline *cl,
4422 __attribute__((unused)) void *data)
4424 struct rte_fdir_masks fdir_masks;
4425 struct cmd_pkt_filter_masks_result *res = parsed_result;
4427 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4429 fdir_masks.set_ipv6_mask = 1;
4430 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4431 fdir_masks.vlan_id = res->vlan_id_value;
4432 fdir_masks.vlan_prio = res->vlan_prio_value;
4433 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4434 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4435 fdir_masks.src_port_mask = res->port_src_mask;
4436 fdir_masks.dst_port_mask = res->port_dst_mask;
4437 fdir_masks.flexbytes = res->flexbytes_value;
4438 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4440 fdir_set_masks(res->port_id, &fdir_masks);
4443 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4444 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4445 filter_mask, "set_ipv6_masks_filter");
4446 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4447 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4448 ipv6_src_mask, UINT16);
4449 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4450 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4451 ipv6_dst_mask, UINT16);
4453 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4454 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4455 comp_ipv6_dst, "compare_dst");
4456 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4457 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4458 comp_ipv6_dst_value, UINT8);
4460 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4461 .f = cmd_pkt_filter_masks_ipv6_parsed,
4463 .help_str = "setup ipv6 masks filter",
4465 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4466 (void *)&cmd_pkt_filter_masks_port_id,
4467 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4468 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4469 (void *)&cmd_pkt_filter_masks_src_mask,
4470 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4471 (void *)&cmd_pkt_filter_masks_port_src_mask,
4472 (void *)&cmd_pkt_filter_masks_dst_mask,
4473 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4474 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4475 (void *)&cmd_pkt_filter_masks_flexbytes,
4476 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4477 (void *)&cmd_pkt_filter_masks_vlan_id,
4478 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4479 (void *)&cmd_pkt_filter_masks_vlan_prio,
4480 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4481 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4482 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4487 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4488 struct cmd_link_flow_ctrl_set_result {
4489 cmdline_fixed_string_t set;
4490 cmdline_fixed_string_t flow_ctrl;
4491 cmdline_fixed_string_t rx;
4492 cmdline_fixed_string_t rx_lfc_mode;
4493 cmdline_fixed_string_t tx;
4494 cmdline_fixed_string_t tx_lfc_mode;
4495 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4496 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4497 cmdline_fixed_string_t autoneg_str;
4498 cmdline_fixed_string_t autoneg;
4499 cmdline_fixed_string_t hw_str;
4500 uint32_t high_water;
4501 cmdline_fixed_string_t lw_str;
4503 cmdline_fixed_string_t pt_str;
4504 uint16_t pause_time;
4505 cmdline_fixed_string_t xon_str;
4510 cmdline_parse_token_string_t cmd_lfc_set_set =
4511 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4513 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4514 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4515 flow_ctrl, "flow_ctrl");
4516 cmdline_parse_token_string_t cmd_lfc_set_rx =
4517 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4519 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4520 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4521 rx_lfc_mode, "on#off");
4522 cmdline_parse_token_string_t cmd_lfc_set_tx =
4523 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4525 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4526 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4527 tx_lfc_mode, "on#off");
4528 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4529 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4530 hw_str, "high_water");
4531 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4532 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4533 high_water, UINT32);
4534 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4535 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4536 lw_str, "low_water");
4537 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4538 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4540 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4541 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4542 pt_str, "pause_time");
4543 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4544 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4545 pause_time, UINT16);
4546 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4547 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4548 xon_str, "send_xon");
4549 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4550 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4552 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4553 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4555 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4556 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4557 mac_ctrl_frame_fwd_mode, "on#off");
4558 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4559 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4560 autoneg_str, "autoneg");
4561 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4564 cmdline_parse_token_num_t cmd_lfc_set_portid =
4565 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4568 /* forward declaration */
4570 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4573 cmdline_parse_inst_t cmd_link_flow_control_set = {
4574 .f = cmd_link_flow_ctrl_set_parsed,
4576 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4577 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4578 autoneg on|off port_id",
4580 (void *)&cmd_lfc_set_set,
4581 (void *)&cmd_lfc_set_flow_ctrl,
4582 (void *)&cmd_lfc_set_rx,
4583 (void *)&cmd_lfc_set_rx_mode,
4584 (void *)&cmd_lfc_set_tx,
4585 (void *)&cmd_lfc_set_tx_mode,
4586 (void *)&cmd_lfc_set_high_water,
4587 (void *)&cmd_lfc_set_low_water,
4588 (void *)&cmd_lfc_set_pause_time,
4589 (void *)&cmd_lfc_set_send_xon,
4590 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4591 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4592 (void *)&cmd_lfc_set_autoneg_str,
4593 (void *)&cmd_lfc_set_autoneg,
4594 (void *)&cmd_lfc_set_portid,
4599 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4600 .f = cmd_link_flow_ctrl_set_parsed,
4601 .data = (void *)&cmd_link_flow_control_set_rx,
4602 .help_str = "Change rx flow control parameter: set flow_ctrl "
4603 "rx on|off port_id",
4605 (void *)&cmd_lfc_set_set,
4606 (void *)&cmd_lfc_set_flow_ctrl,
4607 (void *)&cmd_lfc_set_rx,
4608 (void *)&cmd_lfc_set_rx_mode,
4609 (void *)&cmd_lfc_set_portid,
4614 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4615 .f = cmd_link_flow_ctrl_set_parsed,
4616 .data = (void *)&cmd_link_flow_control_set_tx,
4617 .help_str = "Change tx flow control parameter: set flow_ctrl "
4618 "tx on|off port_id",
4620 (void *)&cmd_lfc_set_set,
4621 (void *)&cmd_lfc_set_flow_ctrl,
4622 (void *)&cmd_lfc_set_tx,
4623 (void *)&cmd_lfc_set_tx_mode,
4624 (void *)&cmd_lfc_set_portid,
4629 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4630 .f = cmd_link_flow_ctrl_set_parsed,
4631 .data = (void *)&cmd_link_flow_control_set_hw,
4632 .help_str = "Change high water flow control parameter: set flow_ctrl "
4633 "high_water value port_id",
4635 (void *)&cmd_lfc_set_set,
4636 (void *)&cmd_lfc_set_flow_ctrl,
4637 (void *)&cmd_lfc_set_high_water_str,
4638 (void *)&cmd_lfc_set_high_water,
4639 (void *)&cmd_lfc_set_portid,
4644 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4645 .f = cmd_link_flow_ctrl_set_parsed,
4646 .data = (void *)&cmd_link_flow_control_set_lw,
4647 .help_str = "Change low water flow control parameter: set flow_ctrl "
4648 "low_water value port_id",
4650 (void *)&cmd_lfc_set_set,
4651 (void *)&cmd_lfc_set_flow_ctrl,
4652 (void *)&cmd_lfc_set_low_water_str,
4653 (void *)&cmd_lfc_set_low_water,
4654 (void *)&cmd_lfc_set_portid,
4659 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4660 .f = cmd_link_flow_ctrl_set_parsed,
4661 .data = (void *)&cmd_link_flow_control_set_pt,
4662 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4663 "pause_time value port_id",
4665 (void *)&cmd_lfc_set_set,
4666 (void *)&cmd_lfc_set_flow_ctrl,
4667 (void *)&cmd_lfc_set_pause_time_str,
4668 (void *)&cmd_lfc_set_pause_time,
4669 (void *)&cmd_lfc_set_portid,
4674 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4675 .f = cmd_link_flow_ctrl_set_parsed,
4676 .data = (void *)&cmd_link_flow_control_set_xon,
4677 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4678 "send_xon value port_id",
4680 (void *)&cmd_lfc_set_set,
4681 (void *)&cmd_lfc_set_flow_ctrl,
4682 (void *)&cmd_lfc_set_send_xon_str,
4683 (void *)&cmd_lfc_set_send_xon,
4684 (void *)&cmd_lfc_set_portid,
4689 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4690 .f = cmd_link_flow_ctrl_set_parsed,
4691 .data = (void *)&cmd_link_flow_control_set_macfwd,
4692 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4693 "mac_ctrl_frame_fwd on|off port_id",
4695 (void *)&cmd_lfc_set_set,
4696 (void *)&cmd_lfc_set_flow_ctrl,
4697 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4698 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4699 (void *)&cmd_lfc_set_portid,
4704 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4705 .f = cmd_link_flow_ctrl_set_parsed,
4706 .data = (void *)&cmd_link_flow_control_set_autoneg,
4707 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4708 "autoneg on|off port_id",
4710 (void *)&cmd_lfc_set_set,
4711 (void *)&cmd_lfc_set_flow_ctrl,
4712 (void *)&cmd_lfc_set_autoneg_str,
4713 (void *)&cmd_lfc_set_autoneg,
4714 (void *)&cmd_lfc_set_portid,
4720 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4721 __attribute__((unused)) struct cmdline *cl,
4724 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4725 cmdline_parse_inst_t *cmd = data;
4726 struct rte_eth_fc_conf fc_conf;
4727 int rx_fc_en, tx_fc_en;
4731 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4732 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4733 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4734 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4736 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4737 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4740 /* Partial command line, retrieve current configuration */
4742 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4744 printf("cannot get current flow ctrl parameters, return"
4745 "code = %d\n", ret);
4749 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4750 (fc_conf.mode == RTE_FC_FULL))
4752 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4753 (fc_conf.mode == RTE_FC_FULL))
4757 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4758 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4760 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4761 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4763 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4765 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4766 fc_conf.high_water = res->high_water;
4768 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4769 fc_conf.low_water = res->low_water;
4771 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4772 fc_conf.pause_time = res->pause_time;
4774 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4775 fc_conf.send_xon = res->send_xon;
4777 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4778 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4779 fc_conf.mac_ctrl_frame_fwd = 1;
4781 fc_conf.mac_ctrl_frame_fwd = 0;
4784 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4785 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4787 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4789 printf("bad flow contrl parameter, return code = %d \n", ret);
4792 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4793 struct cmd_priority_flow_ctrl_set_result {
4794 cmdline_fixed_string_t set;
4795 cmdline_fixed_string_t pfc_ctrl;
4796 cmdline_fixed_string_t rx;
4797 cmdline_fixed_string_t rx_pfc_mode;
4798 cmdline_fixed_string_t tx;
4799 cmdline_fixed_string_t tx_pfc_mode;
4800 uint32_t high_water;
4802 uint16_t pause_time;
4808 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4809 __attribute__((unused)) struct cmdline *cl,
4810 __attribute__((unused)) void *data)
4812 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4813 struct rte_eth_pfc_conf pfc_conf;
4814 int rx_fc_enable, tx_fc_enable;
4818 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4819 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4820 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4821 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4823 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4824 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4827 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4828 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4829 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4830 pfc_conf.fc.high_water = res->high_water;
4831 pfc_conf.fc.low_water = res->low_water;
4832 pfc_conf.fc.pause_time = res->pause_time;
4833 pfc_conf.priority = res->priority;
4835 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4837 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4840 cmdline_parse_token_string_t cmd_pfc_set_set =
4841 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4843 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4844 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4845 pfc_ctrl, "pfc_ctrl");
4846 cmdline_parse_token_string_t cmd_pfc_set_rx =
4847 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4849 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4850 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4851 rx_pfc_mode, "on#off");
4852 cmdline_parse_token_string_t cmd_pfc_set_tx =
4853 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4855 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4856 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4857 tx_pfc_mode, "on#off");
4858 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4859 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4860 high_water, UINT32);
4861 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4862 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4864 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4865 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4866 pause_time, UINT16);
4867 cmdline_parse_token_num_t cmd_pfc_set_priority =
4868 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4870 cmdline_parse_token_num_t cmd_pfc_set_portid =
4871 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4874 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4875 .f = cmd_priority_flow_ctrl_set_parsed,
4877 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4878 tx on|off high_water low_water pause_time priority port_id",
4880 (void *)&cmd_pfc_set_set,
4881 (void *)&cmd_pfc_set_flow_ctrl,
4882 (void *)&cmd_pfc_set_rx,
4883 (void *)&cmd_pfc_set_rx_mode,
4884 (void *)&cmd_pfc_set_tx,
4885 (void *)&cmd_pfc_set_tx_mode,
4886 (void *)&cmd_pfc_set_high_water,
4887 (void *)&cmd_pfc_set_low_water,
4888 (void *)&cmd_pfc_set_pause_time,
4889 (void *)&cmd_pfc_set_priority,
4890 (void *)&cmd_pfc_set_portid,
4895 /* *** RESET CONFIGURATION *** */
4896 struct cmd_reset_result {
4897 cmdline_fixed_string_t reset;
4898 cmdline_fixed_string_t def;
4901 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4903 __attribute__((unused)) void *data)
4905 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4906 set_def_fwd_config();
4909 cmdline_parse_token_string_t cmd_reset_set =
4910 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4911 cmdline_parse_token_string_t cmd_reset_def =
4912 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4915 cmdline_parse_inst_t cmd_reset = {
4916 .f = cmd_reset_parsed,
4918 .help_str = "set default: reset default forwarding configuration",
4920 (void *)&cmd_reset_set,
4921 (void *)&cmd_reset_def,
4926 /* *** START FORWARDING *** */
4927 struct cmd_start_result {
4928 cmdline_fixed_string_t start;
4931 cmdline_parse_token_string_t cmd_start_start =
4932 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4934 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4935 __attribute__((unused)) struct cmdline *cl,
4936 __attribute__((unused)) void *data)
4938 start_packet_forwarding(0);
4941 cmdline_parse_inst_t cmd_start = {
4942 .f = cmd_start_parsed,
4944 .help_str = "start packet forwarding",
4946 (void *)&cmd_start_start,
4951 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4952 struct cmd_start_tx_first_result {
4953 cmdline_fixed_string_t start;
4954 cmdline_fixed_string_t tx_first;
4958 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4959 __attribute__((unused)) struct cmdline *cl,
4960 __attribute__((unused)) void *data)
4962 start_packet_forwarding(1);
4965 cmdline_parse_token_string_t cmd_start_tx_first_start =
4966 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4968 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4969 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4970 tx_first, "tx_first");
4972 cmdline_parse_inst_t cmd_start_tx_first = {
4973 .f = cmd_start_tx_first_parsed,
4975 .help_str = "start packet forwarding, after sending 1 burst of packets",
4977 (void *)&cmd_start_tx_first_start,
4978 (void *)&cmd_start_tx_first_tx_first,
4983 /* *** SET LINK UP *** */
4984 struct cmd_set_link_up_result {
4985 cmdline_fixed_string_t set;
4986 cmdline_fixed_string_t link_up;
4987 cmdline_fixed_string_t port;
4991 cmdline_parse_token_string_t cmd_set_link_up_set =
4992 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4993 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4996 cmdline_parse_token_string_t cmd_set_link_up_port =
4997 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4998 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4999 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5001 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5002 __attribute__((unused)) struct cmdline *cl,
5003 __attribute__((unused)) void *data)
5005 struct cmd_set_link_up_result *res = parsed_result;
5006 dev_set_link_up(res->port_id);
5009 cmdline_parse_inst_t cmd_set_link_up = {
5010 .f = cmd_set_link_up_parsed,
5012 .help_str = "set link-up port (port id)",
5014 (void *)&cmd_set_link_up_set,
5015 (void *)&cmd_set_link_up_link_up,
5016 (void *)&cmd_set_link_up_port,
5017 (void *)&cmd_set_link_up_port_id,
5022 /* *** SET LINK DOWN *** */
5023 struct cmd_set_link_down_result {
5024 cmdline_fixed_string_t set;
5025 cmdline_fixed_string_t link_down;
5026 cmdline_fixed_string_t port;
5030 cmdline_parse_token_string_t cmd_set_link_down_set =
5031 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5032 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5033 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5035 cmdline_parse_token_string_t cmd_set_link_down_port =
5036 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5037 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5038 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5040 static void cmd_set_link_down_parsed(
5041 __attribute__((unused)) void *parsed_result,
5042 __attribute__((unused)) struct cmdline *cl,
5043 __attribute__((unused)) void *data)
5045 struct cmd_set_link_down_result *res = parsed_result;
5046 dev_set_link_down(res->port_id);
5049 cmdline_parse_inst_t cmd_set_link_down = {
5050 .f = cmd_set_link_down_parsed,
5052 .help_str = "set link-down port (port id)",
5054 (void *)&cmd_set_link_down_set,
5055 (void *)&cmd_set_link_down_link_down,
5056 (void *)&cmd_set_link_down_port,
5057 (void *)&cmd_set_link_down_port_id,
5062 /* *** SHOW CFG *** */
5063 struct cmd_showcfg_result {
5064 cmdline_fixed_string_t show;
5065 cmdline_fixed_string_t cfg;
5066 cmdline_fixed_string_t what;
5069 static void cmd_showcfg_parsed(void *parsed_result,
5070 __attribute__((unused)) struct cmdline *cl,
5071 __attribute__((unused)) void *data)
5073 struct cmd_showcfg_result *res = parsed_result;
5074 if (!strcmp(res->what, "rxtx"))
5075 rxtx_config_display();
5076 else if (!strcmp(res->what, "cores"))
5077 fwd_lcores_config_display();
5078 else if (!strcmp(res->what, "fwd"))
5079 fwd_config_display();
5082 cmdline_parse_token_string_t cmd_showcfg_show =
5083 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5084 cmdline_parse_token_string_t cmd_showcfg_port =
5085 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5086 cmdline_parse_token_string_t cmd_showcfg_what =
5087 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5090 cmdline_parse_inst_t cmd_showcfg = {
5091 .f = cmd_showcfg_parsed,
5093 .help_str = "show config rxtx|cores|fwd",
5095 (void *)&cmd_showcfg_show,
5096 (void *)&cmd_showcfg_port,
5097 (void *)&cmd_showcfg_what,
5102 /* *** SHOW ALL PORT INFO *** */
5103 struct cmd_showportall_result {
5104 cmdline_fixed_string_t show;
5105 cmdline_fixed_string_t port;
5106 cmdline_fixed_string_t what;
5107 cmdline_fixed_string_t all;
5110 static void cmd_showportall_parsed(void *parsed_result,
5111 __attribute__((unused)) struct cmdline *cl,
5112 __attribute__((unused)) void *data)
5116 struct cmd_showportall_result *res = parsed_result;
5117 if (!strcmp(res->show, "clear")) {
5118 if (!strcmp(res->what, "stats"))
5119 for (i = 0; i < nb_ports; i++)
5121 else if (!strcmp(res->what, "xstats"))
5122 for (i = 0; i < nb_ports; i++)
5123 nic_xstats_clear(i);
5124 } else if (!strcmp(res->what, "info"))
5125 for (i = 0; i < nb_ports; i++)
5126 port_infos_display(i);
5127 else if (!strcmp(res->what, "stats"))
5128 for (i = 0; i < nb_ports; i++)
5129 nic_stats_display(i);
5130 else if (!strcmp(res->what, "xstats"))
5131 for (i = 0; i < nb_ports; i++)
5132 nic_xstats_display(i);
5133 else if (!strcmp(res->what, "fdir"))
5134 for (i = 0; i < nb_ports; i++)
5136 else if (!strcmp(res->what, "stat_qmap"))
5137 for (i = 0; i < nb_ports; i++)
5138 nic_stats_mapping_display(i);
5141 cmdline_parse_token_string_t cmd_showportall_show =
5142 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5144 cmdline_parse_token_string_t cmd_showportall_port =
5145 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5146 cmdline_parse_token_string_t cmd_showportall_what =
5147 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5148 "info#stats#xstats#fdir#stat_qmap");
5149 cmdline_parse_token_string_t cmd_showportall_all =
5150 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5151 cmdline_parse_inst_t cmd_showportall = {
5152 .f = cmd_showportall_parsed,
5154 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5156 (void *)&cmd_showportall_show,
5157 (void *)&cmd_showportall_port,
5158 (void *)&cmd_showportall_what,
5159 (void *)&cmd_showportall_all,
5164 /* *** SHOW PORT INFO *** */
5165 struct cmd_showport_result {
5166 cmdline_fixed_string_t show;
5167 cmdline_fixed_string_t port;
5168 cmdline_fixed_string_t what;
5172 static void cmd_showport_parsed(void *parsed_result,
5173 __attribute__((unused)) struct cmdline *cl,
5174 __attribute__((unused)) void *data)
5176 struct cmd_showport_result *res = parsed_result;
5177 if (!strcmp(res->show, "clear")) {
5178 if (!strcmp(res->what, "stats"))
5179 nic_stats_clear(res->portnum);
5180 else if (!strcmp(res->what, "xstats"))
5181 nic_xstats_clear(res->portnum);
5182 } else if (!strcmp(res->what, "info"))
5183 port_infos_display(res->portnum);
5184 else if (!strcmp(res->what, "stats"))
5185 nic_stats_display(res->portnum);
5186 else if (!strcmp(res->what, "xstats"))
5187 nic_xstats_display(res->portnum);
5188 else if (!strcmp(res->what, "fdir"))
5189 fdir_get_infos(res->portnum);
5190 else if (!strcmp(res->what, "stat_qmap"))
5191 nic_stats_mapping_display(res->portnum);
5194 cmdline_parse_token_string_t cmd_showport_show =
5195 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5197 cmdline_parse_token_string_t cmd_showport_port =
5198 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5199 cmdline_parse_token_string_t cmd_showport_what =
5200 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5201 "info#stats#xstats#fdir#stat_qmap");
5202 cmdline_parse_token_num_t cmd_showport_portnum =
5203 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5205 cmdline_parse_inst_t cmd_showport = {
5206 .f = cmd_showport_parsed,
5208 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5210 (void *)&cmd_showport_show,
5211 (void *)&cmd_showport_port,
5212 (void *)&cmd_showport_what,
5213 (void *)&cmd_showport_portnum,
5218 /* *** READ PORT REGISTER *** */
5219 struct cmd_read_reg_result {
5220 cmdline_fixed_string_t read;
5221 cmdline_fixed_string_t reg;
5227 cmd_read_reg_parsed(void *parsed_result,
5228 __attribute__((unused)) struct cmdline *cl,
5229 __attribute__((unused)) void *data)
5231 struct cmd_read_reg_result *res = parsed_result;
5232 port_reg_display(res->port_id, res->reg_off);
5235 cmdline_parse_token_string_t cmd_read_reg_read =
5236 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5237 cmdline_parse_token_string_t cmd_read_reg_reg =
5238 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5239 cmdline_parse_token_num_t cmd_read_reg_port_id =
5240 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5241 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5242 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5244 cmdline_parse_inst_t cmd_read_reg = {
5245 .f = cmd_read_reg_parsed,
5247 .help_str = "read reg port_id reg_off",
5249 (void *)&cmd_read_reg_read,
5250 (void *)&cmd_read_reg_reg,
5251 (void *)&cmd_read_reg_port_id,
5252 (void *)&cmd_read_reg_reg_off,
5257 /* *** READ PORT REGISTER BIT FIELD *** */
5258 struct cmd_read_reg_bit_field_result {
5259 cmdline_fixed_string_t read;
5260 cmdline_fixed_string_t regfield;
5268 cmd_read_reg_bit_field_parsed(void *parsed_result,
5269 __attribute__((unused)) struct cmdline *cl,
5270 __attribute__((unused)) void *data)
5272 struct cmd_read_reg_bit_field_result *res = parsed_result;
5273 port_reg_bit_field_display(res->port_id, res->reg_off,
5274 res->bit1_pos, res->bit2_pos);
5277 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5278 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5280 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5281 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5282 regfield, "regfield");
5283 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5284 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5286 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5287 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5289 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5290 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5292 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5293 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5296 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5297 .f = cmd_read_reg_bit_field_parsed,
5299 .help_str = "read regfield port_id reg_off bit_x bit_y "
5300 "(read register bit field between bit_x and bit_y included)",
5302 (void *)&cmd_read_reg_bit_field_read,
5303 (void *)&cmd_read_reg_bit_field_regfield,
5304 (void *)&cmd_read_reg_bit_field_port_id,
5305 (void *)&cmd_read_reg_bit_field_reg_off,
5306 (void *)&cmd_read_reg_bit_field_bit1_pos,
5307 (void *)&cmd_read_reg_bit_field_bit2_pos,
5312 /* *** READ PORT REGISTER BIT *** */
5313 struct cmd_read_reg_bit_result {
5314 cmdline_fixed_string_t read;
5315 cmdline_fixed_string_t regbit;
5322 cmd_read_reg_bit_parsed(void *parsed_result,
5323 __attribute__((unused)) struct cmdline *cl,
5324 __attribute__((unused)) void *data)
5326 struct cmd_read_reg_bit_result *res = parsed_result;
5327 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5330 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5331 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5332 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5333 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5335 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5336 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5337 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5338 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5339 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5340 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5342 cmdline_parse_inst_t cmd_read_reg_bit = {
5343 .f = cmd_read_reg_bit_parsed,
5345 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5347 (void *)&cmd_read_reg_bit_read,
5348 (void *)&cmd_read_reg_bit_regbit,
5349 (void *)&cmd_read_reg_bit_port_id,
5350 (void *)&cmd_read_reg_bit_reg_off,
5351 (void *)&cmd_read_reg_bit_bit_pos,
5356 /* *** WRITE PORT REGISTER *** */
5357 struct cmd_write_reg_result {
5358 cmdline_fixed_string_t write;
5359 cmdline_fixed_string_t reg;
5366 cmd_write_reg_parsed(void *parsed_result,
5367 __attribute__((unused)) struct cmdline *cl,
5368 __attribute__((unused)) void *data)
5370 struct cmd_write_reg_result *res = parsed_result;
5371 port_reg_set(res->port_id, res->reg_off, res->value);
5374 cmdline_parse_token_string_t cmd_write_reg_write =
5375 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5376 cmdline_parse_token_string_t cmd_write_reg_reg =
5377 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5378 cmdline_parse_token_num_t cmd_write_reg_port_id =
5379 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5380 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5381 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5382 cmdline_parse_token_num_t cmd_write_reg_value =
5383 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5385 cmdline_parse_inst_t cmd_write_reg = {
5386 .f = cmd_write_reg_parsed,
5388 .help_str = "write reg port_id reg_off reg_value",
5390 (void *)&cmd_write_reg_write,
5391 (void *)&cmd_write_reg_reg,
5392 (void *)&cmd_write_reg_port_id,
5393 (void *)&cmd_write_reg_reg_off,
5394 (void *)&cmd_write_reg_value,
5399 /* *** WRITE PORT REGISTER BIT FIELD *** */
5400 struct cmd_write_reg_bit_field_result {
5401 cmdline_fixed_string_t write;
5402 cmdline_fixed_string_t regfield;
5411 cmd_write_reg_bit_field_parsed(void *parsed_result,
5412 __attribute__((unused)) struct cmdline *cl,
5413 __attribute__((unused)) void *data)
5415 struct cmd_write_reg_bit_field_result *res = parsed_result;
5416 port_reg_bit_field_set(res->port_id, res->reg_off,
5417 res->bit1_pos, res->bit2_pos, res->value);
5420 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5421 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5423 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5424 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5425 regfield, "regfield");
5426 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5427 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5429 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5430 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5432 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5433 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5435 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5438 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5439 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5442 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5443 .f = cmd_write_reg_bit_field_parsed,
5445 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5446 "(set register bit field between bit_x and bit_y included)",
5448 (void *)&cmd_write_reg_bit_field_write,
5449 (void *)&cmd_write_reg_bit_field_regfield,
5450 (void *)&cmd_write_reg_bit_field_port_id,
5451 (void *)&cmd_write_reg_bit_field_reg_off,
5452 (void *)&cmd_write_reg_bit_field_bit1_pos,
5453 (void *)&cmd_write_reg_bit_field_bit2_pos,
5454 (void *)&cmd_write_reg_bit_field_value,
5459 /* *** WRITE PORT REGISTER BIT *** */
5460 struct cmd_write_reg_bit_result {
5461 cmdline_fixed_string_t write;
5462 cmdline_fixed_string_t regbit;
5470 cmd_write_reg_bit_parsed(void *parsed_result,
5471 __attribute__((unused)) struct cmdline *cl,
5472 __attribute__((unused)) void *data)
5474 struct cmd_write_reg_bit_result *res = parsed_result;
5475 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5478 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5479 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5481 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5482 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5484 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5485 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5486 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5487 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5488 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5489 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5490 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5491 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5493 cmdline_parse_inst_t cmd_write_reg_bit = {
5494 .f = cmd_write_reg_bit_parsed,
5496 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5498 (void *)&cmd_write_reg_bit_write,
5499 (void *)&cmd_write_reg_bit_regbit,
5500 (void *)&cmd_write_reg_bit_port_id,
5501 (void *)&cmd_write_reg_bit_reg_off,
5502 (void *)&cmd_write_reg_bit_bit_pos,
5503 (void *)&cmd_write_reg_bit_value,
5508 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5509 struct cmd_read_rxd_txd_result {
5510 cmdline_fixed_string_t read;
5511 cmdline_fixed_string_t rxd_txd;
5518 cmd_read_rxd_txd_parsed(void *parsed_result,
5519 __attribute__((unused)) struct cmdline *cl,
5520 __attribute__((unused)) void *data)
5522 struct cmd_read_rxd_txd_result *res = parsed_result;
5524 if (!strcmp(res->rxd_txd, "rxd"))
5525 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5526 else if (!strcmp(res->rxd_txd, "txd"))
5527 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5530 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5531 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5532 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5533 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5535 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5536 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5537 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5538 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5539 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5540 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5542 cmdline_parse_inst_t cmd_read_rxd_txd = {
5543 .f = cmd_read_rxd_txd_parsed,
5545 .help_str = "read rxd|txd port_id queue_id rxd_id",
5547 (void *)&cmd_read_rxd_txd_read,
5548 (void *)&cmd_read_rxd_txd_rxd_txd,
5549 (void *)&cmd_read_rxd_txd_port_id,
5550 (void *)&cmd_read_rxd_txd_queue_id,
5551 (void *)&cmd_read_rxd_txd_desc_id,
5557 struct cmd_quit_result {
5558 cmdline_fixed_string_t quit;
5561 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5563 __attribute__((unused)) void *data)
5569 cmdline_parse_token_string_t cmd_quit_quit =
5570 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5572 cmdline_parse_inst_t cmd_quit = {
5573 .f = cmd_quit_parsed,
5575 .help_str = "exit application",
5577 (void *)&cmd_quit_quit,
5582 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5583 struct cmd_mac_addr_result {
5584 cmdline_fixed_string_t mac_addr_cmd;
5585 cmdline_fixed_string_t what;
5587 struct ether_addr address;
5590 static void cmd_mac_addr_parsed(void *parsed_result,
5591 __attribute__((unused)) struct cmdline *cl,
5592 __attribute__((unused)) void *data)
5594 struct cmd_mac_addr_result *res = parsed_result;
5597 if (strcmp(res->what, "add") == 0)
5598 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5600 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5602 /* check the return value and print it if is < 0 */
5604 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5608 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5609 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5611 cmdline_parse_token_string_t cmd_mac_addr_what =
5612 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5614 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5615 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5616 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5619 cmdline_parse_inst_t cmd_mac_addr = {
5620 .f = cmd_mac_addr_parsed,
5622 .help_str = "mac_addr add|remove X <address>: "
5623 "add/remove MAC address on port X",
5625 (void *)&cmd_mac_addr_cmd,
5626 (void *)&cmd_mac_addr_what,
5627 (void *)&cmd_mac_addr_portnum,
5628 (void *)&cmd_mac_addr_addr,
5634 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5635 struct cmd_set_qmap_result {
5636 cmdline_fixed_string_t set;
5637 cmdline_fixed_string_t qmap;
5638 cmdline_fixed_string_t what;
5645 cmd_set_qmap_parsed(void *parsed_result,
5646 __attribute__((unused)) struct cmdline *cl,
5647 __attribute__((unused)) void *data)
5649 struct cmd_set_qmap_result *res = parsed_result;
5650 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5652 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5655 cmdline_parse_token_string_t cmd_setqmap_set =
5656 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5658 cmdline_parse_token_string_t cmd_setqmap_qmap =
5659 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5661 cmdline_parse_token_string_t cmd_setqmap_what =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5664 cmdline_parse_token_num_t cmd_setqmap_portid =
5665 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5667 cmdline_parse_token_num_t cmd_setqmap_queueid =
5668 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5670 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5671 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5674 cmdline_parse_inst_t cmd_set_qmap = {
5675 .f = cmd_set_qmap_parsed,
5677 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5679 (void *)&cmd_setqmap_set,
5680 (void *)&cmd_setqmap_qmap,
5681 (void *)&cmd_setqmap_what,
5682 (void *)&cmd_setqmap_portid,
5683 (void *)&cmd_setqmap_queueid,
5684 (void *)&cmd_setqmap_mapvalue,
5689 /* *** CONFIGURE UNICAST HASH TABLE *** */
5690 struct cmd_set_uc_hash_table {
5691 cmdline_fixed_string_t set;
5692 cmdline_fixed_string_t port;
5694 cmdline_fixed_string_t what;
5695 struct ether_addr address;
5696 cmdline_fixed_string_t mode;
5700 cmd_set_uc_hash_parsed(void *parsed_result,
5701 __attribute__((unused)) struct cmdline *cl,
5702 __attribute__((unused)) void *data)
5705 struct cmd_set_uc_hash_table *res = parsed_result;
5707 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5709 if (strcmp(res->what, "uta") == 0)
5710 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5711 &res->address,(uint8_t)is_on);
5713 printf("bad unicast hash table parameter, return code = %d \n", ret);
5717 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5718 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5720 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5721 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5723 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5724 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5726 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5727 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5729 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5730 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5732 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5736 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5737 .f = cmd_set_uc_hash_parsed,
5739 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5741 (void *)&cmd_set_uc_hash_set,
5742 (void *)&cmd_set_uc_hash_port,
5743 (void *)&cmd_set_uc_hash_portid,
5744 (void *)&cmd_set_uc_hash_what,
5745 (void *)&cmd_set_uc_hash_mac,
5746 (void *)&cmd_set_uc_hash_mode,
5751 struct cmd_set_uc_all_hash_table {
5752 cmdline_fixed_string_t set;
5753 cmdline_fixed_string_t port;
5755 cmdline_fixed_string_t what;
5756 cmdline_fixed_string_t value;
5757 cmdline_fixed_string_t mode;
5761 cmd_set_uc_all_hash_parsed(void *parsed_result,
5762 __attribute__((unused)) struct cmdline *cl,
5763 __attribute__((unused)) void *data)
5766 struct cmd_set_uc_all_hash_table *res = parsed_result;
5768 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5770 if ((strcmp(res->what, "uta") == 0) &&
5771 (strcmp(res->value, "all") == 0))
5772 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5774 printf("bad unicast hash table parameter,"
5775 "return code = %d \n", ret);
5778 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5781 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5784 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5785 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5787 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5790 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5791 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5793 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5797 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5798 .f = cmd_set_uc_all_hash_parsed,
5800 .help_str = "set port X uta all on|off (X = port number)",
5802 (void *)&cmd_set_uc_all_hash_set,
5803 (void *)&cmd_set_uc_all_hash_port,
5804 (void *)&cmd_set_uc_all_hash_portid,
5805 (void *)&cmd_set_uc_all_hash_what,
5806 (void *)&cmd_set_uc_all_hash_value,
5807 (void *)&cmd_set_uc_all_hash_mode,
5812 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5813 struct cmd_set_vf_traffic {
5814 cmdline_fixed_string_t set;
5815 cmdline_fixed_string_t port;
5817 cmdline_fixed_string_t vf;
5819 cmdline_fixed_string_t what;
5820 cmdline_fixed_string_t mode;
5824 cmd_set_vf_traffic_parsed(void *parsed_result,
5825 __attribute__((unused)) struct cmdline *cl,
5826 __attribute__((unused)) void *data)
5828 struct cmd_set_vf_traffic *res = parsed_result;
5829 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5830 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5832 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5835 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5838 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5839 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5841 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5842 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5844 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5845 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5847 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5848 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5850 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5853 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5857 cmdline_parse_inst_t cmd_set_vf_traffic = {
5858 .f = cmd_set_vf_traffic_parsed,
5860 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5862 (void *)&cmd_setvf_traffic_set,
5863 (void *)&cmd_setvf_traffic_port,
5864 (void *)&cmd_setvf_traffic_portid,
5865 (void *)&cmd_setvf_traffic_vf,
5866 (void *)&cmd_setvf_traffic_vfid,
5867 (void *)&cmd_setvf_traffic_what,
5868 (void *)&cmd_setvf_traffic_mode,
5873 /* *** CONFIGURE VF RECEIVE MODE *** */
5874 struct cmd_set_vf_rxmode {
5875 cmdline_fixed_string_t set;
5876 cmdline_fixed_string_t port;
5878 cmdline_fixed_string_t vf;
5880 cmdline_fixed_string_t what;
5881 cmdline_fixed_string_t mode;
5882 cmdline_fixed_string_t on;
5886 cmd_set_vf_rxmode_parsed(void *parsed_result,
5887 __attribute__((unused)) struct cmdline *cl,
5888 __attribute__((unused)) void *data)
5891 uint16_t rx_mode = 0;
5892 struct cmd_set_vf_rxmode *res = parsed_result;
5894 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5895 if (!strcmp(res->what,"rxmode")) {
5896 if (!strcmp(res->mode, "AUPE"))
5897 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5898 else if (!strcmp(res->mode, "ROPE"))
5899 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5900 else if (!strcmp(res->mode, "BAM"))
5901 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5902 else if (!strncmp(res->mode, "MPE",3))
5903 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5906 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5908 printf("bad VF receive mode parameter, return code = %d \n",
5912 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5913 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5915 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5916 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5918 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5919 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5921 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5924 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5925 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5927 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5930 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5932 mode, "AUPE#ROPE#BAM#MPE");
5933 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5937 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5938 .f = cmd_set_vf_rxmode_parsed,
5940 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5942 (void *)&cmd_set_vf_rxmode_set,
5943 (void *)&cmd_set_vf_rxmode_port,
5944 (void *)&cmd_set_vf_rxmode_portid,
5945 (void *)&cmd_set_vf_rxmode_vf,
5946 (void *)&cmd_set_vf_rxmode_vfid,
5947 (void *)&cmd_set_vf_rxmode_what,
5948 (void *)&cmd_set_vf_rxmode_mode,
5949 (void *)&cmd_set_vf_rxmode_on,
5954 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5955 struct cmd_vf_mac_addr_result {
5956 cmdline_fixed_string_t mac_addr_cmd;
5957 cmdline_fixed_string_t what;
5958 cmdline_fixed_string_t port;
5960 cmdline_fixed_string_t vf;
5962 struct ether_addr address;
5965 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5966 __attribute__((unused)) struct cmdline *cl,
5967 __attribute__((unused)) void *data)
5969 struct cmd_vf_mac_addr_result *res = parsed_result;
5972 if (strcmp(res->what, "add") == 0)
5973 ret = rte_eth_dev_mac_addr_add(res->port_num,
5974 &res->address, res->vf_num);
5976 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5980 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5981 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5982 mac_addr_cmd,"mac_addr");
5983 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5984 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5986 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5987 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5989 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5990 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5992 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5993 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5995 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5996 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5998 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5999 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6002 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6003 .f = cmd_vf_mac_addr_parsed,
6005 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6006 "Y = VF number)add MAC address filtering for a VF on port X",
6008 (void *)&cmd_vf_mac_addr_cmd,
6009 (void *)&cmd_vf_mac_addr_what,
6010 (void *)&cmd_vf_mac_addr_port,
6011 (void *)&cmd_vf_mac_addr_portnum,
6012 (void *)&cmd_vf_mac_addr_vf,
6013 (void *)&cmd_vf_mac_addr_vfnum,
6014 (void *)&cmd_vf_mac_addr_addr,
6019 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6020 struct cmd_vf_rx_vlan_filter {
6021 cmdline_fixed_string_t rx_vlan;
6022 cmdline_fixed_string_t what;
6024 cmdline_fixed_string_t port;
6026 cmdline_fixed_string_t vf;
6031 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6032 __attribute__((unused)) struct cmdline *cl,
6033 __attribute__((unused)) void *data)
6035 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6037 if (!strcmp(res->what, "add"))
6038 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6040 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6043 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6044 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6045 rx_vlan, "rx_vlan");
6046 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6047 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6049 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6050 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6052 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6055 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6056 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6058 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6059 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6061 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6062 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6065 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6066 .f = cmd_vf_rx_vlan_filter_parsed,
6068 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6069 "Y = port number,Z = hexadecimal VF mask)",
6071 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6072 (void *)&cmd_vf_rx_vlan_filter_what,
6073 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6074 (void *)&cmd_vf_rx_vlan_filter_port,
6075 (void *)&cmd_vf_rx_vlan_filter_portid,
6076 (void *)&cmd_vf_rx_vlan_filter_vf,
6077 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6082 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6083 struct cmd_queue_rate_limit_result {
6084 cmdline_fixed_string_t set;
6085 cmdline_fixed_string_t port;
6087 cmdline_fixed_string_t queue;
6089 cmdline_fixed_string_t rate;
6093 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6094 __attribute__((unused)) struct cmdline *cl,
6095 __attribute__((unused)) void *data)
6097 struct cmd_queue_rate_limit_result *res = parsed_result;
6100 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6101 && (strcmp(res->queue, "queue") == 0)
6102 && (strcmp(res->rate, "rate") == 0))
6103 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6106 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6110 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6111 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6113 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6114 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6116 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6117 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6119 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6120 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6122 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6123 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6125 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6126 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6129 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6132 cmdline_parse_inst_t cmd_queue_rate_limit = {
6133 .f = cmd_queue_rate_limit_parsed,
6135 .help_str = "set port X queue Y rate Z:(X = port number,"
6136 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6138 (void *)&cmd_queue_rate_limit_set,
6139 (void *)&cmd_queue_rate_limit_port,
6140 (void *)&cmd_queue_rate_limit_portnum,
6141 (void *)&cmd_queue_rate_limit_queue,
6142 (void *)&cmd_queue_rate_limit_queuenum,
6143 (void *)&cmd_queue_rate_limit_rate,
6144 (void *)&cmd_queue_rate_limit_ratenum,
6149 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6150 struct cmd_vf_rate_limit_result {
6151 cmdline_fixed_string_t set;
6152 cmdline_fixed_string_t port;
6154 cmdline_fixed_string_t vf;
6156 cmdline_fixed_string_t rate;
6158 cmdline_fixed_string_t q_msk;
6162 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6166 struct cmd_vf_rate_limit_result *res = parsed_result;
6169 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6170 && (strcmp(res->vf, "vf") == 0)
6171 && (strcmp(res->rate, "rate") == 0)
6172 && (strcmp(res->q_msk, "queue_mask") == 0))
6173 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6174 res->rate_num, res->q_msk_val);
6176 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6180 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6181 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6183 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6184 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6186 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6187 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6189 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6192 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6193 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6195 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6196 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6198 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6199 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6201 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6202 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6203 q_msk, "queue_mask");
6204 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6205 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6208 cmdline_parse_inst_t cmd_vf_rate_limit = {
6209 .f = cmd_vf_rate_limit_parsed,
6211 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6212 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6213 "for queues of VF on port X",
6215 (void *)&cmd_vf_rate_limit_set,
6216 (void *)&cmd_vf_rate_limit_port,
6217 (void *)&cmd_vf_rate_limit_portnum,
6218 (void *)&cmd_vf_rate_limit_vf,
6219 (void *)&cmd_vf_rate_limit_vfnum,
6220 (void *)&cmd_vf_rate_limit_rate,
6221 (void *)&cmd_vf_rate_limit_ratenum,
6222 (void *)&cmd_vf_rate_limit_q_msk,
6223 (void *)&cmd_vf_rate_limit_q_msk_val,
6228 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6229 struct cmd_set_mirror_mask_result {
6230 cmdline_fixed_string_t set;
6231 cmdline_fixed_string_t port;
6233 cmdline_fixed_string_t mirror;
6235 cmdline_fixed_string_t what;
6236 cmdline_fixed_string_t value;
6237 cmdline_fixed_string_t dstpool;
6239 cmdline_fixed_string_t on;
6242 cmdline_parse_token_string_t cmd_mirror_mask_set =
6243 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6245 cmdline_parse_token_string_t cmd_mirror_mask_port =
6246 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6248 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6249 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6251 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6253 mirror, "mirror-rule");
6254 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6255 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6257 cmdline_parse_token_string_t cmd_mirror_mask_what =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6259 what, "pool-mirror#vlan-mirror");
6260 cmdline_parse_token_string_t cmd_mirror_mask_value =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6263 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6265 dstpool, "dst-pool");
6266 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6267 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6269 cmdline_parse_token_string_t cmd_mirror_mask_on =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6274 cmd_set_mirror_mask_parsed(void *parsed_result,
6275 __attribute__((unused)) struct cmdline *cl,
6276 __attribute__((unused)) void *data)
6279 struct cmd_set_mirror_mask_result *res = parsed_result;
6280 struct rte_eth_vmdq_mirror_conf mr_conf;
6282 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6284 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6286 mr_conf.dst_pool = res->dstpool_id;
6288 if (!strcmp(res->what, "pool-mirror")) {
6289 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6290 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6291 } else if(!strcmp(res->what, "vlan-mirror")) {
6292 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6293 nb_item = parse_item_list(res->value, "core",
6294 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6298 for(i=0; i < nb_item; i++) {
6299 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6300 printf("Invalid vlan_id: must be < 4096\n");
6304 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6305 mr_conf.vlan.vlan_mask |= 1ULL << i;
6309 if(!strcmp(res->on, "on"))
6310 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6313 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6316 printf("mirror rule add error: (%s)\n", strerror(-ret));
6319 cmdline_parse_inst_t cmd_set_mirror_mask = {
6320 .f = cmd_set_mirror_mask_parsed,
6322 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6323 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6325 (void *)&cmd_mirror_mask_set,
6326 (void *)&cmd_mirror_mask_port,
6327 (void *)&cmd_mirror_mask_portid,
6328 (void *)&cmd_mirror_mask_mirror,
6329 (void *)&cmd_mirror_mask_ruleid,
6330 (void *)&cmd_mirror_mask_what,
6331 (void *)&cmd_mirror_mask_value,
6332 (void *)&cmd_mirror_mask_dstpool,
6333 (void *)&cmd_mirror_mask_poolid,
6334 (void *)&cmd_mirror_mask_on,
6339 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6340 struct cmd_set_mirror_link_result {
6341 cmdline_fixed_string_t set;
6342 cmdline_fixed_string_t port;
6344 cmdline_fixed_string_t mirror;
6346 cmdline_fixed_string_t what;
6347 cmdline_fixed_string_t dstpool;
6349 cmdline_fixed_string_t on;
6352 cmdline_parse_token_string_t cmd_mirror_link_set =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6355 cmdline_parse_token_string_t cmd_mirror_link_port =
6356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6358 cmdline_parse_token_num_t cmd_mirror_link_portid =
6359 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6361 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6363 mirror, "mirror-rule");
6364 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6365 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6367 cmdline_parse_token_string_t cmd_mirror_link_what =
6368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6369 what, "uplink-mirror#downlink-mirror");
6370 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6371 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6372 dstpool, "dst-pool");
6373 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6374 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6376 cmdline_parse_token_string_t cmd_mirror_link_on =
6377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6381 cmd_set_mirror_link_parsed(void *parsed_result,
6382 __attribute__((unused)) struct cmdline *cl,
6383 __attribute__((unused)) void *data)
6386 struct cmd_set_mirror_link_result *res = parsed_result;
6387 struct rte_eth_vmdq_mirror_conf mr_conf;
6389 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6390 if(!strcmp(res->what, "uplink-mirror")) {
6391 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6392 }else if(!strcmp(res->what, "downlink-mirror"))
6393 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6395 mr_conf.dst_pool = res->dstpool_id;
6397 if(!strcmp(res->on, "on"))
6398 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6401 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6404 /* check the return value and print it if is < 0 */
6406 printf("mirror rule add error: (%s)\n", strerror(-ret));
6410 cmdline_parse_inst_t cmd_set_mirror_link = {
6411 .f = cmd_set_mirror_link_parsed,
6413 .help_str = "set port X mirror-rule Y uplink-mirror|"
6414 "downlink-mirror dst-pool Z on|off",
6416 (void *)&cmd_mirror_link_set,
6417 (void *)&cmd_mirror_link_port,
6418 (void *)&cmd_mirror_link_portid,
6419 (void *)&cmd_mirror_link_mirror,
6420 (void *)&cmd_mirror_link_ruleid,
6421 (void *)&cmd_mirror_link_what,
6422 (void *)&cmd_mirror_link_dstpool,
6423 (void *)&cmd_mirror_link_poolid,
6424 (void *)&cmd_mirror_link_on,
6429 /* *** RESET VM MIRROR RULE *** */
6430 struct cmd_rm_mirror_rule_result {
6431 cmdline_fixed_string_t reset;
6432 cmdline_fixed_string_t port;
6434 cmdline_fixed_string_t mirror;
6438 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6439 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6441 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6442 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6444 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6445 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6447 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6448 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6449 mirror, "mirror-rule");
6450 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6451 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6455 cmd_reset_mirror_rule_parsed(void *parsed_result,
6456 __attribute__((unused)) struct cmdline *cl,
6457 __attribute__((unused)) void *data)
6460 struct cmd_set_mirror_link_result *res = parsed_result;
6462 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6464 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6467 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6468 .f = cmd_reset_mirror_rule_parsed,
6470 .help_str = "reset port X mirror-rule Y",
6472 (void *)&cmd_rm_mirror_rule_reset,
6473 (void *)&cmd_rm_mirror_rule_port,
6474 (void *)&cmd_rm_mirror_rule_portid,
6475 (void *)&cmd_rm_mirror_rule_mirror,
6476 (void *)&cmd_rm_mirror_rule_ruleid,
6481 /* ******************************************************************************** */
6483 struct cmd_dump_result {
6484 cmdline_fixed_string_t dump;
6488 dump_struct_sizes(void)
6490 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6491 DUMP_SIZE(struct rte_mbuf);
6492 DUMP_SIZE(struct rte_mempool);
6493 DUMP_SIZE(struct rte_ring);
6497 static void cmd_dump_parsed(void *parsed_result,
6498 __attribute__((unused)) struct cmdline *cl,
6499 __attribute__((unused)) void *data)
6501 struct cmd_dump_result *res = parsed_result;
6503 if (!strcmp(res->dump, "dump_physmem"))
6504 rte_dump_physmem_layout(stdout);
6505 else if (!strcmp(res->dump, "dump_memzone"))
6506 rte_memzone_dump(stdout);
6507 else if (!strcmp(res->dump, "dump_log_history"))
6508 rte_log_dump_history(stdout);
6509 else if (!strcmp(res->dump, "dump_struct_sizes"))
6510 dump_struct_sizes();
6511 else if (!strcmp(res->dump, "dump_ring"))
6512 rte_ring_list_dump(stdout);
6513 else if (!strcmp(res->dump, "dump_mempool"))
6514 rte_mempool_list_dump(stdout);
6515 else if (!strcmp(res->dump, "dump_devargs"))
6516 rte_eal_devargs_dump(stdout);
6519 cmdline_parse_token_string_t cmd_dump_dump =
6520 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6524 "dump_struct_sizes#"
6529 cmdline_parse_inst_t cmd_dump = {
6530 .f = cmd_dump_parsed, /* function to call */
6531 .data = NULL, /* 2nd arg of func */
6532 .help_str = "dump status",
6533 .tokens = { /* token list, NULL terminated */
6534 (void *)&cmd_dump_dump,
6539 /* ******************************************************************************** */
6541 struct cmd_dump_one_result {
6542 cmdline_fixed_string_t dump;
6543 cmdline_fixed_string_t name;
6546 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6547 __attribute__((unused)) void *data)
6549 struct cmd_dump_one_result *res = parsed_result;
6551 if (!strcmp(res->dump, "dump_ring")) {
6553 r = rte_ring_lookup(res->name);
6555 cmdline_printf(cl, "Cannot find ring\n");
6558 rte_ring_dump(stdout, r);
6559 } else if (!strcmp(res->dump, "dump_mempool")) {
6560 struct rte_mempool *mp;
6561 mp = rte_mempool_lookup(res->name);
6563 cmdline_printf(cl, "Cannot find mempool\n");
6566 rte_mempool_dump(stdout, mp);
6570 cmdline_parse_token_string_t cmd_dump_one_dump =
6571 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6572 "dump_ring#dump_mempool");
6574 cmdline_parse_token_string_t cmd_dump_one_name =
6575 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6577 cmdline_parse_inst_t cmd_dump_one = {
6578 .f = cmd_dump_one_parsed, /* function to call */
6579 .data = NULL, /* 2nd arg of func */
6580 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6581 .tokens = { /* token list, NULL terminated */
6582 (void *)&cmd_dump_one_dump,
6583 (void *)&cmd_dump_one_name,
6588 /* *** ADD/REMOVE an ethertype FILTER *** */
6589 struct cmd_ethertype_filter_result {
6590 cmdline_fixed_string_t filter;
6592 cmdline_fixed_string_t ethertype;
6593 uint16_t ethertype_value;
6594 cmdline_fixed_string_t priority;
6595 cmdline_fixed_string_t priority_en;
6596 uint8_t priority_value;
6597 cmdline_fixed_string_t queue;
6599 cmdline_fixed_string_t index;
6600 uint16_t index_value;
6604 cmd_ethertype_filter_parsed(void *parsed_result,
6605 __attribute__((unused)) struct cmdline *cl,
6606 __attribute__((unused)) void *data)
6609 struct cmd_ethertype_filter_result *res = parsed_result;
6610 struct rte_ethertype_filter filter;
6612 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6613 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6614 filter.priority = res->priority_value;
6616 if (!strcmp(res->priority_en, "enable"))
6617 filter.priority_en = 1;
6618 if (!strcmp(res->filter, "add_ethertype_filter"))
6619 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6621 &filter, res->queue_id);
6622 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6623 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6625 else if (!strcmp(res->filter, "get_ethertype_filter"))
6626 get_ethertype_filter(res->port_id, res->index_value);
6629 printf("ethertype filter setting error: (%s)\n",
6633 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6634 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6636 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6637 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6638 ethertype, "ethertype");
6639 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6640 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6641 ethertype_value, UINT16);
6642 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6643 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6644 priority, "priority");
6645 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6646 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6647 priority_en, "enable#disable");
6648 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6649 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6650 priority_value, UINT8);
6651 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6652 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6654 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6655 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6657 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6658 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6660 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6661 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6662 index_value, UINT16);
6663 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6664 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6665 filter, "add_ethertype_filter");
6666 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6667 .f = cmd_ethertype_filter_parsed,
6669 .help_str = "add an ethertype filter",
6671 (void *)&cmd_ethertype_filter_add_filter,
6672 (void *)&cmd_ethertype_filter_port_id,
6673 (void *)&cmd_ethertype_filter_ethertype,
6674 (void *)&cmd_ethertype_filter_ethertype_value,
6675 (void *)&cmd_ethertype_filter_priority,
6676 (void *)&cmd_ethertype_filter_priority_en,
6677 (void *)&cmd_ethertype_filter_priority_value,
6678 (void *)&cmd_ethertype_filter_queue,
6679 (void *)&cmd_ethertype_filter_queue_id,
6680 (void *)&cmd_ethertype_filter_index,
6681 (void *)&cmd_ethertype_filter_index_value,
6686 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6687 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6688 filter, "remove_ethertype_filter");
6689 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6690 .f = cmd_ethertype_filter_parsed,
6692 .help_str = "remove an ethertype filter",
6694 (void *)&cmd_ethertype_filter_remove_filter,
6695 (void *)&cmd_ethertype_filter_port_id,
6696 (void *)&cmd_ethertype_filter_index,
6697 (void *)&cmd_ethertype_filter_index_value,
6701 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6702 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6703 filter, "get_ethertype_filter");
6704 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6705 .f = cmd_ethertype_filter_parsed,
6707 .help_str = "get an ethertype filter",
6709 (void *)&cmd_ethertype_filter_get_filter,
6710 (void *)&cmd_ethertype_filter_port_id,
6711 (void *)&cmd_ethertype_filter_index,
6712 (void *)&cmd_ethertype_filter_index_value,
6717 /* *** set SYN filter *** */
6718 struct cmd_set_syn_filter_result {
6719 cmdline_fixed_string_t filter;
6721 cmdline_fixed_string_t priority;
6722 cmdline_fixed_string_t high;
6723 cmdline_fixed_string_t queue;
6728 cmd_set_syn_filter_parsed(void *parsed_result,
6729 __attribute__((unused)) struct cmdline *cl,
6730 __attribute__((unused)) void *data)
6733 struct cmd_set_syn_filter_result *res = parsed_result;
6734 struct rte_syn_filter filter;
6736 if (!strcmp(res->filter, "add_syn_filter")) {
6737 if (!strcmp(res->high, "high"))
6741 ret = rte_eth_dev_add_syn_filter(res->port_id,
6742 &filter, res->queue_id);
6743 } else if (!strcmp(res->filter, "remove_syn_filter"))
6744 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6745 else if (!strcmp(res->filter, "get_syn_filter"))
6746 get_syn_filter(res->port_id);
6748 printf("syn filter setting error: (%s)\n", strerror(-ret));
6751 cmdline_parse_token_num_t cmd_syn_filter_portid =
6752 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6754 cmdline_parse_token_string_t cmd_syn_filter_priority =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6756 priority, "priority");
6757 cmdline_parse_token_string_t cmd_syn_filter_high =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6760 cmdline_parse_token_string_t cmd_syn_filter_queue =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6763 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6764 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6766 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6767 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6768 filter, "add_syn_filter");
6769 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6771 filter, "remove_syn_filter");
6772 cmdline_parse_inst_t cmd_add_syn_filter = {
6773 .f = cmd_set_syn_filter_parsed,
6775 .help_str = "add syn filter",
6777 (void *)&cmd_syn_filter_add_filter,
6778 (void *)&cmd_syn_filter_portid,
6779 (void *)&cmd_syn_filter_priority,
6780 (void *)&cmd_syn_filter_high,
6781 (void *)&cmd_syn_filter_queue,
6782 (void *)&cmd_syn_filter_queue_id,
6786 cmdline_parse_inst_t cmd_remove_syn_filter = {
6787 .f = cmd_set_syn_filter_parsed,
6789 .help_str = "remove syn filter",
6791 (void *)&cmd_syn_filter_remove_filter,
6792 (void *)&cmd_syn_filter_portid,
6797 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6798 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6799 filter, "get_syn_filter");
6801 cmdline_parse_inst_t cmd_get_syn_filter = {
6802 .f = cmd_set_syn_filter_parsed,
6804 .help_str = "get syn filter",
6806 (void *)&cmd_syn_filter_get_filter,
6807 (void *)&cmd_syn_filter_portid,
6812 /* *** ADD/REMOVE A 2tuple FILTER *** */
6813 struct cmd_2tuple_filter_result {
6814 cmdline_fixed_string_t filter;
6816 cmdline_fixed_string_t protocol;
6817 uint8_t protocol_value;
6818 uint8_t protocol_mask;
6819 cmdline_fixed_string_t dst_port;
6820 uint16_t dst_port_value;
6821 uint16_t dst_port_mask;
6822 cmdline_fixed_string_t flags;
6823 uint8_t flags_value;
6824 cmdline_fixed_string_t priority;
6825 uint8_t priority_value;
6826 cmdline_fixed_string_t queue;
6828 cmdline_fixed_string_t index;
6829 uint16_t index_value;
6833 cmd_2tuple_filter_parsed(void *parsed_result,
6834 __attribute__((unused)) struct cmdline *cl,
6835 __attribute__((unused)) void *data)
6838 struct rte_2tuple_filter filter;
6839 struct cmd_2tuple_filter_result *res = parsed_result;
6841 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6843 if (!strcmp(res->filter, "add_2tuple_filter")) {
6844 /* need convert to big endian. */
6845 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6846 filter.protocol = res->protocol_value;
6847 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6848 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6849 filter.priority = res->priority_value;
6850 filter.tcp_flags = res->flags_value;
6851 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6852 res->index_value, &filter, res->queue_id);
6853 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6854 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6856 else if (!strcmp(res->filter, "get_2tuple_filter"))
6857 get_2tuple_filter(res->port_id, res->index_value);
6860 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6863 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6864 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6866 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6867 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6868 protocol, "protocol");
6869 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6870 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6871 protocol_value, UINT8);
6872 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6873 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6874 protocol_mask, UINT8);
6875 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6876 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6877 dst_port, "dst_port");
6878 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6879 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6880 dst_port_value, UINT16);
6881 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6882 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6883 dst_port_mask, UINT16);
6884 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6885 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6887 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6888 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6889 flags_value, UINT8);
6890 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6891 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6892 priority, "priority");
6893 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6894 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6895 priority_value, UINT8);
6896 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6897 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6899 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6900 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6902 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6903 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6905 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6906 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6907 index_value, UINT16);
6908 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6909 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6910 filter, "add_2tuple_filter");
6911 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6912 .f = cmd_2tuple_filter_parsed,
6914 .help_str = "add a 2tuple filter",
6916 (void *)&cmd_2tuple_filter_add_filter,
6917 (void *)&cmd_2tuple_filter_port_id,
6918 (void *)&cmd_2tuple_filter_protocol,
6919 (void *)&cmd_2tuple_filter_protocol_value,
6920 (void *)&cmd_2tuple_filter_protocol_mask,
6921 (void *)&cmd_2tuple_filter_dst_port,
6922 (void *)&cmd_2tuple_filter_dst_port_value,
6923 (void *)&cmd_2tuple_filter_dst_port_mask,
6924 (void *)&cmd_2tuple_filter_flags,
6925 (void *)&cmd_2tuple_filter_flags_value,
6926 (void *)&cmd_2tuple_filter_priority,
6927 (void *)&cmd_2tuple_filter_priority_value,
6928 (void *)&cmd_2tuple_filter_queue,
6929 (void *)&cmd_2tuple_filter_queue_id,
6930 (void *)&cmd_2tuple_filter_index,
6931 (void *)&cmd_2tuple_filter_index_value,
6936 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6937 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6938 filter, "remove_2tuple_filter");
6939 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6940 .f = cmd_2tuple_filter_parsed,
6942 .help_str = "remove a 2tuple filter",
6944 (void *)&cmd_2tuple_filter_remove_filter,
6945 (void *)&cmd_2tuple_filter_port_id,
6946 (void *)&cmd_2tuple_filter_index,
6947 (void *)&cmd_2tuple_filter_index_value,
6951 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6952 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6953 filter, "get_2tuple_filter");
6954 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6955 .f = cmd_2tuple_filter_parsed,
6957 .help_str = "get a 2tuple filter",
6959 (void *)&cmd_2tuple_filter_get_filter,
6960 (void *)&cmd_2tuple_filter_port_id,
6961 (void *)&cmd_2tuple_filter_index,
6962 (void *)&cmd_2tuple_filter_index_value,
6967 /* *** ADD/REMOVE A 5tuple FILTER *** */
6968 struct cmd_5tuple_filter_result {
6969 cmdline_fixed_string_t filter;
6971 cmdline_fixed_string_t dst_ip;
6972 cmdline_ipaddr_t dst_ip_value;
6973 cmdline_fixed_string_t src_ip;
6974 cmdline_ipaddr_t src_ip_value;
6975 cmdline_fixed_string_t dst_port;
6976 uint16_t dst_port_value;
6977 cmdline_fixed_string_t src_port;
6978 uint16_t src_port_value;
6979 cmdline_fixed_string_t protocol;
6980 uint8_t protocol_value;
6981 cmdline_fixed_string_t mask;
6983 cmdline_fixed_string_t flags;
6984 uint8_t flags_value;
6985 cmdline_fixed_string_t priority;
6986 uint8_t priority_value;
6987 cmdline_fixed_string_t queue;
6989 cmdline_fixed_string_t index;
6990 uint16_t index_value;
6994 cmd_5tuple_filter_parsed(void *parsed_result,
6995 __attribute__((unused)) struct cmdline *cl,
6996 __attribute__((unused)) void *data)
6999 struct rte_5tuple_filter filter;
7000 struct cmd_5tuple_filter_result *res = parsed_result;
7002 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7004 if (!strcmp(res->filter, "add_5tuple_filter")) {
7005 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7006 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7007 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7008 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7009 filter.protocol = res->protocol_value;
7010 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7011 filter.priority = res->priority_value;
7012 filter.tcp_flags = res->flags_value;
7014 if (res->dst_ip_value.family == AF_INET)
7015 /* no need to convert, already big endian. */
7016 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7018 if (filter.dst_ip_mask == 0) {
7019 printf("can not support ipv6 involved compare.\n");
7025 if (res->src_ip_value.family == AF_INET)
7026 /* no need to convert, already big endian. */
7027 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7029 if (filter.src_ip_mask == 0) {
7030 printf("can not support ipv6 involved compare.\n");
7035 /* need convert to big endian. */
7036 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7037 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7039 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7040 res->index_value, &filter, res->queue_id);
7041 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7042 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7044 else if (!strcmp(res->filter, "get_5tuple_filter"))
7045 get_5tuple_filter(res->port_id, res->index_value);
7047 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7051 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7052 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7054 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7055 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7057 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7058 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7060 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7061 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7063 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7064 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7066 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7067 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7068 dst_port, "dst_port");
7069 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7070 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7071 dst_port_value, UINT16);
7072 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7073 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7074 src_port, "src_port");
7075 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7076 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7077 src_port_value, UINT16);
7078 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7079 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7080 protocol, "protocol");
7081 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7082 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7083 protocol_value, UINT8);
7084 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7085 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7087 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7088 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7090 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7091 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7093 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7094 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7095 flags_value, UINT8);
7096 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7097 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7098 priority, "priority");
7099 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7100 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7101 priority_value, UINT8);
7102 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7103 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7105 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7106 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7108 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7109 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7111 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7112 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7113 index_value, UINT16);
7115 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7116 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7117 filter, "add_5tuple_filter");
7118 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7119 .f = cmd_5tuple_filter_parsed,
7121 .help_str = "add a 5tuple filter",
7123 (void *)&cmd_5tuple_filter_add_filter,
7124 (void *)&cmd_5tuple_filter_port_id,
7125 (void *)&cmd_5tuple_filter_dst_ip,
7126 (void *)&cmd_5tuple_filter_dst_ip_value,
7127 (void *)&cmd_5tuple_filter_src_ip,
7128 (void *)&cmd_5tuple_filter_src_ip_value,
7129 (void *)&cmd_5tuple_filter_dst_port,
7130 (void *)&cmd_5tuple_filter_dst_port_value,
7131 (void *)&cmd_5tuple_filter_src_port,
7132 (void *)&cmd_5tuple_filter_src_port_value,
7133 (void *)&cmd_5tuple_filter_protocol,
7134 (void *)&cmd_5tuple_filter_protocol_value,
7135 (void *)&cmd_5tuple_filter_mask,
7136 (void *)&cmd_5tuple_filter_mask_value,
7137 (void *)&cmd_5tuple_filter_flags,
7138 (void *)&cmd_5tuple_filter_flags_value,
7139 (void *)&cmd_5tuple_filter_priority,
7140 (void *)&cmd_5tuple_filter_priority_value,
7141 (void *)&cmd_5tuple_filter_queue,
7142 (void *)&cmd_5tuple_filter_queue_id,
7143 (void *)&cmd_5tuple_filter_index,
7144 (void *)&cmd_5tuple_filter_index_value,
7149 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7150 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7151 filter, "remove_5tuple_filter");
7152 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7153 .f = cmd_5tuple_filter_parsed,
7155 .help_str = "remove a 5tuple filter",
7157 (void *)&cmd_5tuple_filter_remove_filter,
7158 (void *)&cmd_5tuple_filter_port_id,
7159 (void *)&cmd_5tuple_filter_index,
7160 (void *)&cmd_5tuple_filter_index_value,
7165 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7166 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7167 filter, "get_5tuple_filter");
7168 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7169 .f = cmd_5tuple_filter_parsed,
7171 .help_str = "get a 5tuple filter",
7173 (void *)&cmd_5tuple_filter_get_filter,
7174 (void *)&cmd_5tuple_filter_port_id,
7175 (void *)&cmd_5tuple_filter_index,
7176 (void *)&cmd_5tuple_filter_index_value,
7181 /* *** ADD/REMOVE A flex FILTER *** */
7182 struct cmd_flex_filter_result {
7183 cmdline_fixed_string_t filter;
7185 cmdline_fixed_string_t len;
7187 cmdline_fixed_string_t bytes;
7188 cmdline_fixed_string_t bytes_value;
7189 cmdline_fixed_string_t mask;
7190 cmdline_fixed_string_t mask_value;
7191 cmdline_fixed_string_t priority;
7192 uint8_t priority_value;
7193 cmdline_fixed_string_t queue;
7195 cmdline_fixed_string_t index;
7196 uint16_t index_value;
7199 static int xdigit2val(unsigned char c)
7204 else if (isupper(c))
7212 cmd_flex_filter_parsed(void *parsed_result,
7213 __attribute__((unused)) struct cmdline *cl,
7214 __attribute__((unused)) void *data)
7217 struct rte_flex_filter filter;
7218 struct cmd_flex_filter_result *res = parsed_result;
7219 char *bytes_ptr, *mask_ptr;
7227 if (!strcmp(res->filter, "add_flex_filter")) {
7228 if (res->len_value > 128) {
7229 printf("the len exceed the max length 128\n");
7232 memset(&filter, 0, sizeof(struct rte_flex_filter));
7233 filter.len = res->len_value;
7234 filter.priority = res->priority_value;
7235 bytes_ptr = res->bytes_value;
7236 mask_ptr = res->mask_value;
7239 /* translate bytes string to uint_32 array. */
7240 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7241 (bytes_ptr[1] == 'X')))
7243 len = strnlen(bytes_ptr, res->len_value * 2);
7244 if (len == 0 || (len % 8 != 0)) {
7245 printf("please check len and bytes input\n");
7248 for (i = 0; i < len; i++) {
7250 if (isxdigit(c) == 0) {
7251 /* invalid characters. */
7252 printf("invalid input\n");
7255 val = xdigit2val(c);
7259 dword |= byte << (4 * mod - 4);
7264 filter.dwords[j] = dword;
7265 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7271 /* translate mask string to uint8_t array. */
7273 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7274 (mask_ptr[1] == 'X')))
7276 len = strnlen(mask_ptr, (res->len_value+3)/4);
7278 printf("invalid input\n");
7281 for (i = 0; i < len; i++) {
7283 if (isxdigit(c) == 0) {
7284 /* invalid characters. */
7285 printf("invalid input\n");
7288 val = xdigit2val(c);
7289 hex |= (uint8_t)(val & 0x8) >> 3;
7290 hex |= (uint8_t)(val & 0x4) >> 1;
7291 hex |= (uint8_t)(val & 0x2) << 1;
7292 hex |= (uint8_t)(val & 0x1) << 3;
7295 filter.mask[j] = byte;
7296 printf("mask[%d]:%02x ", j, filter.mask[j]);
7304 printf("call function rte_eth_dev_add_flex_filter: "
7305 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7306 res->index_value, res->queue_id,
7307 filter.len, filter.priority);
7308 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7309 &filter, res->queue_id);
7311 } else if (!strcmp(res->filter, "remove_flex_filter"))
7312 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7314 else if (!strcmp(res->filter, "get_flex_filter"))
7315 get_flex_filter(res->port_id, res->index_value);
7318 printf("flex filter setting error: (%s)\n", strerror(-ret));
7321 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7322 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7324 cmdline_parse_token_string_t cmd_flex_filter_len =
7325 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7327 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7328 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7330 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7331 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7333 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7334 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7336 cmdline_parse_token_string_t cmd_flex_filter_mask =
7337 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7339 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7340 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7342 cmdline_parse_token_string_t cmd_flex_filter_priority =
7343 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7344 priority, "priority");
7345 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7346 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7347 priority_value, UINT8);
7348 cmdline_parse_token_string_t cmd_flex_filter_queue =
7349 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7351 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7352 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7354 cmdline_parse_token_string_t cmd_flex_filter_index =
7355 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7357 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7358 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7359 index_value, UINT16);
7360 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7361 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7362 filter, "add_flex_filter");
7363 cmdline_parse_inst_t cmd_add_flex_filter = {
7364 .f = cmd_flex_filter_parsed,
7366 .help_str = "add a flex filter",
7368 (void *)&cmd_flex_filter_add_filter,
7369 (void *)&cmd_flex_filter_port_id,
7370 (void *)&cmd_flex_filter_len,
7371 (void *)&cmd_flex_filter_len_value,
7372 (void *)&cmd_flex_filter_bytes,
7373 (void *)&cmd_flex_filter_bytes_value,
7374 (void *)&cmd_flex_filter_mask,
7375 (void *)&cmd_flex_filter_mask_value,
7376 (void *)&cmd_flex_filter_priority,
7377 (void *)&cmd_flex_filter_priority_value,
7378 (void *)&cmd_flex_filter_queue,
7379 (void *)&cmd_flex_filter_queue_id,
7380 (void *)&cmd_flex_filter_index,
7381 (void *)&cmd_flex_filter_index_value,
7386 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7387 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7388 filter, "remove_flex_filter");
7389 cmdline_parse_inst_t cmd_remove_flex_filter = {
7390 .f = cmd_flex_filter_parsed,
7392 .help_str = "remove a flex filter",
7394 (void *)&cmd_flex_filter_remove_filter,
7395 (void *)&cmd_flex_filter_port_id,
7396 (void *)&cmd_flex_filter_index,
7397 (void *)&cmd_flex_filter_index_value,
7402 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7403 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7404 filter, "get_flex_filter");
7405 cmdline_parse_inst_t cmd_get_flex_filter = {
7406 .f = cmd_flex_filter_parsed,
7408 .help_str = "get a flex filter",
7410 (void *)&cmd_flex_filter_get_filter,
7411 (void *)&cmd_flex_filter_port_id,
7412 (void *)&cmd_flex_filter_index,
7413 (void *)&cmd_flex_filter_index_value,
7418 /* ******************************************************************************** */
7420 /* list of instructions */
7421 cmdline_parse_ctx_t main_ctx[] = {
7422 (cmdline_parse_inst_t *)&cmd_help_brief,
7423 (cmdline_parse_inst_t *)&cmd_help_long,
7424 (cmdline_parse_inst_t *)&cmd_quit,
7425 (cmdline_parse_inst_t *)&cmd_showport,
7426 (cmdline_parse_inst_t *)&cmd_showportall,
7427 (cmdline_parse_inst_t *)&cmd_showcfg,
7428 (cmdline_parse_inst_t *)&cmd_start,
7429 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7430 (cmdline_parse_inst_t *)&cmd_set_link_up,
7431 (cmdline_parse_inst_t *)&cmd_set_link_down,
7432 (cmdline_parse_inst_t *)&cmd_reset,
7433 (cmdline_parse_inst_t *)&cmd_set_numbers,
7434 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7435 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7436 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7437 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7438 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7439 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7440 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7441 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7442 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7443 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7444 (cmdline_parse_inst_t *)&cmd_set_link_check,
7445 #ifdef RTE_NIC_BYPASS
7446 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7447 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7448 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7449 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7451 #ifdef RTE_LIBRTE_PMD_BOND
7452 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7453 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7454 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7455 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7456 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7457 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7458 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7459 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7461 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7462 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7463 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7464 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7465 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7466 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7467 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7468 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7470 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7472 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7474 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7475 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7476 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7477 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7478 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7479 (cmdline_parse_inst_t *)&cmd_config_dcb,
7480 (cmdline_parse_inst_t *)&cmd_read_reg,
7481 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7482 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7483 (cmdline_parse_inst_t *)&cmd_write_reg,
7484 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7485 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7486 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7487 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7488 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7489 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7490 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7491 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7492 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7493 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7494 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7495 (cmdline_parse_inst_t *)&cmd_stop,
7496 (cmdline_parse_inst_t *)&cmd_mac_addr,
7497 (cmdline_parse_inst_t *)&cmd_set_qmap,
7498 (cmdline_parse_inst_t *)&cmd_operate_port,
7499 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7500 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7501 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7502 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7503 (cmdline_parse_inst_t *)&cmd_config_mtu,
7504 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7505 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7506 (cmdline_parse_inst_t *)&cmd_config_rss,
7507 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7508 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7509 (cmdline_parse_inst_t *)&cmd_showport_reta,
7510 (cmdline_parse_inst_t *)&cmd_config_burst,
7511 (cmdline_parse_inst_t *)&cmd_config_thresh,
7512 (cmdline_parse_inst_t *)&cmd_config_threshold,
7513 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7514 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7515 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7516 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7517 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7518 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7519 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7520 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7521 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7522 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7523 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7524 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7525 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7526 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7527 (cmdline_parse_inst_t *)&cmd_dump,
7528 (cmdline_parse_inst_t *)&cmd_dump_one,
7529 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7530 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7531 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7532 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7533 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7534 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7535 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7536 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7537 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7538 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7539 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7540 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7541 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7542 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7543 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7547 /* prompt function, called from main on MASTER lcore */
7553 /* initialize non-constant commands */
7554 cmd_set_fwd_mode_init();
7556 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7560 cmdline_interact(cl);
7561 cmdline_stdin_exit(cl);
7565 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7567 if (id < nb_ports) {
7568 /* check if need_reconfig has been set to 1 */
7569 if (ports[id].need_reconfig == 0)
7570 ports[id].need_reconfig = dev;
7571 /* check if need_reconfig_queues has been set to 1 */
7572 if (ports[id].need_reconfig_queues == 0)
7573 ports[id].need_reconfig_queues = queue;
7577 for (pid = 0; pid < nb_ports; pid++) {
7578 /* check if need_reconfig has been set to 1 */
7579 if (ports[pid].need_reconfig == 0)
7580 ports[pid].need_reconfig = dev;
7581 /* check if need_reconfig_queues has been set to 1 */
7582 if (ports[pid].need_reconfig_queues == 0)
7583 ports[pid].need_reconfig_queues = queue;
7588 #ifdef RTE_NIC_BYPASS
7590 bypass_is_supported(portid_t port_id)
7592 struct rte_port *port;
7593 struct rte_pci_id *pci_id;
7595 if (port_id >= nb_ports) {
7596 printf("\tPort id must be less than %d.\n", nb_ports);
7600 /* Get the device id. */
7601 port = &ports[port_id];
7602 pci_id = &port->dev_info.pci_dev->id;
7604 /* Check if NIC supports bypass. */
7605 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7609 printf("\tBypass not supported for port_id = %d.\n", port_id);