4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_launch.h>
63 #include <rte_tailq.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
78 #include <cmdline_rdline.h>
79 #include <cmdline_parse.h>
80 #include <cmdline_parse_num.h>
81 #include <cmdline_parse_string.h>
82 #include <cmdline_parse_ipaddr.h>
83 #include <cmdline_parse_etheraddr.h>
84 #include <cmdline_socket.h>
86 #include <rte_pci_dev_ids.h>
87 #ifdef RTE_LIBRTE_PMD_BOND
88 #include <rte_eth_bond.h>
93 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
96 uint8_t bypass_is_supported(portid_t port_id);
99 /* *** Help command with introduction. *** */
100 struct cmd_help_brief_result {
101 cmdline_fixed_string_t help;
104 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
106 __attribute__((unused)) void *data)
111 "Help is available for the following sections:\n\n"
112 " help control : Start and stop forwarding.\n"
113 " help display : Displaying port, stats and config "
115 " help config : Configuration information.\n"
116 " help ports : Configuring ports.\n"
117 " help flowdir : Flow Director filter help.\n"
118 " help registers : Reading and setting port registers.\n"
119 " help filters : Filters configuration help.\n"
120 " help all : All of the above sections.\n\n"
125 cmdline_parse_token_string_t cmd_help_brief_help =
126 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
128 cmdline_parse_inst_t cmd_help_brief = {
129 .f = cmd_help_brief_parsed,
131 .help_str = "show help",
133 (void *)&cmd_help_brief_help,
138 /* *** Help command with help sections. *** */
139 struct cmd_help_long_result {
140 cmdline_fixed_string_t help;
141 cmdline_fixed_string_t section;
144 static void cmd_help_long_parsed(void *parsed_result,
146 __attribute__((unused)) void *data)
149 struct cmd_help_long_result *res = parsed_result;
151 if (!strcmp(res->section, "all"))
154 if (show_all || !strcmp(res->section, "control")) {
159 "Control forwarding:\n"
160 "-------------------\n\n"
163 " Start packet forwarding with current configuration.\n\n"
166 " Start packet forwarding with current config"
167 " after sending one burst of packets.\n\n"
170 " Stop packet forwarding, and display accumulated"
174 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
178 if (show_all || !strcmp(res->section, "display")) {
186 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
187 " Display information for port_id, or all.\n\n"
189 "show port rss-hash [key]\n"
190 " Display the RSS hash functions and RSS hash key"
193 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
194 " Clear information for port_id, or all.\n\n"
196 "show config (rxtx|cores|fwd)\n"
197 " Display the given configuration.\n\n"
199 "read rxd (port_id) (queue_id) (rxd_id)\n"
200 " Display an RX descriptor of a port RX queue.\n\n"
202 "read txd (port_id) (queue_id) (txd_id)\n"
203 " Display a TX descriptor of a port TX queue.\n\n"
207 if (show_all || !strcmp(res->section, "config")) {
213 "Configuration changes only become active when"
214 " forwarding is started/restarted.\n\n"
217 " Reset forwarding to the default configuration.\n\n"
219 "set verbose (level)\n"
220 " Set the debug verbosity level X.\n\n"
223 " Set number of ports.\n\n"
226 " Set number of cores.\n\n"
228 "set coremask (mask)\n"
229 " Set the forwarding cores hexadecimal mask.\n\n"
231 "set portmask (mask)\n"
232 " Set the forwarding ports hexadecimal mask.\n\n"
235 " Set number of packets per burst.\n\n"
237 "set burst tx delay (microseconds) retry (num)\n"
238 " Set the transmit delay time and number of retries"
239 " in mac_retry forwarding mode.\n\n"
241 "set txpkts (x[,y]*)\n"
242 " Set the length of each segment of TXONLY"
245 "set corelist (x[,y]*)\n"
246 " Set the list of forwarding cores.\n\n"
248 "set portlist (x[,y]*)\n"
249 " Set the list of forwarding ports.\n\n"
251 "vlan set strip (on|off) (port_id)\n"
252 " Set the VLAN strip on a port.\n\n"
254 "vlan set stripq (on|off) (port_id,queue_id)\n"
255 " Set the VLAN strip for a queue on a port.\n\n"
257 "vlan set filter (on|off) (port_id)\n"
258 " Set the VLAN filter on a port.\n\n"
260 "vlan set qinq (on|off) (port_id)\n"
261 " Set the VLAN QinQ (extended queue in queue)"
264 "vlan set tpid (value) (port_id)\n"
265 " Set the outer VLAN TPID for Packet Filtering on"
268 "rx_vlan add (vlan_id|all) (port_id)\n"
269 " Add a vlan_id, or all identifiers, to the set"
270 " of VLAN identifiers filtered by port_id.\n\n"
272 "rx_vlan rm (vlan_id|all) (port_id)\n"
273 " Remove a vlan_id, or all identifiers, from the set"
274 " of VLAN identifiers filtered by port_id.\n\n"
276 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
277 " Add a vlan_id, to the set of VLAN identifiers"
278 "filtered for VF(s) from port_id.\n\n"
280 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
281 " Remove a vlan_id, to the set of VLAN identifiers"
282 "filtered for VF(s) from port_id.\n\n"
284 "rx_vlan set tpid (value) (port_id)\n"
285 " Set the outer VLAN TPID for Packet Filtering on"
288 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
289 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
290 " add a tunnel filter of a port.\n\n"
292 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
293 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
294 " remove a tunnel filter of a port.\n\n"
296 "rx_vxlan_port add (udp_port) (port_id)\n"
297 " Add an UDP port for VXLAN packet filter on a port\n\n"
299 "rx_vxlan_port rm (udp_port) (port_id)\n"
300 " Remove an UDP port for VXLAN packet filter on a port\n\n"
302 "tx_vlan set vlan_id (port_id)\n"
303 " Set hardware insertion of VLAN ID in packets sent"
306 "tx_vlan set pvid port_id vlan_id (on|off)\n"
307 " Set port based TX VLAN insertion.\n\n"
309 "tx_vlan reset (port_id)\n"
310 " Disable hardware insertion of a VLAN header in"
311 " packets sent on a port.\n\n"
313 "tx_checksum set (mask) (port_id)\n"
314 " Enable hardware insertion of checksum offload with"
315 " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
316 " bit 0 - insert ip checksum offload if set\n"
317 " bit 1 - insert udp checksum offload if set\n"
318 " bit 2 - insert tcp checksum offload if set\n"
319 " bit 3 - insert sctp checksum offload if set\n"
320 " bit 4 - insert inner ip checksum offload if set\n"
321 " bit 5 - insert inner udp checksum offload if set\n"
322 " bit 6 - insert inner tcp checksum offload if set\n"
323 " bit 7 - insert inner sctp checksum offload if set\n"
324 " Please check the NIC datasheet for HW limits.\n\n"
327 " Set packet forwarding mode.\n\n"
329 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
330 " Add a MAC address on port_id.\n\n"
332 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
333 " Remove a MAC address from port_id.\n\n"
335 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
336 " Add a MAC address for a VF on the port.\n\n"
338 "set port (port_id) uta (mac_address|all) (on|off)\n"
339 " Add/Remove a or all unicast hash filter(s)"
342 "set promisc (port_id|all) (on|off)\n"
343 " Set the promiscuous mode on port_id, or all.\n\n"
345 "set allmulti (port_id|all) (on|off)\n"
346 " Set the allmulti mode on port_id, or all.\n\n"
348 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
349 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
350 " (on|off) autoneg (on|off) (port_id)\n"
351 "set flow_ctrl rx (on|off) (portid)\n"
352 "set flow_ctrl tx (on|off) (portid)\n"
353 "set flow_ctrl high_water (high_water) (portid)\n"
354 "set flow_ctrl low_water (low_water) (portid)\n"
355 "set flow_ctrl pause_time (pause_time) (portid)\n"
356 "set flow_ctrl send_xon (send_xon) (portid)\n"
357 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
358 "set flow_ctrl autoneg (on|off) (port_id)\n"
359 " Set the link flow control parameter on a port.\n\n"
361 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
362 " (low_water) (pause_time) (priority) (port_id)\n"
363 " Set the priority flow control parameter on a"
366 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
367 " Set statistics mapping (qmapping 0..15) for RX/TX"
369 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
370 " on port 0 to mapping 5.\n\n"
372 "set port (port_id) vf (vf_id) rx|tx on|off\n"
373 " Enable/Disable a VF receive/tranmit from a port\n\n"
375 "set port (port_id) vf (vf_id) (mac_addr)"
376 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
377 " Add/Remove unicast or multicast MAC addr filter"
380 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
382 " AUPE:accepts untagged VLAN;"
383 "ROPE:accept unicast hash\n\n"
384 " BAM:accepts broadcast packets;"
385 "MPE:accepts all multicast packets\n\n"
386 " Enable/Disable a VF receive mode of a port\n\n"
388 "set port (port_id) queue (queue_id) rate (rate_num)\n"
389 " Set rate limit for a queue of a port\n\n"
391 "set port (port_id) vf (vf_id) rate (rate_num) "
392 "queue_mask (queue_mask_value)\n"
393 " Set rate limit for queues in VF of a port\n\n"
395 "set port (port_id) mirror-rule (rule_id)"
396 "(pool-mirror|vlan-mirror)\n"
397 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
398 " Set pool or vlan type mirror rule on a port.\n"
399 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
400 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
403 "set port (port_id) mirror-rule (rule_id)"
404 " (uplink-mirror|downlink-mirror) dst-pool"
405 " (pool_id) (on|off)\n"
406 " Set uplink or downlink type mirror rule on a port.\n"
407 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
408 " 0 on' enable mirror income traffic to pool 0.\n\n"
410 "reset port (port_id) mirror-rule (rule_id)\n"
411 " Reset a mirror rule.\n\n"
413 "set flush_rx (on|off)\n"
414 " Flush (default) or don't flush RX streams before"
415 " forwarding. Mainly used with PCAP drivers.\n\n"
417 #ifdef RTE_NIC_BYPASS
418 "set bypass mode (normal|bypass|isolate) (port_id)\n"
419 " Set the bypass mode for the lowest port on bypass enabled"
422 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
423 "mode (normal|bypass|isolate) (port_id)\n"
424 " Set the event required to initiate specified bypass mode for"
425 " the lowest port on a bypass enabled NIC where:\n"
426 " timeout = enable bypass after watchdog timeout.\n"
427 " os_on = enable bypass when OS/board is powered on.\n"
428 " os_off = enable bypass when OS/board is powered off.\n"
429 " power_on = enable bypass when power supply is turned on.\n"
430 " power_off = enable bypass when power supply is turned off."
433 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
434 " Set the bypass watchdog timeout to 'n' seconds"
435 " where 0 = instant.\n\n"
437 "show bypass config (port_id)\n"
438 " Show the bypass configuration for a bypass enabled NIC"
439 " using the lowest port on the NIC.\n\n"
441 #ifdef RTE_LIBRTE_PMD_BOND
442 "create bonded device (mode) (socket)\n"
443 " Create a new bonded device with specific bonding mode and socket.\n\n"
445 "add bonding slave (slave_id) (port_id)\n"
446 " Add a slave device to a bonded device.\n\n"
448 "remove bonding slave (slave_id) (port_id)\n"
449 " Remove a slave device from a bonded device.\n\n"
451 "set bonding mode (value) (port_id)\n"
452 " Set the bonding mode on a bonded device.\n\n"
454 "set bonding primary (slave_id) (port_id)\n"
455 " Set the primary slave for a bonded device.\n\n"
457 "show bonding config (port_id)\n"
458 " Show the bonding config for port_id.\n\n"
460 "set bonding mac_addr (port_id) (address)\n"
461 " Set the MAC address of a bonded device.\n\n"
463 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
464 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
467 , list_pkt_forwarding_modes()
472 if (show_all || !strcmp(res->section, "flowdir")) {
477 "Flow director mode:\n"
478 "-------------------\n\n"
480 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
481 " src (src_ip_address) (src_port)"
482 " dst (dst_ip_address) (dst_port)"
483 " flexbytes (flexbytes_values) vlan (vlan_id)"
484 " queue (queue_id)\n"
485 " Add a signature filter.\n\n"
487 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
488 " src (src_ip_address) (src_port)"
489 " dst (dst_ip_address) (dst_port)"
490 " flexbytes (flexbytes_values) vlan (vlan_id)"
491 " queue (queue_id)\n"
492 " Update a signature filter.\n\n"
494 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
495 " src (src_ip_address) (src_port)"
496 " dst (dst_ip_address) (dst_port)"
497 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
498 " Remove a signature filter.\n\n"
500 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
501 " src (src_ip_address) (src_port)"
502 " dst (dst_ip_address) (dst_port)"
503 " flexbytes (flexbytes_values) vlan (vlan_id)"
504 " queue (queue_id) soft (soft_id)\n"
505 " Add a perfect filter.\n\n"
507 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
508 " src (src_ip_address) (src_port)"
509 " dst (dst_ip_address) (dst_port)"
510 " flexbytes (flexbytes_values) vlan (vlan_id)"
511 " queue (queue_id)\n"
512 " Update a perfect filter.\n\n"
514 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
515 " src (src_ip_address) (src_port)"
516 " dst (dst_ip_address) (dst_port)"
517 " flexbytes (flexbytes_values) vlan (vlan_id)"
519 " Remove a perfect filter.\n\n"
521 "set_masks_filter (port_id) only_ip_flow (0|1)"
522 " src_mask (ip_src_mask) (src_port_mask)"
523 " dst_mask (ip_dst_mask) (dst_port_mask)"
524 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
525 " Set IPv4 filter masks.\n\n"
527 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
528 " src_mask (ip_src_mask) (src_port_mask)"
529 " dst_mask (ip_dst_mask) (dst_port_mask)"
530 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
531 " compare_dst (0|1)\n"
532 " Set IPv6 filter masks.\n\n"
536 if (show_all || !strcmp(res->section, "ports")) {
542 "----------------\n\n"
544 "port start (port_id|all)\n"
545 " Start all ports or port_id.\n\n"
547 "port stop (port_id|all)\n"
548 " Stop all ports or port_id.\n\n"
550 "port close (port_id|all)\n"
551 " Close all ports or port_id.\n\n"
553 "port config (port_id|all)"
554 " speed (10|100|1000|10000|40000|auto)"
555 " duplex (half|full|auto)\n"
556 " Set speed and duplex for all ports or port_id\n\n"
558 "port config all (rxq|txq|rxd|txd) (value)\n"
559 " Set number for rxq/txq/rxd/txd.\n\n"
561 "port config all max-pkt-len (value)\n"
562 " Set the max packet length.\n\n"
564 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
566 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
569 "port config all rss (ip|udp|none)\n"
570 " Set the RSS mode.\n\n"
572 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
573 " Set the RSS redirection table.\n\n"
575 "port config (port_id) dcb vt (on|off) (traffic_class)"
577 " Set the DCB mode.\n\n"
579 "port config all burst (value)\n"
580 " Set the number of packets per burst.\n\n"
582 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
584 " Set the ring prefetch/host/writeback threshold"
585 " for tx/rx queue.\n\n"
587 "port config all (txfreet|txrst|rxfreet) (value)\n"
588 " Set free threshold for rx/tx, or set"
589 " tx rs bit threshold.\n\n"
590 "port config mtu X value\n"
591 " Set the MTU of port X to a given value\n\n"
593 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
594 " Start/stop a rx/tx queue of port X. Only take effect"
595 " when port X is started\n"
599 if (show_all || !strcmp(res->section, "registers")) {
607 "read reg (port_id) (address)\n"
608 " Display value of a port register.\n\n"
610 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
611 " Display a port register bit field.\n\n"
613 "read regbit (port_id) (address) (bit_x)\n"
614 " Display a single port register bit.\n\n"
616 "write reg (port_id) (address) (value)\n"
617 " Set value of a port register.\n\n"
619 "write regfield (port_id) (address) (bit_x) (bit_y)"
621 " Set bit field of a port register.\n\n"
623 "write regbit (port_id) (address) (bit_x) (value)\n"
624 " Set single bit value of a port register.\n\n"
627 if (show_all || !strcmp(res->section, "filters")) {
635 "add_ethertype_filter (port_id) ethertype (eth_value)"
636 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
637 " add an ethertype filter.\n\n"
639 "remove_ethertype_filter (port_id) index (idx)\n"
640 " remove an ethertype filter.\n\n"
642 "get_ethertype_filter (port_id) index (idx)\n"
643 " get info of a ethertype filter.\n\n"
645 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
646 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
647 " queue (queue_id) index (idx)\n"
648 " add a 2tuple filter.\n\n"
650 "remove_2tuple_filter (port_id) index (idx)\n"
651 " remove a 2tuple filter.\n\n"
653 "get_2tuple_filter (port_id) index (idx)\n"
654 " get info of a 2tuple filter.\n\n"
656 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
657 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
658 " mask (mask_value) flags (flags_value) priority (prio_value)"
659 " queue (queue_id) index (idx)\n"
660 " add a 5tuple filter.\n\n"
662 "remove_5tuple_filter (port_id) index (idx)\n"
663 " remove a 5tuple filter.\n\n"
665 "get_5tuple_filter (port_id) index (idx)\n"
666 " get info of a 5tuple filter.\n\n"
668 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
669 " add syn filter.\n\n"
671 "remove_syn_filter (port_id)"
672 " remove syn filter.\n\n"
674 "get_syn_filter (port_id) "
675 " get syn filter info.\n\n"
677 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
678 " priority (prio_value) queue (queue_id) index (idx)\n"
679 " add a flex filter.\n\n"
681 "remove_flex_filter (port_id) index (idx)\n"
682 " remove a flex filter.\n\n"
684 "get_flex_filter (port_id) index (idx)\n"
685 " get info of a flex filter.\n\n"
690 cmdline_parse_token_string_t cmd_help_long_help =
691 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
693 cmdline_parse_token_string_t cmd_help_long_section =
694 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
695 "all#control#display#config#flowdir#"
696 "ports#registers#filters");
698 cmdline_parse_inst_t cmd_help_long = {
699 .f = cmd_help_long_parsed,
701 .help_str = "show help",
703 (void *)&cmd_help_long_help,
704 (void *)&cmd_help_long_section,
710 /* *** start/stop/close all ports *** */
711 struct cmd_operate_port_result {
712 cmdline_fixed_string_t keyword;
713 cmdline_fixed_string_t name;
714 cmdline_fixed_string_t value;
717 static void cmd_operate_port_parsed(void *parsed_result,
718 __attribute__((unused)) struct cmdline *cl,
719 __attribute__((unused)) void *data)
721 struct cmd_operate_port_result *res = parsed_result;
723 if (!strcmp(res->name, "start"))
724 start_port(RTE_PORT_ALL);
725 else if (!strcmp(res->name, "stop"))
726 stop_port(RTE_PORT_ALL);
727 else if (!strcmp(res->name, "close"))
728 close_port(RTE_PORT_ALL);
730 printf("Unknown parameter\n");
733 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
734 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
736 cmdline_parse_token_string_t cmd_operate_port_all_port =
737 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
739 cmdline_parse_token_string_t cmd_operate_port_all_all =
740 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
742 cmdline_parse_inst_t cmd_operate_port = {
743 .f = cmd_operate_port_parsed,
745 .help_str = "port start|stop|close all: start/stop/close all ports",
747 (void *)&cmd_operate_port_all_cmd,
748 (void *)&cmd_operate_port_all_port,
749 (void *)&cmd_operate_port_all_all,
754 /* *** start/stop/close specific port *** */
755 struct cmd_operate_specific_port_result {
756 cmdline_fixed_string_t keyword;
757 cmdline_fixed_string_t name;
761 static void cmd_operate_specific_port_parsed(void *parsed_result,
762 __attribute__((unused)) struct cmdline *cl,
763 __attribute__((unused)) void *data)
765 struct cmd_operate_specific_port_result *res = parsed_result;
767 if (!strcmp(res->name, "start"))
768 start_port(res->value);
769 else if (!strcmp(res->name, "stop"))
770 stop_port(res->value);
771 else if (!strcmp(res->name, "close"))
772 close_port(res->value);
774 printf("Unknown parameter\n");
777 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
778 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
780 cmdline_parse_token_string_t cmd_operate_specific_port_port =
781 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
782 name, "start#stop#close");
783 cmdline_parse_token_num_t cmd_operate_specific_port_id =
784 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
787 cmdline_parse_inst_t cmd_operate_specific_port = {
788 .f = cmd_operate_specific_port_parsed,
790 .help_str = "port start|stop|close X: start/stop/close port X",
792 (void *)&cmd_operate_specific_port_cmd,
793 (void *)&cmd_operate_specific_port_port,
794 (void *)&cmd_operate_specific_port_id,
799 /* *** configure speed for all ports *** */
800 struct cmd_config_speed_all {
801 cmdline_fixed_string_t port;
802 cmdline_fixed_string_t keyword;
803 cmdline_fixed_string_t all;
804 cmdline_fixed_string_t item1;
805 cmdline_fixed_string_t item2;
806 cmdline_fixed_string_t value1;
807 cmdline_fixed_string_t value2;
811 cmd_config_speed_all_parsed(void *parsed_result,
812 __attribute__((unused)) struct cmdline *cl,
813 __attribute__((unused)) void *data)
815 struct cmd_config_speed_all *res = parsed_result;
816 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
817 uint16_t link_duplex = 0;
820 if (!all_ports_stopped()) {
821 printf("Please stop all ports first\n");
825 if (!strcmp(res->value1, "10"))
826 link_speed = ETH_LINK_SPEED_10;
827 else if (!strcmp(res->value1, "100"))
828 link_speed = ETH_LINK_SPEED_100;
829 else if (!strcmp(res->value1, "1000"))
830 link_speed = ETH_LINK_SPEED_1000;
831 else if (!strcmp(res->value1, "10000"))
832 link_speed = ETH_LINK_SPEED_10G;
833 else if (!strcmp(res->value1, "40000"))
834 link_speed = ETH_LINK_SPEED_40G;
835 else if (!strcmp(res->value1, "auto"))
836 link_speed = ETH_LINK_SPEED_AUTONEG;
838 printf("Unknown parameter\n");
842 if (!strcmp(res->value2, "half"))
843 link_duplex = ETH_LINK_HALF_DUPLEX;
844 else if (!strcmp(res->value2, "full"))
845 link_duplex = ETH_LINK_FULL_DUPLEX;
846 else if (!strcmp(res->value2, "auto"))
847 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
849 printf("Unknown parameter\n");
853 for (pid = 0; pid < nb_ports; pid++) {
854 ports[pid].dev_conf.link_speed = link_speed;
855 ports[pid].dev_conf.link_duplex = link_duplex;
858 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
861 cmdline_parse_token_string_t cmd_config_speed_all_port =
862 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
863 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
864 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
866 cmdline_parse_token_string_t cmd_config_speed_all_all =
867 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
868 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
869 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
870 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
871 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
872 "10#100#1000#10000#40000#auto");
873 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
874 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
875 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
876 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
879 cmdline_parse_inst_t cmd_config_speed_all = {
880 .f = cmd_config_speed_all_parsed,
882 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
885 (void *)&cmd_config_speed_all_port,
886 (void *)&cmd_config_speed_all_keyword,
887 (void *)&cmd_config_speed_all_all,
888 (void *)&cmd_config_speed_all_item1,
889 (void *)&cmd_config_speed_all_value1,
890 (void *)&cmd_config_speed_all_item2,
891 (void *)&cmd_config_speed_all_value2,
896 /* *** configure speed for specific port *** */
897 struct cmd_config_speed_specific {
898 cmdline_fixed_string_t port;
899 cmdline_fixed_string_t keyword;
901 cmdline_fixed_string_t item1;
902 cmdline_fixed_string_t item2;
903 cmdline_fixed_string_t value1;
904 cmdline_fixed_string_t value2;
908 cmd_config_speed_specific_parsed(void *parsed_result,
909 __attribute__((unused)) struct cmdline *cl,
910 __attribute__((unused)) void *data)
912 struct cmd_config_speed_specific *res = parsed_result;
913 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
914 uint16_t link_duplex = 0;
916 if (!all_ports_stopped()) {
917 printf("Please stop all ports first\n");
921 if (res->id >= nb_ports) {
922 printf("Port id %d must be less than %d\n", res->id, nb_ports);
926 if (!strcmp(res->value1, "10"))
927 link_speed = ETH_LINK_SPEED_10;
928 else if (!strcmp(res->value1, "100"))
929 link_speed = ETH_LINK_SPEED_100;
930 else if (!strcmp(res->value1, "1000"))
931 link_speed = ETH_LINK_SPEED_1000;
932 else if (!strcmp(res->value1, "10000"))
933 link_speed = ETH_LINK_SPEED_10000;
934 else if (!strcmp(res->value1, "40000"))
935 link_speed = ETH_LINK_SPEED_40G;
936 else if (!strcmp(res->value1, "auto"))
937 link_speed = ETH_LINK_SPEED_AUTONEG;
939 printf("Unknown parameter\n");
943 if (!strcmp(res->value2, "half"))
944 link_duplex = ETH_LINK_HALF_DUPLEX;
945 else if (!strcmp(res->value2, "full"))
946 link_duplex = ETH_LINK_FULL_DUPLEX;
947 else if (!strcmp(res->value2, "auto"))
948 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
950 printf("Unknown parameter\n");
954 ports[res->id].dev_conf.link_speed = link_speed;
955 ports[res->id].dev_conf.link_duplex = link_duplex;
957 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
961 cmdline_parse_token_string_t cmd_config_speed_specific_port =
962 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
964 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
965 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
967 cmdline_parse_token_num_t cmd_config_speed_specific_id =
968 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
969 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
970 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
972 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
973 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
974 "10#100#1000#10000#40000#auto");
975 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
978 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
979 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
982 cmdline_parse_inst_t cmd_config_speed_specific = {
983 .f = cmd_config_speed_specific_parsed,
985 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
988 (void *)&cmd_config_speed_specific_port,
989 (void *)&cmd_config_speed_specific_keyword,
990 (void *)&cmd_config_speed_specific_id,
991 (void *)&cmd_config_speed_specific_item1,
992 (void *)&cmd_config_speed_specific_value1,
993 (void *)&cmd_config_speed_specific_item2,
994 (void *)&cmd_config_speed_specific_value2,
999 /* *** configure txq/rxq, txd/rxd *** */
1000 struct cmd_config_rx_tx {
1001 cmdline_fixed_string_t port;
1002 cmdline_fixed_string_t keyword;
1003 cmdline_fixed_string_t all;
1004 cmdline_fixed_string_t name;
1009 cmd_config_rx_tx_parsed(void *parsed_result,
1010 __attribute__((unused)) struct cmdline *cl,
1011 __attribute__((unused)) void *data)
1013 struct cmd_config_rx_tx *res = parsed_result;
1015 if (!all_ports_stopped()) {
1016 printf("Please stop all ports first\n");
1020 if (!strcmp(res->name, "rxq")) {
1021 if (res->value <= 0) {
1022 printf("rxq %d invalid - must be > 0\n", res->value);
1025 nb_rxq = res->value;
1027 else if (!strcmp(res->name, "txq")) {
1028 if (res->value <= 0) {
1029 printf("txq %d invalid - must be > 0\n", res->value);
1032 nb_txq = res->value;
1034 else if (!strcmp(res->name, "rxd")) {
1035 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1036 printf("rxd %d invalid - must be > 0 && <= %d\n",
1037 res->value, RTE_TEST_RX_DESC_MAX);
1040 nb_rxd = res->value;
1041 } else if (!strcmp(res->name, "txd")) {
1042 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1043 printf("txd %d invalid - must be > 0 && <= %d\n",
1044 res->value, RTE_TEST_TX_DESC_MAX);
1047 nb_txd = res->value;
1049 printf("Unknown parameter\n");
1055 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1058 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1059 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1060 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1061 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1062 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1063 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1064 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1065 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1067 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1068 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1070 cmdline_parse_inst_t cmd_config_rx_tx = {
1071 .f = cmd_config_rx_tx_parsed,
1073 .help_str = "port config all rxq|txq|rxd|txd value",
1075 (void *)&cmd_config_rx_tx_port,
1076 (void *)&cmd_config_rx_tx_keyword,
1077 (void *)&cmd_config_rx_tx_all,
1078 (void *)&cmd_config_rx_tx_name,
1079 (void *)&cmd_config_rx_tx_value,
1084 /* *** config max packet length *** */
1085 struct cmd_config_max_pkt_len_result {
1086 cmdline_fixed_string_t port;
1087 cmdline_fixed_string_t keyword;
1088 cmdline_fixed_string_t all;
1089 cmdline_fixed_string_t name;
1094 cmd_config_max_pkt_len_parsed(void *parsed_result,
1095 __attribute__((unused)) struct cmdline *cl,
1096 __attribute__((unused)) void *data)
1098 struct cmd_config_max_pkt_len_result *res = parsed_result;
1100 if (!all_ports_stopped()) {
1101 printf("Please stop all ports first\n");
1105 if (!strcmp(res->name, "max-pkt-len")) {
1106 if (res->value < ETHER_MIN_LEN) {
1107 printf("max-pkt-len can not be less than %d\n",
1111 if (res->value == rx_mode.max_rx_pkt_len)
1114 rx_mode.max_rx_pkt_len = res->value;
1115 if (res->value > ETHER_MAX_LEN)
1116 rx_mode.jumbo_frame = 1;
1118 rx_mode.jumbo_frame = 0;
1120 printf("Unknown parameter\n");
1126 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1129 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1130 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1132 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1133 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1135 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1136 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1138 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1141 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1142 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1145 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1146 .f = cmd_config_max_pkt_len_parsed,
1148 .help_str = "port config all max-pkt-len value",
1150 (void *)&cmd_config_max_pkt_len_port,
1151 (void *)&cmd_config_max_pkt_len_keyword,
1152 (void *)&cmd_config_max_pkt_len_all,
1153 (void *)&cmd_config_max_pkt_len_name,
1154 (void *)&cmd_config_max_pkt_len_value,
1159 /* *** configure port MTU *** */
1160 struct cmd_config_mtu_result {
1161 cmdline_fixed_string_t port;
1162 cmdline_fixed_string_t keyword;
1163 cmdline_fixed_string_t mtu;
1169 cmd_config_mtu_parsed(void *parsed_result,
1170 __attribute__((unused)) struct cmdline *cl,
1171 __attribute__((unused)) void *data)
1173 struct cmd_config_mtu_result *res = parsed_result;
1175 if (res->value < ETHER_MIN_LEN) {
1176 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1179 port_mtu_set(res->port_id, res->value);
1182 cmdline_parse_token_string_t cmd_config_mtu_port =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1185 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1186 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1188 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1189 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1191 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1192 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1193 cmdline_parse_token_num_t cmd_config_mtu_value =
1194 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1196 cmdline_parse_inst_t cmd_config_mtu = {
1197 .f = cmd_config_mtu_parsed,
1199 .help_str = "port config mtu value",
1201 (void *)&cmd_config_mtu_port,
1202 (void *)&cmd_config_mtu_keyword,
1203 (void *)&cmd_config_mtu_mtu,
1204 (void *)&cmd_config_mtu_port_id,
1205 (void *)&cmd_config_mtu_value,
1210 /* *** configure rx mode *** */
1211 struct cmd_config_rx_mode_flag {
1212 cmdline_fixed_string_t port;
1213 cmdline_fixed_string_t keyword;
1214 cmdline_fixed_string_t all;
1215 cmdline_fixed_string_t name;
1216 cmdline_fixed_string_t value;
1220 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1221 __attribute__((unused)) struct cmdline *cl,
1222 __attribute__((unused)) void *data)
1224 struct cmd_config_rx_mode_flag *res = parsed_result;
1226 if (!all_ports_stopped()) {
1227 printf("Please stop all ports first\n");
1231 if (!strcmp(res->name, "crc-strip")) {
1232 if (!strcmp(res->value, "on"))
1233 rx_mode.hw_strip_crc = 1;
1234 else if (!strcmp(res->value, "off"))
1235 rx_mode.hw_strip_crc = 0;
1237 printf("Unknown parameter\n");
1240 } else if (!strcmp(res->name, "rx-cksum")) {
1241 if (!strcmp(res->value, "on"))
1242 rx_mode.hw_ip_checksum = 1;
1243 else if (!strcmp(res->value, "off"))
1244 rx_mode.hw_ip_checksum = 0;
1246 printf("Unknown parameter\n");
1249 } else if (!strcmp(res->name, "hw-vlan")) {
1250 if (!strcmp(res->value, "on")) {
1251 rx_mode.hw_vlan_filter = 1;
1252 rx_mode.hw_vlan_strip = 1;
1254 else if (!strcmp(res->value, "off")) {
1255 rx_mode.hw_vlan_filter = 0;
1256 rx_mode.hw_vlan_strip = 0;
1259 printf("Unknown parameter\n");
1262 } else if (!strcmp(res->name, "drop-en")) {
1263 if (!strcmp(res->value, "on"))
1265 else if (!strcmp(res->value, "off"))
1268 printf("Unknown parameter\n");
1272 printf("Unknown parameter\n");
1278 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1281 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1282 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1283 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1284 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1286 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1288 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1289 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1290 "crc-strip#rx-cksum#hw-vlan");
1291 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1292 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1295 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1296 .f = cmd_config_rx_mode_flag_parsed,
1298 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1300 (void *)&cmd_config_rx_mode_flag_port,
1301 (void *)&cmd_config_rx_mode_flag_keyword,
1302 (void *)&cmd_config_rx_mode_flag_all,
1303 (void *)&cmd_config_rx_mode_flag_name,
1304 (void *)&cmd_config_rx_mode_flag_value,
1309 /* *** configure rss *** */
1310 struct cmd_config_rss {
1311 cmdline_fixed_string_t port;
1312 cmdline_fixed_string_t keyword;
1313 cmdline_fixed_string_t all;
1314 cmdline_fixed_string_t name;
1315 cmdline_fixed_string_t value;
1319 cmd_config_rss_parsed(void *parsed_result,
1320 __attribute__((unused)) struct cmdline *cl,
1321 __attribute__((unused)) void *data)
1323 struct cmd_config_rss *res = parsed_result;
1324 struct rte_eth_rss_conf rss_conf;
1327 if (!strcmp(res->value, "ip"))
1328 rss_conf.rss_hf = ETH_RSS_IP;
1329 else if (!strcmp(res->value, "udp"))
1330 rss_conf.rss_hf = ETH_RSS_UDP;
1331 else if (!strcmp(res->value, "none"))
1332 rss_conf.rss_hf = 0;
1334 printf("Unknown parameter\n");
1337 rss_conf.rss_key = NULL;
1338 for (i = 0; i < rte_eth_dev_count(); i++)
1339 rte_eth_dev_rss_hash_update(i, &rss_conf);
1342 cmdline_parse_token_string_t cmd_config_rss_port =
1343 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1344 cmdline_parse_token_string_t cmd_config_rss_keyword =
1345 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1346 cmdline_parse_token_string_t cmd_config_rss_all =
1347 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1348 cmdline_parse_token_string_t cmd_config_rss_name =
1349 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1350 cmdline_parse_token_string_t cmd_config_rss_value =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1353 cmdline_parse_inst_t cmd_config_rss = {
1354 .f = cmd_config_rss_parsed,
1356 .help_str = "port config all rss ip|udp|none",
1358 (void *)&cmd_config_rss_port,
1359 (void *)&cmd_config_rss_keyword,
1360 (void *)&cmd_config_rss_all,
1361 (void *)&cmd_config_rss_name,
1362 (void *)&cmd_config_rss_value,
1367 /* *** configure rss hash key *** */
1368 struct cmd_config_rss_hash_key {
1369 cmdline_fixed_string_t port;
1370 cmdline_fixed_string_t config;
1372 cmdline_fixed_string_t rss_hash_key;
1373 cmdline_fixed_string_t key;
1376 #define RSS_HASH_KEY_LENGTH 40
1378 hexa_digit_to_value(char hexa_digit)
1380 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1381 return (uint8_t) (hexa_digit - '0');
1382 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1383 return (uint8_t) ((hexa_digit - 'a') + 10);
1384 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1385 return (uint8_t) ((hexa_digit - 'A') + 10);
1386 /* Invalid hexa digit */
1391 parse_and_check_key_hexa_digit(char *key, int idx)
1395 hexa_v = hexa_digit_to_value(key[idx]);
1397 printf("invalid key: character %c at position %d is not a "
1398 "valid hexa digit\n", key[idx], idx);
1403 cmd_config_rss_hash_key_parsed(void *parsed_result,
1404 __attribute__((unused)) struct cmdline *cl,
1405 __attribute__((unused)) void *data)
1407 struct cmd_config_rss_hash_key *res = parsed_result;
1408 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1413 /* Check the length of the RSS hash key */
1414 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1415 printf("key length: %d invalid - key must be a string of %d"
1416 "hexa-decimal numbers\n", (int) strlen(res->key),
1417 RSS_HASH_KEY_LENGTH * 2);
1420 /* Translate RSS hash key into binary representation */
1421 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1422 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1425 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1428 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1430 port_rss_hash_key_update(res->port_id, hash_key);
1433 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1435 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1436 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1438 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1439 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1440 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1442 rss_hash_key, "rss-hash-key");
1443 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1446 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1447 .f = cmd_config_rss_hash_key_parsed,
1449 .help_str = "port config X rss-hash-key 80 hexa digits",
1451 (void *)&cmd_config_rss_hash_key_port,
1452 (void *)&cmd_config_rss_hash_key_config,
1453 (void *)&cmd_config_rss_hash_key_port_id,
1454 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1455 (void *)&cmd_config_rss_hash_key_value,
1460 /* *** configure port rxq/txq start/stop *** */
1461 struct cmd_config_rxtx_queue {
1462 cmdline_fixed_string_t port;
1464 cmdline_fixed_string_t rxtxq;
1466 cmdline_fixed_string_t opname;
1470 cmd_config_rxtx_queue_parsed(void *parsed_result,
1471 __attribute__((unused)) struct cmdline *cl,
1472 __attribute__((unused)) void *data)
1474 struct cmd_config_rxtx_queue *res = parsed_result;
1479 if (test_done == 0) {
1480 printf("Please stop forwarding first\n");
1484 if (port_id_is_invalid(res->portid))
1487 if (port_is_started(res->portid) != 1) {
1488 printf("Please start port %u first\n", res->portid);
1492 if (!strcmp(res->rxtxq, "rxq"))
1494 else if (!strcmp(res->rxtxq, "txq"))
1497 printf("Unknown parameter\n");
1501 if (isrx && rx_queue_id_is_invalid(res->qid))
1503 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1506 if (!strcmp(res->opname, "start"))
1508 else if (!strcmp(res->opname, "stop"))
1511 printf("Unknown parameter\n");
1515 if (isstart && isrx)
1516 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1517 else if (!isstart && isrx)
1518 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1519 else if (isstart && !isrx)
1520 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1522 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1524 if (ret == -ENOTSUP)
1525 printf("Function not supported in PMD driver\n");
1528 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1530 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1531 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1532 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1533 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1534 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1535 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1536 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1537 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1540 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1541 .f = cmd_config_rxtx_queue_parsed,
1543 .help_str = "port X rxq|txq ID start|stop",
1545 (void *)&cmd_config_speed_all_port,
1546 (void *)&cmd_config_rxtx_queue_portid,
1547 (void *)&cmd_config_rxtx_queue_rxtxq,
1548 (void *)&cmd_config_rxtx_queue_qid,
1549 (void *)&cmd_config_rxtx_queue_opname,
1554 /* *** Configure RSS RETA *** */
1555 struct cmd_config_rss_reta {
1556 cmdline_fixed_string_t port;
1557 cmdline_fixed_string_t keyword;
1559 cmdline_fixed_string_t name;
1560 cmdline_fixed_string_t list_name;
1561 cmdline_fixed_string_t list_of_items;
1565 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1572 const char *p, *p0 = str;
1579 unsigned long int_fld[_NUM_FLD];
1580 char *str_fld[_NUM_FLD];
1582 while ((p = strchr(p0,'(')) != NULL) {
1584 if((p0 = strchr(p,')')) == NULL)
1588 if(size >= sizeof(s))
1591 snprintf(s, sizeof(s), "%.*s", size, p);
1592 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1594 for (i = 0; i < _NUM_FLD; i++) {
1596 int_fld[i] = strtoul(str_fld[i], &end, 0);
1597 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1601 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1602 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1604 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1605 printf("Invalid RETA hash index=%d",hash_index);
1609 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1610 reta_conf->mask_lo |= (1ULL << hash_index);
1612 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1614 reta_conf->reta[hash_index] = nb_queue;
1621 cmd_set_rss_reta_parsed(void *parsed_result,
1622 __attribute__((unused)) struct cmdline *cl,
1623 __attribute__((unused)) void *data)
1626 struct rte_eth_rss_reta reta_conf;
1627 struct cmd_config_rss_reta *res = parsed_result;
1629 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1630 if (!strcmp(res->list_name, "reta")) {
1631 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1632 printf("Invalid RSS Redirection Table config entered\n");
1635 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1637 printf("Bad redirection table parameter, return code = %d \n",ret);
1641 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1643 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1645 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1646 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1647 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1649 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1651 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1654 cmdline_parse_inst_t cmd_config_rss_reta = {
1655 .f = cmd_set_rss_reta_parsed,
1657 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1659 (void *)&cmd_config_rss_reta_port,
1660 (void *)&cmd_config_rss_reta_keyword,
1661 (void *)&cmd_config_rss_reta_port_id,
1662 (void *)&cmd_config_rss_reta_name,
1663 (void *)&cmd_config_rss_reta_list_name,
1664 (void *)&cmd_config_rss_reta_list_of_items,
1669 /* *** SHOW PORT RETA INFO *** */
1670 struct cmd_showport_reta {
1671 cmdline_fixed_string_t show;
1672 cmdline_fixed_string_t port;
1674 cmdline_fixed_string_t rss;
1675 cmdline_fixed_string_t reta;
1680 static void cmd_showport_reta_parsed(void *parsed_result,
1681 __attribute__((unused)) struct cmdline *cl,
1682 __attribute__((unused)) void *data)
1684 struct cmd_showport_reta *res = parsed_result;
1685 struct rte_eth_rss_reta reta_conf;
1687 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1688 printf("Invalid RSS Redirection Table config entered\n");
1692 reta_conf.mask_lo = res->mask_lo;
1693 reta_conf.mask_hi = res->mask_hi;
1695 port_rss_reta_info(res->port_id,&reta_conf);
1698 cmdline_parse_token_string_t cmd_showport_reta_show =
1699 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1700 cmdline_parse_token_string_t cmd_showport_reta_port =
1701 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1702 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1703 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1704 cmdline_parse_token_string_t cmd_showport_reta_rss =
1705 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1706 cmdline_parse_token_string_t cmd_showport_reta_reta =
1707 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1708 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1709 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1710 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1711 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1713 cmdline_parse_inst_t cmd_showport_reta = {
1714 .f = cmd_showport_reta_parsed,
1716 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1717 (mask_lo and mask_hi is UINT64)",
1719 (void *)&cmd_showport_reta_show,
1720 (void *)&cmd_showport_reta_port,
1721 (void *)&cmd_showport_reta_port_id,
1722 (void *)&cmd_showport_reta_rss,
1723 (void *)&cmd_showport_reta_reta,
1724 (void *)&cmd_showport_reta_mask_lo,
1725 (void *)&cmd_showport_reta_mask_hi,
1730 /* *** Show RSS hash configuration *** */
1731 struct cmd_showport_rss_hash {
1732 cmdline_fixed_string_t show;
1733 cmdline_fixed_string_t port;
1735 cmdline_fixed_string_t rss_hash;
1736 cmdline_fixed_string_t key; /* optional argument */
1739 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1740 __attribute__((unused)) struct cmdline *cl,
1743 struct cmd_showport_rss_hash *res = parsed_result;
1745 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1748 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1749 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1750 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1751 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1752 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1753 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1754 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1755 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1757 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1758 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1760 cmdline_parse_inst_t cmd_showport_rss_hash = {
1761 .f = cmd_showport_rss_hash_parsed,
1763 .help_str = "show port X rss-hash (X = port number)\n",
1765 (void *)&cmd_showport_rss_hash_show,
1766 (void *)&cmd_showport_rss_hash_port,
1767 (void *)&cmd_showport_rss_hash_port_id,
1768 (void *)&cmd_showport_rss_hash_rss_hash,
1773 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1774 .f = cmd_showport_rss_hash_parsed,
1776 .help_str = "show port X rss-hash key (X = port number)\n",
1778 (void *)&cmd_showport_rss_hash_show,
1779 (void *)&cmd_showport_rss_hash_port,
1780 (void *)&cmd_showport_rss_hash_port_id,
1781 (void *)&cmd_showport_rss_hash_rss_hash,
1782 (void *)&cmd_showport_rss_hash_rss_key,
1787 /* *** Configure DCB *** */
1788 struct cmd_config_dcb {
1789 cmdline_fixed_string_t port;
1790 cmdline_fixed_string_t config;
1792 cmdline_fixed_string_t dcb;
1793 cmdline_fixed_string_t vt;
1794 cmdline_fixed_string_t vt_en;
1796 cmdline_fixed_string_t pfc;
1797 cmdline_fixed_string_t pfc_en;
1801 cmd_config_dcb_parsed(void *parsed_result,
1802 __attribute__((unused)) struct cmdline *cl,
1803 __attribute__((unused)) void *data)
1805 struct cmd_config_dcb *res = parsed_result;
1806 struct dcb_config dcb_conf;
1807 portid_t port_id = res->port_id;
1808 struct rte_port *port;
1810 port = &ports[port_id];
1811 /** Check if the port is not started **/
1812 if (port->port_status != RTE_PORT_STOPPED) {
1813 printf("Please stop port %d first\n",port_id);
1817 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1818 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1819 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1823 /* DCB in VT mode */
1824 if (!strncmp(res->vt_en, "on",2))
1825 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1827 dcb_conf.dcb_mode = DCB_ENABLED;
1829 if (!strncmp(res->pfc_en, "on",2)) {
1830 dcb_conf.pfc_en = 1;
1833 dcb_conf.pfc_en = 0;
1835 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1836 printf("Cannot initialize network ports\n");
1840 cmd_reconfig_device_queue(port_id, 1, 1);
1843 cmdline_parse_token_string_t cmd_config_dcb_port =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1845 cmdline_parse_token_string_t cmd_config_dcb_config =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1847 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1848 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1849 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1851 cmdline_parse_token_string_t cmd_config_dcb_vt =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1853 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1855 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1856 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1857 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1859 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1862 cmdline_parse_inst_t cmd_config_dcb = {
1863 .f = cmd_config_dcb_parsed,
1865 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1867 (void *)&cmd_config_dcb_port,
1868 (void *)&cmd_config_dcb_config,
1869 (void *)&cmd_config_dcb_port_id,
1870 (void *)&cmd_config_dcb_dcb,
1871 (void *)&cmd_config_dcb_vt,
1872 (void *)&cmd_config_dcb_vt_en,
1873 (void *)&cmd_config_dcb_num_tcs,
1874 (void *)&cmd_config_dcb_pfc,
1875 (void *)&cmd_config_dcb_pfc_en,
1880 /* *** configure number of packets per burst *** */
1881 struct cmd_config_burst {
1882 cmdline_fixed_string_t port;
1883 cmdline_fixed_string_t keyword;
1884 cmdline_fixed_string_t all;
1885 cmdline_fixed_string_t name;
1890 cmd_config_burst_parsed(void *parsed_result,
1891 __attribute__((unused)) struct cmdline *cl,
1892 __attribute__((unused)) void *data)
1894 struct cmd_config_burst *res = parsed_result;
1896 if (!all_ports_stopped()) {
1897 printf("Please stop all ports first\n");
1901 if (!strcmp(res->name, "burst")) {
1902 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1903 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1906 nb_pkt_per_burst = res->value;
1908 printf("Unknown parameter\n");
1914 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1917 cmdline_parse_token_string_t cmd_config_burst_port =
1918 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1919 cmdline_parse_token_string_t cmd_config_burst_keyword =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1921 cmdline_parse_token_string_t cmd_config_burst_all =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1923 cmdline_parse_token_string_t cmd_config_burst_name =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1925 cmdline_parse_token_num_t cmd_config_burst_value =
1926 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1928 cmdline_parse_inst_t cmd_config_burst = {
1929 .f = cmd_config_burst_parsed,
1931 .help_str = "port config all burst value",
1933 (void *)&cmd_config_burst_port,
1934 (void *)&cmd_config_burst_keyword,
1935 (void *)&cmd_config_burst_all,
1936 (void *)&cmd_config_burst_name,
1937 (void *)&cmd_config_burst_value,
1942 /* *** configure rx/tx queues *** */
1943 struct cmd_config_thresh {
1944 cmdline_fixed_string_t port;
1945 cmdline_fixed_string_t keyword;
1946 cmdline_fixed_string_t all;
1947 cmdline_fixed_string_t name;
1952 cmd_config_thresh_parsed(void *parsed_result,
1953 __attribute__((unused)) struct cmdline *cl,
1954 __attribute__((unused)) void *data)
1956 struct cmd_config_thresh *res = parsed_result;
1958 if (!all_ports_stopped()) {
1959 printf("Please stop all ports first\n");
1963 if (!strcmp(res->name, "txpt"))
1964 tx_thresh.pthresh = res->value;
1965 else if(!strcmp(res->name, "txht"))
1966 tx_thresh.hthresh = res->value;
1967 else if(!strcmp(res->name, "txwt"))
1968 tx_thresh.wthresh = res->value;
1969 else if(!strcmp(res->name, "rxpt"))
1970 rx_thresh.pthresh = res->value;
1971 else if(!strcmp(res->name, "rxht"))
1972 rx_thresh.hthresh = res->value;
1973 else if(!strcmp(res->name, "rxwt"))
1974 rx_thresh.wthresh = res->value;
1976 printf("Unknown parameter\n");
1982 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1985 cmdline_parse_token_string_t cmd_config_thresh_port =
1986 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1987 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1989 cmdline_parse_token_string_t cmd_config_thresh_all =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1991 cmdline_parse_token_string_t cmd_config_thresh_name =
1992 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1993 "txpt#txht#txwt#rxpt#rxht#rxwt");
1994 cmdline_parse_token_num_t cmd_config_thresh_value =
1995 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1997 cmdline_parse_inst_t cmd_config_thresh = {
1998 .f = cmd_config_thresh_parsed,
2000 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2002 (void *)&cmd_config_thresh_port,
2003 (void *)&cmd_config_thresh_keyword,
2004 (void *)&cmd_config_thresh_all,
2005 (void *)&cmd_config_thresh_name,
2006 (void *)&cmd_config_thresh_value,
2011 /* *** configure free/rs threshold *** */
2012 struct cmd_config_threshold {
2013 cmdline_fixed_string_t port;
2014 cmdline_fixed_string_t keyword;
2015 cmdline_fixed_string_t all;
2016 cmdline_fixed_string_t name;
2021 cmd_config_threshold_parsed(void *parsed_result,
2022 __attribute__((unused)) struct cmdline *cl,
2023 __attribute__((unused)) void *data)
2025 struct cmd_config_threshold *res = parsed_result;
2027 if (!all_ports_stopped()) {
2028 printf("Please stop all ports first\n");
2032 if (!strcmp(res->name, "txfreet"))
2033 tx_free_thresh = res->value;
2034 else if (!strcmp(res->name, "txrst"))
2035 tx_rs_thresh = res->value;
2036 else if (!strcmp(res->name, "rxfreet"))
2037 rx_free_thresh = res->value;
2039 printf("Unknown parameter\n");
2045 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2048 cmdline_parse_token_string_t cmd_config_threshold_port =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2050 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2053 cmdline_parse_token_string_t cmd_config_threshold_all =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2055 cmdline_parse_token_string_t cmd_config_threshold_name =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2057 "txfreet#txrst#rxfreet");
2058 cmdline_parse_token_num_t cmd_config_threshold_value =
2059 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2061 cmdline_parse_inst_t cmd_config_threshold = {
2062 .f = cmd_config_threshold_parsed,
2064 .help_str = "port config all txfreet|txrst|rxfreet value",
2066 (void *)&cmd_config_threshold_port,
2067 (void *)&cmd_config_threshold_keyword,
2068 (void *)&cmd_config_threshold_all,
2069 (void *)&cmd_config_threshold_name,
2070 (void *)&cmd_config_threshold_value,
2076 struct cmd_stop_result {
2077 cmdline_fixed_string_t stop;
2080 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2081 __attribute__((unused)) struct cmdline *cl,
2082 __attribute__((unused)) void *data)
2084 stop_packet_forwarding();
2087 cmdline_parse_token_string_t cmd_stop_stop =
2088 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2090 cmdline_parse_inst_t cmd_stop = {
2091 .f = cmd_stop_parsed,
2093 .help_str = "stop - stop packet forwarding",
2095 (void *)&cmd_stop_stop,
2100 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2103 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2104 unsigned int *parsed_items, int check_unique_values)
2106 unsigned int nb_item;
2114 * First parse all items in the list and store their value.
2119 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2121 if ((c >= '0') && (c <= '9')) {
2122 value = (unsigned int) (value * 10 + (c - '0'));
2127 printf("character %c is not a decimal digit\n", c);
2131 printf("No valid value before comma\n");
2134 if (nb_item < max_items) {
2135 parsed_items[nb_item] = value;
2141 if (nb_item >= max_items) {
2142 printf("Number of %s = %u > %u (maximum items)\n",
2143 item_name, nb_item + 1, max_items);
2146 parsed_items[nb_item++] = value;
2147 if (! check_unique_values)
2151 * Then, check that all values in the list are differents.
2152 * No optimization here...
2154 for (i = 0; i < nb_item; i++) {
2155 for (j = i + 1; j < nb_item; j++) {
2156 if (parsed_items[j] == parsed_items[i]) {
2157 printf("duplicated %s %u at index %u and %u\n",
2158 item_name, parsed_items[i], i, j);
2166 struct cmd_set_list_result {
2167 cmdline_fixed_string_t cmd_keyword;
2168 cmdline_fixed_string_t list_name;
2169 cmdline_fixed_string_t list_of_items;
2172 static void cmd_set_list_parsed(void *parsed_result,
2173 __attribute__((unused)) struct cmdline *cl,
2174 __attribute__((unused)) void *data)
2176 struct cmd_set_list_result *res;
2178 unsigned int lcorelist[RTE_MAX_LCORE];
2179 unsigned int portlist[RTE_MAX_ETHPORTS];
2181 unsigned int nb_item;
2183 res = parsed_result;
2184 if (!strcmp(res->list_name, "corelist")) {
2185 nb_item = parse_item_list(res->list_of_items, "core",
2187 parsed_items.lcorelist, 1);
2189 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2192 if (!strcmp(res->list_name, "portlist")) {
2193 nb_item = parse_item_list(res->list_of_items, "port",
2195 parsed_items.portlist, 1);
2197 set_fwd_ports_list(parsed_items.portlist, nb_item);
2201 cmdline_parse_token_string_t cmd_set_list_keyword =
2202 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2204 cmdline_parse_token_string_t cmd_set_list_name =
2205 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2206 "corelist#portlist");
2207 cmdline_parse_token_string_t cmd_set_list_of_items =
2208 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2211 cmdline_parse_inst_t cmd_set_fwd_list = {
2212 .f = cmd_set_list_parsed,
2214 .help_str = "set corelist|portlist x[,y]*",
2216 (void *)&cmd_set_list_keyword,
2217 (void *)&cmd_set_list_name,
2218 (void *)&cmd_set_list_of_items,
2223 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2225 struct cmd_setmask_result {
2226 cmdline_fixed_string_t set;
2227 cmdline_fixed_string_t mask;
2231 static void cmd_set_mask_parsed(void *parsed_result,
2232 __attribute__((unused)) struct cmdline *cl,
2233 __attribute__((unused)) void *data)
2235 struct cmd_setmask_result *res = parsed_result;
2237 if (!strcmp(res->mask, "coremask"))
2238 set_fwd_lcores_mask(res->hexavalue);
2239 else if (!strcmp(res->mask, "portmask"))
2240 set_fwd_ports_mask(res->hexavalue);
2243 cmdline_parse_token_string_t cmd_setmask_set =
2244 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2245 cmdline_parse_token_string_t cmd_setmask_mask =
2246 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2247 "coremask#portmask");
2248 cmdline_parse_token_num_t cmd_setmask_value =
2249 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2251 cmdline_parse_inst_t cmd_set_fwd_mask = {
2252 .f = cmd_set_mask_parsed,
2254 .help_str = "set coremask|portmask hexadecimal value",
2256 (void *)&cmd_setmask_set,
2257 (void *)&cmd_setmask_mask,
2258 (void *)&cmd_setmask_value,
2264 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2266 struct cmd_set_result {
2267 cmdline_fixed_string_t set;
2268 cmdline_fixed_string_t what;
2272 static void cmd_set_parsed(void *parsed_result,
2273 __attribute__((unused)) struct cmdline *cl,
2274 __attribute__((unused)) void *data)
2276 struct cmd_set_result *res = parsed_result;
2277 if (!strcmp(res->what, "nbport"))
2278 set_fwd_ports_number(res->value);
2279 else if (!strcmp(res->what, "nbcore"))
2280 set_fwd_lcores_number(res->value);
2281 else if (!strcmp(res->what, "burst"))
2282 set_nb_pkt_per_burst(res->value);
2283 else if (!strcmp(res->what, "verbose"))
2284 set_verbose_level(res->value);
2287 cmdline_parse_token_string_t cmd_set_set =
2288 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2289 cmdline_parse_token_string_t cmd_set_what =
2290 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2291 "nbport#nbcore#burst#verbose");
2292 cmdline_parse_token_num_t cmd_set_value =
2293 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2295 cmdline_parse_inst_t cmd_set_numbers = {
2296 .f = cmd_set_parsed,
2298 .help_str = "set nbport|nbcore|burst|verbose value",
2300 (void *)&cmd_set_set,
2301 (void *)&cmd_set_what,
2302 (void *)&cmd_set_value,
2307 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2309 struct cmd_set_txpkts_result {
2310 cmdline_fixed_string_t cmd_keyword;
2311 cmdline_fixed_string_t txpkts;
2312 cmdline_fixed_string_t seg_lengths;
2316 cmd_set_txpkts_parsed(void *parsed_result,
2317 __attribute__((unused)) struct cmdline *cl,
2318 __attribute__((unused)) void *data)
2320 struct cmd_set_txpkts_result *res;
2321 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2322 unsigned int nb_segs;
2324 res = parsed_result;
2325 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2326 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2328 set_tx_pkt_segments(seg_lengths, nb_segs);
2331 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2332 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2333 cmd_keyword, "set");
2334 cmdline_parse_token_string_t cmd_set_txpkts_name =
2335 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2337 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2338 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2341 cmdline_parse_inst_t cmd_set_txpkts = {
2342 .f = cmd_set_txpkts_parsed,
2344 .help_str = "set txpkts x[,y]*",
2346 (void *)&cmd_set_txpkts_keyword,
2347 (void *)&cmd_set_txpkts_name,
2348 (void *)&cmd_set_txpkts_lengths,
2353 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2354 struct cmd_rx_vlan_filter_all_result {
2355 cmdline_fixed_string_t rx_vlan;
2356 cmdline_fixed_string_t what;
2357 cmdline_fixed_string_t all;
2362 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2363 __attribute__((unused)) struct cmdline *cl,
2364 __attribute__((unused)) void *data)
2366 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2368 if (!strcmp(res->what, "add"))
2369 rx_vlan_all_filter_set(res->port_id, 1);
2371 rx_vlan_all_filter_set(res->port_id, 0);
2374 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2375 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2376 rx_vlan, "rx_vlan");
2377 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2378 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2380 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2381 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2383 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2384 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2387 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2388 .f = cmd_rx_vlan_filter_all_parsed,
2390 .help_str = "add/remove all identifiers to/from the set of VLAN "
2391 "Identifiers filtered by a port",
2393 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2394 (void *)&cmd_rx_vlan_filter_all_what,
2395 (void *)&cmd_rx_vlan_filter_all_all,
2396 (void *)&cmd_rx_vlan_filter_all_portid,
2401 /* *** VLAN OFFLOAD SET ON A PORT *** */
2402 struct cmd_vlan_offload_result {
2403 cmdline_fixed_string_t vlan;
2404 cmdline_fixed_string_t set;
2405 cmdline_fixed_string_t what;
2406 cmdline_fixed_string_t on;
2407 cmdline_fixed_string_t port_id;
2411 cmd_vlan_offload_parsed(void *parsed_result,
2412 __attribute__((unused)) struct cmdline *cl,
2413 __attribute__((unused)) void *data)
2416 struct cmd_vlan_offload_result *res = parsed_result;
2419 portid_t port_id = 0;
2423 len = strnlen(str, STR_TOKEN_SIZE);
2425 /* Get port_id first */
2433 tmp = strtoul(str, NULL, 0);
2434 /* If port_id greater that what portid_t can represent, return */
2435 if(tmp >= RTE_MAX_ETHPORTS)
2437 port_id = (portid_t)tmp;
2439 if (!strcmp(res->on, "on"))
2444 if (!strcmp(res->what, "strip"))
2445 rx_vlan_strip_set(port_id, on);
2446 else if(!strcmp(res->what, "stripq")){
2447 uint16_t queue_id = 0;
2449 /* No queue_id, return */
2451 printf("must specify (port,queue_id)\n");
2454 tmp = strtoul(str + i + 1, NULL, 0);
2455 /* If queue_id greater that what 16-bits can represent, return */
2459 queue_id = (uint16_t)tmp;
2460 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2462 else if (!strcmp(res->what, "filter"))
2463 rx_vlan_filter_set(port_id, on);
2465 vlan_extend_set(port_id, on);
2470 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2471 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2473 cmdline_parse_token_string_t cmd_vlan_offload_set =
2474 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2476 cmdline_parse_token_string_t cmd_vlan_offload_what =
2477 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2478 what, "strip#filter#qinq#stripq");
2479 cmdline_parse_token_string_t cmd_vlan_offload_on =
2480 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2482 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2483 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2486 cmdline_parse_inst_t cmd_vlan_offload = {
2487 .f = cmd_vlan_offload_parsed,
2489 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2490 " qinq(extended) for both rx/tx sides ",
2492 (void *)&cmd_vlan_offload_vlan,
2493 (void *)&cmd_vlan_offload_set,
2494 (void *)&cmd_vlan_offload_what,
2495 (void *)&cmd_vlan_offload_on,
2496 (void *)&cmd_vlan_offload_portid,
2501 /* *** VLAN TPID SET ON A PORT *** */
2502 struct cmd_vlan_tpid_result {
2503 cmdline_fixed_string_t vlan;
2504 cmdline_fixed_string_t set;
2505 cmdline_fixed_string_t what;
2511 cmd_vlan_tpid_parsed(void *parsed_result,
2512 __attribute__((unused)) struct cmdline *cl,
2513 __attribute__((unused)) void *data)
2515 struct cmd_vlan_tpid_result *res = parsed_result;
2516 vlan_tpid_set(res->port_id, res->tp_id);
2520 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2521 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2523 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2524 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2526 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2527 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2529 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2530 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2532 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2533 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2536 cmdline_parse_inst_t cmd_vlan_tpid = {
2537 .f = cmd_vlan_tpid_parsed,
2539 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2541 (void *)&cmd_vlan_tpid_vlan,
2542 (void *)&cmd_vlan_tpid_set,
2543 (void *)&cmd_vlan_tpid_what,
2544 (void *)&cmd_vlan_tpid_tpid,
2545 (void *)&cmd_vlan_tpid_portid,
2550 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2551 struct cmd_rx_vlan_filter_result {
2552 cmdline_fixed_string_t rx_vlan;
2553 cmdline_fixed_string_t what;
2559 cmd_rx_vlan_filter_parsed(void *parsed_result,
2560 __attribute__((unused)) struct cmdline *cl,
2561 __attribute__((unused)) void *data)
2563 struct cmd_rx_vlan_filter_result *res = parsed_result;
2565 if (!strcmp(res->what, "add"))
2566 rx_vft_set(res->port_id, res->vlan_id, 1);
2568 rx_vft_set(res->port_id, res->vlan_id, 0);
2571 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2572 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2573 rx_vlan, "rx_vlan");
2574 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2575 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2577 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2578 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2580 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2581 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2584 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2585 .f = cmd_rx_vlan_filter_parsed,
2587 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2588 "Identifiers filtered by a port",
2590 (void *)&cmd_rx_vlan_filter_rx_vlan,
2591 (void *)&cmd_rx_vlan_filter_what,
2592 (void *)&cmd_rx_vlan_filter_vlanid,
2593 (void *)&cmd_rx_vlan_filter_portid,
2598 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2599 struct cmd_tx_vlan_set_result {
2600 cmdline_fixed_string_t tx_vlan;
2601 cmdline_fixed_string_t set;
2607 cmd_tx_vlan_set_parsed(void *parsed_result,
2608 __attribute__((unused)) struct cmdline *cl,
2609 __attribute__((unused)) void *data)
2611 struct cmd_tx_vlan_set_result *res = parsed_result;
2612 tx_vlan_set(res->port_id, res->vlan_id);
2615 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2616 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2617 tx_vlan, "tx_vlan");
2618 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2619 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2621 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2624 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2625 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2628 cmdline_parse_inst_t cmd_tx_vlan_set = {
2629 .f = cmd_tx_vlan_set_parsed,
2631 .help_str = "enable hardware insertion of a VLAN header with a given "
2632 "TAG Identifier in packets sent on a port",
2634 (void *)&cmd_tx_vlan_set_tx_vlan,
2635 (void *)&cmd_tx_vlan_set_set,
2636 (void *)&cmd_tx_vlan_set_vlanid,
2637 (void *)&cmd_tx_vlan_set_portid,
2642 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2643 struct cmd_tx_vlan_set_pvid_result {
2644 cmdline_fixed_string_t tx_vlan;
2645 cmdline_fixed_string_t set;
2646 cmdline_fixed_string_t pvid;
2649 cmdline_fixed_string_t mode;
2653 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2654 __attribute__((unused)) struct cmdline *cl,
2655 __attribute__((unused)) void *data)
2657 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2659 if (strcmp(res->mode, "on") == 0)
2660 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2662 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2665 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2666 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2667 tx_vlan, "tx_vlan");
2668 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2669 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2671 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2672 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2674 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2675 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2677 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2678 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2680 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2681 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2684 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2685 .f = cmd_tx_vlan_set_pvid_parsed,
2687 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2689 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2690 (void *)&cmd_tx_vlan_set_pvid_set,
2691 (void *)&cmd_tx_vlan_set_pvid_pvid,
2692 (void *)&cmd_tx_vlan_set_pvid_port_id,
2693 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2694 (void *)&cmd_tx_vlan_set_pvid_mode,
2699 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2700 struct cmd_tx_vlan_reset_result {
2701 cmdline_fixed_string_t tx_vlan;
2702 cmdline_fixed_string_t reset;
2707 cmd_tx_vlan_reset_parsed(void *parsed_result,
2708 __attribute__((unused)) struct cmdline *cl,
2709 __attribute__((unused)) void *data)
2711 struct cmd_tx_vlan_reset_result *res = parsed_result;
2713 tx_vlan_reset(res->port_id);
2716 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2717 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2718 tx_vlan, "tx_vlan");
2719 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2720 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2722 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2723 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2726 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2727 .f = cmd_tx_vlan_reset_parsed,
2729 .help_str = "disable hardware insertion of a VLAN header in packets "
2732 (void *)&cmd_tx_vlan_reset_tx_vlan,
2733 (void *)&cmd_tx_vlan_reset_reset,
2734 (void *)&cmd_tx_vlan_reset_portid,
2740 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2741 struct cmd_tx_cksum_set_result {
2742 cmdline_fixed_string_t tx_cksum;
2743 cmdline_fixed_string_t set;
2749 cmd_tx_cksum_set_parsed(void *parsed_result,
2750 __attribute__((unused)) struct cmdline *cl,
2751 __attribute__((unused)) void *data)
2753 struct cmd_tx_cksum_set_result *res = parsed_result;
2755 tx_cksum_set(res->port_id, res->cksum_mask);
2758 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2759 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2760 tx_cksum, "tx_checksum");
2761 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2762 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2764 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2765 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2767 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2768 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2771 cmdline_parse_inst_t cmd_tx_cksum_set = {
2772 .f = cmd_tx_cksum_set_parsed,
2774 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2775 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2776 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2777 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2779 (void *)&cmd_tx_cksum_set_tx_cksum,
2780 (void *)&cmd_tx_cksum_set_set,
2781 (void *)&cmd_tx_cksum_set_cksum_mask,
2782 (void *)&cmd_tx_cksum_set_portid,
2787 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2788 struct cmd_set_flush_rx {
2789 cmdline_fixed_string_t set;
2790 cmdline_fixed_string_t flush_rx;
2791 cmdline_fixed_string_t mode;
2795 cmd_set_flush_rx_parsed(void *parsed_result,
2796 __attribute__((unused)) struct cmdline *cl,
2797 __attribute__((unused)) void *data)
2799 struct cmd_set_flush_rx *res = parsed_result;
2800 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2803 cmdline_parse_token_string_t cmd_setflushrx_set =
2804 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2806 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2807 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2808 flush_rx, "flush_rx");
2809 cmdline_parse_token_string_t cmd_setflushrx_mode =
2810 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2814 cmdline_parse_inst_t cmd_set_flush_rx = {
2815 .f = cmd_set_flush_rx_parsed,
2816 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2819 (void *)&cmd_setflushrx_set,
2820 (void *)&cmd_setflushrx_flush_rx,
2821 (void *)&cmd_setflushrx_mode,
2826 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2827 struct cmd_set_link_check {
2828 cmdline_fixed_string_t set;
2829 cmdline_fixed_string_t link_check;
2830 cmdline_fixed_string_t mode;
2834 cmd_set_link_check_parsed(void *parsed_result,
2835 __attribute__((unused)) struct cmdline *cl,
2836 __attribute__((unused)) void *data)
2838 struct cmd_set_link_check *res = parsed_result;
2839 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2842 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2843 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2845 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2846 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2847 link_check, "link_check");
2848 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2849 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2853 cmdline_parse_inst_t cmd_set_link_check = {
2854 .f = cmd_set_link_check_parsed,
2855 .help_str = "set link_check on|off: enable/disable link status check "
2856 "when starting/stopping a port",
2859 (void *)&cmd_setlinkcheck_set,
2860 (void *)&cmd_setlinkcheck_link_check,
2861 (void *)&cmd_setlinkcheck_mode,
2866 #ifdef RTE_NIC_BYPASS
2867 /* *** SET NIC BYPASS MODE *** */
2868 struct cmd_set_bypass_mode_result {
2869 cmdline_fixed_string_t set;
2870 cmdline_fixed_string_t bypass;
2871 cmdline_fixed_string_t mode;
2872 cmdline_fixed_string_t value;
2877 cmd_set_bypass_mode_parsed(void *parsed_result,
2878 __attribute__((unused)) struct cmdline *cl,
2879 __attribute__((unused)) void *data)
2881 struct cmd_set_bypass_mode_result *res = parsed_result;
2882 portid_t port_id = res->port_id;
2883 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2885 if (!bypass_is_supported(port_id))
2888 if (!strcmp(res->value, "bypass"))
2889 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2890 else if (!strcmp(res->value, "isolate"))
2891 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2893 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2895 /* Set the bypass mode for the relevant port. */
2896 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2897 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2901 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2902 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2904 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2905 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2907 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2908 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2910 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2912 value, "normal#bypass#isolate");
2913 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2914 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2917 cmdline_parse_inst_t cmd_set_bypass_mode = {
2918 .f = cmd_set_bypass_mode_parsed,
2919 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2920 "Set the NIC bypass mode for port_id",
2923 (void *)&cmd_setbypass_mode_set,
2924 (void *)&cmd_setbypass_mode_bypass,
2925 (void *)&cmd_setbypass_mode_mode,
2926 (void *)&cmd_setbypass_mode_value,
2927 (void *)&cmd_setbypass_mode_port,
2932 /* *** SET NIC BYPASS EVENT *** */
2933 struct cmd_set_bypass_event_result {
2934 cmdline_fixed_string_t set;
2935 cmdline_fixed_string_t bypass;
2936 cmdline_fixed_string_t event;
2937 cmdline_fixed_string_t event_value;
2938 cmdline_fixed_string_t mode;
2939 cmdline_fixed_string_t mode_value;
2944 cmd_set_bypass_event_parsed(void *parsed_result,
2945 __attribute__((unused)) struct cmdline *cl,
2946 __attribute__((unused)) void *data)
2949 struct cmd_set_bypass_event_result *res = parsed_result;
2950 portid_t port_id = res->port_id;
2951 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2952 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2954 if (!bypass_is_supported(port_id))
2957 if (!strcmp(res->event_value, "timeout"))
2958 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2959 else if (!strcmp(res->event_value, "os_on"))
2960 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2961 else if (!strcmp(res->event_value, "os_off"))
2962 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2963 else if (!strcmp(res->event_value, "power_on"))
2964 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2965 else if (!strcmp(res->event_value, "power_off"))
2966 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2968 bypass_event = RTE_BYPASS_EVENT_NONE;
2970 if (!strcmp(res->mode_value, "bypass"))
2971 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2972 else if (!strcmp(res->mode_value, "isolate"))
2973 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2975 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2977 /* Set the watchdog timeout. */
2978 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2981 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2982 (rc = rte_eth_dev_wd_timeout_store(port_id,
2983 bypass_timeout)) != 0) {
2984 printf("Failed to set timeout value %u "
2985 "for port %d, errto code: %d.\n",
2986 bypass_timeout, port_id, rc);
2990 /* Set the bypass event to transition to bypass mode. */
2991 if (0 != rte_eth_dev_bypass_event_store(port_id,
2992 bypass_event, bypass_mode)) {
2993 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2998 cmdline_parse_token_string_t cmd_setbypass_event_set =
2999 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3001 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3002 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3004 cmdline_parse_token_string_t cmd_setbypass_event_event =
3005 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3007 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3009 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3010 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3011 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3013 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3014 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3015 mode_value, "normal#bypass#isolate");
3016 cmdline_parse_token_num_t cmd_setbypass_event_port =
3017 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3020 cmdline_parse_inst_t cmd_set_bypass_event = {
3021 .f = cmd_set_bypass_event_parsed,
3022 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3023 "mode (normal|bypass|isolate) (port_id): "
3024 "Set the NIC bypass event mode for port_id",
3027 (void *)&cmd_setbypass_event_set,
3028 (void *)&cmd_setbypass_event_bypass,
3029 (void *)&cmd_setbypass_event_event,
3030 (void *)&cmd_setbypass_event_event_value,
3031 (void *)&cmd_setbypass_event_mode,
3032 (void *)&cmd_setbypass_event_mode_value,
3033 (void *)&cmd_setbypass_event_port,
3039 /* *** SET NIC BYPASS TIMEOUT *** */
3040 struct cmd_set_bypass_timeout_result {
3041 cmdline_fixed_string_t set;
3042 cmdline_fixed_string_t bypass;
3043 cmdline_fixed_string_t timeout;
3044 cmdline_fixed_string_t value;
3048 cmd_set_bypass_timeout_parsed(void *parsed_result,
3049 __attribute__((unused)) struct cmdline *cl,
3050 __attribute__((unused)) void *data)
3052 struct cmd_set_bypass_timeout_result *res = parsed_result;
3054 if (!strcmp(res->value, "1.5"))
3055 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3056 else if (!strcmp(res->value, "2"))
3057 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3058 else if (!strcmp(res->value, "3"))
3059 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3060 else if (!strcmp(res->value, "4"))
3061 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3062 else if (!strcmp(res->value, "8"))
3063 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3064 else if (!strcmp(res->value, "16"))
3065 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3066 else if (!strcmp(res->value, "32"))
3067 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3069 bypass_timeout = RTE_BYPASS_TMT_OFF;
3072 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3073 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3075 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3076 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3078 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3079 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3080 timeout, "timeout");
3081 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3082 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3083 value, "0#1.5#2#3#4#8#16#32");
3085 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3086 .f = cmd_set_bypass_timeout_parsed,
3087 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3088 "Set the NIC bypass watchdog timeout",
3091 (void *)&cmd_setbypass_timeout_set,
3092 (void *)&cmd_setbypass_timeout_bypass,
3093 (void *)&cmd_setbypass_timeout_timeout,
3094 (void *)&cmd_setbypass_timeout_value,
3099 /* *** SHOW NIC BYPASS MODE *** */
3100 struct cmd_show_bypass_config_result {
3101 cmdline_fixed_string_t show;
3102 cmdline_fixed_string_t bypass;
3103 cmdline_fixed_string_t config;
3108 cmd_show_bypass_config_parsed(void *parsed_result,
3109 __attribute__((unused)) struct cmdline *cl,
3110 __attribute__((unused)) void *data)
3112 struct cmd_show_bypass_config_result *res = parsed_result;
3113 uint32_t event_mode;
3114 uint32_t bypass_mode;
3115 portid_t port_id = res->port_id;
3116 uint32_t timeout = bypass_timeout;
3119 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3120 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3121 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3122 {"UNKNOWN", "normal", "bypass", "isolate"};
3123 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3130 int num_events = (sizeof events) / (sizeof events[0]);
3132 if (!bypass_is_supported(port_id))
3135 /* Display the bypass mode.*/
3136 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3137 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3141 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3142 bypass_mode = RTE_BYPASS_MODE_NONE;
3144 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3147 /* Display the bypass timeout.*/
3148 if (!RTE_BYPASS_TMT_VALID(timeout))
3149 timeout = RTE_BYPASS_TMT_OFF;
3151 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3153 /* Display the bypass events and associated modes. */
3154 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3156 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3157 printf("\tFailed to get bypass mode for event = %s\n",
3160 if (!RTE_BYPASS_MODE_VALID(event_mode))
3161 event_mode = RTE_BYPASS_MODE_NONE;
3163 printf("\tbypass event: %-16s = %s\n", events[i],
3169 cmdline_parse_token_string_t cmd_showbypass_config_show =
3170 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3172 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3173 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3175 cmdline_parse_token_string_t cmd_showbypass_config_config =
3176 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3178 cmdline_parse_token_num_t cmd_showbypass_config_port =
3179 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3182 cmdline_parse_inst_t cmd_show_bypass_config = {
3183 .f = cmd_show_bypass_config_parsed,
3184 .help_str = "show bypass config (port_id): "
3185 "Show the NIC bypass config for port_id",
3188 (void *)&cmd_showbypass_config_show,
3189 (void *)&cmd_showbypass_config_bypass,
3190 (void *)&cmd_showbypass_config_config,
3191 (void *)&cmd_showbypass_config_port,
3197 #ifdef RTE_LIBRTE_PMD_BOND
3198 /* *** SET BONDING MODE *** */
3199 struct cmd_set_bonding_mode_result {
3200 cmdline_fixed_string_t set;
3201 cmdline_fixed_string_t bonding;
3202 cmdline_fixed_string_t mode;
3207 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3208 __attribute__((unused)) struct cmdline *cl,
3209 __attribute__((unused)) void *data)
3211 struct cmd_set_bonding_mode_result *res = parsed_result;
3212 portid_t port_id = res->port_id;
3214 /* Set the bonding mode for the relevant port. */
3215 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3216 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3219 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3220 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3222 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3223 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3224 bonding, "bonding");
3225 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3226 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3228 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3229 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3231 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3232 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3235 cmdline_parse_inst_t cmd_set_bonding_mode = {
3236 .f = cmd_set_bonding_mode_parsed,
3237 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3240 (void *) &cmd_setbonding_mode_set,
3241 (void *) &cmd_setbonding_mode_bonding,
3242 (void *) &cmd_setbonding_mode_mode,
3243 (void *) &cmd_setbonding_mode_value,
3244 (void *) &cmd_setbonding_mode_port,
3249 /* *** SET BALANCE XMIT POLICY *** */
3250 struct cmd_set_bonding_balance_xmit_policy_result {
3251 cmdline_fixed_string_t set;
3252 cmdline_fixed_string_t bonding;
3253 cmdline_fixed_string_t balance_xmit_policy;
3255 cmdline_fixed_string_t policy;
3258 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3259 __attribute__((unused)) struct cmdline *cl,
3260 __attribute__((unused)) void *data)
3262 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3263 portid_t port_id = res->port_id;
3266 if (!strcmp(res->policy, "l2")) {
3267 policy = BALANCE_XMIT_POLICY_LAYER2;
3268 } else if (!strcmp(res->policy, "l23")) {
3269 policy = BALANCE_XMIT_POLICY_LAYER23;
3270 } else if (!strcmp(res->policy, "l34")) {
3271 policy = BALANCE_XMIT_POLICY_LAYER34;
3273 printf("\t Invalid xmit policy selection");
3277 /* Set the bonding mode for the relevant port. */
3278 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3279 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3284 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3285 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3287 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3288 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3289 bonding, "bonding");
3290 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3291 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3292 balance_xmit_policy, "balance_xmit_policy");
3293 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3294 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3296 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3297 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3298 policy, "l2#l23#l34");
3300 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3301 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3302 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3305 (void *)&cmd_setbonding_balance_xmit_policy_set,
3306 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3307 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3308 (void *)&cmd_setbonding_balance_xmit_policy_port,
3309 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3314 /* *** SHOW NIC BONDING CONFIGURATION *** */
3315 struct cmd_show_bonding_config_result {
3316 cmdline_fixed_string_t show;
3317 cmdline_fixed_string_t bonding;
3318 cmdline_fixed_string_t config;
3322 static void cmd_show_bonding_config_parsed(void *parsed_result,
3323 __attribute__((unused)) struct cmdline *cl,
3324 __attribute__((unused)) void *data)
3326 struct cmd_show_bonding_config_result *res = parsed_result;
3328 uint8_t slaves[RTE_MAX_ETHPORTS];
3329 int num_slaves, num_active_slaves;
3332 portid_t port_id = res->port_id;
3334 /* Display the bonding mode.*/
3335 bonding_mode = rte_eth_bond_mode_get(port_id);
3336 if (bonding_mode < 0) {
3337 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3340 printf("\tBonding mode: %d\n", bonding_mode);
3342 if (bonding_mode == BONDING_MODE_BALANCE) {
3343 int balance_xmit_policy;
3345 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3346 if (balance_xmit_policy < 0) {
3347 printf("\tFailed to get balance xmit policy for port = %d\n",
3351 printf("\tBalance Xmit Policy: ");
3353 switch (balance_xmit_policy) {
3354 case BALANCE_XMIT_POLICY_LAYER2:
3355 printf("BALANCE_XMIT_POLICY_LAYER2");
3357 case BALANCE_XMIT_POLICY_LAYER23:
3358 printf("BALANCE_XMIT_POLICY_LAYER23");
3360 case BALANCE_XMIT_POLICY_LAYER34:
3361 printf("BALANCE_XMIT_POLICY_LAYER34");
3368 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3370 if (num_slaves < 0) {
3371 printf("\tFailed to get slave list for port = %d\n", port_id);
3374 if (num_slaves > 0) {
3375 printf("\tSlaves (%d): [", num_slaves);
3376 for (i = 0; i < num_slaves - 1; i++)
3377 printf("%d ", slaves[i]);
3379 printf("%d]\n", slaves[num_slaves - 1]);
3381 printf("\tSlaves: []\n");
3385 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3388 if (num_active_slaves < 0) {
3389 printf("\tFailed to get active slave list for port = %d\n", port_id);
3392 if (num_active_slaves > 0) {
3393 printf("\tActive Slaves (%d): [", num_active_slaves);
3394 for (i = 0; i < num_active_slaves - 1; i++)
3395 printf("%d ", slaves[i]);
3397 printf("%d]\n", slaves[num_active_slaves - 1]);
3400 printf("\tActive Slaves: []\n");
3404 primary_id = rte_eth_bond_primary_get(port_id);
3405 if (primary_id < 0) {
3406 printf("\tFailed to get primary slave for port = %d\n", port_id);
3409 printf("\tPrimary: [%d]\n", primary_id);
3413 cmdline_parse_token_string_t cmd_showbonding_config_show =
3414 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3416 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3417 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3418 bonding, "bonding");
3419 cmdline_parse_token_string_t cmd_showbonding_config_config =
3420 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3422 cmdline_parse_token_num_t cmd_showbonding_config_port =
3423 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3426 cmdline_parse_inst_t cmd_show_bonding_config = {
3427 .f = cmd_show_bonding_config_parsed,
3428 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3431 (void *)&cmd_showbonding_config_show,
3432 (void *)&cmd_showbonding_config_bonding,
3433 (void *)&cmd_showbonding_config_config,
3434 (void *)&cmd_showbonding_config_port,
3439 /* *** SET BONDING PRIMARY *** */
3440 struct cmd_set_bonding_primary_result {
3441 cmdline_fixed_string_t set;
3442 cmdline_fixed_string_t bonding;
3443 cmdline_fixed_string_t primary;
3448 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3449 __attribute__((unused)) struct cmdline *cl,
3450 __attribute__((unused)) void *data)
3452 struct cmd_set_bonding_primary_result *res = parsed_result;
3453 portid_t master_port_id = res->port_id;
3454 portid_t slave_port_id = res->slave_id;
3456 /* Set the primary slave for a bonded device. */
3457 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3458 printf("\t Failed to set primary slave for port = %d.\n",
3465 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3466 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3468 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3469 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3470 bonding, "bonding");
3471 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3472 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3473 primary, "primary");
3474 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3475 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3477 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3478 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3481 cmdline_parse_inst_t cmd_set_bonding_primary = {
3482 .f = cmd_set_bonding_primary_parsed,
3483 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3486 (void *)&cmd_setbonding_primary_set,
3487 (void *)&cmd_setbonding_primary_bonding,
3488 (void *)&cmd_setbonding_primary_primary,
3489 (void *)&cmd_setbonding_primary_slave,
3490 (void *)&cmd_setbonding_primary_port,
3495 /* *** ADD SLAVE *** */
3496 struct cmd_add_bonding_slave_result {
3497 cmdline_fixed_string_t add;
3498 cmdline_fixed_string_t bonding;
3499 cmdline_fixed_string_t slave;
3504 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3505 __attribute__((unused)) struct cmdline *cl,
3506 __attribute__((unused)) void *data)
3508 struct cmd_add_bonding_slave_result *res = parsed_result;
3509 portid_t master_port_id = res->port_id;
3510 portid_t slave_port_id = res->slave_id;
3512 /* Set the primary slave for a bonded device. */
3513 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3514 printf("\t Failed to add slave %d to master port = %d.\n",
3515 slave_port_id, master_port_id);
3521 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3524 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3525 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3526 bonding, "bonding");
3527 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3528 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3530 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3531 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3533 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3534 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3537 cmdline_parse_inst_t cmd_add_bonding_slave = {
3538 .f = cmd_add_bonding_slave_parsed,
3539 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3542 (void *)&cmd_addbonding_slave_add,
3543 (void *)&cmd_addbonding_slave_bonding,
3544 (void *)&cmd_addbonding_slave_slave,
3545 (void *)&cmd_addbonding_slave_slaveid,
3546 (void *)&cmd_addbonding_slave_port,
3551 /* *** REMOVE SLAVE *** */
3552 struct cmd_remove_bonding_slave_result {
3553 cmdline_fixed_string_t remove;
3554 cmdline_fixed_string_t bonding;
3555 cmdline_fixed_string_t slave;
3560 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3561 __attribute__((unused)) struct cmdline *cl,
3562 __attribute__((unused)) void *data)
3564 struct cmd_remove_bonding_slave_result *res = parsed_result;
3565 portid_t master_port_id = res->port_id;
3566 portid_t slave_port_id = res->slave_id;
3568 /* Set the primary slave for a bonded device. */
3569 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3570 printf("\t Failed to remove slave %d from master port = %d.\n",
3571 slave_port_id, master_port_id);
3577 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3578 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3580 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3581 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3582 bonding, "bonding");
3583 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3584 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3586 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3587 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3589 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3590 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3593 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3594 .f = cmd_remove_bonding_slave_parsed,
3595 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3598 (void *)&cmd_removebonding_slave_remove,
3599 (void *)&cmd_removebonding_slave_bonding,
3600 (void *)&cmd_removebonding_slave_slave,
3601 (void *)&cmd_removebonding_slave_slaveid,
3602 (void *)&cmd_removebonding_slave_port,
3607 /* *** CREATE BONDED DEVICE *** */
3608 struct cmd_create_bonded_device_result {
3609 cmdline_fixed_string_t create;
3610 cmdline_fixed_string_t bonded;
3611 cmdline_fixed_string_t device;
3616 static int bond_dev_num = 0;
3618 static void cmd_create_bonded_device_parsed(void *parsed_result,
3619 __attribute__((unused)) struct cmdline *cl,
3620 __attribute__((unused)) void *data)
3622 struct cmd_create_bonded_device_result *res = parsed_result;
3623 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3626 if (test_done == 0) {
3627 printf("Please stop forwarding first\n");
3631 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3634 /* Create a new bonded device. */
3635 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3637 printf("\t Failed to create bonded device.\n");
3640 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3643 /* Update number of ports */
3644 nb_ports = rte_eth_dev_count();
3646 rte_eth_promiscuous_enable(port_id);
3651 cmdline_parse_token_string_t cmd_createbonded_device_create =
3652 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3654 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3655 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3657 cmdline_parse_token_string_t cmd_createbonded_device_device =
3658 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3660 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3661 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3663 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3664 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3667 cmdline_parse_inst_t cmd_create_bonded_device = {
3668 .f = cmd_create_bonded_device_parsed,
3669 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3672 (void *)&cmd_createbonded_device_create,
3673 (void *)&cmd_createbonded_device_bonded,
3674 (void *)&cmd_createbonded_device_device,
3675 (void *)&cmd_createbonded_device_mode,
3676 (void *)&cmd_createbonded_device_socket,
3681 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3682 struct cmd_set_bond_mac_addr_result {
3683 cmdline_fixed_string_t set;
3684 cmdline_fixed_string_t bonding;
3685 cmdline_fixed_string_t mac_addr;
3687 struct ether_addr address;
3690 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3691 __attribute__((unused)) struct cmdline *cl,
3692 __attribute__((unused)) void *data)
3694 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3697 if (res->port_num >= nb_ports) {
3698 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3702 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3704 /* check the return value and print it if is < 0 */
3706 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3709 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3710 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3711 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3714 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3717 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3718 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3719 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3720 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3722 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3723 .f = cmd_set_bond_mac_addr_parsed,
3725 .help_str = "set bonding mac_addr (port_id) (address): ",
3727 (void *)&cmd_set_bond_mac_addr_set,
3728 (void *)&cmd_set_bond_mac_addr_bonding,
3729 (void *)&cmd_set_bond_mac_addr_mac,
3730 (void *)&cmd_set_bond_mac_addr_portnum,
3731 (void *)&cmd_set_bond_mac_addr_addr,
3736 #endif /* RTE_LIBRTE_PMD_BOND */
3738 /* *** SET FORWARDING MODE *** */
3739 struct cmd_set_fwd_mode_result {
3740 cmdline_fixed_string_t set;
3741 cmdline_fixed_string_t fwd;
3742 cmdline_fixed_string_t mode;
3745 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3746 __attribute__((unused)) struct cmdline *cl,
3747 __attribute__((unused)) void *data)
3749 struct cmd_set_fwd_mode_result *res = parsed_result;
3751 set_pkt_forwarding_mode(res->mode);
3754 cmdline_parse_token_string_t cmd_setfwd_set =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3756 cmdline_parse_token_string_t cmd_setfwd_fwd =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3758 cmdline_parse_token_string_t cmd_setfwd_mode =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3760 "" /* defined at init */);
3762 cmdline_parse_inst_t cmd_set_fwd_mode = {
3763 .f = cmd_set_fwd_mode_parsed,
3765 .help_str = NULL, /* defined at init */
3767 (void *)&cmd_setfwd_set,
3768 (void *)&cmd_setfwd_fwd,
3769 (void *)&cmd_setfwd_mode,
3774 static void cmd_set_fwd_mode_init(void)
3777 static char token[128];
3778 static char help[256];
3779 cmdline_parse_token_string_t *token_struct;
3781 modes = list_pkt_forwarding_modes();
3782 snprintf(help, sizeof help, "set fwd %s - "
3783 "set packet forwarding mode", modes);
3784 cmd_set_fwd_mode.help_str = help;
3786 /* string token separator is # */
3787 for (c = token; *modes != '\0'; modes++)
3792 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3793 token_struct->string_data.str = token;
3796 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3797 struct cmd_set_burst_tx_retry_result {
3798 cmdline_fixed_string_t set;
3799 cmdline_fixed_string_t burst;
3800 cmdline_fixed_string_t tx;
3801 cmdline_fixed_string_t delay;
3803 cmdline_fixed_string_t retry;
3807 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3808 __attribute__((unused)) struct cmdline *cl,
3809 __attribute__((unused)) void *data)
3811 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3813 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3814 && !strcmp(res->tx, "tx")) {
3815 if (!strcmp(res->delay, "delay"))
3816 burst_tx_delay_time = res->time;
3817 if (!strcmp(res->retry, "retry"))
3818 burst_tx_retry_num = res->retry_num;
3823 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3824 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3825 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3826 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3828 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3829 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3830 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3832 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3833 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3834 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3835 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3836 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3837 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3839 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3840 .f = cmd_set_burst_tx_retry_parsed,
3841 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3843 (void *)&cmd_set_burst_tx_retry_set,
3844 (void *)&cmd_set_burst_tx_retry_burst,
3845 (void *)&cmd_set_burst_tx_retry_tx,
3846 (void *)&cmd_set_burst_tx_retry_delay,
3847 (void *)&cmd_set_burst_tx_retry_time,
3848 (void *)&cmd_set_burst_tx_retry_retry,
3849 (void *)&cmd_set_burst_tx_retry_retry_num,
3854 /* *** SET PROMISC MODE *** */
3855 struct cmd_set_promisc_mode_result {
3856 cmdline_fixed_string_t set;
3857 cmdline_fixed_string_t promisc;
3858 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3859 uint8_t port_num; /* valid if "allports" argument == 0 */
3860 cmdline_fixed_string_t mode;
3863 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3864 __attribute__((unused)) struct cmdline *cl,
3867 struct cmd_set_promisc_mode_result *res = parsed_result;
3871 if (!strcmp(res->mode, "on"))
3878 for (i = 0; i < nb_ports; i++) {
3880 rte_eth_promiscuous_enable(i);
3882 rte_eth_promiscuous_disable(i);
3887 rte_eth_promiscuous_enable(res->port_num);
3889 rte_eth_promiscuous_disable(res->port_num);
3893 cmdline_parse_token_string_t cmd_setpromisc_set =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3895 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3898 cmdline_parse_token_string_t cmd_setpromisc_portall =
3899 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3901 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3902 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3904 cmdline_parse_token_string_t cmd_setpromisc_mode =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3908 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3909 .f = cmd_set_promisc_mode_parsed,
3911 .help_str = "set promisc all on|off: set promisc mode for all ports",
3913 (void *)&cmd_setpromisc_set,
3914 (void *)&cmd_setpromisc_promisc,
3915 (void *)&cmd_setpromisc_portall,
3916 (void *)&cmd_setpromisc_mode,
3921 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3922 .f = cmd_set_promisc_mode_parsed,
3924 .help_str = "set promisc X on|off: set promisc mode on port X",
3926 (void *)&cmd_setpromisc_set,
3927 (void *)&cmd_setpromisc_promisc,
3928 (void *)&cmd_setpromisc_portnum,
3929 (void *)&cmd_setpromisc_mode,
3934 /* *** SET ALLMULTI MODE *** */
3935 struct cmd_set_allmulti_mode_result {
3936 cmdline_fixed_string_t set;
3937 cmdline_fixed_string_t allmulti;
3938 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3939 uint8_t port_num; /* valid if "allports" argument == 0 */
3940 cmdline_fixed_string_t mode;
3943 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3944 __attribute__((unused)) struct cmdline *cl,
3947 struct cmd_set_allmulti_mode_result *res = parsed_result;
3951 if (!strcmp(res->mode, "on"))
3958 for (i = 0; i < nb_ports; i++) {
3960 rte_eth_allmulticast_enable(i);
3962 rte_eth_allmulticast_disable(i);
3967 rte_eth_allmulticast_enable(res->port_num);
3969 rte_eth_allmulticast_disable(res->port_num);
3973 cmdline_parse_token_string_t cmd_setallmulti_set =
3974 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3975 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3976 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3978 cmdline_parse_token_string_t cmd_setallmulti_portall =
3979 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3981 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3982 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3984 cmdline_parse_token_string_t cmd_setallmulti_mode =
3985 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3988 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3989 .f = cmd_set_allmulti_mode_parsed,
3991 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3993 (void *)&cmd_setallmulti_set,
3994 (void *)&cmd_setallmulti_allmulti,
3995 (void *)&cmd_setallmulti_portall,
3996 (void *)&cmd_setallmulti_mode,
4001 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4002 .f = cmd_set_allmulti_mode_parsed,
4004 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4006 (void *)&cmd_setallmulti_set,
4007 (void *)&cmd_setallmulti_allmulti,
4008 (void *)&cmd_setallmulti_portnum,
4009 (void *)&cmd_setallmulti_mode,
4014 /* *** ADD/REMOVE A PKT FILTER *** */
4015 struct cmd_pkt_filter_result {
4016 cmdline_fixed_string_t pkt_filter;
4018 cmdline_fixed_string_t protocol;
4019 cmdline_fixed_string_t src;
4020 cmdline_ipaddr_t ip_src;
4022 cmdline_fixed_string_t dst;
4023 cmdline_ipaddr_t ip_dst;
4025 cmdline_fixed_string_t flexbytes;
4026 uint16_t flexbytes_value;
4027 cmdline_fixed_string_t vlan;
4029 cmdline_fixed_string_t queue;
4031 cmdline_fixed_string_t soft;
4036 cmd_pkt_filter_parsed(void *parsed_result,
4037 __attribute__((unused)) struct cmdline *cl,
4038 __attribute__((unused)) void *data)
4040 struct rte_fdir_filter fdir_filter;
4041 struct cmd_pkt_filter_result *res = parsed_result;
4043 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4045 if (res->ip_src.family == AF_INET)
4046 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4048 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4049 &(res->ip_src.addr.ipv6),
4050 sizeof(struct in6_addr));
4052 if (res->ip_dst.family == AF_INET)
4053 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4055 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4056 &(res->ip_dst.addr.ipv6),
4057 sizeof(struct in6_addr));
4059 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4060 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4062 if (!strcmp(res->protocol, "udp"))
4063 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4064 else if (!strcmp(res->protocol, "tcp"))
4065 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4066 else if (!strcmp(res->protocol, "sctp"))
4067 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4068 else /* default only IP */
4069 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4071 if (res->ip_dst.family == AF_INET6)
4072 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4074 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4076 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4077 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4079 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4080 fdir_add_signature_filter(res->port_id, res->queue_id,
4082 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4083 fdir_update_signature_filter(res->port_id, res->queue_id,
4085 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4086 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4087 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4088 fdir_add_perfect_filter(res->port_id, res->soft_id,
4090 (uint8_t) (res->queue_id < 0),
4092 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4093 fdir_update_perfect_filter(res->port_id, res->soft_id,
4095 (uint8_t) (res->queue_id < 0),
4097 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4098 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4104 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4105 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4107 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4108 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4109 protocol, "ip#tcp#udp#sctp");
4110 cmdline_parse_token_string_t cmd_pkt_filter_src =
4111 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4113 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4114 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4116 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4117 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4119 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4120 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4122 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4123 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4125 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4126 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4128 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4129 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4130 flexbytes, "flexbytes");
4131 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4132 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4133 flexbytes_value, UINT16);
4134 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4135 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4137 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4138 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4140 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4141 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4143 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4144 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4146 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4147 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4149 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4150 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4154 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4155 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4156 pkt_filter, "add_signature_filter");
4157 cmdline_parse_inst_t cmd_add_signature_filter = {
4158 .f = cmd_pkt_filter_parsed,
4160 .help_str = "add a signature filter",
4162 (void *)&cmd_pkt_filter_add_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_upd_signature_filter =
4183 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4184 pkt_filter, "upd_signature_filter");
4185 cmdline_parse_inst_t cmd_upd_signature_filter = {
4186 .f = cmd_pkt_filter_parsed,
4188 .help_str = "update a signature filter",
4190 (void *)&cmd_pkt_filter_upd_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,
4203 (void *)&cmd_pkt_filter_queue,
4204 (void *)&cmd_pkt_filter_queue_id,
4210 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4211 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4212 pkt_filter, "rm_signature_filter");
4213 cmdline_parse_inst_t cmd_rm_signature_filter = {
4214 .f = cmd_pkt_filter_parsed,
4216 .help_str = "remove a signature filter",
4218 (void *)&cmd_pkt_filter_rm_signature_filter,
4219 (void *)&cmd_pkt_filter_port_id,
4220 (void *)&cmd_pkt_filter_protocol,
4221 (void *)&cmd_pkt_filter_src,
4222 (void *)&cmd_pkt_filter_ip_src,
4223 (void *)&cmd_pkt_filter_port_src,
4224 (void *)&cmd_pkt_filter_dst,
4225 (void *)&cmd_pkt_filter_ip_dst,
4226 (void *)&cmd_pkt_filter_port_dst,
4227 (void *)&cmd_pkt_filter_flexbytes,
4228 (void *)&cmd_pkt_filter_flexbytes_value,
4229 (void *)&cmd_pkt_filter_vlan,
4230 (void *)&cmd_pkt_filter_vlan_id,
4236 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4237 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4238 pkt_filter, "add_perfect_filter");
4239 cmdline_parse_inst_t cmd_add_perfect_filter = {
4240 .f = cmd_pkt_filter_parsed,
4242 .help_str = "add a perfect filter",
4244 (void *)&cmd_pkt_filter_add_perfect_filter,
4245 (void *)&cmd_pkt_filter_port_id,
4246 (void *)&cmd_pkt_filter_protocol,
4247 (void *)&cmd_pkt_filter_src,
4248 (void *)&cmd_pkt_filter_ip_src,
4249 (void *)&cmd_pkt_filter_port_src,
4250 (void *)&cmd_pkt_filter_dst,
4251 (void *)&cmd_pkt_filter_ip_dst,
4252 (void *)&cmd_pkt_filter_port_dst,
4253 (void *)&cmd_pkt_filter_flexbytes,
4254 (void *)&cmd_pkt_filter_flexbytes_value,
4255 (void *)&cmd_pkt_filter_vlan,
4256 (void *)&cmd_pkt_filter_vlan_id,
4257 (void *)&cmd_pkt_filter_queue,
4258 (void *)&cmd_pkt_filter_queue_id,
4259 (void *)&cmd_pkt_filter_soft,
4260 (void *)&cmd_pkt_filter_soft_id,
4266 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4267 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4268 pkt_filter, "upd_perfect_filter");
4269 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4270 .f = cmd_pkt_filter_parsed,
4272 .help_str = "update a perfect filter",
4274 (void *)&cmd_pkt_filter_upd_perfect_filter,
4275 (void *)&cmd_pkt_filter_port_id,
4276 (void *)&cmd_pkt_filter_protocol,
4277 (void *)&cmd_pkt_filter_src,
4278 (void *)&cmd_pkt_filter_ip_src,
4279 (void *)&cmd_pkt_filter_port_src,
4280 (void *)&cmd_pkt_filter_dst,
4281 (void *)&cmd_pkt_filter_ip_dst,
4282 (void *)&cmd_pkt_filter_port_dst,
4283 (void *)&cmd_pkt_filter_flexbytes,
4284 (void *)&cmd_pkt_filter_flexbytes_value,
4285 (void *)&cmd_pkt_filter_vlan,
4286 (void *)&cmd_pkt_filter_vlan_id,
4287 (void *)&cmd_pkt_filter_queue,
4288 (void *)&cmd_pkt_filter_queue_id,
4289 (void *)&cmd_pkt_filter_soft,
4290 (void *)&cmd_pkt_filter_soft_id,
4296 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4297 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4298 pkt_filter, "rm_perfect_filter");
4299 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4300 .f = cmd_pkt_filter_parsed,
4302 .help_str = "remove a perfect filter",
4304 (void *)&cmd_pkt_filter_rm_perfect_filter,
4305 (void *)&cmd_pkt_filter_port_id,
4306 (void *)&cmd_pkt_filter_protocol,
4307 (void *)&cmd_pkt_filter_src,
4308 (void *)&cmd_pkt_filter_ip_src,
4309 (void *)&cmd_pkt_filter_port_src,
4310 (void *)&cmd_pkt_filter_dst,
4311 (void *)&cmd_pkt_filter_ip_dst,
4312 (void *)&cmd_pkt_filter_port_dst,
4313 (void *)&cmd_pkt_filter_flexbytes,
4314 (void *)&cmd_pkt_filter_flexbytes_value,
4315 (void *)&cmd_pkt_filter_vlan,
4316 (void *)&cmd_pkt_filter_vlan_id,
4317 (void *)&cmd_pkt_filter_soft,
4318 (void *)&cmd_pkt_filter_soft_id,
4323 /* *** SETUP MASKS FILTER *** */
4324 struct cmd_pkt_filter_masks_result {
4325 cmdline_fixed_string_t filter_mask;
4327 cmdline_fixed_string_t src_mask;
4328 uint32_t ip_src_mask;
4329 uint16_t ipv6_src_mask;
4330 uint16_t port_src_mask;
4331 cmdline_fixed_string_t dst_mask;
4332 uint32_t ip_dst_mask;
4333 uint16_t ipv6_dst_mask;
4334 uint16_t port_dst_mask;
4335 cmdline_fixed_string_t flexbytes;
4336 uint8_t flexbytes_value;
4337 cmdline_fixed_string_t vlan_id;
4338 uint8_t vlan_id_value;
4339 cmdline_fixed_string_t vlan_prio;
4340 uint8_t vlan_prio_value;
4341 cmdline_fixed_string_t only_ip_flow;
4342 uint8_t only_ip_flow_value;
4343 cmdline_fixed_string_t comp_ipv6_dst;
4344 uint8_t comp_ipv6_dst_value;
4348 cmd_pkt_filter_masks_parsed(void *parsed_result,
4349 __attribute__((unused)) struct cmdline *cl,
4350 __attribute__((unused)) void *data)
4352 struct rte_fdir_masks fdir_masks;
4353 struct cmd_pkt_filter_masks_result *res = parsed_result;
4355 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4357 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4358 fdir_masks.vlan_id = res->vlan_id_value;
4359 fdir_masks.vlan_prio = res->vlan_prio_value;
4360 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4361 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4362 fdir_masks.src_port_mask = res->port_src_mask;
4363 fdir_masks.dst_port_mask = res->port_dst_mask;
4364 fdir_masks.flexbytes = res->flexbytes_value;
4366 fdir_set_masks(res->port_id, &fdir_masks);
4369 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4370 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4371 filter_mask, "set_masks_filter");
4372 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4373 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4375 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4376 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4377 only_ip_flow, "only_ip_flow");
4378 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4379 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4380 only_ip_flow_value, UINT8);
4381 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4382 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4383 src_mask, "src_mask");
4384 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4385 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4386 ip_src_mask, UINT32);
4387 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4388 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4389 port_src_mask, UINT16);
4390 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4391 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4392 dst_mask, "dst_mask");
4393 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4394 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4395 ip_dst_mask, UINT32);
4396 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4397 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4398 port_dst_mask, UINT16);
4399 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4400 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4401 flexbytes, "flexbytes");
4402 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4403 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4404 flexbytes_value, UINT8);
4405 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4406 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4407 vlan_id, "vlan_id");
4408 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4409 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4410 vlan_id_value, UINT8);
4411 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4412 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4413 vlan_prio, "vlan_prio");
4414 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4415 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4416 vlan_prio_value, UINT8);
4418 cmdline_parse_inst_t cmd_set_masks_filter = {
4419 .f = cmd_pkt_filter_masks_parsed,
4421 .help_str = "setup masks filter",
4423 (void *)&cmd_pkt_filter_masks_filter_mask,
4424 (void *)&cmd_pkt_filter_masks_port_id,
4425 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4426 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4427 (void *)&cmd_pkt_filter_masks_src_mask,
4428 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4429 (void *)&cmd_pkt_filter_masks_port_src_mask,
4430 (void *)&cmd_pkt_filter_masks_dst_mask,
4431 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4432 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4433 (void *)&cmd_pkt_filter_masks_flexbytes,
4434 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4435 (void *)&cmd_pkt_filter_masks_vlan_id,
4436 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4437 (void *)&cmd_pkt_filter_masks_vlan_prio,
4438 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4444 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct rte_fdir_masks fdir_masks;
4449 struct cmd_pkt_filter_masks_result *res = parsed_result;
4451 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4453 fdir_masks.set_ipv6_mask = 1;
4454 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4455 fdir_masks.vlan_id = res->vlan_id_value;
4456 fdir_masks.vlan_prio = res->vlan_prio_value;
4457 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4458 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4459 fdir_masks.src_port_mask = res->port_src_mask;
4460 fdir_masks.dst_port_mask = res->port_dst_mask;
4461 fdir_masks.flexbytes = res->flexbytes_value;
4462 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4464 fdir_set_masks(res->port_id, &fdir_masks);
4467 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4468 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4469 filter_mask, "set_ipv6_masks_filter");
4470 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4471 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4472 ipv6_src_mask, UINT16);
4473 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4474 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4475 ipv6_dst_mask, UINT16);
4477 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4478 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4479 comp_ipv6_dst, "compare_dst");
4480 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4481 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4482 comp_ipv6_dst_value, UINT8);
4484 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4485 .f = cmd_pkt_filter_masks_ipv6_parsed,
4487 .help_str = "setup ipv6 masks filter",
4489 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4490 (void *)&cmd_pkt_filter_masks_port_id,
4491 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4492 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4493 (void *)&cmd_pkt_filter_masks_src_mask,
4494 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4495 (void *)&cmd_pkt_filter_masks_port_src_mask,
4496 (void *)&cmd_pkt_filter_masks_dst_mask,
4497 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4498 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4499 (void *)&cmd_pkt_filter_masks_flexbytes,
4500 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4501 (void *)&cmd_pkt_filter_masks_vlan_id,
4502 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4503 (void *)&cmd_pkt_filter_masks_vlan_prio,
4504 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4505 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4506 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4511 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4512 struct cmd_link_flow_ctrl_set_result {
4513 cmdline_fixed_string_t set;
4514 cmdline_fixed_string_t flow_ctrl;
4515 cmdline_fixed_string_t rx;
4516 cmdline_fixed_string_t rx_lfc_mode;
4517 cmdline_fixed_string_t tx;
4518 cmdline_fixed_string_t tx_lfc_mode;
4519 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4520 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4521 cmdline_fixed_string_t autoneg_str;
4522 cmdline_fixed_string_t autoneg;
4523 cmdline_fixed_string_t hw_str;
4524 uint32_t high_water;
4525 cmdline_fixed_string_t lw_str;
4527 cmdline_fixed_string_t pt_str;
4528 uint16_t pause_time;
4529 cmdline_fixed_string_t xon_str;
4534 cmdline_parse_token_string_t cmd_lfc_set_set =
4535 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4537 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4538 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4539 flow_ctrl, "flow_ctrl");
4540 cmdline_parse_token_string_t cmd_lfc_set_rx =
4541 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4543 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4544 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4545 rx_lfc_mode, "on#off");
4546 cmdline_parse_token_string_t cmd_lfc_set_tx =
4547 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4549 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4550 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4551 tx_lfc_mode, "on#off");
4552 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4553 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4554 hw_str, "high_water");
4555 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4556 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4557 high_water, UINT32);
4558 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4559 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4560 lw_str, "low_water");
4561 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4562 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4564 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4565 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4566 pt_str, "pause_time");
4567 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4568 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4569 pause_time, UINT16);
4570 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4571 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4572 xon_str, "send_xon");
4573 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4574 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4576 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4578 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4579 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4581 mac_ctrl_frame_fwd_mode, "on#off");
4582 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4584 autoneg_str, "autoneg");
4585 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4586 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4588 cmdline_parse_token_num_t cmd_lfc_set_portid =
4589 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4592 /* forward declaration */
4594 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4597 cmdline_parse_inst_t cmd_link_flow_control_set = {
4598 .f = cmd_link_flow_ctrl_set_parsed,
4600 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4601 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4602 autoneg on|off port_id",
4604 (void *)&cmd_lfc_set_set,
4605 (void *)&cmd_lfc_set_flow_ctrl,
4606 (void *)&cmd_lfc_set_rx,
4607 (void *)&cmd_lfc_set_rx_mode,
4608 (void *)&cmd_lfc_set_tx,
4609 (void *)&cmd_lfc_set_tx_mode,
4610 (void *)&cmd_lfc_set_high_water,
4611 (void *)&cmd_lfc_set_low_water,
4612 (void *)&cmd_lfc_set_pause_time,
4613 (void *)&cmd_lfc_set_send_xon,
4614 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4615 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4616 (void *)&cmd_lfc_set_autoneg_str,
4617 (void *)&cmd_lfc_set_autoneg,
4618 (void *)&cmd_lfc_set_portid,
4623 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4624 .f = cmd_link_flow_ctrl_set_parsed,
4625 .data = (void *)&cmd_link_flow_control_set_rx,
4626 .help_str = "Change rx flow control parameter: set flow_ctrl "
4627 "rx on|off port_id",
4629 (void *)&cmd_lfc_set_set,
4630 (void *)&cmd_lfc_set_flow_ctrl,
4631 (void *)&cmd_lfc_set_rx,
4632 (void *)&cmd_lfc_set_rx_mode,
4633 (void *)&cmd_lfc_set_portid,
4638 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4639 .f = cmd_link_flow_ctrl_set_parsed,
4640 .data = (void *)&cmd_link_flow_control_set_tx,
4641 .help_str = "Change tx flow control parameter: set flow_ctrl "
4642 "tx on|off port_id",
4644 (void *)&cmd_lfc_set_set,
4645 (void *)&cmd_lfc_set_flow_ctrl,
4646 (void *)&cmd_lfc_set_tx,
4647 (void *)&cmd_lfc_set_tx_mode,
4648 (void *)&cmd_lfc_set_portid,
4653 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4654 .f = cmd_link_flow_ctrl_set_parsed,
4655 .data = (void *)&cmd_link_flow_control_set_hw,
4656 .help_str = "Change high water flow control parameter: set flow_ctrl "
4657 "high_water value port_id",
4659 (void *)&cmd_lfc_set_set,
4660 (void *)&cmd_lfc_set_flow_ctrl,
4661 (void *)&cmd_lfc_set_high_water_str,
4662 (void *)&cmd_lfc_set_high_water,
4663 (void *)&cmd_lfc_set_portid,
4668 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4669 .f = cmd_link_flow_ctrl_set_parsed,
4670 .data = (void *)&cmd_link_flow_control_set_lw,
4671 .help_str = "Change low water flow control parameter: set flow_ctrl "
4672 "low_water value port_id",
4674 (void *)&cmd_lfc_set_set,
4675 (void *)&cmd_lfc_set_flow_ctrl,
4676 (void *)&cmd_lfc_set_low_water_str,
4677 (void *)&cmd_lfc_set_low_water,
4678 (void *)&cmd_lfc_set_portid,
4683 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4684 .f = cmd_link_flow_ctrl_set_parsed,
4685 .data = (void *)&cmd_link_flow_control_set_pt,
4686 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4687 "pause_time value port_id",
4689 (void *)&cmd_lfc_set_set,
4690 (void *)&cmd_lfc_set_flow_ctrl,
4691 (void *)&cmd_lfc_set_pause_time_str,
4692 (void *)&cmd_lfc_set_pause_time,
4693 (void *)&cmd_lfc_set_portid,
4698 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4699 .f = cmd_link_flow_ctrl_set_parsed,
4700 .data = (void *)&cmd_link_flow_control_set_xon,
4701 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4702 "send_xon value port_id",
4704 (void *)&cmd_lfc_set_set,
4705 (void *)&cmd_lfc_set_flow_ctrl,
4706 (void *)&cmd_lfc_set_send_xon_str,
4707 (void *)&cmd_lfc_set_send_xon,
4708 (void *)&cmd_lfc_set_portid,
4713 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4714 .f = cmd_link_flow_ctrl_set_parsed,
4715 .data = (void *)&cmd_link_flow_control_set_macfwd,
4716 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4717 "mac_ctrl_frame_fwd on|off port_id",
4719 (void *)&cmd_lfc_set_set,
4720 (void *)&cmd_lfc_set_flow_ctrl,
4721 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4722 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4723 (void *)&cmd_lfc_set_portid,
4728 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4729 .f = cmd_link_flow_ctrl_set_parsed,
4730 .data = (void *)&cmd_link_flow_control_set_autoneg,
4731 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4732 "autoneg on|off port_id",
4734 (void *)&cmd_lfc_set_set,
4735 (void *)&cmd_lfc_set_flow_ctrl,
4736 (void *)&cmd_lfc_set_autoneg_str,
4737 (void *)&cmd_lfc_set_autoneg,
4738 (void *)&cmd_lfc_set_portid,
4744 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4745 __attribute__((unused)) struct cmdline *cl,
4748 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4749 cmdline_parse_inst_t *cmd = data;
4750 struct rte_eth_fc_conf fc_conf;
4751 int rx_fc_en, tx_fc_en;
4755 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4756 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4757 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4758 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4760 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4761 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4764 /* Partial command line, retrieve current configuration */
4766 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4768 printf("cannot get current flow ctrl parameters, return"
4769 "code = %d\n", ret);
4773 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4774 (fc_conf.mode == RTE_FC_FULL))
4776 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4777 (fc_conf.mode == RTE_FC_FULL))
4781 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4782 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4784 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4785 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4787 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4789 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4790 fc_conf.high_water = res->high_water;
4792 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4793 fc_conf.low_water = res->low_water;
4795 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4796 fc_conf.pause_time = res->pause_time;
4798 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4799 fc_conf.send_xon = res->send_xon;
4801 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4802 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4803 fc_conf.mac_ctrl_frame_fwd = 1;
4805 fc_conf.mac_ctrl_frame_fwd = 0;
4808 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4809 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4811 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4813 printf("bad flow contrl parameter, return code = %d \n", ret);
4816 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4817 struct cmd_priority_flow_ctrl_set_result {
4818 cmdline_fixed_string_t set;
4819 cmdline_fixed_string_t pfc_ctrl;
4820 cmdline_fixed_string_t rx;
4821 cmdline_fixed_string_t rx_pfc_mode;
4822 cmdline_fixed_string_t tx;
4823 cmdline_fixed_string_t tx_pfc_mode;
4824 uint32_t high_water;
4826 uint16_t pause_time;
4832 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4833 __attribute__((unused)) struct cmdline *cl,
4834 __attribute__((unused)) void *data)
4836 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4837 struct rte_eth_pfc_conf pfc_conf;
4838 int rx_fc_enable, tx_fc_enable;
4842 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4843 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4844 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4845 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4847 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4848 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4851 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4852 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4853 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4854 pfc_conf.fc.high_water = res->high_water;
4855 pfc_conf.fc.low_water = res->low_water;
4856 pfc_conf.fc.pause_time = res->pause_time;
4857 pfc_conf.priority = res->priority;
4859 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
4861 printf("bad priority flow contrl parameter, return code = %d \n", ret);
4864 cmdline_parse_token_string_t cmd_pfc_set_set =
4865 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4867 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
4868 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4869 pfc_ctrl, "pfc_ctrl");
4870 cmdline_parse_token_string_t cmd_pfc_set_rx =
4871 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4873 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
4874 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4875 rx_pfc_mode, "on#off");
4876 cmdline_parse_token_string_t cmd_pfc_set_tx =
4877 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4879 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
4880 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4881 tx_pfc_mode, "on#off");
4882 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4883 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4884 high_water, UINT32);
4885 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4886 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4888 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4889 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4890 pause_time, UINT16);
4891 cmdline_parse_token_num_t cmd_pfc_set_priority =
4892 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4894 cmdline_parse_token_num_t cmd_pfc_set_portid =
4895 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4898 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4899 .f = cmd_priority_flow_ctrl_set_parsed,
4901 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4902 tx on|off high_water low_water pause_time priority port_id",
4904 (void *)&cmd_pfc_set_set,
4905 (void *)&cmd_pfc_set_flow_ctrl,
4906 (void *)&cmd_pfc_set_rx,
4907 (void *)&cmd_pfc_set_rx_mode,
4908 (void *)&cmd_pfc_set_tx,
4909 (void *)&cmd_pfc_set_tx_mode,
4910 (void *)&cmd_pfc_set_high_water,
4911 (void *)&cmd_pfc_set_low_water,
4912 (void *)&cmd_pfc_set_pause_time,
4913 (void *)&cmd_pfc_set_priority,
4914 (void *)&cmd_pfc_set_portid,
4919 /* *** RESET CONFIGURATION *** */
4920 struct cmd_reset_result {
4921 cmdline_fixed_string_t reset;
4922 cmdline_fixed_string_t def;
4925 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4927 __attribute__((unused)) void *data)
4929 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4930 set_def_fwd_config();
4933 cmdline_parse_token_string_t cmd_reset_set =
4934 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4935 cmdline_parse_token_string_t cmd_reset_def =
4936 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4939 cmdline_parse_inst_t cmd_reset = {
4940 .f = cmd_reset_parsed,
4942 .help_str = "set default: reset default forwarding configuration",
4944 (void *)&cmd_reset_set,
4945 (void *)&cmd_reset_def,
4950 /* *** START FORWARDING *** */
4951 struct cmd_start_result {
4952 cmdline_fixed_string_t start;
4955 cmdline_parse_token_string_t cmd_start_start =
4956 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4958 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4959 __attribute__((unused)) struct cmdline *cl,
4960 __attribute__((unused)) void *data)
4962 start_packet_forwarding(0);
4965 cmdline_parse_inst_t cmd_start = {
4966 .f = cmd_start_parsed,
4968 .help_str = "start packet forwarding",
4970 (void *)&cmd_start_start,
4975 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4976 struct cmd_start_tx_first_result {
4977 cmdline_fixed_string_t start;
4978 cmdline_fixed_string_t tx_first;
4982 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4983 __attribute__((unused)) struct cmdline *cl,
4984 __attribute__((unused)) void *data)
4986 start_packet_forwarding(1);
4989 cmdline_parse_token_string_t cmd_start_tx_first_start =
4990 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4992 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4993 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4994 tx_first, "tx_first");
4996 cmdline_parse_inst_t cmd_start_tx_first = {
4997 .f = cmd_start_tx_first_parsed,
4999 .help_str = "start packet forwarding, after sending 1 burst of packets",
5001 (void *)&cmd_start_tx_first_start,
5002 (void *)&cmd_start_tx_first_tx_first,
5007 /* *** SET LINK UP *** */
5008 struct cmd_set_link_up_result {
5009 cmdline_fixed_string_t set;
5010 cmdline_fixed_string_t link_up;
5011 cmdline_fixed_string_t port;
5015 cmdline_parse_token_string_t cmd_set_link_up_set =
5016 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5017 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5018 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5020 cmdline_parse_token_string_t cmd_set_link_up_port =
5021 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5022 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5023 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5025 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5026 __attribute__((unused)) struct cmdline *cl,
5027 __attribute__((unused)) void *data)
5029 struct cmd_set_link_up_result *res = parsed_result;
5030 dev_set_link_up(res->port_id);
5033 cmdline_parse_inst_t cmd_set_link_up = {
5034 .f = cmd_set_link_up_parsed,
5036 .help_str = "set link-up port (port id)",
5038 (void *)&cmd_set_link_up_set,
5039 (void *)&cmd_set_link_up_link_up,
5040 (void *)&cmd_set_link_up_port,
5041 (void *)&cmd_set_link_up_port_id,
5046 /* *** SET LINK DOWN *** */
5047 struct cmd_set_link_down_result {
5048 cmdline_fixed_string_t set;
5049 cmdline_fixed_string_t link_down;
5050 cmdline_fixed_string_t port;
5054 cmdline_parse_token_string_t cmd_set_link_down_set =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5056 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5057 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5059 cmdline_parse_token_string_t cmd_set_link_down_port =
5060 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5061 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5062 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5064 static void cmd_set_link_down_parsed(
5065 __attribute__((unused)) void *parsed_result,
5066 __attribute__((unused)) struct cmdline *cl,
5067 __attribute__((unused)) void *data)
5069 struct cmd_set_link_down_result *res = parsed_result;
5070 dev_set_link_down(res->port_id);
5073 cmdline_parse_inst_t cmd_set_link_down = {
5074 .f = cmd_set_link_down_parsed,
5076 .help_str = "set link-down port (port id)",
5078 (void *)&cmd_set_link_down_set,
5079 (void *)&cmd_set_link_down_link_down,
5080 (void *)&cmd_set_link_down_port,
5081 (void *)&cmd_set_link_down_port_id,
5086 /* *** SHOW CFG *** */
5087 struct cmd_showcfg_result {
5088 cmdline_fixed_string_t show;
5089 cmdline_fixed_string_t cfg;
5090 cmdline_fixed_string_t what;
5093 static void cmd_showcfg_parsed(void *parsed_result,
5094 __attribute__((unused)) struct cmdline *cl,
5095 __attribute__((unused)) void *data)
5097 struct cmd_showcfg_result *res = parsed_result;
5098 if (!strcmp(res->what, "rxtx"))
5099 rxtx_config_display();
5100 else if (!strcmp(res->what, "cores"))
5101 fwd_lcores_config_display();
5102 else if (!strcmp(res->what, "fwd"))
5103 fwd_config_display();
5106 cmdline_parse_token_string_t cmd_showcfg_show =
5107 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5108 cmdline_parse_token_string_t cmd_showcfg_port =
5109 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5110 cmdline_parse_token_string_t cmd_showcfg_what =
5111 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5114 cmdline_parse_inst_t cmd_showcfg = {
5115 .f = cmd_showcfg_parsed,
5117 .help_str = "show config rxtx|cores|fwd",
5119 (void *)&cmd_showcfg_show,
5120 (void *)&cmd_showcfg_port,
5121 (void *)&cmd_showcfg_what,
5126 /* *** SHOW ALL PORT INFO *** */
5127 struct cmd_showportall_result {
5128 cmdline_fixed_string_t show;
5129 cmdline_fixed_string_t port;
5130 cmdline_fixed_string_t what;
5131 cmdline_fixed_string_t all;
5134 static void cmd_showportall_parsed(void *parsed_result,
5135 __attribute__((unused)) struct cmdline *cl,
5136 __attribute__((unused)) void *data)
5140 struct cmd_showportall_result *res = parsed_result;
5141 if (!strcmp(res->show, "clear")) {
5142 if (!strcmp(res->what, "stats"))
5143 for (i = 0; i < nb_ports; i++)
5145 else if (!strcmp(res->what, "xstats"))
5146 for (i = 0; i < nb_ports; i++)
5147 nic_xstats_clear(i);
5148 } else if (!strcmp(res->what, "info"))
5149 for (i = 0; i < nb_ports; i++)
5150 port_infos_display(i);
5151 else if (!strcmp(res->what, "stats"))
5152 for (i = 0; i < nb_ports; i++)
5153 nic_stats_display(i);
5154 else if (!strcmp(res->what, "xstats"))
5155 for (i = 0; i < nb_ports; i++)
5156 nic_xstats_display(i);
5157 else if (!strcmp(res->what, "fdir"))
5158 for (i = 0; i < nb_ports; i++)
5160 else if (!strcmp(res->what, "stat_qmap"))
5161 for (i = 0; i < nb_ports; i++)
5162 nic_stats_mapping_display(i);
5165 cmdline_parse_token_string_t cmd_showportall_show =
5166 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5168 cmdline_parse_token_string_t cmd_showportall_port =
5169 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5170 cmdline_parse_token_string_t cmd_showportall_what =
5171 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5172 "info#stats#xstats#fdir#stat_qmap");
5173 cmdline_parse_token_string_t cmd_showportall_all =
5174 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5175 cmdline_parse_inst_t cmd_showportall = {
5176 .f = cmd_showportall_parsed,
5178 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5180 (void *)&cmd_showportall_show,
5181 (void *)&cmd_showportall_port,
5182 (void *)&cmd_showportall_what,
5183 (void *)&cmd_showportall_all,
5188 /* *** SHOW PORT INFO *** */
5189 struct cmd_showport_result {
5190 cmdline_fixed_string_t show;
5191 cmdline_fixed_string_t port;
5192 cmdline_fixed_string_t what;
5196 static void cmd_showport_parsed(void *parsed_result,
5197 __attribute__((unused)) struct cmdline *cl,
5198 __attribute__((unused)) void *data)
5200 struct cmd_showport_result *res = parsed_result;
5201 if (!strcmp(res->show, "clear")) {
5202 if (!strcmp(res->what, "stats"))
5203 nic_stats_clear(res->portnum);
5204 else if (!strcmp(res->what, "xstats"))
5205 nic_xstats_clear(res->portnum);
5206 } else if (!strcmp(res->what, "info"))
5207 port_infos_display(res->portnum);
5208 else if (!strcmp(res->what, "stats"))
5209 nic_stats_display(res->portnum);
5210 else if (!strcmp(res->what, "xstats"))
5211 nic_xstats_display(res->portnum);
5212 else if (!strcmp(res->what, "fdir"))
5213 fdir_get_infos(res->portnum);
5214 else if (!strcmp(res->what, "stat_qmap"))
5215 nic_stats_mapping_display(res->portnum);
5218 cmdline_parse_token_string_t cmd_showport_show =
5219 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5221 cmdline_parse_token_string_t cmd_showport_port =
5222 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5223 cmdline_parse_token_string_t cmd_showport_what =
5224 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5225 "info#stats#xstats#fdir#stat_qmap");
5226 cmdline_parse_token_num_t cmd_showport_portnum =
5227 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5229 cmdline_parse_inst_t cmd_showport = {
5230 .f = cmd_showport_parsed,
5232 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5234 (void *)&cmd_showport_show,
5235 (void *)&cmd_showport_port,
5236 (void *)&cmd_showport_what,
5237 (void *)&cmd_showport_portnum,
5242 /* *** READ PORT REGISTER *** */
5243 struct cmd_read_reg_result {
5244 cmdline_fixed_string_t read;
5245 cmdline_fixed_string_t reg;
5251 cmd_read_reg_parsed(void *parsed_result,
5252 __attribute__((unused)) struct cmdline *cl,
5253 __attribute__((unused)) void *data)
5255 struct cmd_read_reg_result *res = parsed_result;
5256 port_reg_display(res->port_id, res->reg_off);
5259 cmdline_parse_token_string_t cmd_read_reg_read =
5260 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5261 cmdline_parse_token_string_t cmd_read_reg_reg =
5262 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5263 cmdline_parse_token_num_t cmd_read_reg_port_id =
5264 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5265 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5266 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5268 cmdline_parse_inst_t cmd_read_reg = {
5269 .f = cmd_read_reg_parsed,
5271 .help_str = "read reg port_id reg_off",
5273 (void *)&cmd_read_reg_read,
5274 (void *)&cmd_read_reg_reg,
5275 (void *)&cmd_read_reg_port_id,
5276 (void *)&cmd_read_reg_reg_off,
5281 /* *** READ PORT REGISTER BIT FIELD *** */
5282 struct cmd_read_reg_bit_field_result {
5283 cmdline_fixed_string_t read;
5284 cmdline_fixed_string_t regfield;
5292 cmd_read_reg_bit_field_parsed(void *parsed_result,
5293 __attribute__((unused)) struct cmdline *cl,
5294 __attribute__((unused)) void *data)
5296 struct cmd_read_reg_bit_field_result *res = parsed_result;
5297 port_reg_bit_field_display(res->port_id, res->reg_off,
5298 res->bit1_pos, res->bit2_pos);
5301 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5302 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5304 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5305 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5306 regfield, "regfield");
5307 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5308 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5310 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5311 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5313 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5314 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5316 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5317 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5320 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5321 .f = cmd_read_reg_bit_field_parsed,
5323 .help_str = "read regfield port_id reg_off bit_x bit_y "
5324 "(read register bit field between bit_x and bit_y included)",
5326 (void *)&cmd_read_reg_bit_field_read,
5327 (void *)&cmd_read_reg_bit_field_regfield,
5328 (void *)&cmd_read_reg_bit_field_port_id,
5329 (void *)&cmd_read_reg_bit_field_reg_off,
5330 (void *)&cmd_read_reg_bit_field_bit1_pos,
5331 (void *)&cmd_read_reg_bit_field_bit2_pos,
5336 /* *** READ PORT REGISTER BIT *** */
5337 struct cmd_read_reg_bit_result {
5338 cmdline_fixed_string_t read;
5339 cmdline_fixed_string_t regbit;
5346 cmd_read_reg_bit_parsed(void *parsed_result,
5347 __attribute__((unused)) struct cmdline *cl,
5348 __attribute__((unused)) void *data)
5350 struct cmd_read_reg_bit_result *res = parsed_result;
5351 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5354 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5355 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5356 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5357 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5359 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5360 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5361 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5362 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5363 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5364 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5366 cmdline_parse_inst_t cmd_read_reg_bit = {
5367 .f = cmd_read_reg_bit_parsed,
5369 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5371 (void *)&cmd_read_reg_bit_read,
5372 (void *)&cmd_read_reg_bit_regbit,
5373 (void *)&cmd_read_reg_bit_port_id,
5374 (void *)&cmd_read_reg_bit_reg_off,
5375 (void *)&cmd_read_reg_bit_bit_pos,
5380 /* *** WRITE PORT REGISTER *** */
5381 struct cmd_write_reg_result {
5382 cmdline_fixed_string_t write;
5383 cmdline_fixed_string_t reg;
5390 cmd_write_reg_parsed(void *parsed_result,
5391 __attribute__((unused)) struct cmdline *cl,
5392 __attribute__((unused)) void *data)
5394 struct cmd_write_reg_result *res = parsed_result;
5395 port_reg_set(res->port_id, res->reg_off, res->value);
5398 cmdline_parse_token_string_t cmd_write_reg_write =
5399 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5400 cmdline_parse_token_string_t cmd_write_reg_reg =
5401 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5402 cmdline_parse_token_num_t cmd_write_reg_port_id =
5403 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5404 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5405 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5406 cmdline_parse_token_num_t cmd_write_reg_value =
5407 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5409 cmdline_parse_inst_t cmd_write_reg = {
5410 .f = cmd_write_reg_parsed,
5412 .help_str = "write reg port_id reg_off reg_value",
5414 (void *)&cmd_write_reg_write,
5415 (void *)&cmd_write_reg_reg,
5416 (void *)&cmd_write_reg_port_id,
5417 (void *)&cmd_write_reg_reg_off,
5418 (void *)&cmd_write_reg_value,
5423 /* *** WRITE PORT REGISTER BIT FIELD *** */
5424 struct cmd_write_reg_bit_field_result {
5425 cmdline_fixed_string_t write;
5426 cmdline_fixed_string_t regfield;
5435 cmd_write_reg_bit_field_parsed(void *parsed_result,
5436 __attribute__((unused)) struct cmdline *cl,
5437 __attribute__((unused)) void *data)
5439 struct cmd_write_reg_bit_field_result *res = parsed_result;
5440 port_reg_bit_field_set(res->port_id, res->reg_off,
5441 res->bit1_pos, res->bit2_pos, res->value);
5444 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5445 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5447 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5448 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5449 regfield, "regfield");
5450 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5451 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5453 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5454 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5456 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5457 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5459 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5460 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5462 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5463 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5466 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5467 .f = cmd_write_reg_bit_field_parsed,
5469 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5470 "(set register bit field between bit_x and bit_y included)",
5472 (void *)&cmd_write_reg_bit_field_write,
5473 (void *)&cmd_write_reg_bit_field_regfield,
5474 (void *)&cmd_write_reg_bit_field_port_id,
5475 (void *)&cmd_write_reg_bit_field_reg_off,
5476 (void *)&cmd_write_reg_bit_field_bit1_pos,
5477 (void *)&cmd_write_reg_bit_field_bit2_pos,
5478 (void *)&cmd_write_reg_bit_field_value,
5483 /* *** WRITE PORT REGISTER BIT *** */
5484 struct cmd_write_reg_bit_result {
5485 cmdline_fixed_string_t write;
5486 cmdline_fixed_string_t regbit;
5494 cmd_write_reg_bit_parsed(void *parsed_result,
5495 __attribute__((unused)) struct cmdline *cl,
5496 __attribute__((unused)) void *data)
5498 struct cmd_write_reg_bit_result *res = parsed_result;
5499 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5502 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5503 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5505 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5506 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5508 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5509 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5510 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5511 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5512 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5513 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5514 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5515 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5517 cmdline_parse_inst_t cmd_write_reg_bit = {
5518 .f = cmd_write_reg_bit_parsed,
5520 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5522 (void *)&cmd_write_reg_bit_write,
5523 (void *)&cmd_write_reg_bit_regbit,
5524 (void *)&cmd_write_reg_bit_port_id,
5525 (void *)&cmd_write_reg_bit_reg_off,
5526 (void *)&cmd_write_reg_bit_bit_pos,
5527 (void *)&cmd_write_reg_bit_value,
5532 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5533 struct cmd_read_rxd_txd_result {
5534 cmdline_fixed_string_t read;
5535 cmdline_fixed_string_t rxd_txd;
5542 cmd_read_rxd_txd_parsed(void *parsed_result,
5543 __attribute__((unused)) struct cmdline *cl,
5544 __attribute__((unused)) void *data)
5546 struct cmd_read_rxd_txd_result *res = parsed_result;
5548 if (!strcmp(res->rxd_txd, "rxd"))
5549 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5550 else if (!strcmp(res->rxd_txd, "txd"))
5551 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5554 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5555 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5556 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5557 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5559 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5560 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5561 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5562 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5563 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5564 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5566 cmdline_parse_inst_t cmd_read_rxd_txd = {
5567 .f = cmd_read_rxd_txd_parsed,
5569 .help_str = "read rxd|txd port_id queue_id rxd_id",
5571 (void *)&cmd_read_rxd_txd_read,
5572 (void *)&cmd_read_rxd_txd_rxd_txd,
5573 (void *)&cmd_read_rxd_txd_port_id,
5574 (void *)&cmd_read_rxd_txd_queue_id,
5575 (void *)&cmd_read_rxd_txd_desc_id,
5581 struct cmd_quit_result {
5582 cmdline_fixed_string_t quit;
5585 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5587 __attribute__((unused)) void *data)
5593 cmdline_parse_token_string_t cmd_quit_quit =
5594 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5596 cmdline_parse_inst_t cmd_quit = {
5597 .f = cmd_quit_parsed,
5599 .help_str = "exit application",
5601 (void *)&cmd_quit_quit,
5606 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5607 struct cmd_mac_addr_result {
5608 cmdline_fixed_string_t mac_addr_cmd;
5609 cmdline_fixed_string_t what;
5611 struct ether_addr address;
5614 static void cmd_mac_addr_parsed(void *parsed_result,
5615 __attribute__((unused)) struct cmdline *cl,
5616 __attribute__((unused)) void *data)
5618 struct cmd_mac_addr_result *res = parsed_result;
5621 if (strcmp(res->what, "add") == 0)
5622 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5624 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5626 /* check the return value and print it if is < 0 */
5628 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5632 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5633 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5635 cmdline_parse_token_string_t cmd_mac_addr_what =
5636 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5638 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5639 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5640 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5641 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5643 cmdline_parse_inst_t cmd_mac_addr = {
5644 .f = cmd_mac_addr_parsed,
5646 .help_str = "mac_addr add|remove X <address>: "
5647 "add/remove MAC address on port X",
5649 (void *)&cmd_mac_addr_cmd,
5650 (void *)&cmd_mac_addr_what,
5651 (void *)&cmd_mac_addr_portnum,
5652 (void *)&cmd_mac_addr_addr,
5658 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5659 struct cmd_set_qmap_result {
5660 cmdline_fixed_string_t set;
5661 cmdline_fixed_string_t qmap;
5662 cmdline_fixed_string_t what;
5669 cmd_set_qmap_parsed(void *parsed_result,
5670 __attribute__((unused)) struct cmdline *cl,
5671 __attribute__((unused)) void *data)
5673 struct cmd_set_qmap_result *res = parsed_result;
5674 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5676 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5679 cmdline_parse_token_string_t cmd_setqmap_set =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5682 cmdline_parse_token_string_t cmd_setqmap_qmap =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5685 cmdline_parse_token_string_t cmd_setqmap_what =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5688 cmdline_parse_token_num_t cmd_setqmap_portid =
5689 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5691 cmdline_parse_token_num_t cmd_setqmap_queueid =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5694 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5695 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5698 cmdline_parse_inst_t cmd_set_qmap = {
5699 .f = cmd_set_qmap_parsed,
5701 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5703 (void *)&cmd_setqmap_set,
5704 (void *)&cmd_setqmap_qmap,
5705 (void *)&cmd_setqmap_what,
5706 (void *)&cmd_setqmap_portid,
5707 (void *)&cmd_setqmap_queueid,
5708 (void *)&cmd_setqmap_mapvalue,
5713 /* *** CONFIGURE UNICAST HASH TABLE *** */
5714 struct cmd_set_uc_hash_table {
5715 cmdline_fixed_string_t set;
5716 cmdline_fixed_string_t port;
5718 cmdline_fixed_string_t what;
5719 struct ether_addr address;
5720 cmdline_fixed_string_t mode;
5724 cmd_set_uc_hash_parsed(void *parsed_result,
5725 __attribute__((unused)) struct cmdline *cl,
5726 __attribute__((unused)) void *data)
5729 struct cmd_set_uc_hash_table *res = parsed_result;
5731 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5733 if (strcmp(res->what, "uta") == 0)
5734 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5735 &res->address,(uint8_t)is_on);
5737 printf("bad unicast hash table parameter, return code = %d \n", ret);
5741 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5744 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5747 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5748 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5750 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5753 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5754 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5756 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5757 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5760 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5761 .f = cmd_set_uc_hash_parsed,
5763 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5765 (void *)&cmd_set_uc_hash_set,
5766 (void *)&cmd_set_uc_hash_port,
5767 (void *)&cmd_set_uc_hash_portid,
5768 (void *)&cmd_set_uc_hash_what,
5769 (void *)&cmd_set_uc_hash_mac,
5770 (void *)&cmd_set_uc_hash_mode,
5775 struct cmd_set_uc_all_hash_table {
5776 cmdline_fixed_string_t set;
5777 cmdline_fixed_string_t port;
5779 cmdline_fixed_string_t what;
5780 cmdline_fixed_string_t value;
5781 cmdline_fixed_string_t mode;
5785 cmd_set_uc_all_hash_parsed(void *parsed_result,
5786 __attribute__((unused)) struct cmdline *cl,
5787 __attribute__((unused)) void *data)
5790 struct cmd_set_uc_all_hash_table *res = parsed_result;
5792 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5794 if ((strcmp(res->what, "uta") == 0) &&
5795 (strcmp(res->value, "all") == 0))
5796 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5798 printf("bad unicast hash table parameter,"
5799 "return code = %d \n", ret);
5802 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5805 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5806 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5808 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5809 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5811 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5812 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5814 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5817 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5821 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5822 .f = cmd_set_uc_all_hash_parsed,
5824 .help_str = "set port X uta all on|off (X = port number)",
5826 (void *)&cmd_set_uc_all_hash_set,
5827 (void *)&cmd_set_uc_all_hash_port,
5828 (void *)&cmd_set_uc_all_hash_portid,
5829 (void *)&cmd_set_uc_all_hash_what,
5830 (void *)&cmd_set_uc_all_hash_value,
5831 (void *)&cmd_set_uc_all_hash_mode,
5836 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5837 struct cmd_set_vf_macvlan_filter {
5838 cmdline_fixed_string_t set;
5839 cmdline_fixed_string_t port;
5841 cmdline_fixed_string_t vf;
5843 struct ether_addr address;
5844 cmdline_fixed_string_t filter_type;
5845 cmdline_fixed_string_t mode;
5849 cmd_set_vf_macvlan_parsed(void *parsed_result,
5850 __attribute__((unused)) struct cmdline *cl,
5851 __attribute__((unused)) void *data)
5854 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5855 struct rte_eth_mac_filter filter;
5857 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
5859 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
5861 /* set VF MAC filter */
5865 filter.dst_id = res->vf_id;
5867 if (!strcmp(res->filter_type, "exact-mac"))
5868 filter.filter_type = RTE_MAC_PERFECT_MATCH;
5869 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
5870 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
5871 else if (!strcmp(res->filter_type, "hashmac"))
5872 filter.filter_type = RTE_MAC_HASH_MATCH;
5873 else if (!strcmp(res->filter_type, "hashmac-vlan"))
5874 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
5876 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5879 ret = rte_eth_dev_filter_ctrl(res->port_id,
5880 RTE_ETH_FILTER_MACVLAN,
5884 ret = rte_eth_dev_filter_ctrl(res->port_id,
5885 RTE_ETH_FILTER_MACVLAN,
5886 RTE_ETH_FILTER_DELETE,
5890 printf("bad set MAC hash parameter, return code = %d\n", ret);
5894 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
5895 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5897 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5900 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
5901 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5903 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
5904 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5906 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
5907 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5909 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
5910 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5912 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
5913 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5914 filter_type, "exact-mac#exact-mac-vlan"
5915 "#hashmac#hashmac-vlan");
5916 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
5920 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
5921 .f = cmd_set_vf_macvlan_parsed,
5923 .help_str = "set port (portid) vf (vfid) (mac-addr) "
5924 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
5926 "exact match rule:exact match of MAC or MAC and VLAN; "
5927 "hash match rule: hash match of MAC and exact match "
5930 (void *)&cmd_set_vf_macvlan_set,
5931 (void *)&cmd_set_vf_macvlan_port,
5932 (void *)&cmd_set_vf_macvlan_portid,
5933 (void *)&cmd_set_vf_macvlan_vf,
5934 (void *)&cmd_set_vf_macvlan_vf_id,
5935 (void *)&cmd_set_vf_macvlan_mac,
5936 (void *)&cmd_set_vf_macvlan_filter_type,
5937 (void *)&cmd_set_vf_macvlan_mode,
5942 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
5943 struct cmd_set_vf_traffic {
5944 cmdline_fixed_string_t set;
5945 cmdline_fixed_string_t port;
5947 cmdline_fixed_string_t vf;
5949 cmdline_fixed_string_t what;
5950 cmdline_fixed_string_t mode;
5954 cmd_set_vf_traffic_parsed(void *parsed_result,
5955 __attribute__((unused)) struct cmdline *cl,
5956 __attribute__((unused)) void *data)
5958 struct cmd_set_vf_traffic *res = parsed_result;
5959 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
5960 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5962 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
5965 cmdline_parse_token_string_t cmd_setvf_traffic_set =
5966 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5968 cmdline_parse_token_string_t cmd_setvf_traffic_port =
5969 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5971 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
5972 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5974 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5977 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
5978 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
5980 cmdline_parse_token_string_t cmd_setvf_traffic_what =
5981 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5983 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
5984 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
5987 cmdline_parse_inst_t cmd_set_vf_traffic = {
5988 .f = cmd_set_vf_traffic_parsed,
5990 .help_str = "set port X vf Y rx|tx on|off"
5991 "(X = port number,Y = vf id)",
5993 (void *)&cmd_setvf_traffic_set,
5994 (void *)&cmd_setvf_traffic_port,
5995 (void *)&cmd_setvf_traffic_portid,
5996 (void *)&cmd_setvf_traffic_vf,
5997 (void *)&cmd_setvf_traffic_vfid,
5998 (void *)&cmd_setvf_traffic_what,
5999 (void *)&cmd_setvf_traffic_mode,
6004 /* *** CONFIGURE VF RECEIVE MODE *** */
6005 struct cmd_set_vf_rxmode {
6006 cmdline_fixed_string_t set;
6007 cmdline_fixed_string_t port;
6009 cmdline_fixed_string_t vf;
6011 cmdline_fixed_string_t what;
6012 cmdline_fixed_string_t mode;
6013 cmdline_fixed_string_t on;
6017 cmd_set_vf_rxmode_parsed(void *parsed_result,
6018 __attribute__((unused)) struct cmdline *cl,
6019 __attribute__((unused)) void *data)
6022 uint16_t rx_mode = 0;
6023 struct cmd_set_vf_rxmode *res = parsed_result;
6025 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6026 if (!strcmp(res->what,"rxmode")) {
6027 if (!strcmp(res->mode, "AUPE"))
6028 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6029 else if (!strcmp(res->mode, "ROPE"))
6030 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6031 else if (!strcmp(res->mode, "BAM"))
6032 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6033 else if (!strncmp(res->mode, "MPE",3))
6034 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6037 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6039 printf("bad VF receive mode parameter, return code = %d \n",
6043 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6044 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6046 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6049 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6050 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6052 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6055 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6056 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6058 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6061 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6063 mode, "AUPE#ROPE#BAM#MPE");
6064 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6068 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6069 .f = cmd_set_vf_rxmode_parsed,
6071 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6073 (void *)&cmd_set_vf_rxmode_set,
6074 (void *)&cmd_set_vf_rxmode_port,
6075 (void *)&cmd_set_vf_rxmode_portid,
6076 (void *)&cmd_set_vf_rxmode_vf,
6077 (void *)&cmd_set_vf_rxmode_vfid,
6078 (void *)&cmd_set_vf_rxmode_what,
6079 (void *)&cmd_set_vf_rxmode_mode,
6080 (void *)&cmd_set_vf_rxmode_on,
6085 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6086 struct cmd_vf_mac_addr_result {
6087 cmdline_fixed_string_t mac_addr_cmd;
6088 cmdline_fixed_string_t what;
6089 cmdline_fixed_string_t port;
6091 cmdline_fixed_string_t vf;
6093 struct ether_addr address;
6096 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6097 __attribute__((unused)) struct cmdline *cl,
6098 __attribute__((unused)) void *data)
6100 struct cmd_vf_mac_addr_result *res = parsed_result;
6103 if (strcmp(res->what, "add") == 0)
6104 ret = rte_eth_dev_mac_addr_add(res->port_num,
6105 &res->address, res->vf_num);
6107 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6111 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6112 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6113 mac_addr_cmd,"mac_addr");
6114 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6115 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6117 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6118 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6120 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6121 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6123 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6124 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6126 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6127 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6129 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6130 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6133 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6134 .f = cmd_vf_mac_addr_parsed,
6136 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6137 "Y = VF number)add MAC address filtering for a VF on port X",
6139 (void *)&cmd_vf_mac_addr_cmd,
6140 (void *)&cmd_vf_mac_addr_what,
6141 (void *)&cmd_vf_mac_addr_port,
6142 (void *)&cmd_vf_mac_addr_portnum,
6143 (void *)&cmd_vf_mac_addr_vf,
6144 (void *)&cmd_vf_mac_addr_vfnum,
6145 (void *)&cmd_vf_mac_addr_addr,
6150 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6151 struct cmd_vf_rx_vlan_filter {
6152 cmdline_fixed_string_t rx_vlan;
6153 cmdline_fixed_string_t what;
6155 cmdline_fixed_string_t port;
6157 cmdline_fixed_string_t vf;
6162 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6166 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6168 if (!strcmp(res->what, "add"))
6169 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6171 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6174 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6175 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6176 rx_vlan, "rx_vlan");
6177 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6180 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6181 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6183 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6184 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6186 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6187 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6189 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6192 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6193 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6196 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6197 .f = cmd_vf_rx_vlan_filter_parsed,
6199 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6200 "Y = port number,Z = hexadecimal VF mask)",
6202 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6203 (void *)&cmd_vf_rx_vlan_filter_what,
6204 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6205 (void *)&cmd_vf_rx_vlan_filter_port,
6206 (void *)&cmd_vf_rx_vlan_filter_portid,
6207 (void *)&cmd_vf_rx_vlan_filter_vf,
6208 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6213 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6214 struct cmd_queue_rate_limit_result {
6215 cmdline_fixed_string_t set;
6216 cmdline_fixed_string_t port;
6218 cmdline_fixed_string_t queue;
6220 cmdline_fixed_string_t rate;
6224 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6225 __attribute__((unused)) struct cmdline *cl,
6226 __attribute__((unused)) void *data)
6228 struct cmd_queue_rate_limit_result *res = parsed_result;
6231 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6232 && (strcmp(res->queue, "queue") == 0)
6233 && (strcmp(res->rate, "rate") == 0))
6234 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6237 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6241 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6242 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6244 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6245 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6247 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6248 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6250 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6251 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6253 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6254 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6256 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6257 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6259 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6260 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6263 cmdline_parse_inst_t cmd_queue_rate_limit = {
6264 .f = cmd_queue_rate_limit_parsed,
6266 .help_str = "set port X queue Y rate Z:(X = port number,"
6267 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6269 (void *)&cmd_queue_rate_limit_set,
6270 (void *)&cmd_queue_rate_limit_port,
6271 (void *)&cmd_queue_rate_limit_portnum,
6272 (void *)&cmd_queue_rate_limit_queue,
6273 (void *)&cmd_queue_rate_limit_queuenum,
6274 (void *)&cmd_queue_rate_limit_rate,
6275 (void *)&cmd_queue_rate_limit_ratenum,
6280 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6281 struct cmd_vf_rate_limit_result {
6282 cmdline_fixed_string_t set;
6283 cmdline_fixed_string_t port;
6285 cmdline_fixed_string_t vf;
6287 cmdline_fixed_string_t rate;
6289 cmdline_fixed_string_t q_msk;
6293 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6294 __attribute__((unused)) struct cmdline *cl,
6295 __attribute__((unused)) void *data)
6297 struct cmd_vf_rate_limit_result *res = parsed_result;
6300 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6301 && (strcmp(res->vf, "vf") == 0)
6302 && (strcmp(res->rate, "rate") == 0)
6303 && (strcmp(res->q_msk, "queue_mask") == 0))
6304 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6305 res->rate_num, res->q_msk_val);
6307 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6311 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6312 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6314 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6315 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6317 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6318 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6320 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6321 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6323 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6324 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6326 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6327 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6329 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6330 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6332 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6333 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6334 q_msk, "queue_mask");
6335 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6336 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6339 cmdline_parse_inst_t cmd_vf_rate_limit = {
6340 .f = cmd_vf_rate_limit_parsed,
6342 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6343 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6344 "for queues of VF on port X",
6346 (void *)&cmd_vf_rate_limit_set,
6347 (void *)&cmd_vf_rate_limit_port,
6348 (void *)&cmd_vf_rate_limit_portnum,
6349 (void *)&cmd_vf_rate_limit_vf,
6350 (void *)&cmd_vf_rate_limit_vfnum,
6351 (void *)&cmd_vf_rate_limit_rate,
6352 (void *)&cmd_vf_rate_limit_ratenum,
6353 (void *)&cmd_vf_rate_limit_q_msk,
6354 (void *)&cmd_vf_rate_limit_q_msk_val,
6359 /* *** ADD TUNNEL FILTER OF A PORT *** */
6360 struct cmd_tunnel_filter_result {
6361 cmdline_fixed_string_t cmd;
6362 cmdline_fixed_string_t what;
6364 struct ether_addr outer_mac;
6365 struct ether_addr inner_mac;
6366 cmdline_ipaddr_t ip_value;
6367 uint16_t inner_vlan;
6368 cmdline_fixed_string_t tunnel_type;
6369 cmdline_fixed_string_t filter_type;
6375 cmd_tunnel_filter_parsed(void *parsed_result,
6376 __attribute__((unused)) struct cmdline *cl,
6377 __attribute__((unused)) void *data)
6379 struct cmd_tunnel_filter_result *res = parsed_result;
6380 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6383 tunnel_filter_conf.outer_mac = &res->outer_mac;
6384 tunnel_filter_conf.inner_mac = &res->inner_mac;
6385 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6387 if (res->ip_value.family == AF_INET) {
6388 tunnel_filter_conf.ip_addr.ipv4_addr =
6389 res->ip_value.addr.ipv4.s_addr;
6390 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6392 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6393 &(res->ip_value.addr.ipv6),
6394 sizeof(struct in6_addr));
6395 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6398 if (!strcmp(res->filter_type, "imac-ivlan"))
6399 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6400 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6401 tunnel_filter_conf.filter_type =
6402 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6403 else if (!strcmp(res->filter_type, "imac-tenid"))
6404 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6405 else if (!strcmp(res->filter_type, "imac"))
6406 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6407 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6408 tunnel_filter_conf.filter_type =
6409 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6411 printf("The filter type is not supported");
6415 if (!strcmp(res->tunnel_type, "vxlan"))
6416 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6418 printf("Only VXLAN is supported now.\n");
6422 tunnel_filter_conf.tenant_id = res->tenant_id;
6423 tunnel_filter_conf.queue_id = res->queue_num;
6424 if (!strcmp(res->what, "add"))
6425 ret = rte_eth_dev_filter_ctrl(res->port_id,
6426 RTE_ETH_FILTER_TUNNEL,
6428 &tunnel_filter_conf);
6430 ret = rte_eth_dev_filter_ctrl(res->port_id,
6431 RTE_ETH_FILTER_TUNNEL,
6432 RTE_ETH_FILTER_DELETE,
6433 &tunnel_filter_conf);
6435 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6439 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6440 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6441 cmd, "tunnel_filter");
6442 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6443 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6445 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6446 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6448 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6449 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6451 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6452 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6454 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6455 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6456 inner_vlan, UINT16);
6457 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6458 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6460 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6461 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6462 tunnel_type, "vxlan");
6464 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6465 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6466 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6467 "imac#omac-imac-tenid");
6468 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6469 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6471 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6472 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6475 cmdline_parse_inst_t cmd_tunnel_filter = {
6476 .f = cmd_tunnel_filter_parsed,
6478 .help_str = "add/rm tunnel filter of a port: "
6479 "tunnel_filter add port_id outer_mac inner_mac ip "
6480 "inner_vlan tunnel_type(vxlan) filter_type "
6481 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6482 "imac|omac-imac-tenid) "
6483 "tenant_id queue_num",
6485 (void *)&cmd_tunnel_filter_cmd,
6486 (void *)&cmd_tunnel_filter_what,
6487 (void *)&cmd_tunnel_filter_port_id,
6488 (void *)&cmd_tunnel_filter_outer_mac,
6489 (void *)&cmd_tunnel_filter_inner_mac,
6490 (void *)&cmd_tunnel_filter_ip_value,
6491 (void *)&cmd_tunnel_filter_innner_vlan,
6492 (void *)&cmd_tunnel_filter_tunnel_type,
6493 (void *)&cmd_tunnel_filter_filter_type,
6494 (void *)&cmd_tunnel_filter_tenant_id,
6495 (void *)&cmd_tunnel_filter_queue_num,
6500 /* *** CONFIGURE TUNNEL UDP PORT *** */
6501 struct cmd_tunnel_udp_config {
6502 cmdline_fixed_string_t cmd;
6503 cmdline_fixed_string_t what;
6509 cmd_tunnel_udp_config_parsed(void *parsed_result,
6510 __attribute__((unused)) struct cmdline *cl,
6511 __attribute__((unused)) void *data)
6513 struct cmd_tunnel_udp_config *res = parsed_result;
6514 struct rte_eth_udp_tunnel tunnel_udp;
6517 tunnel_udp.udp_port = res->udp_port;
6519 if (!strcmp(res->cmd, "rx_vxlan_port"))
6520 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6522 if (!strcmp(res->what, "add"))
6523 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6525 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6528 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6531 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6532 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6533 cmd, "rx_vxlan_port");
6534 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6535 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6537 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6538 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6540 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6541 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6544 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6545 .f = cmd_tunnel_udp_config_parsed,
6547 .help_str = "add/rm an tunneling UDP port filter: "
6548 "rx_vxlan_port add udp_port port_id",
6550 (void *)&cmd_tunnel_udp_config_cmd,
6551 (void *)&cmd_tunnel_udp_config_what,
6552 (void *)&cmd_tunnel_udp_config_udp_port,
6553 (void *)&cmd_tunnel_udp_config_port_id,
6558 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6559 struct cmd_set_mirror_mask_result {
6560 cmdline_fixed_string_t set;
6561 cmdline_fixed_string_t port;
6563 cmdline_fixed_string_t mirror;
6565 cmdline_fixed_string_t what;
6566 cmdline_fixed_string_t value;
6567 cmdline_fixed_string_t dstpool;
6569 cmdline_fixed_string_t on;
6572 cmdline_parse_token_string_t cmd_mirror_mask_set =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6575 cmdline_parse_token_string_t cmd_mirror_mask_port =
6576 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6578 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6579 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6581 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6583 mirror, "mirror-rule");
6584 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6585 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6587 cmdline_parse_token_string_t cmd_mirror_mask_what =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6589 what, "pool-mirror#vlan-mirror");
6590 cmdline_parse_token_string_t cmd_mirror_mask_value =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6593 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6595 dstpool, "dst-pool");
6596 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6597 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6599 cmdline_parse_token_string_t cmd_mirror_mask_on =
6600 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6604 cmd_set_mirror_mask_parsed(void *parsed_result,
6605 __attribute__((unused)) struct cmdline *cl,
6606 __attribute__((unused)) void *data)
6609 struct cmd_set_mirror_mask_result *res = parsed_result;
6610 struct rte_eth_vmdq_mirror_conf mr_conf;
6612 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6614 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6616 mr_conf.dst_pool = res->dstpool_id;
6618 if (!strcmp(res->what, "pool-mirror")) {
6619 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6620 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6621 } else if(!strcmp(res->what, "vlan-mirror")) {
6622 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6623 nb_item = parse_item_list(res->value, "core",
6624 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6628 for(i=0; i < nb_item; i++) {
6629 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6630 printf("Invalid vlan_id: must be < 4096\n");
6634 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6635 mr_conf.vlan.vlan_mask |= 1ULL << i;
6639 if(!strcmp(res->on, "on"))
6640 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6643 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6646 printf("mirror rule add error: (%s)\n", strerror(-ret));
6649 cmdline_parse_inst_t cmd_set_mirror_mask = {
6650 .f = cmd_set_mirror_mask_parsed,
6652 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6653 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6655 (void *)&cmd_mirror_mask_set,
6656 (void *)&cmd_mirror_mask_port,
6657 (void *)&cmd_mirror_mask_portid,
6658 (void *)&cmd_mirror_mask_mirror,
6659 (void *)&cmd_mirror_mask_ruleid,
6660 (void *)&cmd_mirror_mask_what,
6661 (void *)&cmd_mirror_mask_value,
6662 (void *)&cmd_mirror_mask_dstpool,
6663 (void *)&cmd_mirror_mask_poolid,
6664 (void *)&cmd_mirror_mask_on,
6669 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6670 struct cmd_set_mirror_link_result {
6671 cmdline_fixed_string_t set;
6672 cmdline_fixed_string_t port;
6674 cmdline_fixed_string_t mirror;
6676 cmdline_fixed_string_t what;
6677 cmdline_fixed_string_t dstpool;
6679 cmdline_fixed_string_t on;
6682 cmdline_parse_token_string_t cmd_mirror_link_set =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6685 cmdline_parse_token_string_t cmd_mirror_link_port =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6688 cmdline_parse_token_num_t cmd_mirror_link_portid =
6689 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6691 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6692 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6693 mirror, "mirror-rule");
6694 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6695 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6697 cmdline_parse_token_string_t cmd_mirror_link_what =
6698 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6699 what, "uplink-mirror#downlink-mirror");
6700 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6701 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6702 dstpool, "dst-pool");
6703 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6704 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6706 cmdline_parse_token_string_t cmd_mirror_link_on =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6711 cmd_set_mirror_link_parsed(void *parsed_result,
6712 __attribute__((unused)) struct cmdline *cl,
6713 __attribute__((unused)) void *data)
6716 struct cmd_set_mirror_link_result *res = parsed_result;
6717 struct rte_eth_vmdq_mirror_conf mr_conf;
6719 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6720 if(!strcmp(res->what, "uplink-mirror")) {
6721 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6722 }else if(!strcmp(res->what, "downlink-mirror"))
6723 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6725 mr_conf.dst_pool = res->dstpool_id;
6727 if(!strcmp(res->on, "on"))
6728 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6731 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6734 /* check the return value and print it if is < 0 */
6736 printf("mirror rule add error: (%s)\n", strerror(-ret));
6740 cmdline_parse_inst_t cmd_set_mirror_link = {
6741 .f = cmd_set_mirror_link_parsed,
6743 .help_str = "set port X mirror-rule Y uplink-mirror|"
6744 "downlink-mirror dst-pool Z on|off",
6746 (void *)&cmd_mirror_link_set,
6747 (void *)&cmd_mirror_link_port,
6748 (void *)&cmd_mirror_link_portid,
6749 (void *)&cmd_mirror_link_mirror,
6750 (void *)&cmd_mirror_link_ruleid,
6751 (void *)&cmd_mirror_link_what,
6752 (void *)&cmd_mirror_link_dstpool,
6753 (void *)&cmd_mirror_link_poolid,
6754 (void *)&cmd_mirror_link_on,
6759 /* *** RESET VM MIRROR RULE *** */
6760 struct cmd_rm_mirror_rule_result {
6761 cmdline_fixed_string_t reset;
6762 cmdline_fixed_string_t port;
6764 cmdline_fixed_string_t mirror;
6768 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6769 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6771 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6772 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6774 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6775 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6777 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6778 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6779 mirror, "mirror-rule");
6780 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6781 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6785 cmd_reset_mirror_rule_parsed(void *parsed_result,
6786 __attribute__((unused)) struct cmdline *cl,
6787 __attribute__((unused)) void *data)
6790 struct cmd_set_mirror_link_result *res = parsed_result;
6792 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6794 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6797 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6798 .f = cmd_reset_mirror_rule_parsed,
6800 .help_str = "reset port X mirror-rule Y",
6802 (void *)&cmd_rm_mirror_rule_reset,
6803 (void *)&cmd_rm_mirror_rule_port,
6804 (void *)&cmd_rm_mirror_rule_portid,
6805 (void *)&cmd_rm_mirror_rule_mirror,
6806 (void *)&cmd_rm_mirror_rule_ruleid,
6811 /* ******************************************************************************** */
6813 struct cmd_dump_result {
6814 cmdline_fixed_string_t dump;
6818 dump_struct_sizes(void)
6820 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6821 DUMP_SIZE(struct rte_mbuf);
6822 DUMP_SIZE(struct rte_mempool);
6823 DUMP_SIZE(struct rte_ring);
6827 static void cmd_dump_parsed(void *parsed_result,
6828 __attribute__((unused)) struct cmdline *cl,
6829 __attribute__((unused)) void *data)
6831 struct cmd_dump_result *res = parsed_result;
6833 if (!strcmp(res->dump, "dump_physmem"))
6834 rte_dump_physmem_layout(stdout);
6835 else if (!strcmp(res->dump, "dump_memzone"))
6836 rte_memzone_dump(stdout);
6837 else if (!strcmp(res->dump, "dump_log_history"))
6838 rte_log_dump_history(stdout);
6839 else if (!strcmp(res->dump, "dump_struct_sizes"))
6840 dump_struct_sizes();
6841 else if (!strcmp(res->dump, "dump_ring"))
6842 rte_ring_list_dump(stdout);
6843 else if (!strcmp(res->dump, "dump_mempool"))
6844 rte_mempool_list_dump(stdout);
6845 else if (!strcmp(res->dump, "dump_devargs"))
6846 rte_eal_devargs_dump(stdout);
6849 cmdline_parse_token_string_t cmd_dump_dump =
6850 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6854 "dump_struct_sizes#"
6859 cmdline_parse_inst_t cmd_dump = {
6860 .f = cmd_dump_parsed, /* function to call */
6861 .data = NULL, /* 2nd arg of func */
6862 .help_str = "dump status",
6863 .tokens = { /* token list, NULL terminated */
6864 (void *)&cmd_dump_dump,
6869 /* ******************************************************************************** */
6871 struct cmd_dump_one_result {
6872 cmdline_fixed_string_t dump;
6873 cmdline_fixed_string_t name;
6876 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
6877 __attribute__((unused)) void *data)
6879 struct cmd_dump_one_result *res = parsed_result;
6881 if (!strcmp(res->dump, "dump_ring")) {
6883 r = rte_ring_lookup(res->name);
6885 cmdline_printf(cl, "Cannot find ring\n");
6888 rte_ring_dump(stdout, r);
6889 } else if (!strcmp(res->dump, "dump_mempool")) {
6890 struct rte_mempool *mp;
6891 mp = rte_mempool_lookup(res->name);
6893 cmdline_printf(cl, "Cannot find mempool\n");
6896 rte_mempool_dump(stdout, mp);
6900 cmdline_parse_token_string_t cmd_dump_one_dump =
6901 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
6902 "dump_ring#dump_mempool");
6904 cmdline_parse_token_string_t cmd_dump_one_name =
6905 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
6907 cmdline_parse_inst_t cmd_dump_one = {
6908 .f = cmd_dump_one_parsed, /* function to call */
6909 .data = NULL, /* 2nd arg of func */
6910 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
6911 .tokens = { /* token list, NULL terminated */
6912 (void *)&cmd_dump_one_dump,
6913 (void *)&cmd_dump_one_name,
6918 /* *** ADD/REMOVE an ethertype FILTER *** */
6919 struct cmd_ethertype_filter_result {
6920 cmdline_fixed_string_t filter;
6922 cmdline_fixed_string_t ethertype;
6923 uint16_t ethertype_value;
6924 cmdline_fixed_string_t priority;
6925 cmdline_fixed_string_t priority_en;
6926 uint8_t priority_value;
6927 cmdline_fixed_string_t queue;
6929 cmdline_fixed_string_t index;
6930 uint16_t index_value;
6934 cmd_ethertype_filter_parsed(void *parsed_result,
6935 __attribute__((unused)) struct cmdline *cl,
6936 __attribute__((unused)) void *data)
6939 struct cmd_ethertype_filter_result *res = parsed_result;
6940 struct rte_ethertype_filter filter;
6942 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
6943 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
6944 filter.priority = res->priority_value;
6946 if (!strcmp(res->priority_en, "enable"))
6947 filter.priority_en = 1;
6948 if (!strcmp(res->filter, "add_ethertype_filter"))
6949 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
6951 &filter, res->queue_id);
6952 else if (!strcmp(res->filter, "remove_ethertype_filter"))
6953 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
6955 else if (!strcmp(res->filter, "get_ethertype_filter"))
6956 get_ethertype_filter(res->port_id, res->index_value);
6959 printf("ethertype filter setting error: (%s)\n",
6963 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
6964 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6966 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
6967 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6968 ethertype, "ethertype");
6969 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
6970 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6971 ethertype_value, UINT16);
6972 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
6973 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6974 priority, "priority");
6975 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
6976 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6977 priority_en, "enable#disable");
6978 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
6979 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6980 priority_value, UINT8);
6981 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
6982 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6984 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
6985 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6987 cmdline_parse_token_string_t cmd_ethertype_filter_index =
6988 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6990 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
6991 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
6992 index_value, UINT16);
6993 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
6994 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
6995 filter, "add_ethertype_filter");
6996 cmdline_parse_inst_t cmd_add_ethertype_filter = {
6997 .f = cmd_ethertype_filter_parsed,
6999 .help_str = "add an ethertype filter",
7001 (void *)&cmd_ethertype_filter_add_filter,
7002 (void *)&cmd_ethertype_filter_port_id,
7003 (void *)&cmd_ethertype_filter_ethertype,
7004 (void *)&cmd_ethertype_filter_ethertype_value,
7005 (void *)&cmd_ethertype_filter_priority,
7006 (void *)&cmd_ethertype_filter_priority_en,
7007 (void *)&cmd_ethertype_filter_priority_value,
7008 (void *)&cmd_ethertype_filter_queue,
7009 (void *)&cmd_ethertype_filter_queue_id,
7010 (void *)&cmd_ethertype_filter_index,
7011 (void *)&cmd_ethertype_filter_index_value,
7016 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7017 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7018 filter, "remove_ethertype_filter");
7019 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7020 .f = cmd_ethertype_filter_parsed,
7022 .help_str = "remove an ethertype filter",
7024 (void *)&cmd_ethertype_filter_remove_filter,
7025 (void *)&cmd_ethertype_filter_port_id,
7026 (void *)&cmd_ethertype_filter_index,
7027 (void *)&cmd_ethertype_filter_index_value,
7031 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7032 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7033 filter, "get_ethertype_filter");
7034 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7035 .f = cmd_ethertype_filter_parsed,
7037 .help_str = "get an ethertype filter",
7039 (void *)&cmd_ethertype_filter_get_filter,
7040 (void *)&cmd_ethertype_filter_port_id,
7041 (void *)&cmd_ethertype_filter_index,
7042 (void *)&cmd_ethertype_filter_index_value,
7047 /* *** set SYN filter *** */
7048 struct cmd_set_syn_filter_result {
7049 cmdline_fixed_string_t filter;
7051 cmdline_fixed_string_t priority;
7052 cmdline_fixed_string_t high;
7053 cmdline_fixed_string_t queue;
7058 cmd_set_syn_filter_parsed(void *parsed_result,
7059 __attribute__((unused)) struct cmdline *cl,
7060 __attribute__((unused)) void *data)
7063 struct cmd_set_syn_filter_result *res = parsed_result;
7064 struct rte_syn_filter filter;
7066 if (!strcmp(res->filter, "add_syn_filter")) {
7067 if (!strcmp(res->high, "high"))
7071 ret = rte_eth_dev_add_syn_filter(res->port_id,
7072 &filter, res->queue_id);
7073 } else if (!strcmp(res->filter, "remove_syn_filter"))
7074 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7075 else if (!strcmp(res->filter, "get_syn_filter"))
7076 get_syn_filter(res->port_id);
7078 printf("syn filter setting error: (%s)\n", strerror(-ret));
7081 cmdline_parse_token_num_t cmd_syn_filter_portid =
7082 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7084 cmdline_parse_token_string_t cmd_syn_filter_priority =
7085 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7086 priority, "priority");
7087 cmdline_parse_token_string_t cmd_syn_filter_high =
7088 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7090 cmdline_parse_token_string_t cmd_syn_filter_queue =
7091 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7093 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7094 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7096 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7097 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7098 filter, "add_syn_filter");
7099 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7100 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7101 filter, "remove_syn_filter");
7102 cmdline_parse_inst_t cmd_add_syn_filter = {
7103 .f = cmd_set_syn_filter_parsed,
7105 .help_str = "add syn filter",
7107 (void *)&cmd_syn_filter_add_filter,
7108 (void *)&cmd_syn_filter_portid,
7109 (void *)&cmd_syn_filter_priority,
7110 (void *)&cmd_syn_filter_high,
7111 (void *)&cmd_syn_filter_queue,
7112 (void *)&cmd_syn_filter_queue_id,
7116 cmdline_parse_inst_t cmd_remove_syn_filter = {
7117 .f = cmd_set_syn_filter_parsed,
7119 .help_str = "remove syn filter",
7121 (void *)&cmd_syn_filter_remove_filter,
7122 (void *)&cmd_syn_filter_portid,
7127 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7128 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7129 filter, "get_syn_filter");
7131 cmdline_parse_inst_t cmd_get_syn_filter = {
7132 .f = cmd_set_syn_filter_parsed,
7134 .help_str = "get syn filter",
7136 (void *)&cmd_syn_filter_get_filter,
7137 (void *)&cmd_syn_filter_portid,
7142 /* *** ADD/REMOVE A 2tuple FILTER *** */
7143 struct cmd_2tuple_filter_result {
7144 cmdline_fixed_string_t filter;
7146 cmdline_fixed_string_t protocol;
7147 uint8_t protocol_value;
7148 uint8_t protocol_mask;
7149 cmdline_fixed_string_t dst_port;
7150 uint16_t dst_port_value;
7151 uint16_t dst_port_mask;
7152 cmdline_fixed_string_t flags;
7153 uint8_t flags_value;
7154 cmdline_fixed_string_t priority;
7155 uint8_t priority_value;
7156 cmdline_fixed_string_t queue;
7158 cmdline_fixed_string_t index;
7159 uint16_t index_value;
7163 cmd_2tuple_filter_parsed(void *parsed_result,
7164 __attribute__((unused)) struct cmdline *cl,
7165 __attribute__((unused)) void *data)
7168 struct rte_2tuple_filter filter;
7169 struct cmd_2tuple_filter_result *res = parsed_result;
7171 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7173 if (!strcmp(res->filter, "add_2tuple_filter")) {
7174 /* need convert to big endian. */
7175 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7176 filter.protocol = res->protocol_value;
7177 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7178 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7179 filter.priority = res->priority_value;
7180 filter.tcp_flags = res->flags_value;
7181 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7182 res->index_value, &filter, res->queue_id);
7183 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7184 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7186 else if (!strcmp(res->filter, "get_2tuple_filter"))
7187 get_2tuple_filter(res->port_id, res->index_value);
7190 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7193 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7194 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7196 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7197 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7198 protocol, "protocol");
7199 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7200 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7201 protocol_value, UINT8);
7202 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7203 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7204 protocol_mask, UINT8);
7205 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7206 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7207 dst_port, "dst_port");
7208 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7209 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7210 dst_port_value, UINT16);
7211 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7212 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7213 dst_port_mask, UINT16);
7214 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7215 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7217 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7218 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7219 flags_value, UINT8);
7220 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7221 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7222 priority, "priority");
7223 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7224 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7225 priority_value, UINT8);
7226 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7227 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7229 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7230 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7232 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7233 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7235 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7236 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7237 index_value, UINT16);
7238 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7239 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7240 filter, "add_2tuple_filter");
7241 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7242 .f = cmd_2tuple_filter_parsed,
7244 .help_str = "add a 2tuple filter",
7246 (void *)&cmd_2tuple_filter_add_filter,
7247 (void *)&cmd_2tuple_filter_port_id,
7248 (void *)&cmd_2tuple_filter_protocol,
7249 (void *)&cmd_2tuple_filter_protocol_value,
7250 (void *)&cmd_2tuple_filter_protocol_mask,
7251 (void *)&cmd_2tuple_filter_dst_port,
7252 (void *)&cmd_2tuple_filter_dst_port_value,
7253 (void *)&cmd_2tuple_filter_dst_port_mask,
7254 (void *)&cmd_2tuple_filter_flags,
7255 (void *)&cmd_2tuple_filter_flags_value,
7256 (void *)&cmd_2tuple_filter_priority,
7257 (void *)&cmd_2tuple_filter_priority_value,
7258 (void *)&cmd_2tuple_filter_queue,
7259 (void *)&cmd_2tuple_filter_queue_id,
7260 (void *)&cmd_2tuple_filter_index,
7261 (void *)&cmd_2tuple_filter_index_value,
7266 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7267 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7268 filter, "remove_2tuple_filter");
7269 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7270 .f = cmd_2tuple_filter_parsed,
7272 .help_str = "remove a 2tuple filter",
7274 (void *)&cmd_2tuple_filter_remove_filter,
7275 (void *)&cmd_2tuple_filter_port_id,
7276 (void *)&cmd_2tuple_filter_index,
7277 (void *)&cmd_2tuple_filter_index_value,
7281 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7282 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7283 filter, "get_2tuple_filter");
7284 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7285 .f = cmd_2tuple_filter_parsed,
7287 .help_str = "get a 2tuple filter",
7289 (void *)&cmd_2tuple_filter_get_filter,
7290 (void *)&cmd_2tuple_filter_port_id,
7291 (void *)&cmd_2tuple_filter_index,
7292 (void *)&cmd_2tuple_filter_index_value,
7297 /* *** ADD/REMOVE A 5tuple FILTER *** */
7298 struct cmd_5tuple_filter_result {
7299 cmdline_fixed_string_t filter;
7301 cmdline_fixed_string_t dst_ip;
7302 cmdline_ipaddr_t dst_ip_value;
7303 cmdline_fixed_string_t src_ip;
7304 cmdline_ipaddr_t src_ip_value;
7305 cmdline_fixed_string_t dst_port;
7306 uint16_t dst_port_value;
7307 cmdline_fixed_string_t src_port;
7308 uint16_t src_port_value;
7309 cmdline_fixed_string_t protocol;
7310 uint8_t protocol_value;
7311 cmdline_fixed_string_t mask;
7313 cmdline_fixed_string_t flags;
7314 uint8_t flags_value;
7315 cmdline_fixed_string_t priority;
7316 uint8_t priority_value;
7317 cmdline_fixed_string_t queue;
7319 cmdline_fixed_string_t index;
7320 uint16_t index_value;
7324 cmd_5tuple_filter_parsed(void *parsed_result,
7325 __attribute__((unused)) struct cmdline *cl,
7326 __attribute__((unused)) void *data)
7329 struct rte_5tuple_filter filter;
7330 struct cmd_5tuple_filter_result *res = parsed_result;
7332 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7334 if (!strcmp(res->filter, "add_5tuple_filter")) {
7335 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7336 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7337 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7338 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7339 filter.protocol = res->protocol_value;
7340 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7341 filter.priority = res->priority_value;
7342 filter.tcp_flags = res->flags_value;
7344 if (res->dst_ip_value.family == AF_INET)
7345 /* no need to convert, already big endian. */
7346 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7348 if (filter.dst_ip_mask == 0) {
7349 printf("can not support ipv6 involved compare.\n");
7355 if (res->src_ip_value.family == AF_INET)
7356 /* no need to convert, already big endian. */
7357 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7359 if (filter.src_ip_mask == 0) {
7360 printf("can not support ipv6 involved compare.\n");
7365 /* need convert to big endian. */
7366 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7367 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7369 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7370 res->index_value, &filter, res->queue_id);
7371 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7372 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7374 else if (!strcmp(res->filter, "get_5tuple_filter"))
7375 get_5tuple_filter(res->port_id, res->index_value);
7377 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7381 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7382 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7384 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7385 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7387 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7388 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7390 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7391 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7393 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7394 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7396 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7397 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7398 dst_port, "dst_port");
7399 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7400 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7401 dst_port_value, UINT16);
7402 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7403 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7404 src_port, "src_port");
7405 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7406 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7407 src_port_value, UINT16);
7408 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7409 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7410 protocol, "protocol");
7411 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7412 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7413 protocol_value, UINT8);
7414 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7415 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7417 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7418 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7420 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7421 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7423 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7424 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7425 flags_value, UINT8);
7426 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7427 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7428 priority, "priority");
7429 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7430 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7431 priority_value, UINT8);
7432 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7433 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7435 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7436 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7438 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7439 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7441 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7442 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7443 index_value, UINT16);
7445 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7446 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7447 filter, "add_5tuple_filter");
7448 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7449 .f = cmd_5tuple_filter_parsed,
7451 .help_str = "add a 5tuple filter",
7453 (void *)&cmd_5tuple_filter_add_filter,
7454 (void *)&cmd_5tuple_filter_port_id,
7455 (void *)&cmd_5tuple_filter_dst_ip,
7456 (void *)&cmd_5tuple_filter_dst_ip_value,
7457 (void *)&cmd_5tuple_filter_src_ip,
7458 (void *)&cmd_5tuple_filter_src_ip_value,
7459 (void *)&cmd_5tuple_filter_dst_port,
7460 (void *)&cmd_5tuple_filter_dst_port_value,
7461 (void *)&cmd_5tuple_filter_src_port,
7462 (void *)&cmd_5tuple_filter_src_port_value,
7463 (void *)&cmd_5tuple_filter_protocol,
7464 (void *)&cmd_5tuple_filter_protocol_value,
7465 (void *)&cmd_5tuple_filter_mask,
7466 (void *)&cmd_5tuple_filter_mask_value,
7467 (void *)&cmd_5tuple_filter_flags,
7468 (void *)&cmd_5tuple_filter_flags_value,
7469 (void *)&cmd_5tuple_filter_priority,
7470 (void *)&cmd_5tuple_filter_priority_value,
7471 (void *)&cmd_5tuple_filter_queue,
7472 (void *)&cmd_5tuple_filter_queue_id,
7473 (void *)&cmd_5tuple_filter_index,
7474 (void *)&cmd_5tuple_filter_index_value,
7479 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7480 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7481 filter, "remove_5tuple_filter");
7482 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7483 .f = cmd_5tuple_filter_parsed,
7485 .help_str = "remove a 5tuple filter",
7487 (void *)&cmd_5tuple_filter_remove_filter,
7488 (void *)&cmd_5tuple_filter_port_id,
7489 (void *)&cmd_5tuple_filter_index,
7490 (void *)&cmd_5tuple_filter_index_value,
7495 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7496 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7497 filter, "get_5tuple_filter");
7498 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7499 .f = cmd_5tuple_filter_parsed,
7501 .help_str = "get a 5tuple filter",
7503 (void *)&cmd_5tuple_filter_get_filter,
7504 (void *)&cmd_5tuple_filter_port_id,
7505 (void *)&cmd_5tuple_filter_index,
7506 (void *)&cmd_5tuple_filter_index_value,
7511 /* *** ADD/REMOVE A flex FILTER *** */
7512 struct cmd_flex_filter_result {
7513 cmdline_fixed_string_t filter;
7515 cmdline_fixed_string_t len;
7517 cmdline_fixed_string_t bytes;
7518 cmdline_fixed_string_t bytes_value;
7519 cmdline_fixed_string_t mask;
7520 cmdline_fixed_string_t mask_value;
7521 cmdline_fixed_string_t priority;
7522 uint8_t priority_value;
7523 cmdline_fixed_string_t queue;
7525 cmdline_fixed_string_t index;
7526 uint16_t index_value;
7529 static int xdigit2val(unsigned char c)
7534 else if (isupper(c))
7542 cmd_flex_filter_parsed(void *parsed_result,
7543 __attribute__((unused)) struct cmdline *cl,
7544 __attribute__((unused)) void *data)
7547 struct rte_flex_filter filter;
7548 struct cmd_flex_filter_result *res = parsed_result;
7549 char *bytes_ptr, *mask_ptr;
7557 if (!strcmp(res->filter, "add_flex_filter")) {
7558 if (res->len_value > 128) {
7559 printf("the len exceed the max length 128\n");
7562 memset(&filter, 0, sizeof(struct rte_flex_filter));
7563 filter.len = res->len_value;
7564 filter.priority = res->priority_value;
7565 bytes_ptr = res->bytes_value;
7566 mask_ptr = res->mask_value;
7569 /* translate bytes string to uint_32 array. */
7570 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7571 (bytes_ptr[1] == 'X')))
7573 len = strnlen(bytes_ptr, res->len_value * 2);
7574 if (len == 0 || (len % 8 != 0)) {
7575 printf("please check len and bytes input\n");
7578 for (i = 0; i < len; i++) {
7580 if (isxdigit(c) == 0) {
7581 /* invalid characters. */
7582 printf("invalid input\n");
7585 val = xdigit2val(c);
7589 dword |= byte << (4 * mod - 4);
7594 filter.dwords[j] = dword;
7595 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7601 /* translate mask string to uint8_t array. */
7603 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7604 (mask_ptr[1] == 'X')))
7606 len = strnlen(mask_ptr, (res->len_value+3)/4);
7608 printf("invalid input\n");
7611 for (i = 0; i < len; i++) {
7613 if (isxdigit(c) == 0) {
7614 /* invalid characters. */
7615 printf("invalid input\n");
7618 val = xdigit2val(c);
7619 hex |= (uint8_t)(val & 0x8) >> 3;
7620 hex |= (uint8_t)(val & 0x4) >> 1;
7621 hex |= (uint8_t)(val & 0x2) << 1;
7622 hex |= (uint8_t)(val & 0x1) << 3;
7625 filter.mask[j] = byte;
7626 printf("mask[%d]:%02x ", j, filter.mask[j]);
7634 printf("call function rte_eth_dev_add_flex_filter: "
7635 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7636 res->index_value, res->queue_id,
7637 filter.len, filter.priority);
7638 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7639 &filter, res->queue_id);
7641 } else if (!strcmp(res->filter, "remove_flex_filter"))
7642 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7644 else if (!strcmp(res->filter, "get_flex_filter"))
7645 get_flex_filter(res->port_id, res->index_value);
7648 printf("flex filter setting error: (%s)\n", strerror(-ret));
7651 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7652 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7654 cmdline_parse_token_string_t cmd_flex_filter_len =
7655 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7657 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7658 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7660 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7661 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7663 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7664 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7666 cmdline_parse_token_string_t cmd_flex_filter_mask =
7667 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7669 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7670 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7672 cmdline_parse_token_string_t cmd_flex_filter_priority =
7673 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7674 priority, "priority");
7675 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7676 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7677 priority_value, UINT8);
7678 cmdline_parse_token_string_t cmd_flex_filter_queue =
7679 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7681 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7682 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7684 cmdline_parse_token_string_t cmd_flex_filter_index =
7685 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7687 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7688 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7689 index_value, UINT16);
7690 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7691 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7692 filter, "add_flex_filter");
7693 cmdline_parse_inst_t cmd_add_flex_filter = {
7694 .f = cmd_flex_filter_parsed,
7696 .help_str = "add a flex filter",
7698 (void *)&cmd_flex_filter_add_filter,
7699 (void *)&cmd_flex_filter_port_id,
7700 (void *)&cmd_flex_filter_len,
7701 (void *)&cmd_flex_filter_len_value,
7702 (void *)&cmd_flex_filter_bytes,
7703 (void *)&cmd_flex_filter_bytes_value,
7704 (void *)&cmd_flex_filter_mask,
7705 (void *)&cmd_flex_filter_mask_value,
7706 (void *)&cmd_flex_filter_priority,
7707 (void *)&cmd_flex_filter_priority_value,
7708 (void *)&cmd_flex_filter_queue,
7709 (void *)&cmd_flex_filter_queue_id,
7710 (void *)&cmd_flex_filter_index,
7711 (void *)&cmd_flex_filter_index_value,
7716 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7717 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7718 filter, "remove_flex_filter");
7719 cmdline_parse_inst_t cmd_remove_flex_filter = {
7720 .f = cmd_flex_filter_parsed,
7722 .help_str = "remove a flex filter",
7724 (void *)&cmd_flex_filter_remove_filter,
7725 (void *)&cmd_flex_filter_port_id,
7726 (void *)&cmd_flex_filter_index,
7727 (void *)&cmd_flex_filter_index_value,
7732 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7733 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7734 filter, "get_flex_filter");
7735 cmdline_parse_inst_t cmd_get_flex_filter = {
7736 .f = cmd_flex_filter_parsed,
7738 .help_str = "get a flex filter",
7740 (void *)&cmd_flex_filter_get_filter,
7741 (void *)&cmd_flex_filter_port_id,
7742 (void *)&cmd_flex_filter_index,
7743 (void *)&cmd_flex_filter_index_value,
7748 /* ******************************************************************************** */
7750 /* list of instructions */
7751 cmdline_parse_ctx_t main_ctx[] = {
7752 (cmdline_parse_inst_t *)&cmd_help_brief,
7753 (cmdline_parse_inst_t *)&cmd_help_long,
7754 (cmdline_parse_inst_t *)&cmd_quit,
7755 (cmdline_parse_inst_t *)&cmd_showport,
7756 (cmdline_parse_inst_t *)&cmd_showportall,
7757 (cmdline_parse_inst_t *)&cmd_showcfg,
7758 (cmdline_parse_inst_t *)&cmd_start,
7759 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7760 (cmdline_parse_inst_t *)&cmd_set_link_up,
7761 (cmdline_parse_inst_t *)&cmd_set_link_down,
7762 (cmdline_parse_inst_t *)&cmd_reset,
7763 (cmdline_parse_inst_t *)&cmd_set_numbers,
7764 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7765 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7766 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7767 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7768 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7769 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7770 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7771 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7772 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7773 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7774 (cmdline_parse_inst_t *)&cmd_set_link_check,
7775 #ifdef RTE_NIC_BYPASS
7776 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7777 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7778 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7779 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7781 #ifdef RTE_LIBRTE_PMD_BOND
7782 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7783 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7784 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7785 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7786 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7787 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7788 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7789 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7791 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7792 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7793 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7794 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7795 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7796 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7797 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7798 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7799 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7800 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7801 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7802 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7803 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7804 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7805 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7806 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7807 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7808 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7809 (cmdline_parse_inst_t *)&cmd_config_dcb,
7810 (cmdline_parse_inst_t *)&cmd_read_reg,
7811 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7812 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7813 (cmdline_parse_inst_t *)&cmd_write_reg,
7814 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7815 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7816 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7817 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7818 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7819 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7820 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7821 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7822 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7823 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7824 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7825 (cmdline_parse_inst_t *)&cmd_stop,
7826 (cmdline_parse_inst_t *)&cmd_mac_addr,
7827 (cmdline_parse_inst_t *)&cmd_set_qmap,
7828 (cmdline_parse_inst_t *)&cmd_operate_port,
7829 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7830 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7831 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7832 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7833 (cmdline_parse_inst_t *)&cmd_config_mtu,
7834 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7835 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7836 (cmdline_parse_inst_t *)&cmd_config_rss,
7837 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7838 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7839 (cmdline_parse_inst_t *)&cmd_showport_reta,
7840 (cmdline_parse_inst_t *)&cmd_config_burst,
7841 (cmdline_parse_inst_t *)&cmd_config_thresh,
7842 (cmdline_parse_inst_t *)&cmd_config_threshold,
7843 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7844 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7845 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7846 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
7847 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
7848 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7849 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7850 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7851 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7852 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
7853 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7854 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7855 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7856 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7857 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
7858 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
7859 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
7860 (cmdline_parse_inst_t *)&cmd_dump,
7861 (cmdline_parse_inst_t *)&cmd_dump_one,
7862 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
7863 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
7864 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
7865 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
7866 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
7867 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
7868 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
7869 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
7870 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
7871 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
7872 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
7873 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
7874 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
7875 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
7876 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
7880 /* prompt function, called from main on MASTER lcore */
7886 /* initialize non-constant commands */
7887 cmd_set_fwd_mode_init();
7889 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
7893 cmdline_interact(cl);
7894 cmdline_stdin_exit(cl);
7898 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
7900 if (id < nb_ports) {
7901 /* check if need_reconfig has been set to 1 */
7902 if (ports[id].need_reconfig == 0)
7903 ports[id].need_reconfig = dev;
7904 /* check if need_reconfig_queues has been set to 1 */
7905 if (ports[id].need_reconfig_queues == 0)
7906 ports[id].need_reconfig_queues = queue;
7910 for (pid = 0; pid < nb_ports; pid++) {
7911 /* check if need_reconfig has been set to 1 */
7912 if (ports[pid].need_reconfig == 0)
7913 ports[pid].need_reconfig = dev;
7914 /* check if need_reconfig_queues has been set to 1 */
7915 if (ports[pid].need_reconfig_queues == 0)
7916 ports[pid].need_reconfig_queues = queue;
7921 #ifdef RTE_NIC_BYPASS
7923 bypass_is_supported(portid_t port_id)
7925 struct rte_port *port;
7926 struct rte_pci_id *pci_id;
7928 if (port_id >= nb_ports) {
7929 printf("\tPort id must be less than %d.\n", nb_ports);
7933 /* Get the device id. */
7934 port = &ports[port_id];
7935 pci_id = &port->dev_info.pci_dev->id;
7937 /* Check if NIC supports bypass. */
7938 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
7942 printf("\tBypass not supported for port_id = %d.\n", port_id);