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|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|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;
1455 if (test_done == 0) {
1456 printf("Please stop forwarding first\n");
1460 if (port_id_is_invalid(res->portid))
1463 if (port_is_started(res->portid) != 1) {
1464 printf("Please start port %u first\n", res->portid);
1468 if (!strcmp(res->rxtxq, "rxq"))
1470 else if (!strcmp(res->rxtxq, "txq"))
1473 printf("Unknown parameter\n");
1477 if (isrx && rx_queue_id_is_invalid(res->qid))
1479 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1482 if (!strcmp(res->opname, "start"))
1484 else if (!strcmp(res->opname, "stop"))
1487 printf("Unknown parameter\n");
1491 if (isstart && isrx)
1492 rte_eth_dev_rx_queue_start(res->portid, res->qid);
1493 else if (!isstart && isrx)
1494 rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1495 else if (isstart && !isrx)
1496 rte_eth_dev_tx_queue_start(res->portid, res->qid);
1498 rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1501 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1503 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1504 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1505 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1506 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1507 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1508 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1509 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1510 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1513 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1514 .f = cmd_config_rxtx_queue_parsed,
1516 .help_str = "port X rxq|txq ID start|stop",
1518 (void *)&cmd_config_speed_all_port,
1519 (void *)&cmd_config_rxtx_queue_portid,
1520 (void *)&cmd_config_rxtx_queue_rxtxq,
1521 (void *)&cmd_config_rxtx_queue_qid,
1522 (void *)&cmd_config_rxtx_queue_opname,
1527 /* *** Configure RSS RETA *** */
1528 struct cmd_config_rss_reta {
1529 cmdline_fixed_string_t port;
1530 cmdline_fixed_string_t keyword;
1532 cmdline_fixed_string_t name;
1533 cmdline_fixed_string_t list_name;
1534 cmdline_fixed_string_t list_of_items;
1538 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1545 const char *p, *p0 = str;
1552 unsigned long int_fld[_NUM_FLD];
1553 char *str_fld[_NUM_FLD];
1555 while ((p = strchr(p0,'(')) != NULL) {
1557 if((p0 = strchr(p,')')) == NULL)
1561 if(size >= sizeof(s))
1564 snprintf(s, sizeof(s), "%.*s", size, p);
1565 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1567 for (i = 0; i < _NUM_FLD; i++) {
1569 int_fld[i] = strtoul(str_fld[i], &end, 0);
1570 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1574 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1575 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1577 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1578 printf("Invalid RETA hash index=%d",hash_index);
1582 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1583 reta_conf->mask_lo |= (1ULL << hash_index);
1585 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1587 reta_conf->reta[hash_index] = nb_queue;
1594 cmd_set_rss_reta_parsed(void *parsed_result,
1595 __attribute__((unused)) struct cmdline *cl,
1596 __attribute__((unused)) void *data)
1599 struct rte_eth_rss_reta reta_conf;
1600 struct cmd_config_rss_reta *res = parsed_result;
1602 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1603 if (!strcmp(res->list_name, "reta")) {
1604 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1605 printf("Invalid RSS Redirection Table config entered\n");
1608 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1610 printf("Bad redirection table parameter, return code = %d \n",ret);
1614 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1616 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1618 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1619 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1620 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1622 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1624 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1627 cmdline_parse_inst_t cmd_config_rss_reta = {
1628 .f = cmd_set_rss_reta_parsed,
1630 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1632 (void *)&cmd_config_rss_reta_port,
1633 (void *)&cmd_config_rss_reta_keyword,
1634 (void *)&cmd_config_rss_reta_port_id,
1635 (void *)&cmd_config_rss_reta_name,
1636 (void *)&cmd_config_rss_reta_list_name,
1637 (void *)&cmd_config_rss_reta_list_of_items,
1642 /* *** SHOW PORT RETA INFO *** */
1643 struct cmd_showport_reta {
1644 cmdline_fixed_string_t show;
1645 cmdline_fixed_string_t port;
1647 cmdline_fixed_string_t rss;
1648 cmdline_fixed_string_t reta;
1653 static void cmd_showport_reta_parsed(void *parsed_result,
1654 __attribute__((unused)) struct cmdline *cl,
1655 __attribute__((unused)) void *data)
1657 struct cmd_showport_reta *res = parsed_result;
1658 struct rte_eth_rss_reta reta_conf;
1660 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1661 printf("Invalid RSS Redirection Table config entered\n");
1665 reta_conf.mask_lo = res->mask_lo;
1666 reta_conf.mask_hi = res->mask_hi;
1668 port_rss_reta_info(res->port_id,&reta_conf);
1671 cmdline_parse_token_string_t cmd_showport_reta_show =
1672 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1673 cmdline_parse_token_string_t cmd_showport_reta_port =
1674 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1675 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1676 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1677 cmdline_parse_token_string_t cmd_showport_reta_rss =
1678 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1679 cmdline_parse_token_string_t cmd_showport_reta_reta =
1680 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1681 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1682 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1683 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1684 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1686 cmdline_parse_inst_t cmd_showport_reta = {
1687 .f = cmd_showport_reta_parsed,
1689 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1690 (mask_lo and mask_hi is UINT64)",
1692 (void *)&cmd_showport_reta_show,
1693 (void *)&cmd_showport_reta_port,
1694 (void *)&cmd_showport_reta_port_id,
1695 (void *)&cmd_showport_reta_rss,
1696 (void *)&cmd_showport_reta_reta,
1697 (void *)&cmd_showport_reta_mask_lo,
1698 (void *)&cmd_showport_reta_mask_hi,
1703 /* *** Show RSS hash configuration *** */
1704 struct cmd_showport_rss_hash {
1705 cmdline_fixed_string_t show;
1706 cmdline_fixed_string_t port;
1708 cmdline_fixed_string_t rss_hash;
1709 cmdline_fixed_string_t key; /* optional argument */
1712 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1713 __attribute__((unused)) struct cmdline *cl,
1716 struct cmd_showport_rss_hash *res = parsed_result;
1718 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1721 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1722 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1723 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1724 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1725 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1726 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1727 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1728 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1730 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1731 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1733 cmdline_parse_inst_t cmd_showport_rss_hash = {
1734 .f = cmd_showport_rss_hash_parsed,
1736 .help_str = "show port X rss-hash (X = port number)\n",
1738 (void *)&cmd_showport_rss_hash_show,
1739 (void *)&cmd_showport_rss_hash_port,
1740 (void *)&cmd_showport_rss_hash_port_id,
1741 (void *)&cmd_showport_rss_hash_rss_hash,
1746 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1747 .f = cmd_showport_rss_hash_parsed,
1749 .help_str = "show port X rss-hash key (X = port number)\n",
1751 (void *)&cmd_showport_rss_hash_show,
1752 (void *)&cmd_showport_rss_hash_port,
1753 (void *)&cmd_showport_rss_hash_port_id,
1754 (void *)&cmd_showport_rss_hash_rss_hash,
1755 (void *)&cmd_showport_rss_hash_rss_key,
1760 /* *** Configure DCB *** */
1761 struct cmd_config_dcb {
1762 cmdline_fixed_string_t port;
1763 cmdline_fixed_string_t config;
1765 cmdline_fixed_string_t dcb;
1766 cmdline_fixed_string_t vt;
1767 cmdline_fixed_string_t vt_en;
1769 cmdline_fixed_string_t pfc;
1770 cmdline_fixed_string_t pfc_en;
1774 cmd_config_dcb_parsed(void *parsed_result,
1775 __attribute__((unused)) struct cmdline *cl,
1776 __attribute__((unused)) void *data)
1778 struct cmd_config_dcb *res = parsed_result;
1779 struct dcb_config dcb_conf;
1780 portid_t port_id = res->port_id;
1781 struct rte_port *port;
1783 port = &ports[port_id];
1784 /** Check if the port is not started **/
1785 if (port->port_status != RTE_PORT_STOPPED) {
1786 printf("Please stop port %d first\n",port_id);
1790 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1791 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1792 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1796 /* DCB in VT mode */
1797 if (!strncmp(res->vt_en, "on",2))
1798 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1800 dcb_conf.dcb_mode = DCB_ENABLED;
1802 if (!strncmp(res->pfc_en, "on",2)) {
1803 dcb_conf.pfc_en = 1;
1806 dcb_conf.pfc_en = 0;
1808 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1809 printf("Cannot initialize network ports\n");
1813 cmd_reconfig_device_queue(port_id, 1, 1);
1816 cmdline_parse_token_string_t cmd_config_dcb_port =
1817 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1818 cmdline_parse_token_string_t cmd_config_dcb_config =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1820 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1821 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1822 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1824 cmdline_parse_token_string_t cmd_config_dcb_vt =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1826 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1828 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1829 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1830 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1831 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1832 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1835 cmdline_parse_inst_t cmd_config_dcb = {
1836 .f = cmd_config_dcb_parsed,
1838 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1840 (void *)&cmd_config_dcb_port,
1841 (void *)&cmd_config_dcb_config,
1842 (void *)&cmd_config_dcb_port_id,
1843 (void *)&cmd_config_dcb_dcb,
1844 (void *)&cmd_config_dcb_vt,
1845 (void *)&cmd_config_dcb_vt_en,
1846 (void *)&cmd_config_dcb_num_tcs,
1847 (void *)&cmd_config_dcb_pfc,
1848 (void *)&cmd_config_dcb_pfc_en,
1853 /* *** configure number of packets per burst *** */
1854 struct cmd_config_burst {
1855 cmdline_fixed_string_t port;
1856 cmdline_fixed_string_t keyword;
1857 cmdline_fixed_string_t all;
1858 cmdline_fixed_string_t name;
1863 cmd_config_burst_parsed(void *parsed_result,
1864 __attribute__((unused)) struct cmdline *cl,
1865 __attribute__((unused)) void *data)
1867 struct cmd_config_burst *res = parsed_result;
1869 if (!all_ports_stopped()) {
1870 printf("Please stop all ports first\n");
1874 if (!strcmp(res->name, "burst")) {
1875 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1876 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1879 nb_pkt_per_burst = res->value;
1881 printf("Unknown parameter\n");
1887 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1890 cmdline_parse_token_string_t cmd_config_burst_port =
1891 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1892 cmdline_parse_token_string_t cmd_config_burst_keyword =
1893 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1894 cmdline_parse_token_string_t cmd_config_burst_all =
1895 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1896 cmdline_parse_token_string_t cmd_config_burst_name =
1897 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1898 cmdline_parse_token_num_t cmd_config_burst_value =
1899 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1901 cmdline_parse_inst_t cmd_config_burst = {
1902 .f = cmd_config_burst_parsed,
1904 .help_str = "port config all burst value",
1906 (void *)&cmd_config_burst_port,
1907 (void *)&cmd_config_burst_keyword,
1908 (void *)&cmd_config_burst_all,
1909 (void *)&cmd_config_burst_name,
1910 (void *)&cmd_config_burst_value,
1915 /* *** configure rx/tx queues *** */
1916 struct cmd_config_thresh {
1917 cmdline_fixed_string_t port;
1918 cmdline_fixed_string_t keyword;
1919 cmdline_fixed_string_t all;
1920 cmdline_fixed_string_t name;
1925 cmd_config_thresh_parsed(void *parsed_result,
1926 __attribute__((unused)) struct cmdline *cl,
1927 __attribute__((unused)) void *data)
1929 struct cmd_config_thresh *res = parsed_result;
1931 if (!all_ports_stopped()) {
1932 printf("Please stop all ports first\n");
1936 if (!strcmp(res->name, "txpt"))
1937 tx_thresh.pthresh = res->value;
1938 else if(!strcmp(res->name, "txht"))
1939 tx_thresh.hthresh = res->value;
1940 else if(!strcmp(res->name, "txwt"))
1941 tx_thresh.wthresh = res->value;
1942 else if(!strcmp(res->name, "rxpt"))
1943 rx_thresh.pthresh = res->value;
1944 else if(!strcmp(res->name, "rxht"))
1945 rx_thresh.hthresh = res->value;
1946 else if(!strcmp(res->name, "rxwt"))
1947 rx_thresh.wthresh = res->value;
1949 printf("Unknown parameter\n");
1955 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1958 cmdline_parse_token_string_t cmd_config_thresh_port =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1960 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1962 cmdline_parse_token_string_t cmd_config_thresh_all =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1964 cmdline_parse_token_string_t cmd_config_thresh_name =
1965 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1966 "txpt#txht#txwt#rxpt#rxht#rxwt");
1967 cmdline_parse_token_num_t cmd_config_thresh_value =
1968 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1970 cmdline_parse_inst_t cmd_config_thresh = {
1971 .f = cmd_config_thresh_parsed,
1973 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1975 (void *)&cmd_config_thresh_port,
1976 (void *)&cmd_config_thresh_keyword,
1977 (void *)&cmd_config_thresh_all,
1978 (void *)&cmd_config_thresh_name,
1979 (void *)&cmd_config_thresh_value,
1984 /* *** configure free/rs threshold *** */
1985 struct cmd_config_threshold {
1986 cmdline_fixed_string_t port;
1987 cmdline_fixed_string_t keyword;
1988 cmdline_fixed_string_t all;
1989 cmdline_fixed_string_t name;
1994 cmd_config_threshold_parsed(void *parsed_result,
1995 __attribute__((unused)) struct cmdline *cl,
1996 __attribute__((unused)) void *data)
1998 struct cmd_config_threshold *res = parsed_result;
2000 if (!all_ports_stopped()) {
2001 printf("Please stop all ports first\n");
2005 if (!strcmp(res->name, "txfreet"))
2006 tx_free_thresh = res->value;
2007 else if (!strcmp(res->name, "txrst"))
2008 tx_rs_thresh = res->value;
2009 else if (!strcmp(res->name, "rxfreet"))
2010 rx_free_thresh = res->value;
2012 printf("Unknown parameter\n");
2018 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2021 cmdline_parse_token_string_t cmd_config_threshold_port =
2022 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2023 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2026 cmdline_parse_token_string_t cmd_config_threshold_all =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2028 cmdline_parse_token_string_t cmd_config_threshold_name =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2030 "txfreet#txrst#rxfreet");
2031 cmdline_parse_token_num_t cmd_config_threshold_value =
2032 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2034 cmdline_parse_inst_t cmd_config_threshold = {
2035 .f = cmd_config_threshold_parsed,
2037 .help_str = "port config all txfreet|txrst|rxfreet value",
2039 (void *)&cmd_config_threshold_port,
2040 (void *)&cmd_config_threshold_keyword,
2041 (void *)&cmd_config_threshold_all,
2042 (void *)&cmd_config_threshold_name,
2043 (void *)&cmd_config_threshold_value,
2049 struct cmd_stop_result {
2050 cmdline_fixed_string_t stop;
2053 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2054 __attribute__((unused)) struct cmdline *cl,
2055 __attribute__((unused)) void *data)
2057 stop_packet_forwarding();
2060 cmdline_parse_token_string_t cmd_stop_stop =
2061 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2063 cmdline_parse_inst_t cmd_stop = {
2064 .f = cmd_stop_parsed,
2066 .help_str = "stop - stop packet forwarding",
2068 (void *)&cmd_stop_stop,
2073 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2076 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2077 unsigned int *parsed_items, int check_unique_values)
2079 unsigned int nb_item;
2087 * First parse all items in the list and store their value.
2092 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2094 if ((c >= '0') && (c <= '9')) {
2095 value = (unsigned int) (value * 10 + (c - '0'));
2100 printf("character %c is not a decimal digit\n", c);
2104 printf("No valid value before comma\n");
2107 if (nb_item < max_items) {
2108 parsed_items[nb_item] = value;
2114 if (nb_item >= max_items) {
2115 printf("Number of %s = %u > %u (maximum items)\n",
2116 item_name, nb_item + 1, max_items);
2119 parsed_items[nb_item++] = value;
2120 if (! check_unique_values)
2124 * Then, check that all values in the list are differents.
2125 * No optimization here...
2127 for (i = 0; i < nb_item; i++) {
2128 for (j = i + 1; j < nb_item; j++) {
2129 if (parsed_items[j] == parsed_items[i]) {
2130 printf("duplicated %s %u at index %u and %u\n",
2131 item_name, parsed_items[i], i, j);
2139 struct cmd_set_list_result {
2140 cmdline_fixed_string_t cmd_keyword;
2141 cmdline_fixed_string_t list_name;
2142 cmdline_fixed_string_t list_of_items;
2145 static void cmd_set_list_parsed(void *parsed_result,
2146 __attribute__((unused)) struct cmdline *cl,
2147 __attribute__((unused)) void *data)
2149 struct cmd_set_list_result *res;
2151 unsigned int lcorelist[RTE_MAX_LCORE];
2152 unsigned int portlist[RTE_MAX_ETHPORTS];
2154 unsigned int nb_item;
2156 res = parsed_result;
2157 if (!strcmp(res->list_name, "corelist")) {
2158 nb_item = parse_item_list(res->list_of_items, "core",
2160 parsed_items.lcorelist, 1);
2162 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2165 if (!strcmp(res->list_name, "portlist")) {
2166 nb_item = parse_item_list(res->list_of_items, "port",
2168 parsed_items.portlist, 1);
2170 set_fwd_ports_list(parsed_items.portlist, nb_item);
2174 cmdline_parse_token_string_t cmd_set_list_keyword =
2175 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2177 cmdline_parse_token_string_t cmd_set_list_name =
2178 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2179 "corelist#portlist");
2180 cmdline_parse_token_string_t cmd_set_list_of_items =
2181 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2184 cmdline_parse_inst_t cmd_set_fwd_list = {
2185 .f = cmd_set_list_parsed,
2187 .help_str = "set corelist|portlist x[,y]*",
2189 (void *)&cmd_set_list_keyword,
2190 (void *)&cmd_set_list_name,
2191 (void *)&cmd_set_list_of_items,
2196 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2198 struct cmd_setmask_result {
2199 cmdline_fixed_string_t set;
2200 cmdline_fixed_string_t mask;
2204 static void cmd_set_mask_parsed(void *parsed_result,
2205 __attribute__((unused)) struct cmdline *cl,
2206 __attribute__((unused)) void *data)
2208 struct cmd_setmask_result *res = parsed_result;
2210 if (!strcmp(res->mask, "coremask"))
2211 set_fwd_lcores_mask(res->hexavalue);
2212 else if (!strcmp(res->mask, "portmask"))
2213 set_fwd_ports_mask(res->hexavalue);
2216 cmdline_parse_token_string_t cmd_setmask_set =
2217 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2218 cmdline_parse_token_string_t cmd_setmask_mask =
2219 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2220 "coremask#portmask");
2221 cmdline_parse_token_num_t cmd_setmask_value =
2222 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2224 cmdline_parse_inst_t cmd_set_fwd_mask = {
2225 .f = cmd_set_mask_parsed,
2227 .help_str = "set coremask|portmask hexadecimal value",
2229 (void *)&cmd_setmask_set,
2230 (void *)&cmd_setmask_mask,
2231 (void *)&cmd_setmask_value,
2237 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2239 struct cmd_set_result {
2240 cmdline_fixed_string_t set;
2241 cmdline_fixed_string_t what;
2245 static void cmd_set_parsed(void *parsed_result,
2246 __attribute__((unused)) struct cmdline *cl,
2247 __attribute__((unused)) void *data)
2249 struct cmd_set_result *res = parsed_result;
2250 if (!strcmp(res->what, "nbport"))
2251 set_fwd_ports_number(res->value);
2252 else if (!strcmp(res->what, "nbcore"))
2253 set_fwd_lcores_number(res->value);
2254 else if (!strcmp(res->what, "burst"))
2255 set_nb_pkt_per_burst(res->value);
2256 else if (!strcmp(res->what, "verbose"))
2257 set_verbose_level(res->value);
2260 cmdline_parse_token_string_t cmd_set_set =
2261 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2262 cmdline_parse_token_string_t cmd_set_what =
2263 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2264 "nbport#nbcore#burst#verbose");
2265 cmdline_parse_token_num_t cmd_set_value =
2266 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2268 cmdline_parse_inst_t cmd_set_numbers = {
2269 .f = cmd_set_parsed,
2271 .help_str = "set nbport|nbcore|burst|verbose value",
2273 (void *)&cmd_set_set,
2274 (void *)&cmd_set_what,
2275 (void *)&cmd_set_value,
2280 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2282 struct cmd_set_txpkts_result {
2283 cmdline_fixed_string_t cmd_keyword;
2284 cmdline_fixed_string_t txpkts;
2285 cmdline_fixed_string_t seg_lengths;
2289 cmd_set_txpkts_parsed(void *parsed_result,
2290 __attribute__((unused)) struct cmdline *cl,
2291 __attribute__((unused)) void *data)
2293 struct cmd_set_txpkts_result *res;
2294 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2295 unsigned int nb_segs;
2297 res = parsed_result;
2298 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2299 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2301 set_tx_pkt_segments(seg_lengths, nb_segs);
2304 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2305 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2306 cmd_keyword, "set");
2307 cmdline_parse_token_string_t cmd_set_txpkts_name =
2308 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2310 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2311 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2314 cmdline_parse_inst_t cmd_set_txpkts = {
2315 .f = cmd_set_txpkts_parsed,
2317 .help_str = "set txpkts x[,y]*",
2319 (void *)&cmd_set_txpkts_keyword,
2320 (void *)&cmd_set_txpkts_name,
2321 (void *)&cmd_set_txpkts_lengths,
2326 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2327 struct cmd_rx_vlan_filter_all_result {
2328 cmdline_fixed_string_t rx_vlan;
2329 cmdline_fixed_string_t what;
2330 cmdline_fixed_string_t all;
2335 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2336 __attribute__((unused)) struct cmdline *cl,
2337 __attribute__((unused)) void *data)
2339 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2341 if (!strcmp(res->what, "add"))
2342 rx_vlan_all_filter_set(res->port_id, 1);
2344 rx_vlan_all_filter_set(res->port_id, 0);
2347 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2348 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2349 rx_vlan, "rx_vlan");
2350 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2351 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2353 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2354 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2356 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2357 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2360 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2361 .f = cmd_rx_vlan_filter_all_parsed,
2363 .help_str = "add/remove all identifiers to/from the set of VLAN "
2364 "Identifiers filtered by a port",
2366 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2367 (void *)&cmd_rx_vlan_filter_all_what,
2368 (void *)&cmd_rx_vlan_filter_all_all,
2369 (void *)&cmd_rx_vlan_filter_all_portid,
2374 /* *** VLAN OFFLOAD SET ON A PORT *** */
2375 struct cmd_vlan_offload_result {
2376 cmdline_fixed_string_t vlan;
2377 cmdline_fixed_string_t set;
2378 cmdline_fixed_string_t what;
2379 cmdline_fixed_string_t on;
2380 cmdline_fixed_string_t port_id;
2384 cmd_vlan_offload_parsed(void *parsed_result,
2385 __attribute__((unused)) struct cmdline *cl,
2386 __attribute__((unused)) void *data)
2389 struct cmd_vlan_offload_result *res = parsed_result;
2392 portid_t port_id = 0;
2396 len = strnlen(str, STR_TOKEN_SIZE);
2398 /* Get port_id first */
2406 tmp = strtoul(str, NULL, 0);
2407 /* If port_id greater that what portid_t can represent, return */
2408 if(tmp >= RTE_MAX_ETHPORTS)
2410 port_id = (portid_t)tmp;
2412 if (!strcmp(res->on, "on"))
2417 if (!strcmp(res->what, "strip"))
2418 rx_vlan_strip_set(port_id, on);
2419 else if(!strcmp(res->what, "stripq")){
2420 uint16_t queue_id = 0;
2422 /* No queue_id, return */
2424 printf("must specify (port,queue_id)\n");
2427 tmp = strtoul(str + i + 1, NULL, 0);
2428 /* If queue_id greater that what 16-bits can represent, return */
2432 queue_id = (uint16_t)tmp;
2433 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2435 else if (!strcmp(res->what, "filter"))
2436 rx_vlan_filter_set(port_id, on);
2438 vlan_extend_set(port_id, on);
2443 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2444 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2446 cmdline_parse_token_string_t cmd_vlan_offload_set =
2447 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2449 cmdline_parse_token_string_t cmd_vlan_offload_what =
2450 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2451 what, "strip#filter#qinq#stripq");
2452 cmdline_parse_token_string_t cmd_vlan_offload_on =
2453 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2455 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2456 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2459 cmdline_parse_inst_t cmd_vlan_offload = {
2460 .f = cmd_vlan_offload_parsed,
2462 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2463 " qinq(extended) for both rx/tx sides ",
2465 (void *)&cmd_vlan_offload_vlan,
2466 (void *)&cmd_vlan_offload_set,
2467 (void *)&cmd_vlan_offload_what,
2468 (void *)&cmd_vlan_offload_on,
2469 (void *)&cmd_vlan_offload_portid,
2474 /* *** VLAN TPID SET ON A PORT *** */
2475 struct cmd_vlan_tpid_result {
2476 cmdline_fixed_string_t vlan;
2477 cmdline_fixed_string_t set;
2478 cmdline_fixed_string_t what;
2484 cmd_vlan_tpid_parsed(void *parsed_result,
2485 __attribute__((unused)) struct cmdline *cl,
2486 __attribute__((unused)) void *data)
2488 struct cmd_vlan_tpid_result *res = parsed_result;
2489 vlan_tpid_set(res->port_id, res->tp_id);
2493 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2494 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2496 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2497 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2499 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2500 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2502 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2503 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2505 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2506 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2509 cmdline_parse_inst_t cmd_vlan_tpid = {
2510 .f = cmd_vlan_tpid_parsed,
2512 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2514 (void *)&cmd_vlan_tpid_vlan,
2515 (void *)&cmd_vlan_tpid_set,
2516 (void *)&cmd_vlan_tpid_what,
2517 (void *)&cmd_vlan_tpid_tpid,
2518 (void *)&cmd_vlan_tpid_portid,
2523 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2524 struct cmd_rx_vlan_filter_result {
2525 cmdline_fixed_string_t rx_vlan;
2526 cmdline_fixed_string_t what;
2532 cmd_rx_vlan_filter_parsed(void *parsed_result,
2533 __attribute__((unused)) struct cmdline *cl,
2534 __attribute__((unused)) void *data)
2536 struct cmd_rx_vlan_filter_result *res = parsed_result;
2538 if (!strcmp(res->what, "add"))
2539 rx_vft_set(res->port_id, res->vlan_id, 1);
2541 rx_vft_set(res->port_id, res->vlan_id, 0);
2544 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2545 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2546 rx_vlan, "rx_vlan");
2547 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2548 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2550 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2551 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2553 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2554 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2557 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2558 .f = cmd_rx_vlan_filter_parsed,
2560 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2561 "Identifiers filtered by a port",
2563 (void *)&cmd_rx_vlan_filter_rx_vlan,
2564 (void *)&cmd_rx_vlan_filter_what,
2565 (void *)&cmd_rx_vlan_filter_vlanid,
2566 (void *)&cmd_rx_vlan_filter_portid,
2571 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2572 struct cmd_tx_vlan_set_result {
2573 cmdline_fixed_string_t tx_vlan;
2574 cmdline_fixed_string_t set;
2580 cmd_tx_vlan_set_parsed(void *parsed_result,
2581 __attribute__((unused)) struct cmdline *cl,
2582 __attribute__((unused)) void *data)
2584 struct cmd_tx_vlan_set_result *res = parsed_result;
2585 tx_vlan_set(res->port_id, res->vlan_id);
2588 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2589 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2590 tx_vlan, "tx_vlan");
2591 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2592 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2594 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2595 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2597 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2598 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2601 cmdline_parse_inst_t cmd_tx_vlan_set = {
2602 .f = cmd_tx_vlan_set_parsed,
2604 .help_str = "enable hardware insertion of a VLAN header with a given "
2605 "TAG Identifier in packets sent on a port",
2607 (void *)&cmd_tx_vlan_set_tx_vlan,
2608 (void *)&cmd_tx_vlan_set_set,
2609 (void *)&cmd_tx_vlan_set_vlanid,
2610 (void *)&cmd_tx_vlan_set_portid,
2615 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2616 struct cmd_tx_vlan_set_pvid_result {
2617 cmdline_fixed_string_t tx_vlan;
2618 cmdline_fixed_string_t set;
2619 cmdline_fixed_string_t pvid;
2622 cmdline_fixed_string_t mode;
2626 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2627 __attribute__((unused)) struct cmdline *cl,
2628 __attribute__((unused)) void *data)
2630 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2632 if (strcmp(res->mode, "on") == 0)
2633 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2635 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2638 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2639 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2640 tx_vlan, "tx_vlan");
2641 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2642 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2644 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2645 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2647 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2648 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2650 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2651 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2653 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2654 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2657 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2658 .f = cmd_tx_vlan_set_pvid_parsed,
2660 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2662 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2663 (void *)&cmd_tx_vlan_set_pvid_set,
2664 (void *)&cmd_tx_vlan_set_pvid_pvid,
2665 (void *)&cmd_tx_vlan_set_pvid_port_id,
2666 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2667 (void *)&cmd_tx_vlan_set_pvid_mode,
2672 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2673 struct cmd_tx_vlan_reset_result {
2674 cmdline_fixed_string_t tx_vlan;
2675 cmdline_fixed_string_t reset;
2680 cmd_tx_vlan_reset_parsed(void *parsed_result,
2681 __attribute__((unused)) struct cmdline *cl,
2682 __attribute__((unused)) void *data)
2684 struct cmd_tx_vlan_reset_result *res = parsed_result;
2686 tx_vlan_reset(res->port_id);
2689 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2690 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2691 tx_vlan, "tx_vlan");
2692 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2693 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2695 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2696 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2699 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2700 .f = cmd_tx_vlan_reset_parsed,
2702 .help_str = "disable hardware insertion of a VLAN header in packets "
2705 (void *)&cmd_tx_vlan_reset_tx_vlan,
2706 (void *)&cmd_tx_vlan_reset_reset,
2707 (void *)&cmd_tx_vlan_reset_portid,
2713 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2714 struct cmd_tx_cksum_set_result {
2715 cmdline_fixed_string_t tx_cksum;
2716 cmdline_fixed_string_t set;
2722 cmd_tx_cksum_set_parsed(void *parsed_result,
2723 __attribute__((unused)) struct cmdline *cl,
2724 __attribute__((unused)) void *data)
2726 struct cmd_tx_cksum_set_result *res = parsed_result;
2728 tx_cksum_set(res->port_id, res->cksum_mask);
2731 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2732 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2733 tx_cksum, "tx_checksum");
2734 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2735 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2737 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2738 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2740 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2741 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2744 cmdline_parse_inst_t cmd_tx_cksum_set = {
2745 .f = cmd_tx_cksum_set_parsed,
2747 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2748 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2749 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2751 (void *)&cmd_tx_cksum_set_tx_cksum,
2752 (void *)&cmd_tx_cksum_set_set,
2753 (void *)&cmd_tx_cksum_set_cksum_mask,
2754 (void *)&cmd_tx_cksum_set_portid,
2759 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2760 struct cmd_set_flush_rx {
2761 cmdline_fixed_string_t set;
2762 cmdline_fixed_string_t flush_rx;
2763 cmdline_fixed_string_t mode;
2767 cmd_set_flush_rx_parsed(void *parsed_result,
2768 __attribute__((unused)) struct cmdline *cl,
2769 __attribute__((unused)) void *data)
2771 struct cmd_set_flush_rx *res = parsed_result;
2772 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2775 cmdline_parse_token_string_t cmd_setflushrx_set =
2776 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2778 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2779 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2780 flush_rx, "flush_rx");
2781 cmdline_parse_token_string_t cmd_setflushrx_mode =
2782 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2786 cmdline_parse_inst_t cmd_set_flush_rx = {
2787 .f = cmd_set_flush_rx_parsed,
2788 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2791 (void *)&cmd_setflushrx_set,
2792 (void *)&cmd_setflushrx_flush_rx,
2793 (void *)&cmd_setflushrx_mode,
2798 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2799 struct cmd_set_link_check {
2800 cmdline_fixed_string_t set;
2801 cmdline_fixed_string_t link_check;
2802 cmdline_fixed_string_t mode;
2806 cmd_set_link_check_parsed(void *parsed_result,
2807 __attribute__((unused)) struct cmdline *cl,
2808 __attribute__((unused)) void *data)
2810 struct cmd_set_link_check *res = parsed_result;
2811 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2814 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2815 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2817 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2818 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2819 link_check, "link_check");
2820 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2821 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2825 cmdline_parse_inst_t cmd_set_link_check = {
2826 .f = cmd_set_link_check_parsed,
2827 .help_str = "set link_check on|off: enable/disable link status check "
2828 "when starting/stopping a port",
2831 (void *)&cmd_setlinkcheck_set,
2832 (void *)&cmd_setlinkcheck_link_check,
2833 (void *)&cmd_setlinkcheck_mode,
2838 #ifdef RTE_NIC_BYPASS
2839 /* *** SET NIC BYPASS MODE *** */
2840 struct cmd_set_bypass_mode_result {
2841 cmdline_fixed_string_t set;
2842 cmdline_fixed_string_t bypass;
2843 cmdline_fixed_string_t mode;
2844 cmdline_fixed_string_t value;
2849 cmd_set_bypass_mode_parsed(void *parsed_result,
2850 __attribute__((unused)) struct cmdline *cl,
2851 __attribute__((unused)) void *data)
2853 struct cmd_set_bypass_mode_result *res = parsed_result;
2854 portid_t port_id = res->port_id;
2855 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2857 if (!bypass_is_supported(port_id))
2860 if (!strcmp(res->value, "bypass"))
2861 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2862 else if (!strcmp(res->value, "isolate"))
2863 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2865 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2867 /* Set the bypass mode for the relevant port. */
2868 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2869 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2873 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2874 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2876 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2877 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2879 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2880 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2882 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2883 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2884 value, "normal#bypass#isolate");
2885 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2886 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2889 cmdline_parse_inst_t cmd_set_bypass_mode = {
2890 .f = cmd_set_bypass_mode_parsed,
2891 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2892 "Set the NIC bypass mode for port_id",
2895 (void *)&cmd_setbypass_mode_set,
2896 (void *)&cmd_setbypass_mode_bypass,
2897 (void *)&cmd_setbypass_mode_mode,
2898 (void *)&cmd_setbypass_mode_value,
2899 (void *)&cmd_setbypass_mode_port,
2904 /* *** SET NIC BYPASS EVENT *** */
2905 struct cmd_set_bypass_event_result {
2906 cmdline_fixed_string_t set;
2907 cmdline_fixed_string_t bypass;
2908 cmdline_fixed_string_t event;
2909 cmdline_fixed_string_t event_value;
2910 cmdline_fixed_string_t mode;
2911 cmdline_fixed_string_t mode_value;
2916 cmd_set_bypass_event_parsed(void *parsed_result,
2917 __attribute__((unused)) struct cmdline *cl,
2918 __attribute__((unused)) void *data)
2921 struct cmd_set_bypass_event_result *res = parsed_result;
2922 portid_t port_id = res->port_id;
2923 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2924 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2926 if (!bypass_is_supported(port_id))
2929 if (!strcmp(res->event_value, "timeout"))
2930 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2931 else if (!strcmp(res->event_value, "os_on"))
2932 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2933 else if (!strcmp(res->event_value, "os_off"))
2934 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2935 else if (!strcmp(res->event_value, "power_on"))
2936 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2937 else if (!strcmp(res->event_value, "power_off"))
2938 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2940 bypass_event = RTE_BYPASS_EVENT_NONE;
2942 if (!strcmp(res->mode_value, "bypass"))
2943 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2944 else if (!strcmp(res->mode_value, "isolate"))
2945 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2947 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2949 /* Set the watchdog timeout. */
2950 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2953 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2954 (rc = rte_eth_dev_wd_timeout_store(port_id,
2955 bypass_timeout)) != 0) {
2956 printf("Failed to set timeout value %u "
2957 "for port %d, errto code: %d.\n",
2958 bypass_timeout, port_id, rc);
2962 /* Set the bypass event to transition to bypass mode. */
2963 if (0 != rte_eth_dev_bypass_event_store(port_id,
2964 bypass_event, bypass_mode)) {
2965 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2970 cmdline_parse_token_string_t cmd_setbypass_event_set =
2971 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2973 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2974 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2976 cmdline_parse_token_string_t cmd_setbypass_event_event =
2977 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2979 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2980 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2981 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2982 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2983 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2985 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2986 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2987 mode_value, "normal#bypass#isolate");
2988 cmdline_parse_token_num_t cmd_setbypass_event_port =
2989 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2992 cmdline_parse_inst_t cmd_set_bypass_event = {
2993 .f = cmd_set_bypass_event_parsed,
2994 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2995 "mode (normal|bypass|isolate) (port_id): "
2996 "Set the NIC bypass event mode for port_id",
2999 (void *)&cmd_setbypass_event_set,
3000 (void *)&cmd_setbypass_event_bypass,
3001 (void *)&cmd_setbypass_event_event,
3002 (void *)&cmd_setbypass_event_event_value,
3003 (void *)&cmd_setbypass_event_mode,
3004 (void *)&cmd_setbypass_event_mode_value,
3005 (void *)&cmd_setbypass_event_port,
3011 /* *** SET NIC BYPASS TIMEOUT *** */
3012 struct cmd_set_bypass_timeout_result {
3013 cmdline_fixed_string_t set;
3014 cmdline_fixed_string_t bypass;
3015 cmdline_fixed_string_t timeout;
3016 cmdline_fixed_string_t value;
3020 cmd_set_bypass_timeout_parsed(void *parsed_result,
3021 __attribute__((unused)) struct cmdline *cl,
3022 __attribute__((unused)) void *data)
3024 struct cmd_set_bypass_timeout_result *res = parsed_result;
3026 if (!strcmp(res->value, "1.5"))
3027 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3028 else if (!strcmp(res->value, "2"))
3029 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3030 else if (!strcmp(res->value, "3"))
3031 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3032 else if (!strcmp(res->value, "4"))
3033 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3034 else if (!strcmp(res->value, "8"))
3035 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3036 else if (!strcmp(res->value, "16"))
3037 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3038 else if (!strcmp(res->value, "32"))
3039 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3041 bypass_timeout = RTE_BYPASS_TMT_OFF;
3044 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3045 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3047 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3048 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3050 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3052 timeout, "timeout");
3053 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3055 value, "0#1.5#2#3#4#8#16#32");
3057 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3058 .f = cmd_set_bypass_timeout_parsed,
3059 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3060 "Set the NIC bypass watchdog timeout",
3063 (void *)&cmd_setbypass_timeout_set,
3064 (void *)&cmd_setbypass_timeout_bypass,
3065 (void *)&cmd_setbypass_timeout_timeout,
3066 (void *)&cmd_setbypass_timeout_value,
3071 /* *** SHOW NIC BYPASS MODE *** */
3072 struct cmd_show_bypass_config_result {
3073 cmdline_fixed_string_t show;
3074 cmdline_fixed_string_t bypass;
3075 cmdline_fixed_string_t config;
3080 cmd_show_bypass_config_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_show_bypass_config_result *res = parsed_result;
3085 uint32_t event_mode;
3086 uint32_t bypass_mode;
3087 portid_t port_id = res->port_id;
3088 uint32_t timeout = bypass_timeout;
3091 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3092 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3093 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3094 {"UNKNOWN", "normal", "bypass", "isolate"};
3095 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3102 int num_events = (sizeof events) / (sizeof events[0]);
3104 if (!bypass_is_supported(port_id))
3107 /* Display the bypass mode.*/
3108 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3109 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3113 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3114 bypass_mode = RTE_BYPASS_MODE_NONE;
3116 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3119 /* Display the bypass timeout.*/
3120 if (!RTE_BYPASS_TMT_VALID(timeout))
3121 timeout = RTE_BYPASS_TMT_OFF;
3123 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3125 /* Display the bypass events and associated modes. */
3126 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3128 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3129 printf("\tFailed to get bypass mode for event = %s\n",
3132 if (!RTE_BYPASS_MODE_VALID(event_mode))
3133 event_mode = RTE_BYPASS_MODE_NONE;
3135 printf("\tbypass event: %-16s = %s\n", events[i],
3141 cmdline_parse_token_string_t cmd_showbypass_config_show =
3142 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3144 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3145 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3147 cmdline_parse_token_string_t cmd_showbypass_config_config =
3148 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3150 cmdline_parse_token_num_t cmd_showbypass_config_port =
3151 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3154 cmdline_parse_inst_t cmd_show_bypass_config = {
3155 .f = cmd_show_bypass_config_parsed,
3156 .help_str = "show bypass config (port_id): "
3157 "Show the NIC bypass config for port_id",
3160 (void *)&cmd_showbypass_config_show,
3161 (void *)&cmd_showbypass_config_bypass,
3162 (void *)&cmd_showbypass_config_config,
3163 (void *)&cmd_showbypass_config_port,
3169 #ifdef RTE_LIBRTE_PMD_BOND
3170 /* *** SET BONDING MODE *** */
3171 struct cmd_set_bonding_mode_result {
3172 cmdline_fixed_string_t set;
3173 cmdline_fixed_string_t bonding;
3174 cmdline_fixed_string_t mode;
3179 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3180 __attribute__((unused)) struct cmdline *cl,
3181 __attribute__((unused)) void *data)
3183 struct cmd_set_bonding_mode_result *res = parsed_result;
3184 portid_t port_id = res->port_id;
3186 /* Set the bonding mode for the relevant port. */
3187 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3188 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3191 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3192 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3194 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3195 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3196 bonding, "bonding");
3197 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3198 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3200 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3201 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3203 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3204 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3207 cmdline_parse_inst_t cmd_set_bonding_mode = {
3208 .f = cmd_set_bonding_mode_parsed,
3209 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3212 (void *) &cmd_setbonding_mode_set,
3213 (void *) &cmd_setbonding_mode_bonding,
3214 (void *) &cmd_setbonding_mode_mode,
3215 (void *) &cmd_setbonding_mode_value,
3216 (void *) &cmd_setbonding_mode_port,
3221 /* *** SET BALANCE XMIT POLICY *** */
3222 struct cmd_set_bonding_balance_xmit_policy_result {
3223 cmdline_fixed_string_t set;
3224 cmdline_fixed_string_t bonding;
3225 cmdline_fixed_string_t balance_xmit_policy;
3227 cmdline_fixed_string_t policy;
3230 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3231 __attribute__((unused)) struct cmdline *cl,
3232 __attribute__((unused)) void *data)
3234 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3235 portid_t port_id = res->port_id;
3238 if (!strcmp(res->policy, "l2")) {
3239 policy = BALANCE_XMIT_POLICY_LAYER2;
3240 } else if (!strcmp(res->policy, "l23")) {
3241 policy = BALANCE_XMIT_POLICY_LAYER23;
3242 } else if (!strcmp(res->policy, "l34")) {
3243 policy = BALANCE_XMIT_POLICY_LAYER34;
3245 printf("\t Invalid xmit policy selection");
3249 /* Set the bonding mode for the relevant port. */
3250 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3251 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3256 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3257 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3259 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3260 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3261 bonding, "bonding");
3262 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3263 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3264 balance_xmit_policy, "balance_xmit_policy");
3265 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3266 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3268 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3269 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3270 policy, "l2#l23#l34");
3272 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3273 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3274 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3277 (void *)&cmd_setbonding_balance_xmit_policy_set,
3278 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3279 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3280 (void *)&cmd_setbonding_balance_xmit_policy_port,
3281 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3286 /* *** SHOW NIC BONDING CONFIGURATION *** */
3287 struct cmd_show_bonding_config_result {
3288 cmdline_fixed_string_t show;
3289 cmdline_fixed_string_t bonding;
3290 cmdline_fixed_string_t config;
3294 static void cmd_show_bonding_config_parsed(void *parsed_result,
3295 __attribute__((unused)) struct cmdline *cl,
3296 __attribute__((unused)) void *data)
3298 struct cmd_show_bonding_config_result *res = parsed_result;
3300 uint8_t slaves[RTE_MAX_ETHPORTS];
3301 int num_slaves, num_active_slaves;
3304 portid_t port_id = res->port_id;
3306 /* Display the bonding mode.*/
3307 bonding_mode = rte_eth_bond_mode_get(port_id);
3308 if (bonding_mode < 0) {
3309 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3312 printf("\tBonding mode: %d\n", bonding_mode);
3314 if (bonding_mode == BONDING_MODE_BALANCE) {
3315 int balance_xmit_policy;
3317 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3318 if (balance_xmit_policy < 0) {
3319 printf("\tFailed to get balance xmit policy for port = %d\n",
3323 printf("\tBalance Xmit Policy: ");
3325 switch (balance_xmit_policy) {
3326 case BALANCE_XMIT_POLICY_LAYER2:
3327 printf("BALANCE_XMIT_POLICY_LAYER2");
3329 case BALANCE_XMIT_POLICY_LAYER23:
3330 printf("BALANCE_XMIT_POLICY_LAYER23");
3332 case BALANCE_XMIT_POLICY_LAYER34:
3333 printf("BALANCE_XMIT_POLICY_LAYER34");
3340 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3342 if (num_slaves < 0) {
3343 printf("\tFailed to get slave list for port = %d\n", port_id);
3346 if (num_slaves > 0) {
3347 printf("\tSlaves (%d): [", num_slaves);
3348 for (i = 0; i < num_slaves - 1; i++)
3349 printf("%d ", slaves[i]);
3351 printf("%d]\n", slaves[num_slaves - 1]);
3353 printf("\tSlaves: []\n");
3357 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3360 if (num_active_slaves < 0) {
3361 printf("\tFailed to get active slave list for port = %d\n", port_id);
3364 if (num_active_slaves > 0) {
3365 printf("\tActive Slaves (%d): [", num_active_slaves);
3366 for (i = 0; i < num_active_slaves - 1; i++)
3367 printf("%d ", slaves[i]);
3369 printf("%d]\n", slaves[num_active_slaves - 1]);
3372 printf("\tActive Slaves: []\n");
3376 primary_id = rte_eth_bond_primary_get(port_id);
3377 if (primary_id < 0) {
3378 printf("\tFailed to get primary slave for port = %d\n", port_id);
3381 printf("\tPrimary: [%d]\n", primary_id);
3385 cmdline_parse_token_string_t cmd_showbonding_config_show =
3386 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3388 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3389 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3390 bonding, "bonding");
3391 cmdline_parse_token_string_t cmd_showbonding_config_config =
3392 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3394 cmdline_parse_token_num_t cmd_showbonding_config_port =
3395 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3398 cmdline_parse_inst_t cmd_show_bonding_config = {
3399 .f = cmd_show_bonding_config_parsed,
3400 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3403 (void *)&cmd_showbonding_config_show,
3404 (void *)&cmd_showbonding_config_bonding,
3405 (void *)&cmd_showbonding_config_config,
3406 (void *)&cmd_showbonding_config_port,
3411 /* *** SET BONDING PRIMARY *** */
3412 struct cmd_set_bonding_primary_result {
3413 cmdline_fixed_string_t set;
3414 cmdline_fixed_string_t bonding;
3415 cmdline_fixed_string_t primary;
3420 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3421 __attribute__((unused)) struct cmdline *cl,
3422 __attribute__((unused)) void *data)
3424 struct cmd_set_bonding_primary_result *res = parsed_result;
3425 portid_t master_port_id = res->port_id;
3426 portid_t slave_port_id = res->slave_id;
3428 /* Set the primary slave for a bonded device. */
3429 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3430 printf("\t Failed to set primary slave for port = %d.\n",
3437 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3438 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3440 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3441 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3442 bonding, "bonding");
3443 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3444 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3445 primary, "primary");
3446 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3447 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3449 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3450 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3453 cmdline_parse_inst_t cmd_set_bonding_primary = {
3454 .f = cmd_set_bonding_primary_parsed,
3455 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3458 (void *)&cmd_setbonding_primary_set,
3459 (void *)&cmd_setbonding_primary_bonding,
3460 (void *)&cmd_setbonding_primary_primary,
3461 (void *)&cmd_setbonding_primary_slave,
3462 (void *)&cmd_setbonding_primary_port,
3467 /* *** ADD SLAVE *** */
3468 struct cmd_add_bonding_slave_result {
3469 cmdline_fixed_string_t add;
3470 cmdline_fixed_string_t bonding;
3471 cmdline_fixed_string_t slave;
3476 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3477 __attribute__((unused)) struct cmdline *cl,
3478 __attribute__((unused)) void *data)
3480 struct cmd_add_bonding_slave_result *res = parsed_result;
3481 portid_t master_port_id = res->port_id;
3482 portid_t slave_port_id = res->slave_id;
3484 /* Set the primary slave for a bonded device. */
3485 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3486 printf("\t Failed to add slave %d to master port = %d.\n",
3487 slave_port_id, master_port_id);
3493 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3494 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3496 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3497 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3498 bonding, "bonding");
3499 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3500 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3502 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3503 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3505 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3506 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3509 cmdline_parse_inst_t cmd_add_bonding_slave = {
3510 .f = cmd_add_bonding_slave_parsed,
3511 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3514 (void *)&cmd_addbonding_slave_add,
3515 (void *)&cmd_addbonding_slave_bonding,
3516 (void *)&cmd_addbonding_slave_slave,
3517 (void *)&cmd_addbonding_slave_slaveid,
3518 (void *)&cmd_addbonding_slave_port,
3523 /* *** REMOVE SLAVE *** */
3524 struct cmd_remove_bonding_slave_result {
3525 cmdline_fixed_string_t remove;
3526 cmdline_fixed_string_t bonding;
3527 cmdline_fixed_string_t slave;
3532 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3533 __attribute__((unused)) struct cmdline *cl,
3534 __attribute__((unused)) void *data)
3536 struct cmd_remove_bonding_slave_result *res = parsed_result;
3537 portid_t master_port_id = res->port_id;
3538 portid_t slave_port_id = res->slave_id;
3540 /* Set the primary slave for a bonded device. */
3541 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3542 printf("\t Failed to remove slave %d from master port = %d.\n",
3543 slave_port_id, master_port_id);
3549 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3550 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3552 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3553 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3554 bonding, "bonding");
3555 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3556 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3558 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3559 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3561 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3562 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3565 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3566 .f = cmd_remove_bonding_slave_parsed,
3567 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3570 (void *)&cmd_removebonding_slave_remove,
3571 (void *)&cmd_removebonding_slave_bonding,
3572 (void *)&cmd_removebonding_slave_slave,
3573 (void *)&cmd_removebonding_slave_slaveid,
3574 (void *)&cmd_removebonding_slave_port,
3579 /* *** CREATE BONDED DEVICE *** */
3580 struct cmd_create_bonded_device_result {
3581 cmdline_fixed_string_t create;
3582 cmdline_fixed_string_t bonded;
3583 cmdline_fixed_string_t device;
3588 static int bond_dev_num = 0;
3590 static void cmd_create_bonded_device_parsed(void *parsed_result,
3591 __attribute__((unused)) struct cmdline *cl,
3592 __attribute__((unused)) void *data)
3594 struct cmd_create_bonded_device_result *res = parsed_result;
3595 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3598 if (test_done == 0) {
3599 printf("Please stop forwarding first\n");
3603 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3606 /* Create a new bonded device. */
3607 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3609 printf("\t Failed to create bonded device.\n");
3612 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3615 /* Update number of ports */
3616 nb_ports = rte_eth_dev_count();
3618 rte_eth_promiscuous_enable(port_id);
3623 cmdline_parse_token_string_t cmd_createbonded_device_create =
3624 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3626 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3627 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3629 cmdline_parse_token_string_t cmd_createbonded_device_device =
3630 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3632 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3633 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3635 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3636 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3639 cmdline_parse_inst_t cmd_create_bonded_device = {
3640 .f = cmd_create_bonded_device_parsed,
3641 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3644 (void *)&cmd_createbonded_device_create,
3645 (void *)&cmd_createbonded_device_bonded,
3646 (void *)&cmd_createbonded_device_device,
3647 (void *)&cmd_createbonded_device_mode,
3648 (void *)&cmd_createbonded_device_socket,
3653 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3654 struct cmd_set_bond_mac_addr_result {
3655 cmdline_fixed_string_t set;
3656 cmdline_fixed_string_t bonding;
3657 cmdline_fixed_string_t mac_addr;
3659 struct ether_addr address;
3662 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3663 __attribute__((unused)) struct cmdline *cl,
3664 __attribute__((unused)) void *data)
3666 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3669 if (res->port_num >= nb_ports) {
3670 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3674 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3676 /* check the return value and print it if is < 0 */
3678 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3681 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3682 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3683 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3684 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3686 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3687 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3689 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3690 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3691 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3692 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3694 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3695 .f = cmd_set_bond_mac_addr_parsed,
3697 .help_str = "set bonding mac_addr (port_id) (address): ",
3699 (void *)&cmd_set_bond_mac_addr_set,
3700 (void *)&cmd_set_bond_mac_addr_bonding,
3701 (void *)&cmd_set_bond_mac_addr_mac,
3702 (void *)&cmd_set_bond_mac_addr_portnum,
3703 (void *)&cmd_set_bond_mac_addr_addr,
3708 #endif /* RTE_LIBRTE_PMD_BOND */
3710 /* *** SET FORWARDING MODE *** */
3711 struct cmd_set_fwd_mode_result {
3712 cmdline_fixed_string_t set;
3713 cmdline_fixed_string_t fwd;
3714 cmdline_fixed_string_t mode;
3717 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3718 __attribute__((unused)) struct cmdline *cl,
3719 __attribute__((unused)) void *data)
3721 struct cmd_set_fwd_mode_result *res = parsed_result;
3723 set_pkt_forwarding_mode(res->mode);
3726 cmdline_parse_token_string_t cmd_setfwd_set =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3728 cmdline_parse_token_string_t cmd_setfwd_fwd =
3729 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3730 cmdline_parse_token_string_t cmd_setfwd_mode =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3732 "" /* defined at init */);
3734 cmdline_parse_inst_t cmd_set_fwd_mode = {
3735 .f = cmd_set_fwd_mode_parsed,
3737 .help_str = NULL, /* defined at init */
3739 (void *)&cmd_setfwd_set,
3740 (void *)&cmd_setfwd_fwd,
3741 (void *)&cmd_setfwd_mode,
3746 static void cmd_set_fwd_mode_init(void)
3749 static char token[128];
3750 static char help[256];
3751 cmdline_parse_token_string_t *token_struct;
3753 modes = list_pkt_forwarding_modes();
3754 snprintf(help, sizeof help, "set fwd %s - "
3755 "set packet forwarding mode", modes);
3756 cmd_set_fwd_mode.help_str = help;
3758 /* string token separator is # */
3759 for (c = token; *modes != '\0'; modes++)
3764 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3765 token_struct->string_data.str = token;
3768 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3769 struct cmd_set_burst_tx_retry_result {
3770 cmdline_fixed_string_t set;
3771 cmdline_fixed_string_t burst;
3772 cmdline_fixed_string_t tx;
3773 cmdline_fixed_string_t delay;
3775 cmdline_fixed_string_t retry;
3779 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3780 __attribute__((unused)) struct cmdline *cl,
3781 __attribute__((unused)) void *data)
3783 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3785 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3786 && !strcmp(res->tx, "tx")) {
3787 if (!strcmp(res->delay, "delay"))
3788 burst_tx_delay_time = res->time;
3789 if (!strcmp(res->retry, "retry"))
3790 burst_tx_retry_num = res->retry_num;
3795 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3797 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3800 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3802 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3803 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3804 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3805 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3806 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3808 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3809 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3811 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3812 .f = cmd_set_burst_tx_retry_parsed,
3813 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3815 (void *)&cmd_set_burst_tx_retry_set,
3816 (void *)&cmd_set_burst_tx_retry_burst,
3817 (void *)&cmd_set_burst_tx_retry_tx,
3818 (void *)&cmd_set_burst_tx_retry_delay,
3819 (void *)&cmd_set_burst_tx_retry_time,
3820 (void *)&cmd_set_burst_tx_retry_retry,
3821 (void *)&cmd_set_burst_tx_retry_retry_num,
3826 /* *** SET PROMISC MODE *** */
3827 struct cmd_set_promisc_mode_result {
3828 cmdline_fixed_string_t set;
3829 cmdline_fixed_string_t promisc;
3830 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3831 uint8_t port_num; /* valid if "allports" argument == 0 */
3832 cmdline_fixed_string_t mode;
3835 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3836 __attribute__((unused)) struct cmdline *cl,
3839 struct cmd_set_promisc_mode_result *res = parsed_result;
3843 if (!strcmp(res->mode, "on"))
3850 for (i = 0; i < nb_ports; i++) {
3852 rte_eth_promiscuous_enable(i);
3854 rte_eth_promiscuous_disable(i);
3859 rte_eth_promiscuous_enable(res->port_num);
3861 rte_eth_promiscuous_disable(res->port_num);
3865 cmdline_parse_token_string_t cmd_setpromisc_set =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3867 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3868 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3870 cmdline_parse_token_string_t cmd_setpromisc_portall =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3873 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3874 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3876 cmdline_parse_token_string_t cmd_setpromisc_mode =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3880 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3881 .f = cmd_set_promisc_mode_parsed,
3883 .help_str = "set promisc all on|off: set promisc mode for all ports",
3885 (void *)&cmd_setpromisc_set,
3886 (void *)&cmd_setpromisc_promisc,
3887 (void *)&cmd_setpromisc_portall,
3888 (void *)&cmd_setpromisc_mode,
3893 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3894 .f = cmd_set_promisc_mode_parsed,
3896 .help_str = "set promisc X on|off: set promisc mode on port X",
3898 (void *)&cmd_setpromisc_set,
3899 (void *)&cmd_setpromisc_promisc,
3900 (void *)&cmd_setpromisc_portnum,
3901 (void *)&cmd_setpromisc_mode,
3906 /* *** SET ALLMULTI MODE *** */
3907 struct cmd_set_allmulti_mode_result {
3908 cmdline_fixed_string_t set;
3909 cmdline_fixed_string_t allmulti;
3910 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3911 uint8_t port_num; /* valid if "allports" argument == 0 */
3912 cmdline_fixed_string_t mode;
3915 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3916 __attribute__((unused)) struct cmdline *cl,
3919 struct cmd_set_allmulti_mode_result *res = parsed_result;
3923 if (!strcmp(res->mode, "on"))
3930 for (i = 0; i < nb_ports; i++) {
3932 rte_eth_allmulticast_enable(i);
3934 rte_eth_allmulticast_disable(i);
3939 rte_eth_allmulticast_enable(res->port_num);
3941 rte_eth_allmulticast_disable(res->port_num);
3945 cmdline_parse_token_string_t cmd_setallmulti_set =
3946 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3947 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3950 cmdline_parse_token_string_t cmd_setallmulti_portall =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3953 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3954 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3956 cmdline_parse_token_string_t cmd_setallmulti_mode =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3960 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3961 .f = cmd_set_allmulti_mode_parsed,
3963 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3965 (void *)&cmd_setallmulti_set,
3966 (void *)&cmd_setallmulti_allmulti,
3967 (void *)&cmd_setallmulti_portall,
3968 (void *)&cmd_setallmulti_mode,
3973 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3974 .f = cmd_set_allmulti_mode_parsed,
3976 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3978 (void *)&cmd_setallmulti_set,
3979 (void *)&cmd_setallmulti_allmulti,
3980 (void *)&cmd_setallmulti_portnum,
3981 (void *)&cmd_setallmulti_mode,
3986 /* *** ADD/REMOVE A PKT FILTER *** */
3987 struct cmd_pkt_filter_result {
3988 cmdline_fixed_string_t pkt_filter;
3990 cmdline_fixed_string_t protocol;
3991 cmdline_fixed_string_t src;
3992 cmdline_ipaddr_t ip_src;
3994 cmdline_fixed_string_t dst;
3995 cmdline_ipaddr_t ip_dst;
3997 cmdline_fixed_string_t flexbytes;
3998 uint16_t flexbytes_value;
3999 cmdline_fixed_string_t vlan;
4001 cmdline_fixed_string_t queue;
4003 cmdline_fixed_string_t soft;
4008 cmd_pkt_filter_parsed(void *parsed_result,
4009 __attribute__((unused)) struct cmdline *cl,
4010 __attribute__((unused)) void *data)
4012 struct rte_fdir_filter fdir_filter;
4013 struct cmd_pkt_filter_result *res = parsed_result;
4015 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4017 if (res->ip_src.family == AF_INET)
4018 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4020 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4021 &(res->ip_src.addr.ipv6),
4022 sizeof(struct in6_addr));
4024 if (res->ip_dst.family == AF_INET)
4025 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4027 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4028 &(res->ip_dst.addr.ipv6),
4029 sizeof(struct in6_addr));
4031 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4032 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4034 if (!strcmp(res->protocol, "udp"))
4035 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4036 else if (!strcmp(res->protocol, "tcp"))
4037 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4038 else if (!strcmp(res->protocol, "sctp"))
4039 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4040 else /* default only IP */
4041 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4043 if (res->ip_dst.family == AF_INET6)
4044 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4046 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4048 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4049 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4051 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4052 fdir_add_signature_filter(res->port_id, res->queue_id,
4054 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4055 fdir_update_signature_filter(res->port_id, res->queue_id,
4057 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4058 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4059 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4060 fdir_add_perfect_filter(res->port_id, res->soft_id,
4062 (uint8_t) (res->queue_id < 0),
4064 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4065 fdir_update_perfect_filter(res->port_id, res->soft_id,
4067 (uint8_t) (res->queue_id < 0),
4069 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4070 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4076 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4077 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4079 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4080 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4081 protocol, "ip#tcp#udp#sctp");
4082 cmdline_parse_token_string_t cmd_pkt_filter_src =
4083 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4085 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4086 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4088 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4089 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4091 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4092 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4094 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4095 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4097 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4098 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4100 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4101 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4102 flexbytes, "flexbytes");
4103 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4104 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4105 flexbytes_value, UINT16);
4106 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4107 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4109 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4110 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4112 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4113 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4115 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4116 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4118 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4119 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4121 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4122 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4126 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4127 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4128 pkt_filter, "add_signature_filter");
4129 cmdline_parse_inst_t cmd_add_signature_filter = {
4130 .f = cmd_pkt_filter_parsed,
4132 .help_str = "add a signature filter",
4134 (void *)&cmd_pkt_filter_add_signature_filter,
4135 (void *)&cmd_pkt_filter_port_id,
4136 (void *)&cmd_pkt_filter_protocol,
4137 (void *)&cmd_pkt_filter_src,
4138 (void *)&cmd_pkt_filter_ip_src,
4139 (void *)&cmd_pkt_filter_port_src,
4140 (void *)&cmd_pkt_filter_dst,
4141 (void *)&cmd_pkt_filter_ip_dst,
4142 (void *)&cmd_pkt_filter_port_dst,
4143 (void *)&cmd_pkt_filter_flexbytes,
4144 (void *)&cmd_pkt_filter_flexbytes_value,
4145 (void *)&cmd_pkt_filter_vlan,
4146 (void *)&cmd_pkt_filter_vlan_id,
4147 (void *)&cmd_pkt_filter_queue,
4148 (void *)&cmd_pkt_filter_queue_id,
4154 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4155 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4156 pkt_filter, "upd_signature_filter");
4157 cmdline_parse_inst_t cmd_upd_signature_filter = {
4158 .f = cmd_pkt_filter_parsed,
4160 .help_str = "update a signature filter",
4162 (void *)&cmd_pkt_filter_upd_signature_filter,
4163 (void *)&cmd_pkt_filter_port_id,
4164 (void *)&cmd_pkt_filter_protocol,
4165 (void *)&cmd_pkt_filter_src,
4166 (void *)&cmd_pkt_filter_ip_src,
4167 (void *)&cmd_pkt_filter_port_src,
4168 (void *)&cmd_pkt_filter_dst,
4169 (void *)&cmd_pkt_filter_ip_dst,
4170 (void *)&cmd_pkt_filter_port_dst,
4171 (void *)&cmd_pkt_filter_flexbytes,
4172 (void *)&cmd_pkt_filter_flexbytes_value,
4173 (void *)&cmd_pkt_filter_vlan,
4174 (void *)&cmd_pkt_filter_vlan_id,
4175 (void *)&cmd_pkt_filter_queue,
4176 (void *)&cmd_pkt_filter_queue_id,
4182 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4183 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4184 pkt_filter, "rm_signature_filter");
4185 cmdline_parse_inst_t cmd_rm_signature_filter = {
4186 .f = cmd_pkt_filter_parsed,
4188 .help_str = "remove a signature filter",
4190 (void *)&cmd_pkt_filter_rm_signature_filter,
4191 (void *)&cmd_pkt_filter_port_id,
4192 (void *)&cmd_pkt_filter_protocol,
4193 (void *)&cmd_pkt_filter_src,
4194 (void *)&cmd_pkt_filter_ip_src,
4195 (void *)&cmd_pkt_filter_port_src,
4196 (void *)&cmd_pkt_filter_dst,
4197 (void *)&cmd_pkt_filter_ip_dst,
4198 (void *)&cmd_pkt_filter_port_dst,
4199 (void *)&cmd_pkt_filter_flexbytes,
4200 (void *)&cmd_pkt_filter_flexbytes_value,
4201 (void *)&cmd_pkt_filter_vlan,
4202 (void *)&cmd_pkt_filter_vlan_id,
4208 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4209 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4210 pkt_filter, "add_perfect_filter");
4211 cmdline_parse_inst_t cmd_add_perfect_filter = {
4212 .f = cmd_pkt_filter_parsed,
4214 .help_str = "add a perfect filter",
4216 (void *)&cmd_pkt_filter_add_perfect_filter,
4217 (void *)&cmd_pkt_filter_port_id,
4218 (void *)&cmd_pkt_filter_protocol,
4219 (void *)&cmd_pkt_filter_src,
4220 (void *)&cmd_pkt_filter_ip_src,
4221 (void *)&cmd_pkt_filter_port_src,
4222 (void *)&cmd_pkt_filter_dst,
4223 (void *)&cmd_pkt_filter_ip_dst,
4224 (void *)&cmd_pkt_filter_port_dst,
4225 (void *)&cmd_pkt_filter_flexbytes,
4226 (void *)&cmd_pkt_filter_flexbytes_value,
4227 (void *)&cmd_pkt_filter_vlan,
4228 (void *)&cmd_pkt_filter_vlan_id,
4229 (void *)&cmd_pkt_filter_queue,
4230 (void *)&cmd_pkt_filter_queue_id,
4231 (void *)&cmd_pkt_filter_soft,
4232 (void *)&cmd_pkt_filter_soft_id,
4238 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4239 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4240 pkt_filter, "upd_perfect_filter");
4241 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4242 .f = cmd_pkt_filter_parsed,
4244 .help_str = "update a perfect filter",
4246 (void *)&cmd_pkt_filter_upd_perfect_filter,
4247 (void *)&cmd_pkt_filter_port_id,
4248 (void *)&cmd_pkt_filter_protocol,
4249 (void *)&cmd_pkt_filter_src,
4250 (void *)&cmd_pkt_filter_ip_src,
4251 (void *)&cmd_pkt_filter_port_src,
4252 (void *)&cmd_pkt_filter_dst,
4253 (void *)&cmd_pkt_filter_ip_dst,
4254 (void *)&cmd_pkt_filter_port_dst,
4255 (void *)&cmd_pkt_filter_flexbytes,
4256 (void *)&cmd_pkt_filter_flexbytes_value,
4257 (void *)&cmd_pkt_filter_vlan,
4258 (void *)&cmd_pkt_filter_vlan_id,
4259 (void *)&cmd_pkt_filter_queue,
4260 (void *)&cmd_pkt_filter_queue_id,
4261 (void *)&cmd_pkt_filter_soft,
4262 (void *)&cmd_pkt_filter_soft_id,
4268 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4269 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4270 pkt_filter, "rm_perfect_filter");
4271 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4272 .f = cmd_pkt_filter_parsed,
4274 .help_str = "remove a perfect filter",
4276 (void *)&cmd_pkt_filter_rm_perfect_filter,
4277 (void *)&cmd_pkt_filter_port_id,
4278 (void *)&cmd_pkt_filter_protocol,
4279 (void *)&cmd_pkt_filter_src,
4280 (void *)&cmd_pkt_filter_ip_src,
4281 (void *)&cmd_pkt_filter_port_src,
4282 (void *)&cmd_pkt_filter_dst,
4283 (void *)&cmd_pkt_filter_ip_dst,
4284 (void *)&cmd_pkt_filter_port_dst,
4285 (void *)&cmd_pkt_filter_flexbytes,
4286 (void *)&cmd_pkt_filter_flexbytes_value,
4287 (void *)&cmd_pkt_filter_vlan,
4288 (void *)&cmd_pkt_filter_vlan_id,
4289 (void *)&cmd_pkt_filter_soft,
4290 (void *)&cmd_pkt_filter_soft_id,
4295 /* *** SETUP MASKS FILTER *** */
4296 struct cmd_pkt_filter_masks_result {
4297 cmdline_fixed_string_t filter_mask;
4299 cmdline_fixed_string_t src_mask;
4300 uint32_t ip_src_mask;
4301 uint16_t ipv6_src_mask;
4302 uint16_t port_src_mask;
4303 cmdline_fixed_string_t dst_mask;
4304 uint32_t ip_dst_mask;
4305 uint16_t ipv6_dst_mask;
4306 uint16_t port_dst_mask;
4307 cmdline_fixed_string_t flexbytes;
4308 uint8_t flexbytes_value;
4309 cmdline_fixed_string_t vlan_id;
4310 uint8_t vlan_id_value;
4311 cmdline_fixed_string_t vlan_prio;
4312 uint8_t vlan_prio_value;
4313 cmdline_fixed_string_t only_ip_flow;
4314 uint8_t only_ip_flow_value;
4315 cmdline_fixed_string_t comp_ipv6_dst;
4316 uint8_t comp_ipv6_dst_value;
4320 cmd_pkt_filter_masks_parsed(void *parsed_result,
4321 __attribute__((unused)) struct cmdline *cl,
4322 __attribute__((unused)) void *data)
4324 struct rte_fdir_masks fdir_masks;
4325 struct cmd_pkt_filter_masks_result *res = parsed_result;
4327 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4329 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4330 fdir_masks.vlan_id = res->vlan_id_value;
4331 fdir_masks.vlan_prio = res->vlan_prio_value;
4332 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4333 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4334 fdir_masks.src_port_mask = res->port_src_mask;
4335 fdir_masks.dst_port_mask = res->port_dst_mask;
4336 fdir_masks.flexbytes = res->flexbytes_value;
4338 fdir_set_masks(res->port_id, &fdir_masks);
4341 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4342 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4343 filter_mask, "set_masks_filter");
4344 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4345 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4347 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4348 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4349 only_ip_flow, "only_ip_flow");
4350 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4351 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4352 only_ip_flow_value, UINT8);
4353 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4354 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4355 src_mask, "src_mask");
4356 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4357 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4358 ip_src_mask, UINT32);
4359 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4360 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4361 port_src_mask, UINT16);
4362 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4363 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4364 dst_mask, "dst_mask");
4365 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4366 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4367 ip_dst_mask, UINT32);
4368 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4369 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4370 port_dst_mask, UINT16);
4371 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4372 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4373 flexbytes, "flexbytes");
4374 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4375 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4376 flexbytes_value, UINT8);
4377 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4378 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4379 vlan_id, "vlan_id");
4380 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4381 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4382 vlan_id_value, UINT8);
4383 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4384 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4385 vlan_prio, "vlan_prio");
4386 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4387 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4388 vlan_prio_value, UINT8);
4390 cmdline_parse_inst_t cmd_set_masks_filter = {
4391 .f = cmd_pkt_filter_masks_parsed,
4393 .help_str = "setup masks filter",
4395 (void *)&cmd_pkt_filter_masks_filter_mask,
4396 (void *)&cmd_pkt_filter_masks_port_id,
4397 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4398 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4399 (void *)&cmd_pkt_filter_masks_src_mask,
4400 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4401 (void *)&cmd_pkt_filter_masks_port_src_mask,
4402 (void *)&cmd_pkt_filter_masks_dst_mask,
4403 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4404 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4405 (void *)&cmd_pkt_filter_masks_flexbytes,
4406 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4407 (void *)&cmd_pkt_filter_masks_vlan_id,
4408 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4409 (void *)&cmd_pkt_filter_masks_vlan_prio,
4410 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4416 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4417 __attribute__((unused)) struct cmdline *cl,
4418 __attribute__((unused)) void *data)
4420 struct rte_fdir_masks fdir_masks;
4421 struct cmd_pkt_filter_masks_result *res = parsed_result;
4423 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4425 fdir_masks.set_ipv6_mask = 1;
4426 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4427 fdir_masks.vlan_id = res->vlan_id_value;
4428 fdir_masks.vlan_prio = res->vlan_prio_value;
4429 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4430 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4431 fdir_masks.src_port_mask = res->port_src_mask;
4432 fdir_masks.dst_port_mask = res->port_dst_mask;
4433 fdir_masks.flexbytes = res->flexbytes_value;
4434 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4436 fdir_set_masks(res->port_id, &fdir_masks);
4439 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4440 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4441 filter_mask, "set_ipv6_masks_filter");
4442 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4443 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4444 ipv6_src_mask, UINT16);
4445 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4446 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4447 ipv6_dst_mask, UINT16);
4449 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4450 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4451 comp_ipv6_dst, "compare_dst");
4452 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4453 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4454 comp_ipv6_dst_value, UINT8);
4456 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4457 .f = cmd_pkt_filter_masks_ipv6_parsed,
4459 .help_str = "setup ipv6 masks filter",
4461 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4462 (void *)&cmd_pkt_filter_masks_port_id,
4463 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4464 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4465 (void *)&cmd_pkt_filter_masks_src_mask,
4466 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4467 (void *)&cmd_pkt_filter_masks_port_src_mask,
4468 (void *)&cmd_pkt_filter_masks_dst_mask,
4469 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4470 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4471 (void *)&cmd_pkt_filter_masks_flexbytes,
4472 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4473 (void *)&cmd_pkt_filter_masks_vlan_id,
4474 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4475 (void *)&cmd_pkt_filter_masks_vlan_prio,
4476 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4477 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4478 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4483 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4484 struct cmd_link_flow_ctrl_set_result {
4485 cmdline_fixed_string_t set;
4486 cmdline_fixed_string_t flow_ctrl;
4487 cmdline_fixed_string_t rx;
4488 cmdline_fixed_string_t rx_lfc_mode;
4489 cmdline_fixed_string_t tx;
4490 cmdline_fixed_string_t tx_lfc_mode;
4491 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4492 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4493 cmdline_fixed_string_t autoneg_str;
4494 cmdline_fixed_string_t autoneg;
4495 cmdline_fixed_string_t hw_str;
4496 uint32_t high_water;
4497 cmdline_fixed_string_t lw_str;
4499 cmdline_fixed_string_t pt_str;
4500 uint16_t pause_time;
4501 cmdline_fixed_string_t xon_str;
4506 cmdline_parse_token_string_t cmd_lfc_set_set =
4507 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4509 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4510 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4511 flow_ctrl, "flow_ctrl");
4512 cmdline_parse_token_string_t cmd_lfc_set_rx =
4513 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4515 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4516 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4517 rx_lfc_mode, "on#off");
4518 cmdline_parse_token_string_t cmd_lfc_set_tx =
4519 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4521 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4522 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4523 tx_lfc_mode, "on#off");
4524 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4525 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4526 hw_str, "high_water");
4527 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4528 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4529 high_water, UINT32);
4530 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4531 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4532 lw_str, "low_water");
4533 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4534 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4536 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4537 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4538 pt_str, "pause_time");
4539 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4540 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4541 pause_time, UINT16);
4542 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4543 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4544 xon_str, "send_xon");
4545 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4546 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4548 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4549 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4550 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4551 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4552 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4553 mac_ctrl_frame_fwd_mode, "on#off");
4554 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4555 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4556 autoneg_str, "autoneg");
4557 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4558 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4560 cmdline_parse_token_num_t cmd_lfc_set_portid =
4561 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4564 /* forward declaration */
4566 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4569 cmdline_parse_inst_t cmd_link_flow_control_set = {
4570 .f = cmd_link_flow_ctrl_set_parsed,
4572 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4573 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4574 autoneg on|off port_id",
4576 (void *)&cmd_lfc_set_set,
4577 (void *)&cmd_lfc_set_flow_ctrl,
4578 (void *)&cmd_lfc_set_rx,
4579 (void *)&cmd_lfc_set_rx_mode,
4580 (void *)&cmd_lfc_set_tx,
4581 (void *)&cmd_lfc_set_tx_mode,
4582 (void *)&cmd_lfc_set_high_water,
4583 (void *)&cmd_lfc_set_low_water,
4584 (void *)&cmd_lfc_set_pause_time,
4585 (void *)&cmd_lfc_set_send_xon,
4586 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4587 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4588 (void *)&cmd_lfc_set_autoneg_str,
4589 (void *)&cmd_lfc_set_autoneg,
4590 (void *)&cmd_lfc_set_portid,
4595 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4596 .f = cmd_link_flow_ctrl_set_parsed,
4597 .data = (void *)&cmd_link_flow_control_set_rx,
4598 .help_str = "Change rx flow control parameter: set flow_ctrl "
4599 "rx on|off port_id",
4601 (void *)&cmd_lfc_set_set,
4602 (void *)&cmd_lfc_set_flow_ctrl,
4603 (void *)&cmd_lfc_set_rx,
4604 (void *)&cmd_lfc_set_rx_mode,
4605 (void *)&cmd_lfc_set_portid,
4610 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4611 .f = cmd_link_flow_ctrl_set_parsed,
4612 .data = (void *)&cmd_link_flow_control_set_tx,
4613 .help_str = "Change tx flow control parameter: set flow_ctrl "
4614 "tx on|off port_id",
4616 (void *)&cmd_lfc_set_set,
4617 (void *)&cmd_lfc_set_flow_ctrl,
4618 (void *)&cmd_lfc_set_tx,
4619 (void *)&cmd_lfc_set_tx_mode,
4620 (void *)&cmd_lfc_set_portid,
4625 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4626 .f = cmd_link_flow_ctrl_set_parsed,
4627 .data = (void *)&cmd_link_flow_control_set_hw,
4628 .help_str = "Change high water flow control parameter: set flow_ctrl "
4629 "high_water value port_id",
4631 (void *)&cmd_lfc_set_set,
4632 (void *)&cmd_lfc_set_flow_ctrl,
4633 (void *)&cmd_lfc_set_high_water_str,
4634 (void *)&cmd_lfc_set_high_water,
4635 (void *)&cmd_lfc_set_portid,
4640 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4641 .f = cmd_link_flow_ctrl_set_parsed,
4642 .data = (void *)&cmd_link_flow_control_set_lw,
4643 .help_str = "Change low water flow control parameter: set flow_ctrl "
4644 "low_water value port_id",
4646 (void *)&cmd_lfc_set_set,
4647 (void *)&cmd_lfc_set_flow_ctrl,
4648 (void *)&cmd_lfc_set_low_water_str,
4649 (void *)&cmd_lfc_set_low_water,
4650 (void *)&cmd_lfc_set_portid,
4655 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4656 .f = cmd_link_flow_ctrl_set_parsed,
4657 .data = (void *)&cmd_link_flow_control_set_pt,
4658 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4659 "pause_time value port_id",
4661 (void *)&cmd_lfc_set_set,
4662 (void *)&cmd_lfc_set_flow_ctrl,
4663 (void *)&cmd_lfc_set_pause_time_str,
4664 (void *)&cmd_lfc_set_pause_time,
4665 (void *)&cmd_lfc_set_portid,
4670 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4671 .f = cmd_link_flow_ctrl_set_parsed,
4672 .data = (void *)&cmd_link_flow_control_set_xon,
4673 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4674 "send_xon value port_id",
4676 (void *)&cmd_lfc_set_set,
4677 (void *)&cmd_lfc_set_flow_ctrl,
4678 (void *)&cmd_lfc_set_send_xon_str,
4679 (void *)&cmd_lfc_set_send_xon,
4680 (void *)&cmd_lfc_set_portid,
4685 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4686 .f = cmd_link_flow_ctrl_set_parsed,
4687 .data = (void *)&cmd_link_flow_control_set_macfwd,
4688 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4689 "mac_ctrl_frame_fwd on|off port_id",
4691 (void *)&cmd_lfc_set_set,
4692 (void *)&cmd_lfc_set_flow_ctrl,
4693 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4694 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4695 (void *)&cmd_lfc_set_portid,
4700 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4701 .f = cmd_link_flow_ctrl_set_parsed,
4702 .data = (void *)&cmd_link_flow_control_set_autoneg,
4703 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4704 "autoneg on|off port_id",
4706 (void *)&cmd_lfc_set_set,
4707 (void *)&cmd_lfc_set_flow_ctrl,
4708 (void *)&cmd_lfc_set_autoneg_str,
4709 (void *)&cmd_lfc_set_autoneg,
4710 (void *)&cmd_lfc_set_portid,
4716 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4717 __attribute__((unused)) struct cmdline *cl,
4720 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4721 cmdline_parse_inst_t *cmd = data;
4722 struct rte_eth_fc_conf fc_conf;
4723 int rx_fc_en, tx_fc_en;
4727 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4728 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4729 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4730 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4732 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4733 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4736 /* Partial command line, retrieve current configuration */
4738 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4740 printf("cannot get current flow ctrl parameters, return"
4741 "code = %d\n", ret);
4745 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4746 (fc_conf.mode == RTE_FC_FULL))
4748 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4749 (fc_conf.mode == RTE_FC_FULL))
4753 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4754 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4756 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4757 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4759 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4761 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4762 fc_conf.high_water = res->high_water;
4764 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4765 fc_conf.low_water = res->low_water;
4767 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4768 fc_conf.pause_time = res->pause_time;
4770 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4771 fc_conf.send_xon = res->send_xon;
4773 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4774 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4775 fc_conf.mac_ctrl_frame_fwd = 1;
4777 fc_conf.mac_ctrl_frame_fwd = 0;
4780 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4781 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4783 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4785 printf("bad flow contrl parameter, return code = %d \n", ret);
4788 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4789 struct cmd_priority_flow_ctrl_set_result {
4790 cmdline_fixed_string_t set;
4791 cmdline_fixed_string_t pfc_ctrl;
4792 cmdline_fixed_string_t rx;
4793 cmdline_fixed_string_t rx_pfc_mode;
4794 cmdline_fixed_string_t tx;
4795 cmdline_fixed_string_t tx_pfc_mode;
4796 uint32_t high_water;
4798 uint16_t pause_time;
4804 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4805 __attribute__((unused)) struct cmdline *cl,
4806 __attribute__((unused)) void *data)
4808 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4809 struct rte_eth_pfc_conf pfc_conf;
4810 int rx_fc_enable, tx_fc_enable;
4814 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4815 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4816 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4817 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4819 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4820 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4823 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4824 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4825 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4826 pfc_conf.fc.high_water = res->high_water;
4827 pfc_conf.fc.low_water = res->low_water;
4828 pfc_conf.fc.pause_time = res->pause_time;
4829 pfc_conf.priority = res->priority;
4831 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4833 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4836 cmdline_parse_token_string_t cmd_pfc_set_set =
4837 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4839 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4840 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4841 pfc_ctrl, "pfc_ctrl");
4842 cmdline_parse_token_string_t cmd_pfc_set_rx =
4843 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4845 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4846 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4847 rx_pfc_mode, "on#off");
4848 cmdline_parse_token_string_t cmd_pfc_set_tx =
4849 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4851 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4852 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4853 tx_pfc_mode, "on#off");
4854 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4855 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4856 high_water, UINT32);
4857 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4858 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4860 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4861 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4862 pause_time, UINT16);
4863 cmdline_parse_token_num_t cmd_pfc_set_priority =
4864 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4866 cmdline_parse_token_num_t cmd_pfc_set_portid =
4867 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4870 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4871 .f = cmd_priority_flow_ctrl_set_parsed,
4873 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4874 tx on|off high_water low_water pause_time priority port_id",
4876 (void *)&cmd_pfc_set_set,
4877 (void *)&cmd_pfc_set_flow_ctrl,
4878 (void *)&cmd_pfc_set_rx,
4879 (void *)&cmd_pfc_set_rx_mode,
4880 (void *)&cmd_pfc_set_tx,
4881 (void *)&cmd_pfc_set_tx_mode,
4882 (void *)&cmd_pfc_set_high_water,
4883 (void *)&cmd_pfc_set_low_water,
4884 (void *)&cmd_pfc_set_pause_time,
4885 (void *)&cmd_pfc_set_priority,
4886 (void *)&cmd_pfc_set_portid,
4891 /* *** RESET CONFIGURATION *** */
4892 struct cmd_reset_result {
4893 cmdline_fixed_string_t reset;
4894 cmdline_fixed_string_t def;
4897 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4899 __attribute__((unused)) void *data)
4901 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4902 set_def_fwd_config();
4905 cmdline_parse_token_string_t cmd_reset_set =
4906 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4907 cmdline_parse_token_string_t cmd_reset_def =
4908 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4911 cmdline_parse_inst_t cmd_reset = {
4912 .f = cmd_reset_parsed,
4914 .help_str = "set default: reset default forwarding configuration",
4916 (void *)&cmd_reset_set,
4917 (void *)&cmd_reset_def,
4922 /* *** START FORWARDING *** */
4923 struct cmd_start_result {
4924 cmdline_fixed_string_t start;
4927 cmdline_parse_token_string_t cmd_start_start =
4928 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4930 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4931 __attribute__((unused)) struct cmdline *cl,
4932 __attribute__((unused)) void *data)
4934 start_packet_forwarding(0);
4937 cmdline_parse_inst_t cmd_start = {
4938 .f = cmd_start_parsed,
4940 .help_str = "start packet forwarding",
4942 (void *)&cmd_start_start,
4947 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4948 struct cmd_start_tx_first_result {
4949 cmdline_fixed_string_t start;
4950 cmdline_fixed_string_t tx_first;
4954 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4955 __attribute__((unused)) struct cmdline *cl,
4956 __attribute__((unused)) void *data)
4958 start_packet_forwarding(1);
4961 cmdline_parse_token_string_t cmd_start_tx_first_start =
4962 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4964 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4965 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4966 tx_first, "tx_first");
4968 cmdline_parse_inst_t cmd_start_tx_first = {
4969 .f = cmd_start_tx_first_parsed,
4971 .help_str = "start packet forwarding, after sending 1 burst of packets",
4973 (void *)&cmd_start_tx_first_start,
4974 (void *)&cmd_start_tx_first_tx_first,
4979 /* *** SET LINK UP *** */
4980 struct cmd_set_link_up_result {
4981 cmdline_fixed_string_t set;
4982 cmdline_fixed_string_t link_up;
4983 cmdline_fixed_string_t port;
4987 cmdline_parse_token_string_t cmd_set_link_up_set =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4989 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4990 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4992 cmdline_parse_token_string_t cmd_set_link_up_port =
4993 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4994 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4995 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4997 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4998 __attribute__((unused)) struct cmdline *cl,
4999 __attribute__((unused)) void *data)
5001 struct cmd_set_link_up_result *res = parsed_result;
5002 dev_set_link_up(res->port_id);
5005 cmdline_parse_inst_t cmd_set_link_up = {
5006 .f = cmd_set_link_up_parsed,
5008 .help_str = "set link-up port (port id)",
5010 (void *)&cmd_set_link_up_set,
5011 (void *)&cmd_set_link_up_link_up,
5012 (void *)&cmd_set_link_up_port,
5013 (void *)&cmd_set_link_up_port_id,
5018 /* *** SET LINK DOWN *** */
5019 struct cmd_set_link_down_result {
5020 cmdline_fixed_string_t set;
5021 cmdline_fixed_string_t link_down;
5022 cmdline_fixed_string_t port;
5026 cmdline_parse_token_string_t cmd_set_link_down_set =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5028 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5029 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5031 cmdline_parse_token_string_t cmd_set_link_down_port =
5032 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5033 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5034 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5036 static void cmd_set_link_down_parsed(
5037 __attribute__((unused)) void *parsed_result,
5038 __attribute__((unused)) struct cmdline *cl,
5039 __attribute__((unused)) void *data)
5041 struct cmd_set_link_down_result *res = parsed_result;
5042 dev_set_link_down(res->port_id);
5045 cmdline_parse_inst_t cmd_set_link_down = {
5046 .f = cmd_set_link_down_parsed,
5048 .help_str = "set link-down port (port id)",
5050 (void *)&cmd_set_link_down_set,
5051 (void *)&cmd_set_link_down_link_down,
5052 (void *)&cmd_set_link_down_port,
5053 (void *)&cmd_set_link_down_port_id,
5058 /* *** SHOW CFG *** */
5059 struct cmd_showcfg_result {
5060 cmdline_fixed_string_t show;
5061 cmdline_fixed_string_t cfg;
5062 cmdline_fixed_string_t what;
5065 static void cmd_showcfg_parsed(void *parsed_result,
5066 __attribute__((unused)) struct cmdline *cl,
5067 __attribute__((unused)) void *data)
5069 struct cmd_showcfg_result *res = parsed_result;
5070 if (!strcmp(res->what, "rxtx"))
5071 rxtx_config_display();
5072 else if (!strcmp(res->what, "cores"))
5073 fwd_lcores_config_display();
5074 else if (!strcmp(res->what, "fwd"))
5075 fwd_config_display();
5078 cmdline_parse_token_string_t cmd_showcfg_show =
5079 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5080 cmdline_parse_token_string_t cmd_showcfg_port =
5081 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5082 cmdline_parse_token_string_t cmd_showcfg_what =
5083 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5086 cmdline_parse_inst_t cmd_showcfg = {
5087 .f = cmd_showcfg_parsed,
5089 .help_str = "show config rxtx|cores|fwd",
5091 (void *)&cmd_showcfg_show,
5092 (void *)&cmd_showcfg_port,
5093 (void *)&cmd_showcfg_what,
5098 /* *** SHOW ALL PORT INFO *** */
5099 struct cmd_showportall_result {
5100 cmdline_fixed_string_t show;
5101 cmdline_fixed_string_t port;
5102 cmdline_fixed_string_t what;
5103 cmdline_fixed_string_t all;
5106 static void cmd_showportall_parsed(void *parsed_result,
5107 __attribute__((unused)) struct cmdline *cl,
5108 __attribute__((unused)) void *data)
5112 struct cmd_showportall_result *res = parsed_result;
5113 if (!strcmp(res->show, "clear")) {
5114 if (!strcmp(res->what, "stats"))
5115 for (i = 0; i < nb_ports; i++)
5117 } else if (!strcmp(res->what, "info"))
5118 for (i = 0; i < nb_ports; i++)
5119 port_infos_display(i);
5120 else if (!strcmp(res->what, "stats"))
5121 for (i = 0; i < nb_ports; i++)
5122 nic_stats_display(i);
5123 else if (!strcmp(res->what, "fdir"))
5124 for (i = 0; i < nb_ports; i++)
5126 else if (!strcmp(res->what, "stat_qmap"))
5127 for (i = 0; i < nb_ports; i++)
5128 nic_stats_mapping_display(i);
5131 cmdline_parse_token_string_t cmd_showportall_show =
5132 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5134 cmdline_parse_token_string_t cmd_showportall_port =
5135 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5136 cmdline_parse_token_string_t cmd_showportall_what =
5137 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5138 "info#stats#fdir#stat_qmap");
5139 cmdline_parse_token_string_t cmd_showportall_all =
5140 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5141 cmdline_parse_inst_t cmd_showportall = {
5142 .f = cmd_showportall_parsed,
5144 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
5146 (void *)&cmd_showportall_show,
5147 (void *)&cmd_showportall_port,
5148 (void *)&cmd_showportall_what,
5149 (void *)&cmd_showportall_all,
5154 /* *** SHOW PORT INFO *** */
5155 struct cmd_showport_result {
5156 cmdline_fixed_string_t show;
5157 cmdline_fixed_string_t port;
5158 cmdline_fixed_string_t what;
5162 static void cmd_showport_parsed(void *parsed_result,
5163 __attribute__((unused)) struct cmdline *cl,
5164 __attribute__((unused)) void *data)
5166 struct cmd_showport_result *res = parsed_result;
5167 if (!strcmp(res->show, "clear")) {
5168 if (!strcmp(res->what, "stats"))
5169 nic_stats_clear(res->portnum);
5170 } else if (!strcmp(res->what, "info"))
5171 port_infos_display(res->portnum);
5172 else if (!strcmp(res->what, "stats"))
5173 nic_stats_display(res->portnum);
5174 else if (!strcmp(res->what, "fdir"))
5175 fdir_get_infos(res->portnum);
5176 else if (!strcmp(res->what, "stat_qmap"))
5177 nic_stats_mapping_display(res->portnum);
5180 cmdline_parse_token_string_t cmd_showport_show =
5181 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5183 cmdline_parse_token_string_t cmd_showport_port =
5184 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5185 cmdline_parse_token_string_t cmd_showport_what =
5186 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5187 "info#stats#fdir#stat_qmap");
5188 cmdline_parse_token_num_t cmd_showport_portnum =
5189 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5191 cmdline_parse_inst_t cmd_showport = {
5192 .f = cmd_showport_parsed,
5194 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
5196 (void *)&cmd_showport_show,
5197 (void *)&cmd_showport_port,
5198 (void *)&cmd_showport_what,
5199 (void *)&cmd_showport_portnum,
5204 /* *** READ PORT REGISTER *** */
5205 struct cmd_read_reg_result {
5206 cmdline_fixed_string_t read;
5207 cmdline_fixed_string_t reg;
5213 cmd_read_reg_parsed(void *parsed_result,
5214 __attribute__((unused)) struct cmdline *cl,
5215 __attribute__((unused)) void *data)
5217 struct cmd_read_reg_result *res = parsed_result;
5218 port_reg_display(res->port_id, res->reg_off);
5221 cmdline_parse_token_string_t cmd_read_reg_read =
5222 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5223 cmdline_parse_token_string_t cmd_read_reg_reg =
5224 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5225 cmdline_parse_token_num_t cmd_read_reg_port_id =
5226 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5227 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5228 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5230 cmdline_parse_inst_t cmd_read_reg = {
5231 .f = cmd_read_reg_parsed,
5233 .help_str = "read reg port_id reg_off",
5235 (void *)&cmd_read_reg_read,
5236 (void *)&cmd_read_reg_reg,
5237 (void *)&cmd_read_reg_port_id,
5238 (void *)&cmd_read_reg_reg_off,
5243 /* *** READ PORT REGISTER BIT FIELD *** */
5244 struct cmd_read_reg_bit_field_result {
5245 cmdline_fixed_string_t read;
5246 cmdline_fixed_string_t regfield;
5254 cmd_read_reg_bit_field_parsed(void *parsed_result,
5255 __attribute__((unused)) struct cmdline *cl,
5256 __attribute__((unused)) void *data)
5258 struct cmd_read_reg_bit_field_result *res = parsed_result;
5259 port_reg_bit_field_display(res->port_id, res->reg_off,
5260 res->bit1_pos, res->bit2_pos);
5263 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5264 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5266 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5267 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5268 regfield, "regfield");
5269 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5270 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5272 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5273 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5275 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5276 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5278 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5279 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5282 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5283 .f = cmd_read_reg_bit_field_parsed,
5285 .help_str = "read regfield port_id reg_off bit_x bit_y "
5286 "(read register bit field between bit_x and bit_y included)",
5288 (void *)&cmd_read_reg_bit_field_read,
5289 (void *)&cmd_read_reg_bit_field_regfield,
5290 (void *)&cmd_read_reg_bit_field_port_id,
5291 (void *)&cmd_read_reg_bit_field_reg_off,
5292 (void *)&cmd_read_reg_bit_field_bit1_pos,
5293 (void *)&cmd_read_reg_bit_field_bit2_pos,
5298 /* *** READ PORT REGISTER BIT *** */
5299 struct cmd_read_reg_bit_result {
5300 cmdline_fixed_string_t read;
5301 cmdline_fixed_string_t regbit;
5308 cmd_read_reg_bit_parsed(void *parsed_result,
5309 __attribute__((unused)) struct cmdline *cl,
5310 __attribute__((unused)) void *data)
5312 struct cmd_read_reg_bit_result *res = parsed_result;
5313 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5316 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5317 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5318 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5319 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5321 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5322 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5323 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5324 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5325 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5326 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5328 cmdline_parse_inst_t cmd_read_reg_bit = {
5329 .f = cmd_read_reg_bit_parsed,
5331 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5333 (void *)&cmd_read_reg_bit_read,
5334 (void *)&cmd_read_reg_bit_regbit,
5335 (void *)&cmd_read_reg_bit_port_id,
5336 (void *)&cmd_read_reg_bit_reg_off,
5337 (void *)&cmd_read_reg_bit_bit_pos,
5342 /* *** WRITE PORT REGISTER *** */
5343 struct cmd_write_reg_result {
5344 cmdline_fixed_string_t write;
5345 cmdline_fixed_string_t reg;
5352 cmd_write_reg_parsed(void *parsed_result,
5353 __attribute__((unused)) struct cmdline *cl,
5354 __attribute__((unused)) void *data)
5356 struct cmd_write_reg_result *res = parsed_result;
5357 port_reg_set(res->port_id, res->reg_off, res->value);
5360 cmdline_parse_token_string_t cmd_write_reg_write =
5361 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5362 cmdline_parse_token_string_t cmd_write_reg_reg =
5363 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5364 cmdline_parse_token_num_t cmd_write_reg_port_id =
5365 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5366 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5367 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5368 cmdline_parse_token_num_t cmd_write_reg_value =
5369 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5371 cmdline_parse_inst_t cmd_write_reg = {
5372 .f = cmd_write_reg_parsed,
5374 .help_str = "write reg port_id reg_off reg_value",
5376 (void *)&cmd_write_reg_write,
5377 (void *)&cmd_write_reg_reg,
5378 (void *)&cmd_write_reg_port_id,
5379 (void *)&cmd_write_reg_reg_off,
5380 (void *)&cmd_write_reg_value,
5385 /* *** WRITE PORT REGISTER BIT FIELD *** */
5386 struct cmd_write_reg_bit_field_result {
5387 cmdline_fixed_string_t write;
5388 cmdline_fixed_string_t regfield;
5397 cmd_write_reg_bit_field_parsed(void *parsed_result,
5398 __attribute__((unused)) struct cmdline *cl,
5399 __attribute__((unused)) void *data)
5401 struct cmd_write_reg_bit_field_result *res = parsed_result;
5402 port_reg_bit_field_set(res->port_id, res->reg_off,
5403 res->bit1_pos, res->bit2_pos, res->value);
5406 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5407 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5409 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5410 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5411 regfield, "regfield");
5412 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5413 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5415 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5416 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5418 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5419 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5421 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5422 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5424 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5425 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5428 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5429 .f = cmd_write_reg_bit_field_parsed,
5431 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5432 "(set register bit field between bit_x and bit_y included)",
5434 (void *)&cmd_write_reg_bit_field_write,
5435 (void *)&cmd_write_reg_bit_field_regfield,
5436 (void *)&cmd_write_reg_bit_field_port_id,
5437 (void *)&cmd_write_reg_bit_field_reg_off,
5438 (void *)&cmd_write_reg_bit_field_bit1_pos,
5439 (void *)&cmd_write_reg_bit_field_bit2_pos,
5440 (void *)&cmd_write_reg_bit_field_value,
5445 /* *** WRITE PORT REGISTER BIT *** */
5446 struct cmd_write_reg_bit_result {
5447 cmdline_fixed_string_t write;
5448 cmdline_fixed_string_t regbit;
5456 cmd_write_reg_bit_parsed(void *parsed_result,
5457 __attribute__((unused)) struct cmdline *cl,
5458 __attribute__((unused)) void *data)
5460 struct cmd_write_reg_bit_result *res = parsed_result;
5461 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5464 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5465 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5467 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5468 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5470 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5471 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5472 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5473 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5474 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5475 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5476 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5477 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5479 cmdline_parse_inst_t cmd_write_reg_bit = {
5480 .f = cmd_write_reg_bit_parsed,
5482 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5484 (void *)&cmd_write_reg_bit_write,
5485 (void *)&cmd_write_reg_bit_regbit,
5486 (void *)&cmd_write_reg_bit_port_id,
5487 (void *)&cmd_write_reg_bit_reg_off,
5488 (void *)&cmd_write_reg_bit_bit_pos,
5489 (void *)&cmd_write_reg_bit_value,
5494 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5495 struct cmd_read_rxd_txd_result {
5496 cmdline_fixed_string_t read;
5497 cmdline_fixed_string_t rxd_txd;
5504 cmd_read_rxd_txd_parsed(void *parsed_result,
5505 __attribute__((unused)) struct cmdline *cl,
5506 __attribute__((unused)) void *data)
5508 struct cmd_read_rxd_txd_result *res = parsed_result;
5510 if (!strcmp(res->rxd_txd, "rxd"))
5511 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5512 else if (!strcmp(res->rxd_txd, "txd"))
5513 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5516 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5517 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5518 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5519 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5521 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5522 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5523 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5524 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5525 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5526 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5528 cmdline_parse_inst_t cmd_read_rxd_txd = {
5529 .f = cmd_read_rxd_txd_parsed,
5531 .help_str = "read rxd|txd port_id queue_id rxd_id",
5533 (void *)&cmd_read_rxd_txd_read,
5534 (void *)&cmd_read_rxd_txd_rxd_txd,
5535 (void *)&cmd_read_rxd_txd_port_id,
5536 (void *)&cmd_read_rxd_txd_queue_id,
5537 (void *)&cmd_read_rxd_txd_desc_id,
5543 struct cmd_quit_result {
5544 cmdline_fixed_string_t quit;
5547 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5549 __attribute__((unused)) void *data)
5555 cmdline_parse_token_string_t cmd_quit_quit =
5556 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5558 cmdline_parse_inst_t cmd_quit = {
5559 .f = cmd_quit_parsed,
5561 .help_str = "exit application",
5563 (void *)&cmd_quit_quit,
5568 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5569 struct cmd_mac_addr_result {
5570 cmdline_fixed_string_t mac_addr_cmd;
5571 cmdline_fixed_string_t what;
5573 struct ether_addr address;
5576 static void cmd_mac_addr_parsed(void *parsed_result,
5577 __attribute__((unused)) struct cmdline *cl,
5578 __attribute__((unused)) void *data)
5580 struct cmd_mac_addr_result *res = parsed_result;
5583 if (strcmp(res->what, "add") == 0)
5584 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5586 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5588 /* check the return value and print it if is < 0 */
5590 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5594 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5595 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5597 cmdline_parse_token_string_t cmd_mac_addr_what =
5598 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5600 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5601 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5602 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5603 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5605 cmdline_parse_inst_t cmd_mac_addr = {
5606 .f = cmd_mac_addr_parsed,
5608 .help_str = "mac_addr add|remove X <address>: "
5609 "add/remove MAC address on port X",
5611 (void *)&cmd_mac_addr_cmd,
5612 (void *)&cmd_mac_addr_what,
5613 (void *)&cmd_mac_addr_portnum,
5614 (void *)&cmd_mac_addr_addr,
5620 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5621 struct cmd_set_qmap_result {
5622 cmdline_fixed_string_t set;
5623 cmdline_fixed_string_t qmap;
5624 cmdline_fixed_string_t what;
5631 cmd_set_qmap_parsed(void *parsed_result,
5632 __attribute__((unused)) struct cmdline *cl,
5633 __attribute__((unused)) void *data)
5635 struct cmd_set_qmap_result *res = parsed_result;
5636 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5638 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5641 cmdline_parse_token_string_t cmd_setqmap_set =
5642 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5644 cmdline_parse_token_string_t cmd_setqmap_qmap =
5645 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5647 cmdline_parse_token_string_t cmd_setqmap_what =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5650 cmdline_parse_token_num_t cmd_setqmap_portid =
5651 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5653 cmdline_parse_token_num_t cmd_setqmap_queueid =
5654 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5656 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5657 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5660 cmdline_parse_inst_t cmd_set_qmap = {
5661 .f = cmd_set_qmap_parsed,
5663 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5665 (void *)&cmd_setqmap_set,
5666 (void *)&cmd_setqmap_qmap,
5667 (void *)&cmd_setqmap_what,
5668 (void *)&cmd_setqmap_portid,
5669 (void *)&cmd_setqmap_queueid,
5670 (void *)&cmd_setqmap_mapvalue,
5675 /* *** CONFIGURE UNICAST HASH TABLE *** */
5676 struct cmd_set_uc_hash_table {
5677 cmdline_fixed_string_t set;
5678 cmdline_fixed_string_t port;
5680 cmdline_fixed_string_t what;
5681 struct ether_addr address;
5682 cmdline_fixed_string_t mode;
5686 cmd_set_uc_hash_parsed(void *parsed_result,
5687 __attribute__((unused)) struct cmdline *cl,
5688 __attribute__((unused)) void *data)
5691 struct cmd_set_uc_hash_table *res = parsed_result;
5693 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5695 if (strcmp(res->what, "uta") == 0)
5696 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5697 &res->address,(uint8_t)is_on);
5699 printf("bad unicast hash table parameter, return code = %d \n", ret);
5703 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5706 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5709 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5710 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5712 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5715 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5718 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5722 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5723 .f = cmd_set_uc_hash_parsed,
5725 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5727 (void *)&cmd_set_uc_hash_set,
5728 (void *)&cmd_set_uc_hash_port,
5729 (void *)&cmd_set_uc_hash_portid,
5730 (void *)&cmd_set_uc_hash_what,
5731 (void *)&cmd_set_uc_hash_mac,
5732 (void *)&cmd_set_uc_hash_mode,
5737 struct cmd_set_uc_all_hash_table {
5738 cmdline_fixed_string_t set;
5739 cmdline_fixed_string_t port;
5741 cmdline_fixed_string_t what;
5742 cmdline_fixed_string_t value;
5743 cmdline_fixed_string_t mode;
5747 cmd_set_uc_all_hash_parsed(void *parsed_result,
5748 __attribute__((unused)) struct cmdline *cl,
5749 __attribute__((unused)) void *data)
5752 struct cmd_set_uc_all_hash_table *res = parsed_result;
5754 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5756 if ((strcmp(res->what, "uta") == 0) &&
5757 (strcmp(res->value, "all") == 0))
5758 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5760 printf("bad unicast hash table parameter,"
5761 "return code = %d \n", ret);
5764 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5765 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5767 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5770 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5771 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5773 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5776 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5779 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5783 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5784 .f = cmd_set_uc_all_hash_parsed,
5786 .help_str = "set port X uta all on|off (X = port number)",
5788 (void *)&cmd_set_uc_all_hash_set,
5789 (void *)&cmd_set_uc_all_hash_port,
5790 (void *)&cmd_set_uc_all_hash_portid,
5791 (void *)&cmd_set_uc_all_hash_what,
5792 (void *)&cmd_set_uc_all_hash_value,
5793 (void *)&cmd_set_uc_all_hash_mode,
5798 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5799 struct cmd_set_vf_traffic {
5800 cmdline_fixed_string_t set;
5801 cmdline_fixed_string_t port;
5803 cmdline_fixed_string_t vf;
5805 cmdline_fixed_string_t what;
5806 cmdline_fixed_string_t mode;
5810 cmd_set_vf_traffic_parsed(void *parsed_result,
5811 __attribute__((unused)) struct cmdline *cl,
5812 __attribute__((unused)) void *data)
5814 struct cmd_set_vf_traffic *res = parsed_result;
5815 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5816 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5818 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5821 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5822 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5824 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5825 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5827 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5828 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5830 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5831 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5833 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5834 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5836 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5837 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5839 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5840 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5843 cmdline_parse_inst_t cmd_set_vf_traffic = {
5844 .f = cmd_set_vf_traffic_parsed,
5846 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5848 (void *)&cmd_setvf_traffic_set,
5849 (void *)&cmd_setvf_traffic_port,
5850 (void *)&cmd_setvf_traffic_portid,
5851 (void *)&cmd_setvf_traffic_vf,
5852 (void *)&cmd_setvf_traffic_vfid,
5853 (void *)&cmd_setvf_traffic_what,
5854 (void *)&cmd_setvf_traffic_mode,
5859 /* *** CONFIGURE VF RECEIVE MODE *** */
5860 struct cmd_set_vf_rxmode {
5861 cmdline_fixed_string_t set;
5862 cmdline_fixed_string_t port;
5864 cmdline_fixed_string_t vf;
5866 cmdline_fixed_string_t what;
5867 cmdline_fixed_string_t mode;
5868 cmdline_fixed_string_t on;
5872 cmd_set_vf_rxmode_parsed(void *parsed_result,
5873 __attribute__((unused)) struct cmdline *cl,
5874 __attribute__((unused)) void *data)
5877 uint16_t rx_mode = 0;
5878 struct cmd_set_vf_rxmode *res = parsed_result;
5880 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5881 if (!strcmp(res->what,"rxmode")) {
5882 if (!strcmp(res->mode, "AUPE"))
5883 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5884 else if (!strcmp(res->mode, "ROPE"))
5885 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5886 else if (!strcmp(res->mode, "BAM"))
5887 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5888 else if (!strncmp(res->mode, "MPE",3))
5889 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5892 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5894 printf("bad VF receive mode parameter, return code = %d \n",
5898 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5899 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5901 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5902 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5904 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5905 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5907 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5908 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5910 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5911 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5913 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5916 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5918 mode, "AUPE#ROPE#BAM#MPE");
5919 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5923 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5924 .f = cmd_set_vf_rxmode_parsed,
5926 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5928 (void *)&cmd_set_vf_rxmode_set,
5929 (void *)&cmd_set_vf_rxmode_port,
5930 (void *)&cmd_set_vf_rxmode_portid,
5931 (void *)&cmd_set_vf_rxmode_vf,
5932 (void *)&cmd_set_vf_rxmode_vfid,
5933 (void *)&cmd_set_vf_rxmode_what,
5934 (void *)&cmd_set_vf_rxmode_mode,
5935 (void *)&cmd_set_vf_rxmode_on,
5940 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5941 struct cmd_vf_mac_addr_result {
5942 cmdline_fixed_string_t mac_addr_cmd;
5943 cmdline_fixed_string_t what;
5944 cmdline_fixed_string_t port;
5946 cmdline_fixed_string_t vf;
5948 struct ether_addr address;
5951 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5952 __attribute__((unused)) struct cmdline *cl,
5953 __attribute__((unused)) void *data)
5955 struct cmd_vf_mac_addr_result *res = parsed_result;
5958 if (strcmp(res->what, "add") == 0)
5959 ret = rte_eth_dev_mac_addr_add(res->port_num,
5960 &res->address, res->vf_num);
5962 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5966 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5967 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5968 mac_addr_cmd,"mac_addr");
5969 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5970 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5972 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5973 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5975 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5976 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5978 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5979 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5981 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5982 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5984 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5985 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5988 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5989 .f = cmd_vf_mac_addr_parsed,
5991 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5992 "Y = VF number)add MAC address filtering for a VF on port X",
5994 (void *)&cmd_vf_mac_addr_cmd,
5995 (void *)&cmd_vf_mac_addr_what,
5996 (void *)&cmd_vf_mac_addr_port,
5997 (void *)&cmd_vf_mac_addr_portnum,
5998 (void *)&cmd_vf_mac_addr_vf,
5999 (void *)&cmd_vf_mac_addr_vfnum,
6000 (void *)&cmd_vf_mac_addr_addr,
6005 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6006 struct cmd_vf_rx_vlan_filter {
6007 cmdline_fixed_string_t rx_vlan;
6008 cmdline_fixed_string_t what;
6010 cmdline_fixed_string_t port;
6012 cmdline_fixed_string_t vf;
6017 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6018 __attribute__((unused)) struct cmdline *cl,
6019 __attribute__((unused)) void *data)
6021 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6023 if (!strcmp(res->what, "add"))
6024 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6026 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6029 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6030 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6031 rx_vlan, "rx_vlan");
6032 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6033 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6035 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6036 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6038 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6039 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6041 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6042 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6044 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6045 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6047 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6048 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6051 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6052 .f = cmd_vf_rx_vlan_filter_parsed,
6054 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6055 "Y = port number,Z = hexadecimal VF mask)",
6057 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6058 (void *)&cmd_vf_rx_vlan_filter_what,
6059 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6060 (void *)&cmd_vf_rx_vlan_filter_port,
6061 (void *)&cmd_vf_rx_vlan_filter_portid,
6062 (void *)&cmd_vf_rx_vlan_filter_vf,
6063 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6068 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6069 struct cmd_queue_rate_limit_result {
6070 cmdline_fixed_string_t set;
6071 cmdline_fixed_string_t port;
6073 cmdline_fixed_string_t queue;
6075 cmdline_fixed_string_t rate;
6079 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6080 __attribute__((unused)) struct cmdline *cl,
6081 __attribute__((unused)) void *data)
6083 struct cmd_queue_rate_limit_result *res = parsed_result;
6086 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6087 && (strcmp(res->queue, "queue") == 0)
6088 && (strcmp(res->rate, "rate") == 0))
6089 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6092 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6096 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6097 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6099 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6100 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6102 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6103 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6105 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6106 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6108 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6109 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6111 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6112 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6114 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6115 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6118 cmdline_parse_inst_t cmd_queue_rate_limit = {
6119 .f = cmd_queue_rate_limit_parsed,
6121 .help_str = "set port X queue Y rate Z:(X = port number,"
6122 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6124 (void *)&cmd_queue_rate_limit_set,
6125 (void *)&cmd_queue_rate_limit_port,
6126 (void *)&cmd_queue_rate_limit_portnum,
6127 (void *)&cmd_queue_rate_limit_queue,
6128 (void *)&cmd_queue_rate_limit_queuenum,
6129 (void *)&cmd_queue_rate_limit_rate,
6130 (void *)&cmd_queue_rate_limit_ratenum,
6135 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6136 struct cmd_vf_rate_limit_result {
6137 cmdline_fixed_string_t set;
6138 cmdline_fixed_string_t port;
6140 cmdline_fixed_string_t vf;
6142 cmdline_fixed_string_t rate;
6144 cmdline_fixed_string_t q_msk;
6148 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6149 __attribute__((unused)) struct cmdline *cl,
6150 __attribute__((unused)) void *data)
6152 struct cmd_vf_rate_limit_result *res = parsed_result;
6155 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6156 && (strcmp(res->vf, "vf") == 0)
6157 && (strcmp(res->rate, "rate") == 0)
6158 && (strcmp(res->q_msk, "queue_mask") == 0))
6159 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6160 res->rate_num, res->q_msk_val);
6162 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6166 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6167 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6169 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6170 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6172 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6173 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6175 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6176 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6178 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6179 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6181 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6182 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6184 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6185 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6187 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6188 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6189 q_msk, "queue_mask");
6190 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6191 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6194 cmdline_parse_inst_t cmd_vf_rate_limit = {
6195 .f = cmd_vf_rate_limit_parsed,
6197 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6198 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6199 "for queues of VF on port X",
6201 (void *)&cmd_vf_rate_limit_set,
6202 (void *)&cmd_vf_rate_limit_port,
6203 (void *)&cmd_vf_rate_limit_portnum,
6204 (void *)&cmd_vf_rate_limit_vf,
6205 (void *)&cmd_vf_rate_limit_vfnum,
6206 (void *)&cmd_vf_rate_limit_rate,
6207 (void *)&cmd_vf_rate_limit_ratenum,
6208 (void *)&cmd_vf_rate_limit_q_msk,
6209 (void *)&cmd_vf_rate_limit_q_msk_val,
6214 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6215 struct cmd_set_mirror_mask_result {
6216 cmdline_fixed_string_t set;
6217 cmdline_fixed_string_t port;
6219 cmdline_fixed_string_t mirror;
6221 cmdline_fixed_string_t what;
6222 cmdline_fixed_string_t value;
6223 cmdline_fixed_string_t dstpool;
6225 cmdline_fixed_string_t on;
6228 cmdline_parse_token_string_t cmd_mirror_mask_set =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6231 cmdline_parse_token_string_t cmd_mirror_mask_port =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6234 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6235 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6237 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6238 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6239 mirror, "mirror-rule");
6240 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6241 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6243 cmdline_parse_token_string_t cmd_mirror_mask_what =
6244 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6245 what, "pool-mirror#vlan-mirror");
6246 cmdline_parse_token_string_t cmd_mirror_mask_value =
6247 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6249 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6250 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6251 dstpool, "dst-pool");
6252 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6253 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6255 cmdline_parse_token_string_t cmd_mirror_mask_on =
6256 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6260 cmd_set_mirror_mask_parsed(void *parsed_result,
6261 __attribute__((unused)) struct cmdline *cl,
6262 __attribute__((unused)) void *data)
6265 struct cmd_set_mirror_mask_result *res = parsed_result;
6266 struct rte_eth_vmdq_mirror_conf mr_conf;
6268 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6270 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6272 mr_conf.dst_pool = res->dstpool_id;
6274 if (!strcmp(res->what, "pool-mirror")) {
6275 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6276 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6277 } else if(!strcmp(res->what, "vlan-mirror")) {
6278 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6279 nb_item = parse_item_list(res->value, "core",
6280 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6284 for(i=0; i < nb_item; i++) {
6285 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6286 printf("Invalid vlan_id: must be < 4096\n");
6290 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6291 mr_conf.vlan.vlan_mask |= 1ULL << i;
6295 if(!strcmp(res->on, "on"))
6296 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6299 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6302 printf("mirror rule add error: (%s)\n", strerror(-ret));
6305 cmdline_parse_inst_t cmd_set_mirror_mask = {
6306 .f = cmd_set_mirror_mask_parsed,
6308 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6309 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6311 (void *)&cmd_mirror_mask_set,
6312 (void *)&cmd_mirror_mask_port,
6313 (void *)&cmd_mirror_mask_portid,
6314 (void *)&cmd_mirror_mask_mirror,
6315 (void *)&cmd_mirror_mask_ruleid,
6316 (void *)&cmd_mirror_mask_what,
6317 (void *)&cmd_mirror_mask_value,
6318 (void *)&cmd_mirror_mask_dstpool,
6319 (void *)&cmd_mirror_mask_poolid,
6320 (void *)&cmd_mirror_mask_on,
6325 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6326 struct cmd_set_mirror_link_result {
6327 cmdline_fixed_string_t set;
6328 cmdline_fixed_string_t port;
6330 cmdline_fixed_string_t mirror;
6332 cmdline_fixed_string_t what;
6333 cmdline_fixed_string_t dstpool;
6335 cmdline_fixed_string_t on;
6338 cmdline_parse_token_string_t cmd_mirror_link_set =
6339 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6341 cmdline_parse_token_string_t cmd_mirror_link_port =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6344 cmdline_parse_token_num_t cmd_mirror_link_portid =
6345 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6347 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6348 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6349 mirror, "mirror-rule");
6350 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6351 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6353 cmdline_parse_token_string_t cmd_mirror_link_what =
6354 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6355 what, "uplink-mirror#downlink-mirror");
6356 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6357 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6358 dstpool, "dst-pool");
6359 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6360 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6362 cmdline_parse_token_string_t cmd_mirror_link_on =
6363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6367 cmd_set_mirror_link_parsed(void *parsed_result,
6368 __attribute__((unused)) struct cmdline *cl,
6369 __attribute__((unused)) void *data)
6372 struct cmd_set_mirror_link_result *res = parsed_result;
6373 struct rte_eth_vmdq_mirror_conf mr_conf;
6375 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6376 if(!strcmp(res->what, "uplink-mirror")) {
6377 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6378 }else if(!strcmp(res->what, "downlink-mirror"))
6379 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6381 mr_conf.dst_pool = res->dstpool_id;
6383 if(!strcmp(res->on, "on"))
6384 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6387 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6390 /* check the return value and print it if is < 0 */
6392 printf("mirror rule add error: (%s)\n", strerror(-ret));
6396 cmdline_parse_inst_t cmd_set_mirror_link = {
6397 .f = cmd_set_mirror_link_parsed,
6399 .help_str = "set port X mirror-rule Y uplink-mirror|"
6400 "downlink-mirror dst-pool Z on|off",
6402 (void *)&cmd_mirror_link_set,
6403 (void *)&cmd_mirror_link_port,
6404 (void *)&cmd_mirror_link_portid,
6405 (void *)&cmd_mirror_link_mirror,
6406 (void *)&cmd_mirror_link_ruleid,
6407 (void *)&cmd_mirror_link_what,
6408 (void *)&cmd_mirror_link_dstpool,
6409 (void *)&cmd_mirror_link_poolid,
6410 (void *)&cmd_mirror_link_on,
6415 /* *** RESET VM MIRROR RULE *** */
6416 struct cmd_rm_mirror_rule_result {
6417 cmdline_fixed_string_t reset;
6418 cmdline_fixed_string_t port;
6420 cmdline_fixed_string_t mirror;
6424 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6425 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6427 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6428 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6430 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6431 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6433 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6434 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6435 mirror, "mirror-rule");
6436 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6437 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6441 cmd_reset_mirror_rule_parsed(void *parsed_result,
6442 __attribute__((unused)) struct cmdline *cl,
6443 __attribute__((unused)) void *data)
6446 struct cmd_set_mirror_link_result *res = parsed_result;
6448 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6450 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6453 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6454 .f = cmd_reset_mirror_rule_parsed,
6456 .help_str = "reset port X mirror-rule Y",
6458 (void *)&cmd_rm_mirror_rule_reset,
6459 (void *)&cmd_rm_mirror_rule_port,
6460 (void *)&cmd_rm_mirror_rule_portid,
6461 (void *)&cmd_rm_mirror_rule_mirror,
6462 (void *)&cmd_rm_mirror_rule_ruleid,
6467 /* ******************************************************************************** */
6469 struct cmd_dump_result {
6470 cmdline_fixed_string_t dump;
6474 dump_struct_sizes(void)
6476 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6477 DUMP_SIZE(struct rte_mbuf);
6478 DUMP_SIZE(struct rte_mempool);
6479 DUMP_SIZE(struct rte_ring);
6483 static void cmd_dump_parsed(void *parsed_result,
6484 __attribute__((unused)) struct cmdline *cl,
6485 __attribute__((unused)) void *data)
6487 struct cmd_dump_result *res = parsed_result;
6489 if (!strcmp(res->dump, "dump_physmem"))
6490 rte_dump_physmem_layout(stdout);
6491 else if (!strcmp(res->dump, "dump_memzone"))
6492 rte_memzone_dump(stdout);
6493 else if (!strcmp(res->dump, "dump_log_history"))
6494 rte_log_dump_history(stdout);
6495 else if (!strcmp(res->dump, "dump_struct_sizes"))
6496 dump_struct_sizes();
6497 else if (!strcmp(res->dump, "dump_ring"))
6498 rte_ring_list_dump(stdout);
6499 else if (!strcmp(res->dump, "dump_mempool"))
6500 rte_mempool_list_dump(stdout);
6501 else if (!strcmp(res->dump, "dump_devargs"))
6502 rte_eal_devargs_dump(stdout);
6505 cmdline_parse_token_string_t cmd_dump_dump =
6506 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6510 "dump_struct_sizes#"
6515 cmdline_parse_inst_t cmd_dump = {
6516 .f = cmd_dump_parsed, /* function to call */
6517 .data = NULL, /* 2nd arg of func */
6518 .help_str = "dump status",
6519 .tokens = { /* token list, NULL terminated */
6520 (void *)&cmd_dump_dump,
6525 /* ******************************************************************************** */
6527 struct cmd_dump_one_result {
6528 cmdline_fixed_string_t dump;
6529 cmdline_fixed_string_t name;
6532 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6533 __attribute__((unused)) void *data)
6535 struct cmd_dump_one_result *res = parsed_result;
6537 if (!strcmp(res->dump, "dump_ring")) {
6539 r = rte_ring_lookup(res->name);
6541 cmdline_printf(cl, "Cannot find ring\n");
6544 rte_ring_dump(stdout, r);
6545 } else if (!strcmp(res->dump, "dump_mempool")) {
6546 struct rte_mempool *mp;
6547 mp = rte_mempool_lookup(res->name);
6549 cmdline_printf(cl, "Cannot find mempool\n");
6552 rte_mempool_dump(stdout, mp);
6556 cmdline_parse_token_string_t cmd_dump_one_dump =
6557 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6558 "dump_ring#dump_mempool");
6560 cmdline_parse_token_string_t cmd_dump_one_name =
6561 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6563 cmdline_parse_inst_t cmd_dump_one = {
6564 .f = cmd_dump_one_parsed, /* function to call */
6565 .data = NULL, /* 2nd arg of func */
6566 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6567 .tokens = { /* token list, NULL terminated */
6568 (void *)&cmd_dump_one_dump,
6569 (void *)&cmd_dump_one_name,
6574 /* *** ADD/REMOVE an ethertype FILTER *** */
6575 struct cmd_ethertype_filter_result {
6576 cmdline_fixed_string_t filter;
6578 cmdline_fixed_string_t ethertype;
6579 uint16_t ethertype_value;
6580 cmdline_fixed_string_t priority;
6581 cmdline_fixed_string_t priority_en;
6582 uint8_t priority_value;
6583 cmdline_fixed_string_t queue;
6585 cmdline_fixed_string_t index;
6586 uint16_t index_value;
6590 cmd_ethertype_filter_parsed(void *parsed_result,
6591 __attribute__((unused)) struct cmdline *cl,
6592 __attribute__((unused)) void *data)
6595 struct cmd_ethertype_filter_result *res = parsed_result;
6596 struct rte_ethertype_filter filter;
6598 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6599 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6600 filter.priority = res->priority_value;
6602 if (!strcmp(res->priority_en, "enable"))
6603 filter.priority_en = 1;
6604 if (!strcmp(res->filter, "add_ethertype_filter"))
6605 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6607 &filter, res->queue_id);
6608 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6609 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6611 else if (!strcmp(res->filter, "get_ethertype_filter"))
6612 get_ethertype_filter(res->port_id, res->index_value);
6615 printf("ethertype filter setting error: (%s)\n",
6619 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6620 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6622 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6623 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6624 ethertype, "ethertype");
6625 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6626 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6627 ethertype_value, UINT16);
6628 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6629 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6630 priority, "priority");
6631 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6632 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6633 priority_en, "enable#disable");
6634 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6635 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6636 priority_value, UINT8);
6637 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6638 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6640 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6641 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6643 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6644 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6646 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6647 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6648 index_value, UINT16);
6649 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6650 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6651 filter, "add_ethertype_filter");
6652 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6653 .f = cmd_ethertype_filter_parsed,
6655 .help_str = "add an ethertype filter",
6657 (void *)&cmd_ethertype_filter_add_filter,
6658 (void *)&cmd_ethertype_filter_port_id,
6659 (void *)&cmd_ethertype_filter_ethertype,
6660 (void *)&cmd_ethertype_filter_ethertype_value,
6661 (void *)&cmd_ethertype_filter_priority,
6662 (void *)&cmd_ethertype_filter_priority_en,
6663 (void *)&cmd_ethertype_filter_priority_value,
6664 (void *)&cmd_ethertype_filter_queue,
6665 (void *)&cmd_ethertype_filter_queue_id,
6666 (void *)&cmd_ethertype_filter_index,
6667 (void *)&cmd_ethertype_filter_index_value,
6672 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6673 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6674 filter, "remove_ethertype_filter");
6675 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6676 .f = cmd_ethertype_filter_parsed,
6678 .help_str = "remove an ethertype filter",
6680 (void *)&cmd_ethertype_filter_remove_filter,
6681 (void *)&cmd_ethertype_filter_port_id,
6682 (void *)&cmd_ethertype_filter_index,
6683 (void *)&cmd_ethertype_filter_index_value,
6687 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6688 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6689 filter, "get_ethertype_filter");
6690 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6691 .f = cmd_ethertype_filter_parsed,
6693 .help_str = "get an ethertype filter",
6695 (void *)&cmd_ethertype_filter_get_filter,
6696 (void *)&cmd_ethertype_filter_port_id,
6697 (void *)&cmd_ethertype_filter_index,
6698 (void *)&cmd_ethertype_filter_index_value,
6703 /* *** set SYN filter *** */
6704 struct cmd_set_syn_filter_result {
6705 cmdline_fixed_string_t filter;
6707 cmdline_fixed_string_t priority;
6708 cmdline_fixed_string_t high;
6709 cmdline_fixed_string_t queue;
6714 cmd_set_syn_filter_parsed(void *parsed_result,
6715 __attribute__((unused)) struct cmdline *cl,
6716 __attribute__((unused)) void *data)
6719 struct cmd_set_syn_filter_result *res = parsed_result;
6720 struct rte_syn_filter filter;
6722 if (!strcmp(res->filter, "add_syn_filter")) {
6723 if (!strcmp(res->high, "high"))
6727 ret = rte_eth_dev_add_syn_filter(res->port_id,
6728 &filter, res->queue_id);
6729 } else if (!strcmp(res->filter, "remove_syn_filter"))
6730 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6731 else if (!strcmp(res->filter, "get_syn_filter"))
6732 get_syn_filter(res->port_id);
6734 printf("syn filter setting error: (%s)\n", strerror(-ret));
6737 cmdline_parse_token_num_t cmd_syn_filter_portid =
6738 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6740 cmdline_parse_token_string_t cmd_syn_filter_priority =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6742 priority, "priority");
6743 cmdline_parse_token_string_t cmd_syn_filter_high =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6746 cmdline_parse_token_string_t cmd_syn_filter_queue =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6749 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6750 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6752 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6754 filter, "add_syn_filter");
6755 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6756 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6757 filter, "remove_syn_filter");
6758 cmdline_parse_inst_t cmd_add_syn_filter = {
6759 .f = cmd_set_syn_filter_parsed,
6761 .help_str = "add syn filter",
6763 (void *)&cmd_syn_filter_add_filter,
6764 (void *)&cmd_syn_filter_portid,
6765 (void *)&cmd_syn_filter_priority,
6766 (void *)&cmd_syn_filter_high,
6767 (void *)&cmd_syn_filter_queue,
6768 (void *)&cmd_syn_filter_queue_id,
6772 cmdline_parse_inst_t cmd_remove_syn_filter = {
6773 .f = cmd_set_syn_filter_parsed,
6775 .help_str = "remove syn filter",
6777 (void *)&cmd_syn_filter_remove_filter,
6778 (void *)&cmd_syn_filter_portid,
6783 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6784 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6785 filter, "get_syn_filter");
6787 cmdline_parse_inst_t cmd_get_syn_filter = {
6788 .f = cmd_set_syn_filter_parsed,
6790 .help_str = "get syn filter",
6792 (void *)&cmd_syn_filter_get_filter,
6793 (void *)&cmd_syn_filter_portid,
6798 /* *** ADD/REMOVE A 2tuple FILTER *** */
6799 struct cmd_2tuple_filter_result {
6800 cmdline_fixed_string_t filter;
6802 cmdline_fixed_string_t protocol;
6803 uint8_t protocol_value;
6804 uint8_t protocol_mask;
6805 cmdline_fixed_string_t dst_port;
6806 uint16_t dst_port_value;
6807 uint16_t dst_port_mask;
6808 cmdline_fixed_string_t flags;
6809 uint8_t flags_value;
6810 cmdline_fixed_string_t priority;
6811 uint8_t priority_value;
6812 cmdline_fixed_string_t queue;
6814 cmdline_fixed_string_t index;
6815 uint16_t index_value;
6819 cmd_2tuple_filter_parsed(void *parsed_result,
6820 __attribute__((unused)) struct cmdline *cl,
6821 __attribute__((unused)) void *data)
6824 struct rte_2tuple_filter filter;
6825 struct cmd_2tuple_filter_result *res = parsed_result;
6827 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6829 if (!strcmp(res->filter, "add_2tuple_filter")) {
6830 /* need convert to big endian. */
6831 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6832 filter.protocol = res->protocol_value;
6833 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6834 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6835 filter.priority = res->priority_value;
6836 filter.tcp_flags = res->flags_value;
6837 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6838 res->index_value, &filter, res->queue_id);
6839 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6840 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6842 else if (!strcmp(res->filter, "get_2tuple_filter"))
6843 get_2tuple_filter(res->port_id, res->index_value);
6846 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6849 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6850 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6852 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6853 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6854 protocol, "protocol");
6855 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6856 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6857 protocol_value, UINT8);
6858 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6859 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6860 protocol_mask, UINT8);
6861 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6862 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6863 dst_port, "dst_port");
6864 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6865 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6866 dst_port_value, UINT16);
6867 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6868 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6869 dst_port_mask, UINT16);
6870 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6871 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6873 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6874 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6875 flags_value, UINT8);
6876 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6877 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6878 priority, "priority");
6879 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6880 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6881 priority_value, UINT8);
6882 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6883 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6885 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6886 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6888 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6889 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6891 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6892 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6893 index_value, UINT16);
6894 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6895 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6896 filter, "add_2tuple_filter");
6897 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6898 .f = cmd_2tuple_filter_parsed,
6900 .help_str = "add a 2tuple filter",
6902 (void *)&cmd_2tuple_filter_add_filter,
6903 (void *)&cmd_2tuple_filter_port_id,
6904 (void *)&cmd_2tuple_filter_protocol,
6905 (void *)&cmd_2tuple_filter_protocol_value,
6906 (void *)&cmd_2tuple_filter_protocol_mask,
6907 (void *)&cmd_2tuple_filter_dst_port,
6908 (void *)&cmd_2tuple_filter_dst_port_value,
6909 (void *)&cmd_2tuple_filter_dst_port_mask,
6910 (void *)&cmd_2tuple_filter_flags,
6911 (void *)&cmd_2tuple_filter_flags_value,
6912 (void *)&cmd_2tuple_filter_priority,
6913 (void *)&cmd_2tuple_filter_priority_value,
6914 (void *)&cmd_2tuple_filter_queue,
6915 (void *)&cmd_2tuple_filter_queue_id,
6916 (void *)&cmd_2tuple_filter_index,
6917 (void *)&cmd_2tuple_filter_index_value,
6922 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6923 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6924 filter, "remove_2tuple_filter");
6925 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6926 .f = cmd_2tuple_filter_parsed,
6928 .help_str = "remove a 2tuple filter",
6930 (void *)&cmd_2tuple_filter_remove_filter,
6931 (void *)&cmd_2tuple_filter_port_id,
6932 (void *)&cmd_2tuple_filter_index,
6933 (void *)&cmd_2tuple_filter_index_value,
6937 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6938 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6939 filter, "get_2tuple_filter");
6940 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6941 .f = cmd_2tuple_filter_parsed,
6943 .help_str = "get a 2tuple filter",
6945 (void *)&cmd_2tuple_filter_get_filter,
6946 (void *)&cmd_2tuple_filter_port_id,
6947 (void *)&cmd_2tuple_filter_index,
6948 (void *)&cmd_2tuple_filter_index_value,
6953 /* *** ADD/REMOVE A 5tuple FILTER *** */
6954 struct cmd_5tuple_filter_result {
6955 cmdline_fixed_string_t filter;
6957 cmdline_fixed_string_t dst_ip;
6958 cmdline_ipaddr_t dst_ip_value;
6959 cmdline_fixed_string_t src_ip;
6960 cmdline_ipaddr_t src_ip_value;
6961 cmdline_fixed_string_t dst_port;
6962 uint16_t dst_port_value;
6963 cmdline_fixed_string_t src_port;
6964 uint16_t src_port_value;
6965 cmdline_fixed_string_t protocol;
6966 uint8_t protocol_value;
6967 cmdline_fixed_string_t mask;
6969 cmdline_fixed_string_t flags;
6970 uint8_t flags_value;
6971 cmdline_fixed_string_t priority;
6972 uint8_t priority_value;
6973 cmdline_fixed_string_t queue;
6975 cmdline_fixed_string_t index;
6976 uint16_t index_value;
6980 cmd_5tuple_filter_parsed(void *parsed_result,
6981 __attribute__((unused)) struct cmdline *cl,
6982 __attribute__((unused)) void *data)
6985 struct rte_5tuple_filter filter;
6986 struct cmd_5tuple_filter_result *res = parsed_result;
6988 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6990 if (!strcmp(res->filter, "add_5tuple_filter")) {
6991 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6992 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6993 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6994 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6995 filter.protocol = res->protocol_value;
6996 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6997 filter.priority = res->priority_value;
6998 filter.tcp_flags = res->flags_value;
7000 if (res->dst_ip_value.family == AF_INET)
7001 /* no need to convert, already big endian. */
7002 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7004 if (filter.dst_ip_mask == 0) {
7005 printf("can not support ipv6 involved compare.\n");
7011 if (res->src_ip_value.family == AF_INET)
7012 /* no need to convert, already big endian. */
7013 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7015 if (filter.src_ip_mask == 0) {
7016 printf("can not support ipv6 involved compare.\n");
7021 /* need convert to big endian. */
7022 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7023 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7025 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7026 res->index_value, &filter, res->queue_id);
7027 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7028 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7030 else if (!strcmp(res->filter, "get_5tuple_filter"))
7031 get_5tuple_filter(res->port_id, res->index_value);
7033 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7037 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7038 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7040 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7041 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7043 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7044 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7046 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7047 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7049 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7050 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7052 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7053 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7054 dst_port, "dst_port");
7055 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7056 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7057 dst_port_value, UINT16);
7058 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7059 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7060 src_port, "src_port");
7061 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7062 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7063 src_port_value, UINT16);
7064 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7065 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7066 protocol, "protocol");
7067 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7068 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7069 protocol_value, UINT8);
7070 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7071 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7073 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7074 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7076 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7077 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7079 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7080 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7081 flags_value, UINT8);
7082 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7083 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7084 priority, "priority");
7085 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7086 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7087 priority_value, UINT8);
7088 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7089 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7091 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7092 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7094 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7095 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7097 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7098 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7099 index_value, UINT16);
7101 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7103 filter, "add_5tuple_filter");
7104 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7105 .f = cmd_5tuple_filter_parsed,
7107 .help_str = "add a 5tuple filter",
7109 (void *)&cmd_5tuple_filter_add_filter,
7110 (void *)&cmd_5tuple_filter_port_id,
7111 (void *)&cmd_5tuple_filter_dst_ip,
7112 (void *)&cmd_5tuple_filter_dst_ip_value,
7113 (void *)&cmd_5tuple_filter_src_ip,
7114 (void *)&cmd_5tuple_filter_src_ip_value,
7115 (void *)&cmd_5tuple_filter_dst_port,
7116 (void *)&cmd_5tuple_filter_dst_port_value,
7117 (void *)&cmd_5tuple_filter_src_port,
7118 (void *)&cmd_5tuple_filter_src_port_value,
7119 (void *)&cmd_5tuple_filter_protocol,
7120 (void *)&cmd_5tuple_filter_protocol_value,
7121 (void *)&cmd_5tuple_filter_mask,
7122 (void *)&cmd_5tuple_filter_mask_value,
7123 (void *)&cmd_5tuple_filter_flags,
7124 (void *)&cmd_5tuple_filter_flags_value,
7125 (void *)&cmd_5tuple_filter_priority,
7126 (void *)&cmd_5tuple_filter_priority_value,
7127 (void *)&cmd_5tuple_filter_queue,
7128 (void *)&cmd_5tuple_filter_queue_id,
7129 (void *)&cmd_5tuple_filter_index,
7130 (void *)&cmd_5tuple_filter_index_value,
7135 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7136 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7137 filter, "remove_5tuple_filter");
7138 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7139 .f = cmd_5tuple_filter_parsed,
7141 .help_str = "remove a 5tuple filter",
7143 (void *)&cmd_5tuple_filter_remove_filter,
7144 (void *)&cmd_5tuple_filter_port_id,
7145 (void *)&cmd_5tuple_filter_index,
7146 (void *)&cmd_5tuple_filter_index_value,
7151 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7152 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7153 filter, "get_5tuple_filter");
7154 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7155 .f = cmd_5tuple_filter_parsed,
7157 .help_str = "get a 5tuple filter",
7159 (void *)&cmd_5tuple_filter_get_filter,
7160 (void *)&cmd_5tuple_filter_port_id,
7161 (void *)&cmd_5tuple_filter_index,
7162 (void *)&cmd_5tuple_filter_index_value,
7167 /* *** ADD/REMOVE A flex FILTER *** */
7168 struct cmd_flex_filter_result {
7169 cmdline_fixed_string_t filter;
7171 cmdline_fixed_string_t len;
7173 cmdline_fixed_string_t bytes;
7174 cmdline_fixed_string_t bytes_value;
7175 cmdline_fixed_string_t mask;
7176 cmdline_fixed_string_t mask_value;
7177 cmdline_fixed_string_t priority;
7178 uint8_t priority_value;
7179 cmdline_fixed_string_t queue;
7181 cmdline_fixed_string_t index;
7182 uint16_t index_value;
7185 static int xdigit2val(unsigned char c)
7190 else if (isupper(c))
7198 cmd_flex_filter_parsed(void *parsed_result,
7199 __attribute__((unused)) struct cmdline *cl,
7200 __attribute__((unused)) void *data)
7203 struct rte_flex_filter filter;
7204 struct cmd_flex_filter_result *res = parsed_result;
7205 char *bytes_ptr, *mask_ptr;
7213 if (!strcmp(res->filter, "add_flex_filter")) {
7214 if (res->len_value > 128) {
7215 printf("the len exceed the max length 128\n");
7218 memset(&filter, 0, sizeof(struct rte_flex_filter));
7219 filter.len = res->len_value;
7220 filter.priority = res->priority_value;
7221 bytes_ptr = res->bytes_value;
7222 mask_ptr = res->mask_value;
7225 /* translate bytes string to uint_32 array. */
7226 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7227 (bytes_ptr[1] == 'X')))
7229 len = strnlen(bytes_ptr, res->len_value * 2);
7230 if (len == 0 || (len % 8 != 0)) {
7231 printf("please check len and bytes input\n");
7234 for (i = 0; i < len; i++) {
7236 if (isxdigit(c) == 0) {
7237 /* invalid characters. */
7238 printf("invalid input\n");
7241 val = xdigit2val(c);
7245 dword |= byte << (4 * mod - 4);
7250 filter.dwords[j] = dword;
7251 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7257 /* translate mask string to uint8_t array. */
7259 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7260 (mask_ptr[1] == 'X')))
7262 len = strnlen(mask_ptr, (res->len_value+3)/4);
7264 printf("invalid input\n");
7267 for (i = 0; i < len; i++) {
7269 if (isxdigit(c) == 0) {
7270 /* invalid characters. */
7271 printf("invalid input\n");
7274 val = xdigit2val(c);
7275 hex |= (uint8_t)(val & 0x8) >> 3;
7276 hex |= (uint8_t)(val & 0x4) >> 1;
7277 hex |= (uint8_t)(val & 0x2) << 1;
7278 hex |= (uint8_t)(val & 0x1) << 3;
7281 filter.mask[j] = byte;
7282 printf("mask[%d]:%02x ", j, filter.mask[j]);
7290 printf("call function rte_eth_dev_add_flex_filter: "
7291 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7292 res->index_value, res->queue_id,
7293 filter.len, filter.priority);
7294 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7295 &filter, res->queue_id);
7297 } else if (!strcmp(res->filter, "remove_flex_filter"))
7298 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7300 else if (!strcmp(res->filter, "get_flex_filter"))
7301 get_flex_filter(res->port_id, res->index_value);
7304 printf("flex filter setting error: (%s)\n", strerror(-ret));
7307 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7308 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7310 cmdline_parse_token_string_t cmd_flex_filter_len =
7311 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7313 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7314 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7316 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7317 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7319 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7320 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7322 cmdline_parse_token_string_t cmd_flex_filter_mask =
7323 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7325 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7326 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7328 cmdline_parse_token_string_t cmd_flex_filter_priority =
7329 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7330 priority, "priority");
7331 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7332 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7333 priority_value, UINT8);
7334 cmdline_parse_token_string_t cmd_flex_filter_queue =
7335 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7337 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7338 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7340 cmdline_parse_token_string_t cmd_flex_filter_index =
7341 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7343 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7344 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7345 index_value, UINT16);
7346 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7347 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7348 filter, "add_flex_filter");
7349 cmdline_parse_inst_t cmd_add_flex_filter = {
7350 .f = cmd_flex_filter_parsed,
7352 .help_str = "add a flex filter",
7354 (void *)&cmd_flex_filter_add_filter,
7355 (void *)&cmd_flex_filter_port_id,
7356 (void *)&cmd_flex_filter_len,
7357 (void *)&cmd_flex_filter_len_value,
7358 (void *)&cmd_flex_filter_bytes,
7359 (void *)&cmd_flex_filter_bytes_value,
7360 (void *)&cmd_flex_filter_mask,
7361 (void *)&cmd_flex_filter_mask_value,
7362 (void *)&cmd_flex_filter_priority,
7363 (void *)&cmd_flex_filter_priority_value,
7364 (void *)&cmd_flex_filter_queue,
7365 (void *)&cmd_flex_filter_queue_id,
7366 (void *)&cmd_flex_filter_index,
7367 (void *)&cmd_flex_filter_index_value,
7372 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7373 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7374 filter, "remove_flex_filter");
7375 cmdline_parse_inst_t cmd_remove_flex_filter = {
7376 .f = cmd_flex_filter_parsed,
7378 .help_str = "remove a flex filter",
7380 (void *)&cmd_flex_filter_remove_filter,
7381 (void *)&cmd_flex_filter_port_id,
7382 (void *)&cmd_flex_filter_index,
7383 (void *)&cmd_flex_filter_index_value,
7388 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7389 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7390 filter, "get_flex_filter");
7391 cmdline_parse_inst_t cmd_get_flex_filter = {
7392 .f = cmd_flex_filter_parsed,
7394 .help_str = "get a flex filter",
7396 (void *)&cmd_flex_filter_get_filter,
7397 (void *)&cmd_flex_filter_port_id,
7398 (void *)&cmd_flex_filter_index,
7399 (void *)&cmd_flex_filter_index_value,
7404 /* ******************************************************************************** */
7406 /* list of instructions */
7407 cmdline_parse_ctx_t main_ctx[] = {
7408 (cmdline_parse_inst_t *)&cmd_help_brief,
7409 (cmdline_parse_inst_t *)&cmd_help_long,
7410 (cmdline_parse_inst_t *)&cmd_quit,
7411 (cmdline_parse_inst_t *)&cmd_showport,
7412 (cmdline_parse_inst_t *)&cmd_showportall,
7413 (cmdline_parse_inst_t *)&cmd_showcfg,
7414 (cmdline_parse_inst_t *)&cmd_start,
7415 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7416 (cmdline_parse_inst_t *)&cmd_set_link_up,
7417 (cmdline_parse_inst_t *)&cmd_set_link_down,
7418 (cmdline_parse_inst_t *)&cmd_reset,
7419 (cmdline_parse_inst_t *)&cmd_set_numbers,
7420 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7421 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7422 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7423 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7424 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7425 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7426 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7427 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7428 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7429 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7430 (cmdline_parse_inst_t *)&cmd_set_link_check,
7431 #ifdef RTE_NIC_BYPASS
7432 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7433 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7434 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7435 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7437 #ifdef RTE_LIBRTE_PMD_BOND
7438 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7439 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7440 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7441 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7442 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7443 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7444 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7445 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7447 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7448 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7449 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7450 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7451 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7452 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7453 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7454 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7455 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7456 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7457 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7458 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7459 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7460 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7461 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7462 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7463 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7464 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7465 (cmdline_parse_inst_t *)&cmd_config_dcb,
7466 (cmdline_parse_inst_t *)&cmd_read_reg,
7467 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7468 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7469 (cmdline_parse_inst_t *)&cmd_write_reg,
7470 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7471 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7472 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7473 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7474 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7475 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7476 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7477 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7478 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7479 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7480 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7481 (cmdline_parse_inst_t *)&cmd_stop,
7482 (cmdline_parse_inst_t *)&cmd_mac_addr,
7483 (cmdline_parse_inst_t *)&cmd_set_qmap,
7484 (cmdline_parse_inst_t *)&cmd_operate_port,
7485 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7486 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7487 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7488 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7489 (cmdline_parse_inst_t *)&cmd_config_mtu,
7490 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7491 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7492 (cmdline_parse_inst_t *)&cmd_config_rss,
7493 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7494 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7495 (cmdline_parse_inst_t *)&cmd_showport_reta,
7496 (cmdline_parse_inst_t *)&cmd_config_burst,
7497 (cmdline_parse_inst_t *)&cmd_config_thresh,
7498 (cmdline_parse_inst_t *)&cmd_config_threshold,
7499 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7500 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7501 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7502 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7503 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7504 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7505 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7506 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7507 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7508 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7509 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7510 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7511 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7512 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7513 (cmdline_parse_inst_t *)&cmd_dump,
7514 (cmdline_parse_inst_t *)&cmd_dump_one,
7515 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7516 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7517 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7518 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7519 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7520 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7521 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7522 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7523 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7524 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7525 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7526 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7527 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7528 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7529 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7533 /* prompt function, called from main on MASTER lcore */
7539 /* initialize non-constant commands */
7540 cmd_set_fwd_mode_init();
7542 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7546 cmdline_interact(cl);
7547 cmdline_stdin_exit(cl);
7551 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7553 if (id < nb_ports) {
7554 /* check if need_reconfig has been set to 1 */
7555 if (ports[id].need_reconfig == 0)
7556 ports[id].need_reconfig = dev;
7557 /* check if need_reconfig_queues has been set to 1 */
7558 if (ports[id].need_reconfig_queues == 0)
7559 ports[id].need_reconfig_queues = queue;
7563 for (pid = 0; pid < nb_ports; pid++) {
7564 /* check if need_reconfig has been set to 1 */
7565 if (ports[pid].need_reconfig == 0)
7566 ports[pid].need_reconfig = dev;
7567 /* check if need_reconfig_queues has been set to 1 */
7568 if (ports[pid].need_reconfig_queues == 0)
7569 ports[pid].need_reconfig_queues = queue;
7574 #ifdef RTE_NIC_BYPASS
7576 bypass_is_supported(portid_t port_id)
7578 struct rte_port *port;
7579 struct rte_pci_id *pci_id;
7581 if (port_id >= nb_ports) {
7582 printf("\tPort id must be less than %d.\n", nb_ports);
7586 /* Get the device id. */
7587 port = &ports[port_id];
7588 pci_id = &port->dev_info.pci_dev->id;
7590 /* Check if NIC supports bypass. */
7591 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7595 printf("\tBypass not supported for port_id = %d.\n", port_id);