4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_launch.h>
63 #include <rte_tailq.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
78 #include <cmdline_rdline.h>
79 #include <cmdline_parse.h>
80 #include <cmdline_parse_num.h>
81 #include <cmdline_parse_string.h>
82 #include <cmdline_parse_ipaddr.h>
83 #include <cmdline_parse_etheraddr.h>
84 #include <cmdline_socket.h>
86 #include <rte_pci_dev_ids.h>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
96 uint8_t bypass_is_supported(portid_t port_id);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help flowdir : Flow Director filter help.\n"
118 " help registers : Reading and setting port registers.\n"
119 " help filters : Filters configuration help.\n"
120 " help all : All of the above sections.\n\n"
125 cmdline_parse_token_string_t cmd_help_brief_help =
126 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
128 cmdline_parse_inst_t cmd_help_brief = {
129 .f = cmd_help_brief_parsed,
131 .help_str = "show help",
133 (void *)&cmd_help_brief_help,
138 /* *** Help command with help sections. *** */
139 struct cmd_help_long_result {
140 cmdline_fixed_string_t help;
141 cmdline_fixed_string_t section;
144 static void cmd_help_long_parsed(void *parsed_result,
146 __attribute__((unused)) void *data)
149 struct cmd_help_long_result *res = parsed_result;
151 if (!strcmp(res->section, "all"))
154 if (show_all || !strcmp(res->section, "control")) {
159 "Control forwarding:\n"
160 "-------------------\n\n"
163 " Start packet forwarding with current configuration.\n\n"
166 " Start packet forwarding with current config"
167 " after sending one burst of packets.\n\n"
170 " Stop packet forwarding, and display accumulated"
174 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
178 if (show_all || !strcmp(res->section, "display")) {
186 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
187 " Display information for port_id, or all.\n\n"
189 "show port rss-hash [key]\n"
190 " Display the RSS hash functions and RSS hash key"
193 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
194 " Clear information for port_id, or all.\n\n"
196 "show config (rxtx|cores|fwd)\n"
197 " Display the given configuration.\n\n"
199 "read rxd (port_id) (queue_id) (rxd_id)\n"
200 " Display an RX descriptor of a port RX queue.\n\n"
202 "read txd (port_id) (queue_id) (txd_id)\n"
203 " Display a TX descriptor of a port TX queue.\n\n"
207 if (show_all || !strcmp(res->section, "config")) {
213 "Configuration changes only become active when"
214 " forwarding is started/restarted.\n\n"
217 " Reset forwarding to the default configuration.\n\n"
219 "set verbose (level)\n"
220 " Set the debug verbosity level X.\n\n"
223 " Set number of ports.\n\n"
226 " Set number of cores.\n\n"
228 "set coremask (mask)\n"
229 " Set the forwarding cores hexadecimal mask.\n\n"
231 "set portmask (mask)\n"
232 " Set the forwarding ports hexadecimal mask.\n\n"
235 " Set number of packets per burst.\n\n"
237 "set burst tx delay (microseconds) retry (num)\n"
238 " Set the transmit delay time and number of retries"
239 " in mac_retry forwarding mode.\n\n"
241 "set txpkts (x[,y]*)\n"
242 " Set the length of each segment of TXONLY"
245 "set corelist (x[,y]*)\n"
246 " Set the list of forwarding cores.\n\n"
248 "set portlist (x[,y]*)\n"
249 " Set the list of forwarding ports.\n\n"
251 "vlan set strip (on|off) (port_id)\n"
252 " Set the VLAN strip on a port.\n\n"
254 "vlan set stripq (on|off) (port_id,queue_id)\n"
255 " Set the VLAN strip for a queue on a port.\n\n"
257 "vlan set filter (on|off) (port_id)\n"
258 " Set the VLAN filter on a port.\n\n"
260 "vlan set qinq (on|off) (port_id)\n"
261 " Set the VLAN QinQ (extended queue in queue)"
264 "vlan set tpid (value) (port_id)\n"
265 " Set the outer VLAN TPID for Packet Filtering on"
268 "rx_vlan add (vlan_id|all) (port_id)\n"
269 " Add a vlan_id, or all identifiers, to the set"
270 " of VLAN identifiers filtered by port_id.\n\n"
272 "rx_vlan rm (vlan_id|all) (port_id)\n"
273 " Remove a vlan_id, or all identifiers, from the set"
274 " of VLAN identifiers filtered by port_id.\n\n"
276 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
277 " Add a vlan_id, to the set of VLAN identifiers"
278 "filtered for VF(s) from port_id.\n\n"
280 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
281 " Remove a vlan_id, to the set of VLAN identifiers"
282 "filtered for VF(s) from port_id.\n\n"
284 "rx_vlan set tpid (value) (port_id)\n"
285 " Set the outer VLAN TPID for Packet Filtering on"
288 "tx_vlan set vlan_id (port_id)\n"
289 " Set hardware insertion of VLAN ID in packets sent"
292 "tx_vlan set pvid port_id vlan_id (on|off)\n"
293 " Set port based TX VLAN insertion.\n\n"
295 "tx_vlan reset (port_id)\n"
296 " Disable hardware insertion of a VLAN header in"
297 " packets sent on a port.\n\n"
299 "tx_checksum set mask (port_id)\n"
300 " Enable hardware insertion of checksum offload with"
301 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
302 " bit 0 - insert ip checksum offload if set\n"
303 " bit 1 - insert udp checksum offload if set\n"
304 " bit 2 - insert tcp checksum offload if set\n"
305 " bit 3 - insert sctp checksum offload if set\n"
306 " Please check the NIC datasheet for HW limits.\n\n"
309 " Set packet forwarding mode.\n\n"
311 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
312 " Add a MAC address on port_id.\n\n"
314 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
315 " Remove a MAC address from port_id.\n\n"
317 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
318 " Add a MAC address for a VF on the port.\n\n"
320 "set port (port_id) uta (mac_address|all) (on|off)\n"
321 " Add/Remove a or all unicast hash filter(s)"
324 "set promisc (port_id|all) (on|off)\n"
325 " Set the promiscuous mode on port_id, or all.\n\n"
327 "set allmulti (port_id|all) (on|off)\n"
328 " Set the allmulti mode on port_id, or all.\n\n"
330 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
331 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
332 " (on|off) autoneg (on|off) (port_id)\n"
333 "set flow_ctrl rx (on|off) (portid)\n"
334 "set flow_ctrl tx (on|off) (portid)\n"
335 "set flow_ctrl high_water (high_water) (portid)\n"
336 "set flow_ctrl low_water (low_water) (portid)\n"
337 "set flow_ctrl pause_time (pause_time) (portid)\n"
338 "set flow_ctrl send_xon (send_xon) (portid)\n"
339 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
340 "set flow_ctrl autoneg (on|off) (port_id)\n"
341 " Set the link flow control parameter on a port.\n\n"
343 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
344 " (low_water) (pause_time) (priority) (port_id)\n"
345 " Set the priority flow control parameter on a"
348 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
349 " Set statistics mapping (qmapping 0..15) for RX/TX"
351 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
352 " on port 0 to mapping 5.\n\n"
354 "set port (port_id) vf (vf_id) rx|tx on|off \n"
355 " Enable/Disable a VF receive/tranmit from a port\n\n"
357 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
359 " AUPE:accepts untagged VLAN;"
360 "ROPE:accept unicast hash\n\n"
361 " BAM:accepts broadcast packets;"
362 "MPE:accepts all multicast packets\n\n"
363 " Enable/Disable a VF receive mode of a port\n\n"
365 "set port (port_id) queue (queue_id) rate (rate_num)\n"
366 " Set rate limit for a queue of a port\n\n"
368 "set port (port_id) vf (vf_id) rate (rate_num) "
369 "queue_mask (queue_mask_value)\n"
370 " Set rate limit for queues in VF of a port\n\n"
372 "set port (port_id) mirror-rule (rule_id)"
373 "(pool-mirror|vlan-mirror)\n"
374 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
375 " Set pool or vlan type mirror rule on a port.\n"
376 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
377 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
380 "set port (port_id) mirror-rule (rule_id)"
381 " (uplink-mirror|downlink-mirror) dst-pool"
382 " (pool_id) (on|off)\n"
383 " Set uplink or downlink type mirror rule on a port.\n"
384 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
385 " 0 on' enable mirror income traffic to pool 0.\n\n"
387 "reset port (port_id) mirror-rule (rule_id)\n"
388 " Reset a mirror rule.\n\n"
390 "set flush_rx (on|off)\n"
391 " Flush (default) or don't flush RX streams before"
392 " forwarding. Mainly used with PCAP drivers.\n\n"
394 #ifdef RTE_NIC_BYPASS
395 "set bypass mode (normal|bypass|isolate) (port_id)\n"
396 " Set the bypass mode for the lowest port on bypass enabled"
399 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
400 "mode (normal|bypass|isolate) (port_id)\n"
401 " Set the event required to initiate specified bypass mode for"
402 " the lowest port on a bypass enabled NIC where:\n"
403 " timeout = enable bypass after watchdog timeout.\n"
404 " os_on = enable bypass when OS/board is powered on.\n"
405 " os_off = enable bypass when OS/board is powered off.\n"
406 " power_on = enable bypass when power supply is turned on.\n"
407 " power_off = enable bypass when power supply is turned off."
410 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
411 " Set the bypass watchdog timeout to 'n' seconds"
412 " where 0 = instant.\n\n"
414 "show bypass config (port_id)\n"
415 " Show the bypass configuration for a bypass enabled NIC"
416 " using the lowest port on the NIC.\n\n"
418 #ifdef RTE_LIBRTE_PMD_BOND
419 "create bonded device (mode) (socket)\n"
420 " Create a new bonded device with specific bonding mode and socket.\n\n"
422 "add bonding slave (slave_id) (port_id)\n"
423 " Add a slave device to a bonded device.\n\n"
425 "remove bonding slave (slave_id) (port_id)\n"
426 " Remove a slave device from a bonded device.\n\n"
428 "set bonding mode (value) (port_id)\n"
429 " Set the bonding mode on a bonded device.\n\n"
431 "set bonding primary (slave_id) (port_id)\n"
432 " Set the primary slave for a bonded device.\n\n"
434 "show bonding config (port_id)\n"
435 " Show the bonding config for port_id.\n\n"
437 "set bonding mac_addr (port_id) (address)\n"
438 " Set the MAC address of a bonded device.\n\n"
440 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
441 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
444 , list_pkt_forwarding_modes()
449 if (show_all || !strcmp(res->section, "flowdir")) {
454 "Flow director mode:\n"
455 "-------------------\n\n"
457 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
458 " src (src_ip_address) (src_port)"
459 " dst (dst_ip_address) (dst_port)"
460 " flexbytes (flexbytes_values) vlan (vlan_id)"
461 " queue (queue_id)\n"
462 " Add a signature filter.\n\n"
464 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
465 " src (src_ip_address) (src_port)"
466 " dst (dst_ip_address) (dst_port)"
467 " flexbytes (flexbytes_values) vlan (vlan_id)"
468 " queue (queue_id)\n"
469 " Update a signature filter.\n\n"
471 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
472 " src (src_ip_address) (src_port)"
473 " dst (dst_ip_address) (dst_port)"
474 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
475 " Remove a signature filter.\n\n"
477 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
478 " src (src_ip_address) (src_port)"
479 " dst (dst_ip_address) (dst_port)"
480 " flexbytes (flexbytes_values) vlan (vlan_id)"
481 " queue (queue_id) soft (soft_id)\n"
482 " Add a perfect filter.\n\n"
484 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
485 " src (src_ip_address) (src_port)"
486 " dst (dst_ip_address) (dst_port)"
487 " flexbytes (flexbytes_values) vlan (vlan_id)"
488 " queue (queue_id)\n"
489 " Update a perfect filter.\n\n"
491 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
492 " src (src_ip_address) (src_port)"
493 " dst (dst_ip_address) (dst_port)"
494 " flexbytes (flexbytes_values) vlan (vlan_id)"
496 " Remove a perfect filter.\n\n"
498 "set_masks_filter (port_id) only_ip_flow (0|1)"
499 " src_mask (ip_src_mask) (src_port_mask)"
500 " dst_mask (ip_dst_mask) (dst_port_mask)"
501 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
502 " Set IPv4 filter masks.\n\n"
504 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
505 " src_mask (ip_src_mask) (src_port_mask)"
506 " dst_mask (ip_dst_mask) (dst_port_mask)"
507 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
508 " compare_dst (0|1)\n"
509 " Set IPv6 filter masks.\n\n"
513 if (show_all || !strcmp(res->section, "ports")) {
519 "----------------\n\n"
521 "port start (port_id|all)\n"
522 " Start all ports or port_id.\n\n"
524 "port stop (port_id|all)\n"
525 " Stop all ports or port_id.\n\n"
527 "port close (port_id|all)\n"
528 " Close all ports or port_id.\n\n"
530 "port config (port_id|all)"
531 " speed (10|100|1000|10000|40000|auto)"
532 " duplex (half|full|auto)\n"
533 " Set speed and duplex for all ports or port_id\n\n"
535 "port config all (rxq|txq|rxd|txd) (value)\n"
536 " Set number for rxq/txq/rxd/txd.\n\n"
538 "port config all max-pkt-len (value)\n"
539 " Set the max packet length.\n\n"
541 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
543 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
546 "port config all rss (ip|udp|none)\n"
547 " Set the RSS mode.\n\n"
549 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
550 " Set the RSS redirection table.\n\n"
552 "port config (port_id) dcb vt (on|off) (traffic_class)"
554 " Set the DCB mode.\n\n"
556 "port config all burst (value)\n"
557 " Set the number of packets per burst.\n\n"
559 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
561 " Set the ring prefetch/host/writeback threshold"
562 " for tx/rx queue.\n\n"
564 "port config all (txfreet|txrst|rxfreet) (value)\n"
565 " Set free threshold for rx/tx, or set"
566 " tx rs bit threshold.\n\n"
567 "port config mtu X value\n"
568 " Set the MTU of port X to a given value\n\n"
570 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
571 " Start/stop a rx/tx queue of port X. Only take effect"
572 " when port X is started\n"
576 if (show_all || !strcmp(res->section, "registers")) {
584 "read reg (port_id) (address)\n"
585 " Display value of a port register.\n\n"
587 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
588 " Display a port register bit field.\n\n"
590 "read regbit (port_id) (address) (bit_x)\n"
591 " Display a single port register bit.\n\n"
593 "write reg (port_id) (address) (value)\n"
594 " Set value of a port register.\n\n"
596 "write regfield (port_id) (address) (bit_x) (bit_y)"
598 " Set bit field of a port register.\n\n"
600 "write regbit (port_id) (address) (bit_x) (value)\n"
601 " Set single bit value of a port register.\n\n"
604 if (show_all || !strcmp(res->section, "filters")) {
612 "add_ethertype_filter (port_id) ethertype (eth_value)"
613 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
614 " add an ethertype filter.\n\n"
616 "remove_ethertype_filter (port_id) index (idx)\n"
617 " remove an ethertype filter.\n\n"
619 "get_ethertype_filter (port_id) index (idx)\n"
620 " get info of a ethertype filter.\n\n"
622 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
623 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
624 " queue (queue_id) index (idx)\n"
625 " add a 2tuple filter.\n\n"
627 "remove_2tuple_filter (port_id) index (idx)\n"
628 " remove a 2tuple filter.\n\n"
630 "get_2tuple_filter (port_id) index (idx)\n"
631 " get info of a 2tuple filter.\n\n"
633 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
634 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
635 " mask (mask_value) flags (flags_value) priority (prio_value)"
636 " queue (queue_id) index (idx)\n"
637 " add a 5tuple filter.\n\n"
639 "remove_5tuple_filter (port_id) index (idx)\n"
640 " remove a 5tuple filter.\n\n"
642 "get_5tuple_filter (port_id) index (idx)\n"
643 " get info of a 5tuple filter.\n\n"
645 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
646 " add syn filter.\n\n"
648 "remove_syn_filter (port_id)"
649 " remove syn filter.\n\n"
651 "get_syn_filter (port_id) "
652 " get syn filter info.\n\n"
654 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
655 " priority (prio_value) queue (queue_id) index (idx)\n"
656 " add a flex filter.\n\n"
658 "remove_flex_filter (port_id) index (idx)\n"
659 " remove a flex filter.\n\n"
661 "get_flex_filter (port_id) index (idx)\n"
662 " get info of a flex filter.\n\n"
667 cmdline_parse_token_string_t cmd_help_long_help =
668 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
670 cmdline_parse_token_string_t cmd_help_long_section =
671 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
672 "all#control#display#config#flowdir#"
673 "ports#registers#filters");
675 cmdline_parse_inst_t cmd_help_long = {
676 .f = cmd_help_long_parsed,
678 .help_str = "show help",
680 (void *)&cmd_help_long_help,
681 (void *)&cmd_help_long_section,
687 /* *** start/stop/close all ports *** */
688 struct cmd_operate_port_result {
689 cmdline_fixed_string_t keyword;
690 cmdline_fixed_string_t name;
691 cmdline_fixed_string_t value;
694 static void cmd_operate_port_parsed(void *parsed_result,
695 __attribute__((unused)) struct cmdline *cl,
696 __attribute__((unused)) void *data)
698 struct cmd_operate_port_result *res = parsed_result;
700 if (!strcmp(res->name, "start"))
701 start_port(RTE_PORT_ALL);
702 else if (!strcmp(res->name, "stop"))
703 stop_port(RTE_PORT_ALL);
704 else if (!strcmp(res->name, "close"))
705 close_port(RTE_PORT_ALL);
707 printf("Unknown parameter\n");
710 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
711 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
713 cmdline_parse_token_string_t cmd_operate_port_all_port =
714 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
716 cmdline_parse_token_string_t cmd_operate_port_all_all =
717 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
719 cmdline_parse_inst_t cmd_operate_port = {
720 .f = cmd_operate_port_parsed,
722 .help_str = "port start|stop|close all: start/stop/close all ports",
724 (void *)&cmd_operate_port_all_cmd,
725 (void *)&cmd_operate_port_all_port,
726 (void *)&cmd_operate_port_all_all,
731 /* *** start/stop/close specific port *** */
732 struct cmd_operate_specific_port_result {
733 cmdline_fixed_string_t keyword;
734 cmdline_fixed_string_t name;
738 static void cmd_operate_specific_port_parsed(void *parsed_result,
739 __attribute__((unused)) struct cmdline *cl,
740 __attribute__((unused)) void *data)
742 struct cmd_operate_specific_port_result *res = parsed_result;
744 if (!strcmp(res->name, "start"))
745 start_port(res->value);
746 else if (!strcmp(res->name, "stop"))
747 stop_port(res->value);
748 else if (!strcmp(res->name, "close"))
749 close_port(res->value);
751 printf("Unknown parameter\n");
754 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
755 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
757 cmdline_parse_token_string_t cmd_operate_specific_port_port =
758 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
759 name, "start#stop#close");
760 cmdline_parse_token_num_t cmd_operate_specific_port_id =
761 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
764 cmdline_parse_inst_t cmd_operate_specific_port = {
765 .f = cmd_operate_specific_port_parsed,
767 .help_str = "port start|stop|close X: start/stop/close port X",
769 (void *)&cmd_operate_specific_port_cmd,
770 (void *)&cmd_operate_specific_port_port,
771 (void *)&cmd_operate_specific_port_id,
776 /* *** configure speed for all ports *** */
777 struct cmd_config_speed_all {
778 cmdline_fixed_string_t port;
779 cmdline_fixed_string_t keyword;
780 cmdline_fixed_string_t all;
781 cmdline_fixed_string_t item1;
782 cmdline_fixed_string_t item2;
783 cmdline_fixed_string_t value1;
784 cmdline_fixed_string_t value2;
788 cmd_config_speed_all_parsed(void *parsed_result,
789 __attribute__((unused)) struct cmdline *cl,
790 __attribute__((unused)) void *data)
792 struct cmd_config_speed_all *res = parsed_result;
793 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
794 uint16_t link_duplex = 0;
797 if (!all_ports_stopped()) {
798 printf("Please stop all ports first\n");
802 if (!strcmp(res->value1, "10"))
803 link_speed = ETH_LINK_SPEED_10;
804 else if (!strcmp(res->value1, "100"))
805 link_speed = ETH_LINK_SPEED_100;
806 else if (!strcmp(res->value1, "1000"))
807 link_speed = ETH_LINK_SPEED_1000;
808 else if (!strcmp(res->value1, "10000"))
809 link_speed = ETH_LINK_SPEED_10G;
810 else if (!strcmp(res->value1, "40000"))
811 link_speed = ETH_LINK_SPEED_40G;
812 else if (!strcmp(res->value1, "auto"))
813 link_speed = ETH_LINK_SPEED_AUTONEG;
815 printf("Unknown parameter\n");
819 if (!strcmp(res->value2, "half"))
820 link_duplex = ETH_LINK_HALF_DUPLEX;
821 else if (!strcmp(res->value2, "full"))
822 link_duplex = ETH_LINK_FULL_DUPLEX;
823 else if (!strcmp(res->value2, "auto"))
824 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
826 printf("Unknown parameter\n");
830 for (pid = 0; pid < nb_ports; pid++) {
831 ports[pid].dev_conf.link_speed = link_speed;
832 ports[pid].dev_conf.link_duplex = link_duplex;
835 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
838 cmdline_parse_token_string_t cmd_config_speed_all_port =
839 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
840 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
841 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
843 cmdline_parse_token_string_t cmd_config_speed_all_all =
844 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
845 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
846 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
847 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
848 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
849 "10#100#1000#10000#40000#auto");
850 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
851 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
852 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
853 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
856 cmdline_parse_inst_t cmd_config_speed_all = {
857 .f = cmd_config_speed_all_parsed,
859 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
862 (void *)&cmd_config_speed_all_port,
863 (void *)&cmd_config_speed_all_keyword,
864 (void *)&cmd_config_speed_all_all,
865 (void *)&cmd_config_speed_all_item1,
866 (void *)&cmd_config_speed_all_value1,
867 (void *)&cmd_config_speed_all_item2,
868 (void *)&cmd_config_speed_all_value2,
873 /* *** configure speed for specific port *** */
874 struct cmd_config_speed_specific {
875 cmdline_fixed_string_t port;
876 cmdline_fixed_string_t keyword;
878 cmdline_fixed_string_t item1;
879 cmdline_fixed_string_t item2;
880 cmdline_fixed_string_t value1;
881 cmdline_fixed_string_t value2;
885 cmd_config_speed_specific_parsed(void *parsed_result,
886 __attribute__((unused)) struct cmdline *cl,
887 __attribute__((unused)) void *data)
889 struct cmd_config_speed_specific *res = parsed_result;
890 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
891 uint16_t link_duplex = 0;
893 if (!all_ports_stopped()) {
894 printf("Please stop all ports first\n");
898 if (res->id >= nb_ports) {
899 printf("Port id %d must be less than %d\n", res->id, nb_ports);
903 if (!strcmp(res->value1, "10"))
904 link_speed = ETH_LINK_SPEED_10;
905 else if (!strcmp(res->value1, "100"))
906 link_speed = ETH_LINK_SPEED_100;
907 else if (!strcmp(res->value1, "1000"))
908 link_speed = ETH_LINK_SPEED_1000;
909 else if (!strcmp(res->value1, "10000"))
910 link_speed = ETH_LINK_SPEED_10000;
911 else if (!strcmp(res->value1, "40000"))
912 link_speed = ETH_LINK_SPEED_40G;
913 else if (!strcmp(res->value1, "auto"))
914 link_speed = ETH_LINK_SPEED_AUTONEG;
916 printf("Unknown parameter\n");
920 if (!strcmp(res->value2, "half"))
921 link_duplex = ETH_LINK_HALF_DUPLEX;
922 else if (!strcmp(res->value2, "full"))
923 link_duplex = ETH_LINK_FULL_DUPLEX;
924 else if (!strcmp(res->value2, "auto"))
925 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
927 printf("Unknown parameter\n");
931 ports[res->id].dev_conf.link_speed = link_speed;
932 ports[res->id].dev_conf.link_duplex = link_duplex;
934 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
938 cmdline_parse_token_string_t cmd_config_speed_specific_port =
939 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
941 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
942 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
944 cmdline_parse_token_num_t cmd_config_speed_specific_id =
945 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
946 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
947 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
949 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
950 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
951 "10#100#1000#10000#40000#auto");
952 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
955 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
956 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
959 cmdline_parse_inst_t cmd_config_speed_specific = {
960 .f = cmd_config_speed_specific_parsed,
962 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
965 (void *)&cmd_config_speed_specific_port,
966 (void *)&cmd_config_speed_specific_keyword,
967 (void *)&cmd_config_speed_specific_id,
968 (void *)&cmd_config_speed_specific_item1,
969 (void *)&cmd_config_speed_specific_value1,
970 (void *)&cmd_config_speed_specific_item2,
971 (void *)&cmd_config_speed_specific_value2,
976 /* *** configure txq/rxq, txd/rxd *** */
977 struct cmd_config_rx_tx {
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t keyword;
980 cmdline_fixed_string_t all;
981 cmdline_fixed_string_t name;
986 cmd_config_rx_tx_parsed(void *parsed_result,
987 __attribute__((unused)) struct cmdline *cl,
988 __attribute__((unused)) void *data)
990 struct cmd_config_rx_tx *res = parsed_result;
992 if (!all_ports_stopped()) {
993 printf("Please stop all ports first\n");
997 if (!strcmp(res->name, "rxq")) {
998 if (res->value <= 0) {
999 printf("rxq %d invalid - must be > 0\n", res->value);
1002 nb_rxq = res->value;
1004 else if (!strcmp(res->name, "txq")) {
1005 if (res->value <= 0) {
1006 printf("txq %d invalid - must be > 0\n", res->value);
1009 nb_txq = res->value;
1011 else if (!strcmp(res->name, "rxd")) {
1012 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1013 printf("rxd %d invalid - must be > 0 && <= %d\n",
1014 res->value, RTE_TEST_RX_DESC_MAX);
1017 nb_rxd = res->value;
1018 } else if (!strcmp(res->name, "txd")) {
1019 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1020 printf("txd %d invalid - must be > 0 && <= %d\n",
1021 res->value, RTE_TEST_TX_DESC_MAX);
1024 nb_txd = res->value;
1026 printf("Unknown parameter\n");
1032 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1035 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1036 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1037 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1038 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1039 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1040 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1041 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1042 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1044 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1045 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1047 cmdline_parse_inst_t cmd_config_rx_tx = {
1048 .f = cmd_config_rx_tx_parsed,
1050 .help_str = "port config all rxq|txq|rxd|txd value",
1052 (void *)&cmd_config_rx_tx_port,
1053 (void *)&cmd_config_rx_tx_keyword,
1054 (void *)&cmd_config_rx_tx_all,
1055 (void *)&cmd_config_rx_tx_name,
1056 (void *)&cmd_config_rx_tx_value,
1061 /* *** config max packet length *** */
1062 struct cmd_config_max_pkt_len_result {
1063 cmdline_fixed_string_t port;
1064 cmdline_fixed_string_t keyword;
1065 cmdline_fixed_string_t all;
1066 cmdline_fixed_string_t name;
1071 cmd_config_max_pkt_len_parsed(void *parsed_result,
1072 __attribute__((unused)) struct cmdline *cl,
1073 __attribute__((unused)) void *data)
1075 struct cmd_config_max_pkt_len_result *res = parsed_result;
1077 if (!all_ports_stopped()) {
1078 printf("Please stop all ports first\n");
1082 if (!strcmp(res->name, "max-pkt-len")) {
1083 if (res->value < ETHER_MIN_LEN) {
1084 printf("max-pkt-len can not be less than %d\n",
1088 if (res->value == rx_mode.max_rx_pkt_len)
1091 rx_mode.max_rx_pkt_len = res->value;
1092 if (res->value > ETHER_MAX_LEN)
1093 rx_mode.jumbo_frame = 1;
1095 rx_mode.jumbo_frame = 0;
1097 printf("Unknown parameter\n");
1103 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1106 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1107 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1109 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1112 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1113 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1115 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1118 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1119 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1122 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1123 .f = cmd_config_max_pkt_len_parsed,
1125 .help_str = "port config all max-pkt-len value",
1127 (void *)&cmd_config_max_pkt_len_port,
1128 (void *)&cmd_config_max_pkt_len_keyword,
1129 (void *)&cmd_config_max_pkt_len_all,
1130 (void *)&cmd_config_max_pkt_len_name,
1131 (void *)&cmd_config_max_pkt_len_value,
1136 /* *** configure port MTU *** */
1137 struct cmd_config_mtu_result {
1138 cmdline_fixed_string_t port;
1139 cmdline_fixed_string_t keyword;
1140 cmdline_fixed_string_t mtu;
1146 cmd_config_mtu_parsed(void *parsed_result,
1147 __attribute__((unused)) struct cmdline *cl,
1148 __attribute__((unused)) void *data)
1150 struct cmd_config_mtu_result *res = parsed_result;
1152 if (res->value < ETHER_MIN_LEN) {
1153 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1156 port_mtu_set(res->port_id, res->value);
1159 cmdline_parse_token_string_t cmd_config_mtu_port =
1160 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1162 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1165 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1166 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1168 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1169 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1170 cmdline_parse_token_num_t cmd_config_mtu_value =
1171 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1173 cmdline_parse_inst_t cmd_config_mtu = {
1174 .f = cmd_config_mtu_parsed,
1176 .help_str = "port config mtu value",
1178 (void *)&cmd_config_mtu_port,
1179 (void *)&cmd_config_mtu_keyword,
1180 (void *)&cmd_config_mtu_mtu,
1181 (void *)&cmd_config_mtu_port_id,
1182 (void *)&cmd_config_mtu_value,
1187 /* *** configure rx mode *** */
1188 struct cmd_config_rx_mode_flag {
1189 cmdline_fixed_string_t port;
1190 cmdline_fixed_string_t keyword;
1191 cmdline_fixed_string_t all;
1192 cmdline_fixed_string_t name;
1193 cmdline_fixed_string_t value;
1197 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1198 __attribute__((unused)) struct cmdline *cl,
1199 __attribute__((unused)) void *data)
1201 struct cmd_config_rx_mode_flag *res = parsed_result;
1203 if (!all_ports_stopped()) {
1204 printf("Please stop all ports first\n");
1208 if (!strcmp(res->name, "crc-strip")) {
1209 if (!strcmp(res->value, "on"))
1210 rx_mode.hw_strip_crc = 1;
1211 else if (!strcmp(res->value, "off"))
1212 rx_mode.hw_strip_crc = 0;
1214 printf("Unknown parameter\n");
1217 } else if (!strcmp(res->name, "rx-cksum")) {
1218 if (!strcmp(res->value, "on"))
1219 rx_mode.hw_ip_checksum = 1;
1220 else if (!strcmp(res->value, "off"))
1221 rx_mode.hw_ip_checksum = 0;
1223 printf("Unknown parameter\n");
1226 } else if (!strcmp(res->name, "hw-vlan")) {
1227 if (!strcmp(res->value, "on")) {
1228 rx_mode.hw_vlan_filter = 1;
1229 rx_mode.hw_vlan_strip = 1;
1231 else if (!strcmp(res->value, "off")) {
1232 rx_mode.hw_vlan_filter = 0;
1233 rx_mode.hw_vlan_strip = 0;
1236 printf("Unknown parameter\n");
1239 } else if (!strcmp(res->name, "drop-en")) {
1240 if (!strcmp(res->value, "on"))
1242 else if (!strcmp(res->value, "off"))
1245 printf("Unknown parameter\n");
1249 printf("Unknown parameter\n");
1255 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1258 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1259 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1260 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1263 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1265 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1266 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1267 "crc-strip#rx-cksum#hw-vlan");
1268 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1272 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1273 .f = cmd_config_rx_mode_flag_parsed,
1275 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1277 (void *)&cmd_config_rx_mode_flag_port,
1278 (void *)&cmd_config_rx_mode_flag_keyword,
1279 (void *)&cmd_config_rx_mode_flag_all,
1280 (void *)&cmd_config_rx_mode_flag_name,
1281 (void *)&cmd_config_rx_mode_flag_value,
1286 /* *** configure rss *** */
1287 struct cmd_config_rss {
1288 cmdline_fixed_string_t port;
1289 cmdline_fixed_string_t keyword;
1290 cmdline_fixed_string_t all;
1291 cmdline_fixed_string_t name;
1292 cmdline_fixed_string_t value;
1296 cmd_config_rss_parsed(void *parsed_result,
1297 __attribute__((unused)) struct cmdline *cl,
1298 __attribute__((unused)) void *data)
1300 struct cmd_config_rss *res = parsed_result;
1301 struct rte_eth_rss_conf rss_conf;
1304 if (!strcmp(res->value, "ip"))
1305 rss_conf.rss_hf = ETH_RSS_IP;
1306 else if (!strcmp(res->value, "udp"))
1307 rss_conf.rss_hf = ETH_RSS_UDP;
1308 else if (!strcmp(res->value, "none"))
1309 rss_conf.rss_hf = 0;
1311 printf("Unknown parameter\n");
1314 rss_conf.rss_key = NULL;
1315 for (i = 0; i < rte_eth_dev_count(); i++)
1316 rte_eth_dev_rss_hash_update(i, &rss_conf);
1319 cmdline_parse_token_string_t cmd_config_rss_port =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1321 cmdline_parse_token_string_t cmd_config_rss_keyword =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1323 cmdline_parse_token_string_t cmd_config_rss_all =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1325 cmdline_parse_token_string_t cmd_config_rss_name =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1327 cmdline_parse_token_string_t cmd_config_rss_value =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1330 cmdline_parse_inst_t cmd_config_rss = {
1331 .f = cmd_config_rss_parsed,
1333 .help_str = "port config all rss ip|udp|none",
1335 (void *)&cmd_config_rss_port,
1336 (void *)&cmd_config_rss_keyword,
1337 (void *)&cmd_config_rss_all,
1338 (void *)&cmd_config_rss_name,
1339 (void *)&cmd_config_rss_value,
1344 /* *** configure rss hash key *** */
1345 struct cmd_config_rss_hash_key {
1346 cmdline_fixed_string_t port;
1347 cmdline_fixed_string_t config;
1349 cmdline_fixed_string_t rss_hash_key;
1350 cmdline_fixed_string_t key;
1353 #define RSS_HASH_KEY_LENGTH 40
1355 hexa_digit_to_value(char hexa_digit)
1357 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1358 return (uint8_t) (hexa_digit - '0');
1359 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1360 return (uint8_t) ((hexa_digit - 'a') + 10);
1361 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1362 return (uint8_t) ((hexa_digit - 'A') + 10);
1363 /* Invalid hexa digit */
1368 parse_and_check_key_hexa_digit(char *key, int idx)
1372 hexa_v = hexa_digit_to_value(key[idx]);
1374 printf("invalid key: character %c at position %d is not a "
1375 "valid hexa digit\n", key[idx], idx);
1380 cmd_config_rss_hash_key_parsed(void *parsed_result,
1381 __attribute__((unused)) struct cmdline *cl,
1382 __attribute__((unused)) void *data)
1384 struct cmd_config_rss_hash_key *res = parsed_result;
1385 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1390 /* Check the length of the RSS hash key */
1391 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1392 printf("key length: %d invalid - key must be a string of %d"
1393 "hexa-decimal numbers\n", (int) strlen(res->key),
1394 RSS_HASH_KEY_LENGTH * 2);
1397 /* Translate RSS hash key into binary representation */
1398 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1399 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1402 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1405 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1407 port_rss_hash_key_update(res->port_id, hash_key);
1410 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1412 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1415 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1416 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1417 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1419 rss_hash_key, "rss-hash-key");
1420 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1423 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1424 .f = cmd_config_rss_hash_key_parsed,
1426 .help_str = "port config X rss-hash-key 80 hexa digits",
1428 (void *)&cmd_config_rss_hash_key_port,
1429 (void *)&cmd_config_rss_hash_key_config,
1430 (void *)&cmd_config_rss_hash_key_port_id,
1431 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1432 (void *)&cmd_config_rss_hash_key_value,
1437 /* *** configure port rxq/txq start/stop *** */
1438 struct cmd_config_rxtx_queue {
1439 cmdline_fixed_string_t port;
1441 cmdline_fixed_string_t rxtxq;
1443 cmdline_fixed_string_t opname;
1447 cmd_config_rxtx_queue_parsed(void *parsed_result,
1448 __attribute__((unused)) struct cmdline *cl,
1449 __attribute__((unused)) void *data)
1451 struct cmd_config_rxtx_queue *res = parsed_result;
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, "xstats"))
5118 for (i = 0; i < nb_ports; i++)
5119 nic_xstats_clear(i);
5120 } else if (!strcmp(res->what, "info"))
5121 for (i = 0; i < nb_ports; i++)
5122 port_infos_display(i);
5123 else if (!strcmp(res->what, "stats"))
5124 for (i = 0; i < nb_ports; i++)
5125 nic_stats_display(i);
5126 else if (!strcmp(res->what, "xstats"))
5127 for (i = 0; i < nb_ports; i++)
5128 nic_xstats_display(i);
5129 else if (!strcmp(res->what, "fdir"))
5130 for (i = 0; i < nb_ports; i++)
5132 else if (!strcmp(res->what, "stat_qmap"))
5133 for (i = 0; i < nb_ports; i++)
5134 nic_stats_mapping_display(i);
5137 cmdline_parse_token_string_t cmd_showportall_show =
5138 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5140 cmdline_parse_token_string_t cmd_showportall_port =
5141 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5142 cmdline_parse_token_string_t cmd_showportall_what =
5143 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5144 "info#stats#xstats#fdir#stat_qmap");
5145 cmdline_parse_token_string_t cmd_showportall_all =
5146 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5147 cmdline_parse_inst_t cmd_showportall = {
5148 .f = cmd_showportall_parsed,
5150 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5152 (void *)&cmd_showportall_show,
5153 (void *)&cmd_showportall_port,
5154 (void *)&cmd_showportall_what,
5155 (void *)&cmd_showportall_all,
5160 /* *** SHOW PORT INFO *** */
5161 struct cmd_showport_result {
5162 cmdline_fixed_string_t show;
5163 cmdline_fixed_string_t port;
5164 cmdline_fixed_string_t what;
5168 static void cmd_showport_parsed(void *parsed_result,
5169 __attribute__((unused)) struct cmdline *cl,
5170 __attribute__((unused)) void *data)
5172 struct cmd_showport_result *res = parsed_result;
5173 if (!strcmp(res->show, "clear")) {
5174 if (!strcmp(res->what, "stats"))
5175 nic_stats_clear(res->portnum);
5176 else if (!strcmp(res->what, "xstats"))
5177 nic_xstats_clear(res->portnum);
5178 } else if (!strcmp(res->what, "info"))
5179 port_infos_display(res->portnum);
5180 else if (!strcmp(res->what, "stats"))
5181 nic_stats_display(res->portnum);
5182 else if (!strcmp(res->what, "xstats"))
5183 nic_xstats_display(res->portnum);
5184 else if (!strcmp(res->what, "fdir"))
5185 fdir_get_infos(res->portnum);
5186 else if (!strcmp(res->what, "stat_qmap"))
5187 nic_stats_mapping_display(res->portnum);
5190 cmdline_parse_token_string_t cmd_showport_show =
5191 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5193 cmdline_parse_token_string_t cmd_showport_port =
5194 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5195 cmdline_parse_token_string_t cmd_showport_what =
5196 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5197 "info#stats#xstats#fdir#stat_qmap");
5198 cmdline_parse_token_num_t cmd_showport_portnum =
5199 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5201 cmdline_parse_inst_t cmd_showport = {
5202 .f = cmd_showport_parsed,
5204 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5206 (void *)&cmd_showport_show,
5207 (void *)&cmd_showport_port,
5208 (void *)&cmd_showport_what,
5209 (void *)&cmd_showport_portnum,
5214 /* *** READ PORT REGISTER *** */
5215 struct cmd_read_reg_result {
5216 cmdline_fixed_string_t read;
5217 cmdline_fixed_string_t reg;
5223 cmd_read_reg_parsed(void *parsed_result,
5224 __attribute__((unused)) struct cmdline *cl,
5225 __attribute__((unused)) void *data)
5227 struct cmd_read_reg_result *res = parsed_result;
5228 port_reg_display(res->port_id, res->reg_off);
5231 cmdline_parse_token_string_t cmd_read_reg_read =
5232 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5233 cmdline_parse_token_string_t cmd_read_reg_reg =
5234 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5235 cmdline_parse_token_num_t cmd_read_reg_port_id =
5236 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5237 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5238 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5240 cmdline_parse_inst_t cmd_read_reg = {
5241 .f = cmd_read_reg_parsed,
5243 .help_str = "read reg port_id reg_off",
5245 (void *)&cmd_read_reg_read,
5246 (void *)&cmd_read_reg_reg,
5247 (void *)&cmd_read_reg_port_id,
5248 (void *)&cmd_read_reg_reg_off,
5253 /* *** READ PORT REGISTER BIT FIELD *** */
5254 struct cmd_read_reg_bit_field_result {
5255 cmdline_fixed_string_t read;
5256 cmdline_fixed_string_t regfield;
5264 cmd_read_reg_bit_field_parsed(void *parsed_result,
5265 __attribute__((unused)) struct cmdline *cl,
5266 __attribute__((unused)) void *data)
5268 struct cmd_read_reg_bit_field_result *res = parsed_result;
5269 port_reg_bit_field_display(res->port_id, res->reg_off,
5270 res->bit1_pos, res->bit2_pos);
5273 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5274 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5276 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5277 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5278 regfield, "regfield");
5279 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5280 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5282 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5283 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5285 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5286 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5288 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5289 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5292 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5293 .f = cmd_read_reg_bit_field_parsed,
5295 .help_str = "read regfield port_id reg_off bit_x bit_y "
5296 "(read register bit field between bit_x and bit_y included)",
5298 (void *)&cmd_read_reg_bit_field_read,
5299 (void *)&cmd_read_reg_bit_field_regfield,
5300 (void *)&cmd_read_reg_bit_field_port_id,
5301 (void *)&cmd_read_reg_bit_field_reg_off,
5302 (void *)&cmd_read_reg_bit_field_bit1_pos,
5303 (void *)&cmd_read_reg_bit_field_bit2_pos,
5308 /* *** READ PORT REGISTER BIT *** */
5309 struct cmd_read_reg_bit_result {
5310 cmdline_fixed_string_t read;
5311 cmdline_fixed_string_t regbit;
5318 cmd_read_reg_bit_parsed(void *parsed_result,
5319 __attribute__((unused)) struct cmdline *cl,
5320 __attribute__((unused)) void *data)
5322 struct cmd_read_reg_bit_result *res = parsed_result;
5323 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5326 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5327 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5328 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5329 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5331 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5332 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5333 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5334 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5335 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5336 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5338 cmdline_parse_inst_t cmd_read_reg_bit = {
5339 .f = cmd_read_reg_bit_parsed,
5341 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5343 (void *)&cmd_read_reg_bit_read,
5344 (void *)&cmd_read_reg_bit_regbit,
5345 (void *)&cmd_read_reg_bit_port_id,
5346 (void *)&cmd_read_reg_bit_reg_off,
5347 (void *)&cmd_read_reg_bit_bit_pos,
5352 /* *** WRITE PORT REGISTER *** */
5353 struct cmd_write_reg_result {
5354 cmdline_fixed_string_t write;
5355 cmdline_fixed_string_t reg;
5362 cmd_write_reg_parsed(void *parsed_result,
5363 __attribute__((unused)) struct cmdline *cl,
5364 __attribute__((unused)) void *data)
5366 struct cmd_write_reg_result *res = parsed_result;
5367 port_reg_set(res->port_id, res->reg_off, res->value);
5370 cmdline_parse_token_string_t cmd_write_reg_write =
5371 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5372 cmdline_parse_token_string_t cmd_write_reg_reg =
5373 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5374 cmdline_parse_token_num_t cmd_write_reg_port_id =
5375 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5376 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5377 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5378 cmdline_parse_token_num_t cmd_write_reg_value =
5379 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5381 cmdline_parse_inst_t cmd_write_reg = {
5382 .f = cmd_write_reg_parsed,
5384 .help_str = "write reg port_id reg_off reg_value",
5386 (void *)&cmd_write_reg_write,
5387 (void *)&cmd_write_reg_reg,
5388 (void *)&cmd_write_reg_port_id,
5389 (void *)&cmd_write_reg_reg_off,
5390 (void *)&cmd_write_reg_value,
5395 /* *** WRITE PORT REGISTER BIT FIELD *** */
5396 struct cmd_write_reg_bit_field_result {
5397 cmdline_fixed_string_t write;
5398 cmdline_fixed_string_t regfield;
5407 cmd_write_reg_bit_field_parsed(void *parsed_result,
5408 __attribute__((unused)) struct cmdline *cl,
5409 __attribute__((unused)) void *data)
5411 struct cmd_write_reg_bit_field_result *res = parsed_result;
5412 port_reg_bit_field_set(res->port_id, res->reg_off,
5413 res->bit1_pos, res->bit2_pos, res->value);
5416 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5417 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5419 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5420 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5421 regfield, "regfield");
5422 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5423 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5425 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5426 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5428 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5429 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5431 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5432 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5434 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5435 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5438 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5439 .f = cmd_write_reg_bit_field_parsed,
5441 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5442 "(set register bit field between bit_x and bit_y included)",
5444 (void *)&cmd_write_reg_bit_field_write,
5445 (void *)&cmd_write_reg_bit_field_regfield,
5446 (void *)&cmd_write_reg_bit_field_port_id,
5447 (void *)&cmd_write_reg_bit_field_reg_off,
5448 (void *)&cmd_write_reg_bit_field_bit1_pos,
5449 (void *)&cmd_write_reg_bit_field_bit2_pos,
5450 (void *)&cmd_write_reg_bit_field_value,
5455 /* *** WRITE PORT REGISTER BIT *** */
5456 struct cmd_write_reg_bit_result {
5457 cmdline_fixed_string_t write;
5458 cmdline_fixed_string_t regbit;
5466 cmd_write_reg_bit_parsed(void *parsed_result,
5467 __attribute__((unused)) struct cmdline *cl,
5468 __attribute__((unused)) void *data)
5470 struct cmd_write_reg_bit_result *res = parsed_result;
5471 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5474 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5475 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5477 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5478 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5480 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5481 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5482 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5483 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5484 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5485 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5486 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5487 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5489 cmdline_parse_inst_t cmd_write_reg_bit = {
5490 .f = cmd_write_reg_bit_parsed,
5492 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5494 (void *)&cmd_write_reg_bit_write,
5495 (void *)&cmd_write_reg_bit_regbit,
5496 (void *)&cmd_write_reg_bit_port_id,
5497 (void *)&cmd_write_reg_bit_reg_off,
5498 (void *)&cmd_write_reg_bit_bit_pos,
5499 (void *)&cmd_write_reg_bit_value,
5504 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5505 struct cmd_read_rxd_txd_result {
5506 cmdline_fixed_string_t read;
5507 cmdline_fixed_string_t rxd_txd;
5514 cmd_read_rxd_txd_parsed(void *parsed_result,
5515 __attribute__((unused)) struct cmdline *cl,
5516 __attribute__((unused)) void *data)
5518 struct cmd_read_rxd_txd_result *res = parsed_result;
5520 if (!strcmp(res->rxd_txd, "rxd"))
5521 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5522 else if (!strcmp(res->rxd_txd, "txd"))
5523 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5526 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5527 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5528 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5529 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5531 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5532 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5533 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5534 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5535 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5536 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5538 cmdline_parse_inst_t cmd_read_rxd_txd = {
5539 .f = cmd_read_rxd_txd_parsed,
5541 .help_str = "read rxd|txd port_id queue_id rxd_id",
5543 (void *)&cmd_read_rxd_txd_read,
5544 (void *)&cmd_read_rxd_txd_rxd_txd,
5545 (void *)&cmd_read_rxd_txd_port_id,
5546 (void *)&cmd_read_rxd_txd_queue_id,
5547 (void *)&cmd_read_rxd_txd_desc_id,
5553 struct cmd_quit_result {
5554 cmdline_fixed_string_t quit;
5557 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5559 __attribute__((unused)) void *data)
5565 cmdline_parse_token_string_t cmd_quit_quit =
5566 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5568 cmdline_parse_inst_t cmd_quit = {
5569 .f = cmd_quit_parsed,
5571 .help_str = "exit application",
5573 (void *)&cmd_quit_quit,
5578 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5579 struct cmd_mac_addr_result {
5580 cmdline_fixed_string_t mac_addr_cmd;
5581 cmdline_fixed_string_t what;
5583 struct ether_addr address;
5586 static void cmd_mac_addr_parsed(void *parsed_result,
5587 __attribute__((unused)) struct cmdline *cl,
5588 __attribute__((unused)) void *data)
5590 struct cmd_mac_addr_result *res = parsed_result;
5593 if (strcmp(res->what, "add") == 0)
5594 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5596 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5598 /* check the return value and print it if is < 0 */
5600 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5604 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5605 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5607 cmdline_parse_token_string_t cmd_mac_addr_what =
5608 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5610 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5611 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5612 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5613 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5615 cmdline_parse_inst_t cmd_mac_addr = {
5616 .f = cmd_mac_addr_parsed,
5618 .help_str = "mac_addr add|remove X <address>: "
5619 "add/remove MAC address on port X",
5621 (void *)&cmd_mac_addr_cmd,
5622 (void *)&cmd_mac_addr_what,
5623 (void *)&cmd_mac_addr_portnum,
5624 (void *)&cmd_mac_addr_addr,
5630 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5631 struct cmd_set_qmap_result {
5632 cmdline_fixed_string_t set;
5633 cmdline_fixed_string_t qmap;
5634 cmdline_fixed_string_t what;
5641 cmd_set_qmap_parsed(void *parsed_result,
5642 __attribute__((unused)) struct cmdline *cl,
5643 __attribute__((unused)) void *data)
5645 struct cmd_set_qmap_result *res = parsed_result;
5646 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5648 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5651 cmdline_parse_token_string_t cmd_setqmap_set =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5654 cmdline_parse_token_string_t cmd_setqmap_qmap =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5657 cmdline_parse_token_string_t cmd_setqmap_what =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5660 cmdline_parse_token_num_t cmd_setqmap_portid =
5661 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5663 cmdline_parse_token_num_t cmd_setqmap_queueid =
5664 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5666 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5667 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5670 cmdline_parse_inst_t cmd_set_qmap = {
5671 .f = cmd_set_qmap_parsed,
5673 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5675 (void *)&cmd_setqmap_set,
5676 (void *)&cmd_setqmap_qmap,
5677 (void *)&cmd_setqmap_what,
5678 (void *)&cmd_setqmap_portid,
5679 (void *)&cmd_setqmap_queueid,
5680 (void *)&cmd_setqmap_mapvalue,
5685 /* *** CONFIGURE UNICAST HASH TABLE *** */
5686 struct cmd_set_uc_hash_table {
5687 cmdline_fixed_string_t set;
5688 cmdline_fixed_string_t port;
5690 cmdline_fixed_string_t what;
5691 struct ether_addr address;
5692 cmdline_fixed_string_t mode;
5696 cmd_set_uc_hash_parsed(void *parsed_result,
5697 __attribute__((unused)) struct cmdline *cl,
5698 __attribute__((unused)) void *data)
5701 struct cmd_set_uc_hash_table *res = parsed_result;
5703 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5705 if (strcmp(res->what, "uta") == 0)
5706 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5707 &res->address,(uint8_t)is_on);
5709 printf("bad unicast hash table parameter, return code = %d \n", ret);
5713 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5716 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5719 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5720 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5722 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5725 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5726 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5728 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5732 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5733 .f = cmd_set_uc_hash_parsed,
5735 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5737 (void *)&cmd_set_uc_hash_set,
5738 (void *)&cmd_set_uc_hash_port,
5739 (void *)&cmd_set_uc_hash_portid,
5740 (void *)&cmd_set_uc_hash_what,
5741 (void *)&cmd_set_uc_hash_mac,
5742 (void *)&cmd_set_uc_hash_mode,
5747 struct cmd_set_uc_all_hash_table {
5748 cmdline_fixed_string_t set;
5749 cmdline_fixed_string_t port;
5751 cmdline_fixed_string_t what;
5752 cmdline_fixed_string_t value;
5753 cmdline_fixed_string_t mode;
5757 cmd_set_uc_all_hash_parsed(void *parsed_result,
5758 __attribute__((unused)) struct cmdline *cl,
5759 __attribute__((unused)) void *data)
5762 struct cmd_set_uc_all_hash_table *res = parsed_result;
5764 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5766 if ((strcmp(res->what, "uta") == 0) &&
5767 (strcmp(res->value, "all") == 0))
5768 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5770 printf("bad unicast hash table parameter,"
5771 "return code = %d \n", ret);
5774 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5775 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5777 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5780 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5781 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5783 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5786 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5789 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5793 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5794 .f = cmd_set_uc_all_hash_parsed,
5796 .help_str = "set port X uta all on|off (X = port number)",
5798 (void *)&cmd_set_uc_all_hash_set,
5799 (void *)&cmd_set_uc_all_hash_port,
5800 (void *)&cmd_set_uc_all_hash_portid,
5801 (void *)&cmd_set_uc_all_hash_what,
5802 (void *)&cmd_set_uc_all_hash_value,
5803 (void *)&cmd_set_uc_all_hash_mode,
5808 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5809 struct cmd_set_vf_traffic {
5810 cmdline_fixed_string_t set;
5811 cmdline_fixed_string_t port;
5813 cmdline_fixed_string_t vf;
5815 cmdline_fixed_string_t what;
5816 cmdline_fixed_string_t mode;
5820 cmd_set_vf_traffic_parsed(void *parsed_result,
5821 __attribute__((unused)) struct cmdline *cl,
5822 __attribute__((unused)) void *data)
5824 struct cmd_set_vf_traffic *res = parsed_result;
5825 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5826 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5828 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5831 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5834 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5837 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5838 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5840 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5843 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5844 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5846 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5849 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5853 cmdline_parse_inst_t cmd_set_vf_traffic = {
5854 .f = cmd_set_vf_traffic_parsed,
5856 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
5858 (void *)&cmd_setvf_traffic_set,
5859 (void *)&cmd_setvf_traffic_port,
5860 (void *)&cmd_setvf_traffic_portid,
5861 (void *)&cmd_setvf_traffic_vf,
5862 (void *)&cmd_setvf_traffic_vfid,
5863 (void *)&cmd_setvf_traffic_what,
5864 (void *)&cmd_setvf_traffic_mode,
5869 /* *** CONFIGURE VF RECEIVE MODE *** */
5870 struct cmd_set_vf_rxmode {
5871 cmdline_fixed_string_t set;
5872 cmdline_fixed_string_t port;
5874 cmdline_fixed_string_t vf;
5876 cmdline_fixed_string_t what;
5877 cmdline_fixed_string_t mode;
5878 cmdline_fixed_string_t on;
5882 cmd_set_vf_rxmode_parsed(void *parsed_result,
5883 __attribute__((unused)) struct cmdline *cl,
5884 __attribute__((unused)) void *data)
5887 uint16_t rx_mode = 0;
5888 struct cmd_set_vf_rxmode *res = parsed_result;
5890 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5891 if (!strcmp(res->what,"rxmode")) {
5892 if (!strcmp(res->mode, "AUPE"))
5893 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5894 else if (!strcmp(res->mode, "ROPE"))
5895 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5896 else if (!strcmp(res->mode, "BAM"))
5897 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5898 else if (!strncmp(res->mode, "MPE",3))
5899 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5902 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5904 printf("bad VF receive mode parameter, return code = %d \n",
5908 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5911 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5914 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5917 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5920 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5921 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5923 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5926 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5928 mode, "AUPE#ROPE#BAM#MPE");
5929 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5933 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5934 .f = cmd_set_vf_rxmode_parsed,
5936 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5938 (void *)&cmd_set_vf_rxmode_set,
5939 (void *)&cmd_set_vf_rxmode_port,
5940 (void *)&cmd_set_vf_rxmode_portid,
5941 (void *)&cmd_set_vf_rxmode_vf,
5942 (void *)&cmd_set_vf_rxmode_vfid,
5943 (void *)&cmd_set_vf_rxmode_what,
5944 (void *)&cmd_set_vf_rxmode_mode,
5945 (void *)&cmd_set_vf_rxmode_on,
5950 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5951 struct cmd_vf_mac_addr_result {
5952 cmdline_fixed_string_t mac_addr_cmd;
5953 cmdline_fixed_string_t what;
5954 cmdline_fixed_string_t port;
5956 cmdline_fixed_string_t vf;
5958 struct ether_addr address;
5961 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5962 __attribute__((unused)) struct cmdline *cl,
5963 __attribute__((unused)) void *data)
5965 struct cmd_vf_mac_addr_result *res = parsed_result;
5968 if (strcmp(res->what, "add") == 0)
5969 ret = rte_eth_dev_mac_addr_add(res->port_num,
5970 &res->address, res->vf_num);
5972 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5976 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5977 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5978 mac_addr_cmd,"mac_addr");
5979 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5980 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5982 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5983 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5985 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5986 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5988 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5989 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5991 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5992 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5994 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5995 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5998 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5999 .f = cmd_vf_mac_addr_parsed,
6001 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6002 "Y = VF number)add MAC address filtering for a VF on port X",
6004 (void *)&cmd_vf_mac_addr_cmd,
6005 (void *)&cmd_vf_mac_addr_what,
6006 (void *)&cmd_vf_mac_addr_port,
6007 (void *)&cmd_vf_mac_addr_portnum,
6008 (void *)&cmd_vf_mac_addr_vf,
6009 (void *)&cmd_vf_mac_addr_vfnum,
6010 (void *)&cmd_vf_mac_addr_addr,
6015 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6016 struct cmd_vf_rx_vlan_filter {
6017 cmdline_fixed_string_t rx_vlan;
6018 cmdline_fixed_string_t what;
6020 cmdline_fixed_string_t port;
6022 cmdline_fixed_string_t vf;
6027 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6028 __attribute__((unused)) struct cmdline *cl,
6029 __attribute__((unused)) void *data)
6031 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6033 if (!strcmp(res->what, "add"))
6034 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6036 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6039 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6040 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6041 rx_vlan, "rx_vlan");
6042 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6043 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6045 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6046 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6048 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6049 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6051 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6052 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6054 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6055 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6057 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6058 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6061 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6062 .f = cmd_vf_rx_vlan_filter_parsed,
6064 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6065 "Y = port number,Z = hexadecimal VF mask)",
6067 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6068 (void *)&cmd_vf_rx_vlan_filter_what,
6069 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6070 (void *)&cmd_vf_rx_vlan_filter_port,
6071 (void *)&cmd_vf_rx_vlan_filter_portid,
6072 (void *)&cmd_vf_rx_vlan_filter_vf,
6073 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6078 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6079 struct cmd_queue_rate_limit_result {
6080 cmdline_fixed_string_t set;
6081 cmdline_fixed_string_t port;
6083 cmdline_fixed_string_t queue;
6085 cmdline_fixed_string_t rate;
6089 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6090 __attribute__((unused)) struct cmdline *cl,
6091 __attribute__((unused)) void *data)
6093 struct cmd_queue_rate_limit_result *res = parsed_result;
6096 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6097 && (strcmp(res->queue, "queue") == 0)
6098 && (strcmp(res->rate, "rate") == 0))
6099 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6102 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6106 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6109 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6110 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6112 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6113 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6115 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6116 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6118 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6119 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6121 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6122 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6124 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6125 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6128 cmdline_parse_inst_t cmd_queue_rate_limit = {
6129 .f = cmd_queue_rate_limit_parsed,
6131 .help_str = "set port X queue Y rate Z:(X = port number,"
6132 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6134 (void *)&cmd_queue_rate_limit_set,
6135 (void *)&cmd_queue_rate_limit_port,
6136 (void *)&cmd_queue_rate_limit_portnum,
6137 (void *)&cmd_queue_rate_limit_queue,
6138 (void *)&cmd_queue_rate_limit_queuenum,
6139 (void *)&cmd_queue_rate_limit_rate,
6140 (void *)&cmd_queue_rate_limit_ratenum,
6145 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6146 struct cmd_vf_rate_limit_result {
6147 cmdline_fixed_string_t set;
6148 cmdline_fixed_string_t port;
6150 cmdline_fixed_string_t vf;
6152 cmdline_fixed_string_t rate;
6154 cmdline_fixed_string_t q_msk;
6158 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6159 __attribute__((unused)) struct cmdline *cl,
6160 __attribute__((unused)) void *data)
6162 struct cmd_vf_rate_limit_result *res = parsed_result;
6165 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6166 && (strcmp(res->vf, "vf") == 0)
6167 && (strcmp(res->rate, "rate") == 0)
6168 && (strcmp(res->q_msk, "queue_mask") == 0))
6169 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6170 res->rate_num, res->q_msk_val);
6172 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6176 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6177 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6179 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6180 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6182 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6183 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6185 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6186 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6188 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6189 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6191 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6192 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6194 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6195 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6197 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6198 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6199 q_msk, "queue_mask");
6200 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6201 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6204 cmdline_parse_inst_t cmd_vf_rate_limit = {
6205 .f = cmd_vf_rate_limit_parsed,
6207 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6208 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6209 "for queues of VF on port X",
6211 (void *)&cmd_vf_rate_limit_set,
6212 (void *)&cmd_vf_rate_limit_port,
6213 (void *)&cmd_vf_rate_limit_portnum,
6214 (void *)&cmd_vf_rate_limit_vf,
6215 (void *)&cmd_vf_rate_limit_vfnum,
6216 (void *)&cmd_vf_rate_limit_rate,
6217 (void *)&cmd_vf_rate_limit_ratenum,
6218 (void *)&cmd_vf_rate_limit_q_msk,
6219 (void *)&cmd_vf_rate_limit_q_msk_val,
6224 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6225 struct cmd_set_mirror_mask_result {
6226 cmdline_fixed_string_t set;
6227 cmdline_fixed_string_t port;
6229 cmdline_fixed_string_t mirror;
6231 cmdline_fixed_string_t what;
6232 cmdline_fixed_string_t value;
6233 cmdline_fixed_string_t dstpool;
6235 cmdline_fixed_string_t on;
6238 cmdline_parse_token_string_t cmd_mirror_mask_set =
6239 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6241 cmdline_parse_token_string_t cmd_mirror_mask_port =
6242 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6244 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6245 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6247 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6249 mirror, "mirror-rule");
6250 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6253 cmdline_parse_token_string_t cmd_mirror_mask_what =
6254 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6255 what, "pool-mirror#vlan-mirror");
6256 cmdline_parse_token_string_t cmd_mirror_mask_value =
6257 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6259 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6261 dstpool, "dst-pool");
6262 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6263 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6265 cmdline_parse_token_string_t cmd_mirror_mask_on =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6270 cmd_set_mirror_mask_parsed(void *parsed_result,
6271 __attribute__((unused)) struct cmdline *cl,
6272 __attribute__((unused)) void *data)
6275 struct cmd_set_mirror_mask_result *res = parsed_result;
6276 struct rte_eth_vmdq_mirror_conf mr_conf;
6278 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6280 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6282 mr_conf.dst_pool = res->dstpool_id;
6284 if (!strcmp(res->what, "pool-mirror")) {
6285 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6286 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6287 } else if(!strcmp(res->what, "vlan-mirror")) {
6288 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6289 nb_item = parse_item_list(res->value, "core",
6290 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6294 for(i=0; i < nb_item; i++) {
6295 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6296 printf("Invalid vlan_id: must be < 4096\n");
6300 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6301 mr_conf.vlan.vlan_mask |= 1ULL << i;
6305 if(!strcmp(res->on, "on"))
6306 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6309 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6312 printf("mirror rule add error: (%s)\n", strerror(-ret));
6315 cmdline_parse_inst_t cmd_set_mirror_mask = {
6316 .f = cmd_set_mirror_mask_parsed,
6318 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6319 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6321 (void *)&cmd_mirror_mask_set,
6322 (void *)&cmd_mirror_mask_port,
6323 (void *)&cmd_mirror_mask_portid,
6324 (void *)&cmd_mirror_mask_mirror,
6325 (void *)&cmd_mirror_mask_ruleid,
6326 (void *)&cmd_mirror_mask_what,
6327 (void *)&cmd_mirror_mask_value,
6328 (void *)&cmd_mirror_mask_dstpool,
6329 (void *)&cmd_mirror_mask_poolid,
6330 (void *)&cmd_mirror_mask_on,
6335 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6336 struct cmd_set_mirror_link_result {
6337 cmdline_fixed_string_t set;
6338 cmdline_fixed_string_t port;
6340 cmdline_fixed_string_t mirror;
6342 cmdline_fixed_string_t what;
6343 cmdline_fixed_string_t dstpool;
6345 cmdline_fixed_string_t on;
6348 cmdline_parse_token_string_t cmd_mirror_link_set =
6349 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6351 cmdline_parse_token_string_t cmd_mirror_link_port =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6354 cmdline_parse_token_num_t cmd_mirror_link_portid =
6355 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6357 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6359 mirror, "mirror-rule");
6360 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6361 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6363 cmdline_parse_token_string_t cmd_mirror_link_what =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6365 what, "uplink-mirror#downlink-mirror");
6366 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6368 dstpool, "dst-pool");
6369 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6370 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6372 cmdline_parse_token_string_t cmd_mirror_link_on =
6373 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6377 cmd_set_mirror_link_parsed(void *parsed_result,
6378 __attribute__((unused)) struct cmdline *cl,
6379 __attribute__((unused)) void *data)
6382 struct cmd_set_mirror_link_result *res = parsed_result;
6383 struct rte_eth_vmdq_mirror_conf mr_conf;
6385 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6386 if(!strcmp(res->what, "uplink-mirror")) {
6387 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6388 }else if(!strcmp(res->what, "downlink-mirror"))
6389 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6391 mr_conf.dst_pool = res->dstpool_id;
6393 if(!strcmp(res->on, "on"))
6394 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6397 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6400 /* check the return value and print it if is < 0 */
6402 printf("mirror rule add error: (%s)\n", strerror(-ret));
6406 cmdline_parse_inst_t cmd_set_mirror_link = {
6407 .f = cmd_set_mirror_link_parsed,
6409 .help_str = "set port X mirror-rule Y uplink-mirror|"
6410 "downlink-mirror dst-pool Z on|off",
6412 (void *)&cmd_mirror_link_set,
6413 (void *)&cmd_mirror_link_port,
6414 (void *)&cmd_mirror_link_portid,
6415 (void *)&cmd_mirror_link_mirror,
6416 (void *)&cmd_mirror_link_ruleid,
6417 (void *)&cmd_mirror_link_what,
6418 (void *)&cmd_mirror_link_dstpool,
6419 (void *)&cmd_mirror_link_poolid,
6420 (void *)&cmd_mirror_link_on,
6425 /* *** RESET VM MIRROR RULE *** */
6426 struct cmd_rm_mirror_rule_result {
6427 cmdline_fixed_string_t reset;
6428 cmdline_fixed_string_t port;
6430 cmdline_fixed_string_t mirror;
6434 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6435 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6437 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6438 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6440 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6441 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6443 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6444 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6445 mirror, "mirror-rule");
6446 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6447 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6451 cmd_reset_mirror_rule_parsed(void *parsed_result,
6452 __attribute__((unused)) struct cmdline *cl,
6453 __attribute__((unused)) void *data)
6456 struct cmd_set_mirror_link_result *res = parsed_result;
6458 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6460 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6463 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6464 .f = cmd_reset_mirror_rule_parsed,
6466 .help_str = "reset port X mirror-rule Y",
6468 (void *)&cmd_rm_mirror_rule_reset,
6469 (void *)&cmd_rm_mirror_rule_port,
6470 (void *)&cmd_rm_mirror_rule_portid,
6471 (void *)&cmd_rm_mirror_rule_mirror,
6472 (void *)&cmd_rm_mirror_rule_ruleid,
6477 /* ******************************************************************************** */
6479 struct cmd_dump_result {
6480 cmdline_fixed_string_t dump;
6484 dump_struct_sizes(void)
6486 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6487 DUMP_SIZE(struct rte_mbuf);
6488 DUMP_SIZE(struct rte_mempool);
6489 DUMP_SIZE(struct rte_ring);
6493 static void cmd_dump_parsed(void *parsed_result,
6494 __attribute__((unused)) struct cmdline *cl,
6495 __attribute__((unused)) void *data)
6497 struct cmd_dump_result *res = parsed_result;
6499 if (!strcmp(res->dump, "dump_physmem"))
6500 rte_dump_physmem_layout(stdout);
6501 else if (!strcmp(res->dump, "dump_memzone"))
6502 rte_memzone_dump(stdout);
6503 else if (!strcmp(res->dump, "dump_log_history"))
6504 rte_log_dump_history(stdout);
6505 else if (!strcmp(res->dump, "dump_struct_sizes"))
6506 dump_struct_sizes();
6507 else if (!strcmp(res->dump, "dump_ring"))
6508 rte_ring_list_dump(stdout);
6509 else if (!strcmp(res->dump, "dump_mempool"))
6510 rte_mempool_list_dump(stdout);
6511 else if (!strcmp(res->dump, "dump_devargs"))
6512 rte_eal_devargs_dump(stdout);
6515 cmdline_parse_token_string_t cmd_dump_dump =
6516 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6520 "dump_struct_sizes#"
6525 cmdline_parse_inst_t cmd_dump = {
6526 .f = cmd_dump_parsed, /* function to call */
6527 .data = NULL, /* 2nd arg of func */
6528 .help_str = "dump status",
6529 .tokens = { /* token list, NULL terminated */
6530 (void *)&cmd_dump_dump,
6535 /* ******************************************************************************** */
6537 struct cmd_dump_one_result {
6538 cmdline_fixed_string_t dump;
6539 cmdline_fixed_string_t name;
6542 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6543 __attribute__((unused)) void *data)
6545 struct cmd_dump_one_result *res = parsed_result;
6547 if (!strcmp(res->dump, "dump_ring")) {
6549 r = rte_ring_lookup(res->name);
6551 cmdline_printf(cl, "Cannot find ring\n");
6554 rte_ring_dump(stdout, r);
6555 } else if (!strcmp(res->dump, "dump_mempool")) {
6556 struct rte_mempool *mp;
6557 mp = rte_mempool_lookup(res->name);
6559 cmdline_printf(cl, "Cannot find mempool\n");
6562 rte_mempool_dump(stdout, mp);
6566 cmdline_parse_token_string_t cmd_dump_one_dump =
6567 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6568 "dump_ring#dump_mempool");
6570 cmdline_parse_token_string_t cmd_dump_one_name =
6571 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6573 cmdline_parse_inst_t cmd_dump_one = {
6574 .f = cmd_dump_one_parsed, /* function to call */
6575 .data = NULL, /* 2nd arg of func */
6576 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6577 .tokens = { /* token list, NULL terminated */
6578 (void *)&cmd_dump_one_dump,
6579 (void *)&cmd_dump_one_name,
6584 /* *** ADD/REMOVE an ethertype FILTER *** */
6585 struct cmd_ethertype_filter_result {
6586 cmdline_fixed_string_t filter;
6588 cmdline_fixed_string_t ethertype;
6589 uint16_t ethertype_value;
6590 cmdline_fixed_string_t priority;
6591 cmdline_fixed_string_t priority_en;
6592 uint8_t priority_value;
6593 cmdline_fixed_string_t queue;
6595 cmdline_fixed_string_t index;
6596 uint16_t index_value;
6600 cmd_ethertype_filter_parsed(void *parsed_result,
6601 __attribute__((unused)) struct cmdline *cl,
6602 __attribute__((unused)) void *data)
6605 struct cmd_ethertype_filter_result *res = parsed_result;
6606 struct rte_ethertype_filter filter;
6608 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6609 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6610 filter.priority = res->priority_value;
6612 if (!strcmp(res->priority_en, "enable"))
6613 filter.priority_en = 1;
6614 if (!strcmp(res->filter, "add_ethertype_filter"))
6615 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6617 &filter, res->queue_id);
6618 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6619 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6621 else if (!strcmp(res->filter, "get_ethertype_filter"))
6622 get_ethertype_filter(res->port_id, res->index_value);
6625 printf("ethertype filter setting error: (%s)\n",
6629 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6630 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6632 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6633 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6634 ethertype, "ethertype");
6635 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6636 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6637 ethertype_value, UINT16);
6638 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6639 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6640 priority, "priority");
6641 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6642 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6643 priority_en, "enable#disable");
6644 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6645 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6646 priority_value, UINT8);
6647 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6648 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6650 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6651 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6653 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6656 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6657 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6658 index_value, UINT16);
6659 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6660 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6661 filter, "add_ethertype_filter");
6662 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6663 .f = cmd_ethertype_filter_parsed,
6665 .help_str = "add an ethertype filter",
6667 (void *)&cmd_ethertype_filter_add_filter,
6668 (void *)&cmd_ethertype_filter_port_id,
6669 (void *)&cmd_ethertype_filter_ethertype,
6670 (void *)&cmd_ethertype_filter_ethertype_value,
6671 (void *)&cmd_ethertype_filter_priority,
6672 (void *)&cmd_ethertype_filter_priority_en,
6673 (void *)&cmd_ethertype_filter_priority_value,
6674 (void *)&cmd_ethertype_filter_queue,
6675 (void *)&cmd_ethertype_filter_queue_id,
6676 (void *)&cmd_ethertype_filter_index,
6677 (void *)&cmd_ethertype_filter_index_value,
6682 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
6683 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6684 filter, "remove_ethertype_filter");
6685 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
6686 .f = cmd_ethertype_filter_parsed,
6688 .help_str = "remove an ethertype filter",
6690 (void *)&cmd_ethertype_filter_remove_filter,
6691 (void *)&cmd_ethertype_filter_port_id,
6692 (void *)&cmd_ethertype_filter_index,
6693 (void *)&cmd_ethertype_filter_index_value,
6697 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
6698 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6699 filter, "get_ethertype_filter");
6700 cmdline_parse_inst_t cmd_get_ethertype_filter = {
6701 .f = cmd_ethertype_filter_parsed,
6703 .help_str = "get an ethertype filter",
6705 (void *)&cmd_ethertype_filter_get_filter,
6706 (void *)&cmd_ethertype_filter_port_id,
6707 (void *)&cmd_ethertype_filter_index,
6708 (void *)&cmd_ethertype_filter_index_value,
6713 /* *** set SYN filter *** */
6714 struct cmd_set_syn_filter_result {
6715 cmdline_fixed_string_t filter;
6717 cmdline_fixed_string_t priority;
6718 cmdline_fixed_string_t high;
6719 cmdline_fixed_string_t queue;
6724 cmd_set_syn_filter_parsed(void *parsed_result,
6725 __attribute__((unused)) struct cmdline *cl,
6726 __attribute__((unused)) void *data)
6729 struct cmd_set_syn_filter_result *res = parsed_result;
6730 struct rte_syn_filter filter;
6732 if (!strcmp(res->filter, "add_syn_filter")) {
6733 if (!strcmp(res->high, "high"))
6737 ret = rte_eth_dev_add_syn_filter(res->port_id,
6738 &filter, res->queue_id);
6739 } else if (!strcmp(res->filter, "remove_syn_filter"))
6740 ret = rte_eth_dev_remove_syn_filter(res->port_id);
6741 else if (!strcmp(res->filter, "get_syn_filter"))
6742 get_syn_filter(res->port_id);
6744 printf("syn filter setting error: (%s)\n", strerror(-ret));
6747 cmdline_parse_token_num_t cmd_syn_filter_portid =
6748 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6750 cmdline_parse_token_string_t cmd_syn_filter_priority =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6752 priority, "priority");
6753 cmdline_parse_token_string_t cmd_syn_filter_high =
6754 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6756 cmdline_parse_token_string_t cmd_syn_filter_queue =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6759 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
6760 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
6762 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6764 filter, "add_syn_filter");
6765 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6767 filter, "remove_syn_filter");
6768 cmdline_parse_inst_t cmd_add_syn_filter = {
6769 .f = cmd_set_syn_filter_parsed,
6771 .help_str = "add syn filter",
6773 (void *)&cmd_syn_filter_add_filter,
6774 (void *)&cmd_syn_filter_portid,
6775 (void *)&cmd_syn_filter_priority,
6776 (void *)&cmd_syn_filter_high,
6777 (void *)&cmd_syn_filter_queue,
6778 (void *)&cmd_syn_filter_queue_id,
6782 cmdline_parse_inst_t cmd_remove_syn_filter = {
6783 .f = cmd_set_syn_filter_parsed,
6785 .help_str = "remove syn filter",
6787 (void *)&cmd_syn_filter_remove_filter,
6788 (void *)&cmd_syn_filter_portid,
6793 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
6794 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
6795 filter, "get_syn_filter");
6797 cmdline_parse_inst_t cmd_get_syn_filter = {
6798 .f = cmd_set_syn_filter_parsed,
6800 .help_str = "get syn filter",
6802 (void *)&cmd_syn_filter_get_filter,
6803 (void *)&cmd_syn_filter_portid,
6808 /* *** ADD/REMOVE A 2tuple FILTER *** */
6809 struct cmd_2tuple_filter_result {
6810 cmdline_fixed_string_t filter;
6812 cmdline_fixed_string_t protocol;
6813 uint8_t protocol_value;
6814 uint8_t protocol_mask;
6815 cmdline_fixed_string_t dst_port;
6816 uint16_t dst_port_value;
6817 uint16_t dst_port_mask;
6818 cmdline_fixed_string_t flags;
6819 uint8_t flags_value;
6820 cmdline_fixed_string_t priority;
6821 uint8_t priority_value;
6822 cmdline_fixed_string_t queue;
6824 cmdline_fixed_string_t index;
6825 uint16_t index_value;
6829 cmd_2tuple_filter_parsed(void *parsed_result,
6830 __attribute__((unused)) struct cmdline *cl,
6831 __attribute__((unused)) void *data)
6834 struct rte_2tuple_filter filter;
6835 struct cmd_2tuple_filter_result *res = parsed_result;
6837 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
6839 if (!strcmp(res->filter, "add_2tuple_filter")) {
6840 /* need convert to big endian. */
6841 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6842 filter.protocol = res->protocol_value;
6843 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
6844 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
6845 filter.priority = res->priority_value;
6846 filter.tcp_flags = res->flags_value;
6847 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
6848 res->index_value, &filter, res->queue_id);
6849 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
6850 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
6852 else if (!strcmp(res->filter, "get_2tuple_filter"))
6853 get_2tuple_filter(res->port_id, res->index_value);
6856 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
6859 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
6860 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6862 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6863 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6864 protocol, "protocol");
6865 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6866 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6867 protocol_value, UINT8);
6868 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6869 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6870 protocol_mask, UINT8);
6871 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6872 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6873 dst_port, "dst_port");
6874 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6875 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6876 dst_port_value, UINT16);
6877 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6878 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6879 dst_port_mask, UINT16);
6880 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6881 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6883 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6884 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6885 flags_value, UINT8);
6886 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6887 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6888 priority, "priority");
6889 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6890 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6891 priority_value, UINT8);
6892 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6893 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6895 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6896 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6898 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6899 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6901 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6902 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6903 index_value, UINT16);
6904 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6905 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6906 filter, "add_2tuple_filter");
6907 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6908 .f = cmd_2tuple_filter_parsed,
6910 .help_str = "add a 2tuple filter",
6912 (void *)&cmd_2tuple_filter_add_filter,
6913 (void *)&cmd_2tuple_filter_port_id,
6914 (void *)&cmd_2tuple_filter_protocol,
6915 (void *)&cmd_2tuple_filter_protocol_value,
6916 (void *)&cmd_2tuple_filter_protocol_mask,
6917 (void *)&cmd_2tuple_filter_dst_port,
6918 (void *)&cmd_2tuple_filter_dst_port_value,
6919 (void *)&cmd_2tuple_filter_dst_port_mask,
6920 (void *)&cmd_2tuple_filter_flags,
6921 (void *)&cmd_2tuple_filter_flags_value,
6922 (void *)&cmd_2tuple_filter_priority,
6923 (void *)&cmd_2tuple_filter_priority_value,
6924 (void *)&cmd_2tuple_filter_queue,
6925 (void *)&cmd_2tuple_filter_queue_id,
6926 (void *)&cmd_2tuple_filter_index,
6927 (void *)&cmd_2tuple_filter_index_value,
6932 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6933 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6934 filter, "remove_2tuple_filter");
6935 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6936 .f = cmd_2tuple_filter_parsed,
6938 .help_str = "remove a 2tuple filter",
6940 (void *)&cmd_2tuple_filter_remove_filter,
6941 (void *)&cmd_2tuple_filter_port_id,
6942 (void *)&cmd_2tuple_filter_index,
6943 (void *)&cmd_2tuple_filter_index_value,
6947 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6948 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6949 filter, "get_2tuple_filter");
6950 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6951 .f = cmd_2tuple_filter_parsed,
6953 .help_str = "get a 2tuple filter",
6955 (void *)&cmd_2tuple_filter_get_filter,
6956 (void *)&cmd_2tuple_filter_port_id,
6957 (void *)&cmd_2tuple_filter_index,
6958 (void *)&cmd_2tuple_filter_index_value,
6963 /* *** ADD/REMOVE A 5tuple FILTER *** */
6964 struct cmd_5tuple_filter_result {
6965 cmdline_fixed_string_t filter;
6967 cmdline_fixed_string_t dst_ip;
6968 cmdline_ipaddr_t dst_ip_value;
6969 cmdline_fixed_string_t src_ip;
6970 cmdline_ipaddr_t src_ip_value;
6971 cmdline_fixed_string_t dst_port;
6972 uint16_t dst_port_value;
6973 cmdline_fixed_string_t src_port;
6974 uint16_t src_port_value;
6975 cmdline_fixed_string_t protocol;
6976 uint8_t protocol_value;
6977 cmdline_fixed_string_t mask;
6979 cmdline_fixed_string_t flags;
6980 uint8_t flags_value;
6981 cmdline_fixed_string_t priority;
6982 uint8_t priority_value;
6983 cmdline_fixed_string_t queue;
6985 cmdline_fixed_string_t index;
6986 uint16_t index_value;
6990 cmd_5tuple_filter_parsed(void *parsed_result,
6991 __attribute__((unused)) struct cmdline *cl,
6992 __attribute__((unused)) void *data)
6995 struct rte_5tuple_filter filter;
6996 struct cmd_5tuple_filter_result *res = parsed_result;
6998 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7000 if (!strcmp(res->filter, "add_5tuple_filter")) {
7001 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7002 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7003 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7004 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7005 filter.protocol = res->protocol_value;
7006 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7007 filter.priority = res->priority_value;
7008 filter.tcp_flags = res->flags_value;
7010 if (res->dst_ip_value.family == AF_INET)
7011 /* no need to convert, already big endian. */
7012 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7014 if (filter.dst_ip_mask == 0) {
7015 printf("can not support ipv6 involved compare.\n");
7021 if (res->src_ip_value.family == AF_INET)
7022 /* no need to convert, already big endian. */
7023 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7025 if (filter.src_ip_mask == 0) {
7026 printf("can not support ipv6 involved compare.\n");
7031 /* need convert to big endian. */
7032 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7033 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7035 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7036 res->index_value, &filter, res->queue_id);
7037 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7038 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7040 else if (!strcmp(res->filter, "get_5tuple_filter"))
7041 get_5tuple_filter(res->port_id, res->index_value);
7043 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7047 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7048 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7050 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7051 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7053 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7054 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7056 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7057 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7059 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7060 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7062 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7063 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7064 dst_port, "dst_port");
7065 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7066 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7067 dst_port_value, UINT16);
7068 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7069 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7070 src_port, "src_port");
7071 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7072 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7073 src_port_value, UINT16);
7074 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7075 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7076 protocol, "protocol");
7077 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7078 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7079 protocol_value, UINT8);
7080 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7081 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7083 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7084 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7086 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7087 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7089 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7090 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7091 flags_value, UINT8);
7092 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7093 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7094 priority, "priority");
7095 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7096 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7097 priority_value, UINT8);
7098 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7099 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7101 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7102 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7104 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7105 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7107 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7108 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7109 index_value, UINT16);
7111 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7112 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7113 filter, "add_5tuple_filter");
7114 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7115 .f = cmd_5tuple_filter_parsed,
7117 .help_str = "add a 5tuple filter",
7119 (void *)&cmd_5tuple_filter_add_filter,
7120 (void *)&cmd_5tuple_filter_port_id,
7121 (void *)&cmd_5tuple_filter_dst_ip,
7122 (void *)&cmd_5tuple_filter_dst_ip_value,
7123 (void *)&cmd_5tuple_filter_src_ip,
7124 (void *)&cmd_5tuple_filter_src_ip_value,
7125 (void *)&cmd_5tuple_filter_dst_port,
7126 (void *)&cmd_5tuple_filter_dst_port_value,
7127 (void *)&cmd_5tuple_filter_src_port,
7128 (void *)&cmd_5tuple_filter_src_port_value,
7129 (void *)&cmd_5tuple_filter_protocol,
7130 (void *)&cmd_5tuple_filter_protocol_value,
7131 (void *)&cmd_5tuple_filter_mask,
7132 (void *)&cmd_5tuple_filter_mask_value,
7133 (void *)&cmd_5tuple_filter_flags,
7134 (void *)&cmd_5tuple_filter_flags_value,
7135 (void *)&cmd_5tuple_filter_priority,
7136 (void *)&cmd_5tuple_filter_priority_value,
7137 (void *)&cmd_5tuple_filter_queue,
7138 (void *)&cmd_5tuple_filter_queue_id,
7139 (void *)&cmd_5tuple_filter_index,
7140 (void *)&cmd_5tuple_filter_index_value,
7145 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7146 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7147 filter, "remove_5tuple_filter");
7148 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7149 .f = cmd_5tuple_filter_parsed,
7151 .help_str = "remove a 5tuple filter",
7153 (void *)&cmd_5tuple_filter_remove_filter,
7154 (void *)&cmd_5tuple_filter_port_id,
7155 (void *)&cmd_5tuple_filter_index,
7156 (void *)&cmd_5tuple_filter_index_value,
7161 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7162 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7163 filter, "get_5tuple_filter");
7164 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7165 .f = cmd_5tuple_filter_parsed,
7167 .help_str = "get a 5tuple filter",
7169 (void *)&cmd_5tuple_filter_get_filter,
7170 (void *)&cmd_5tuple_filter_port_id,
7171 (void *)&cmd_5tuple_filter_index,
7172 (void *)&cmd_5tuple_filter_index_value,
7177 /* *** ADD/REMOVE A flex FILTER *** */
7178 struct cmd_flex_filter_result {
7179 cmdline_fixed_string_t filter;
7181 cmdline_fixed_string_t len;
7183 cmdline_fixed_string_t bytes;
7184 cmdline_fixed_string_t bytes_value;
7185 cmdline_fixed_string_t mask;
7186 cmdline_fixed_string_t mask_value;
7187 cmdline_fixed_string_t priority;
7188 uint8_t priority_value;
7189 cmdline_fixed_string_t queue;
7191 cmdline_fixed_string_t index;
7192 uint16_t index_value;
7195 static int xdigit2val(unsigned char c)
7200 else if (isupper(c))
7208 cmd_flex_filter_parsed(void *parsed_result,
7209 __attribute__((unused)) struct cmdline *cl,
7210 __attribute__((unused)) void *data)
7213 struct rte_flex_filter filter;
7214 struct cmd_flex_filter_result *res = parsed_result;
7215 char *bytes_ptr, *mask_ptr;
7223 if (!strcmp(res->filter, "add_flex_filter")) {
7224 if (res->len_value > 128) {
7225 printf("the len exceed the max length 128\n");
7228 memset(&filter, 0, sizeof(struct rte_flex_filter));
7229 filter.len = res->len_value;
7230 filter.priority = res->priority_value;
7231 bytes_ptr = res->bytes_value;
7232 mask_ptr = res->mask_value;
7235 /* translate bytes string to uint_32 array. */
7236 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7237 (bytes_ptr[1] == 'X')))
7239 len = strnlen(bytes_ptr, res->len_value * 2);
7240 if (len == 0 || (len % 8 != 0)) {
7241 printf("please check len and bytes input\n");
7244 for (i = 0; i < len; i++) {
7246 if (isxdigit(c) == 0) {
7247 /* invalid characters. */
7248 printf("invalid input\n");
7251 val = xdigit2val(c);
7255 dword |= byte << (4 * mod - 4);
7260 filter.dwords[j] = dword;
7261 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7267 /* translate mask string to uint8_t array. */
7269 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7270 (mask_ptr[1] == 'X')))
7272 len = strnlen(mask_ptr, (res->len_value+3)/4);
7274 printf("invalid input\n");
7277 for (i = 0; i < len; i++) {
7279 if (isxdigit(c) == 0) {
7280 /* invalid characters. */
7281 printf("invalid input\n");
7284 val = xdigit2val(c);
7285 hex |= (uint8_t)(val & 0x8) >> 3;
7286 hex |= (uint8_t)(val & 0x4) >> 1;
7287 hex |= (uint8_t)(val & 0x2) << 1;
7288 hex |= (uint8_t)(val & 0x1) << 3;
7291 filter.mask[j] = byte;
7292 printf("mask[%d]:%02x ", j, filter.mask[j]);
7300 printf("call function rte_eth_dev_add_flex_filter: "
7301 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7302 res->index_value, res->queue_id,
7303 filter.len, filter.priority);
7304 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7305 &filter, res->queue_id);
7307 } else if (!strcmp(res->filter, "remove_flex_filter"))
7308 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7310 else if (!strcmp(res->filter, "get_flex_filter"))
7311 get_flex_filter(res->port_id, res->index_value);
7314 printf("flex filter setting error: (%s)\n", strerror(-ret));
7317 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7318 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7320 cmdline_parse_token_string_t cmd_flex_filter_len =
7321 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7323 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7324 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7326 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7327 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7329 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7330 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7332 cmdline_parse_token_string_t cmd_flex_filter_mask =
7333 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7335 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7336 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7338 cmdline_parse_token_string_t cmd_flex_filter_priority =
7339 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7340 priority, "priority");
7341 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7342 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7343 priority_value, UINT8);
7344 cmdline_parse_token_string_t cmd_flex_filter_queue =
7345 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7347 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7348 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7350 cmdline_parse_token_string_t cmd_flex_filter_index =
7351 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7353 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7354 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7355 index_value, UINT16);
7356 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7357 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7358 filter, "add_flex_filter");
7359 cmdline_parse_inst_t cmd_add_flex_filter = {
7360 .f = cmd_flex_filter_parsed,
7362 .help_str = "add a flex filter",
7364 (void *)&cmd_flex_filter_add_filter,
7365 (void *)&cmd_flex_filter_port_id,
7366 (void *)&cmd_flex_filter_len,
7367 (void *)&cmd_flex_filter_len_value,
7368 (void *)&cmd_flex_filter_bytes,
7369 (void *)&cmd_flex_filter_bytes_value,
7370 (void *)&cmd_flex_filter_mask,
7371 (void *)&cmd_flex_filter_mask_value,
7372 (void *)&cmd_flex_filter_priority,
7373 (void *)&cmd_flex_filter_priority_value,
7374 (void *)&cmd_flex_filter_queue,
7375 (void *)&cmd_flex_filter_queue_id,
7376 (void *)&cmd_flex_filter_index,
7377 (void *)&cmd_flex_filter_index_value,
7382 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7383 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7384 filter, "remove_flex_filter");
7385 cmdline_parse_inst_t cmd_remove_flex_filter = {
7386 .f = cmd_flex_filter_parsed,
7388 .help_str = "remove a flex filter",
7390 (void *)&cmd_flex_filter_remove_filter,
7391 (void *)&cmd_flex_filter_port_id,
7392 (void *)&cmd_flex_filter_index,
7393 (void *)&cmd_flex_filter_index_value,
7398 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7399 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7400 filter, "get_flex_filter");
7401 cmdline_parse_inst_t cmd_get_flex_filter = {
7402 .f = cmd_flex_filter_parsed,
7404 .help_str = "get a flex filter",
7406 (void *)&cmd_flex_filter_get_filter,
7407 (void *)&cmd_flex_filter_port_id,
7408 (void *)&cmd_flex_filter_index,
7409 (void *)&cmd_flex_filter_index_value,
7414 /* ******************************************************************************** */
7416 /* list of instructions */
7417 cmdline_parse_ctx_t main_ctx[] = {
7418 (cmdline_parse_inst_t *)&cmd_help_brief,
7419 (cmdline_parse_inst_t *)&cmd_help_long,
7420 (cmdline_parse_inst_t *)&cmd_quit,
7421 (cmdline_parse_inst_t *)&cmd_showport,
7422 (cmdline_parse_inst_t *)&cmd_showportall,
7423 (cmdline_parse_inst_t *)&cmd_showcfg,
7424 (cmdline_parse_inst_t *)&cmd_start,
7425 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7426 (cmdline_parse_inst_t *)&cmd_set_link_up,
7427 (cmdline_parse_inst_t *)&cmd_set_link_down,
7428 (cmdline_parse_inst_t *)&cmd_reset,
7429 (cmdline_parse_inst_t *)&cmd_set_numbers,
7430 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7431 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7432 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7433 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7434 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7435 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7436 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7437 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7438 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7439 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7440 (cmdline_parse_inst_t *)&cmd_set_link_check,
7441 #ifdef RTE_NIC_BYPASS
7442 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7443 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7444 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7445 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7447 #ifdef RTE_LIBRTE_PMD_BOND
7448 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7449 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7450 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7451 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7452 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7453 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7454 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7455 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7457 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7458 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7459 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7460 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7461 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7462 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7463 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7464 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7465 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7466 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7467 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7470 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7471 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7472 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7473 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7474 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7475 (cmdline_parse_inst_t *)&cmd_config_dcb,
7476 (cmdline_parse_inst_t *)&cmd_read_reg,
7477 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7478 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7479 (cmdline_parse_inst_t *)&cmd_write_reg,
7480 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7481 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7482 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7483 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7484 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7485 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7486 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7487 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7488 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7489 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7490 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7491 (cmdline_parse_inst_t *)&cmd_stop,
7492 (cmdline_parse_inst_t *)&cmd_mac_addr,
7493 (cmdline_parse_inst_t *)&cmd_set_qmap,
7494 (cmdline_parse_inst_t *)&cmd_operate_port,
7495 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7496 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7497 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7498 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7499 (cmdline_parse_inst_t *)&cmd_config_mtu,
7500 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7501 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7502 (cmdline_parse_inst_t *)&cmd_config_rss,
7503 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7504 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7505 (cmdline_parse_inst_t *)&cmd_showport_reta,
7506 (cmdline_parse_inst_t *)&cmd_config_burst,
7507 (cmdline_parse_inst_t *)&cmd_config_thresh,
7508 (cmdline_parse_inst_t *)&cmd_config_threshold,
7509 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7510 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7511 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7512 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
7513 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7514 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7515 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7516 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7517 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7518 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7519 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7520 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7521 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7522 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7523 (cmdline_parse_inst_t *)&cmd_dump,
7524 (cmdline_parse_inst_t *)&cmd_dump_one,
7525 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7526 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7527 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7528 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7529 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7530 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7531 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7532 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7533 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7534 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7535 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7536 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7537 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7538 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7539 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7543 /* prompt function, called from main on MASTER lcore */
7549 /* initialize non-constant commands */
7550 cmd_set_fwd_mode_init();
7552 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7556 cmdline_interact(cl);
7557 cmdline_stdin_exit(cl);
7561 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7563 if (id < nb_ports) {
7564 /* check if need_reconfig has been set to 1 */
7565 if (ports[id].need_reconfig == 0)
7566 ports[id].need_reconfig = dev;
7567 /* check if need_reconfig_queues has been set to 1 */
7568 if (ports[id].need_reconfig_queues == 0)
7569 ports[id].need_reconfig_queues = queue;
7573 for (pid = 0; pid < nb_ports; pid++) {
7574 /* check if need_reconfig has been set to 1 */
7575 if (ports[pid].need_reconfig == 0)
7576 ports[pid].need_reconfig = dev;
7577 /* check if need_reconfig_queues has been set to 1 */
7578 if (ports[pid].need_reconfig_queues == 0)
7579 ports[pid].need_reconfig_queues = queue;
7584 #ifdef RTE_NIC_BYPASS
7586 bypass_is_supported(portid_t port_id)
7588 struct rte_port *port;
7589 struct rte_pci_id *pci_id;
7591 if (port_id >= nb_ports) {
7592 printf("\tPort id must be less than %d.\n", nb_ports);
7596 /* Get the device id. */
7597 port = &ports[port_id];
7598 pci_id = &port->dev_info.pci_dev->id;
7600 /* Check if NIC supports bypass. */
7601 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7605 printf("\tBypass not supported for port_id = %d.\n", port_id);