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_malloc.h>
63 #include <rte_launch.h>
64 #include <rte_tailq.h>
66 #include <rte_per_lcore.h>
67 #include <rte_lcore.h>
68 #include <rte_atomic.h>
69 #include <rte_branch_prediction.h>
71 #include <rte_mempool.h>
72 #include <rte_interrupts.h>
74 #include <rte_ether.h>
75 #include <rte_ethdev.h>
76 #include <rte_string_fns.h>
77 #include <rte_devargs.h>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #include <rte_pci_dev_ids.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
94 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
97 uint8_t bypass_is_supported(portid_t port_id);
100 /* *** Help command with introduction. *** */
101 struct cmd_help_brief_result {
102 cmdline_fixed_string_t help;
105 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
107 __attribute__((unused)) void *data)
112 "Help is available for the following sections:\n\n"
113 " help control : Start and stop forwarding.\n"
114 " help display : Displaying port, stats and config "
116 " help config : Configuration information.\n"
117 " help ports : Configuring ports.\n"
118 " help flowdir : Flow Director filter help.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
251 "set corelist (x[,y]*)\n"
252 " Set the list of forwarding cores.\n\n"
254 "set portlist (x[,y]*)\n"
255 " Set the list of forwarding ports.\n\n"
257 "vlan set strip (on|off) (port_id)\n"
258 " Set the VLAN strip on a port.\n\n"
260 "vlan set stripq (on|off) (port_id,queue_id)\n"
261 " Set the VLAN strip for a queue on a port.\n\n"
263 "vlan set filter (on|off) (port_id)\n"
264 " Set the VLAN filter on a port.\n\n"
266 "vlan set qinq (on|off) (port_id)\n"
267 " Set the VLAN QinQ (extended queue in queue)"
270 "vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "rx_vlan add (vlan_id|all) (port_id)\n"
275 " Add a vlan_id, or all identifiers, to the set"
276 " of VLAN identifiers filtered by port_id.\n\n"
278 "rx_vlan rm (vlan_id|all) (port_id)\n"
279 " Remove a vlan_id, or all identifiers, from the set"
280 " of VLAN identifiers filtered by port_id.\n\n"
282 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
283 " Add a vlan_id, to the set of VLAN identifiers"
284 "filtered for VF(s) from port_id.\n\n"
286 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
287 " Remove a vlan_id, to the set of VLAN identifiers"
288 "filtered for VF(s) from port_id.\n\n"
290 "rx_vlan set tpid (value) (port_id)\n"
291 " Set the outer VLAN TPID for Packet Filtering on"
294 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
295 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
296 " add a tunnel filter of a port.\n\n"
298 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
299 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
300 " remove a tunnel filter of a port.\n\n"
302 "rx_vxlan_port add (udp_port) (port_id)\n"
303 " Add an UDP port for VXLAN packet filter on a port\n\n"
305 "rx_vxlan_port rm (udp_port) (port_id)\n"
306 " Remove an UDP port for VXLAN packet filter on a port\n\n"
308 "tx_vlan set vlan_id (port_id)\n"
309 " Set hardware insertion of VLAN ID in packets sent"
312 "tx_vlan set pvid port_id vlan_id (on|off)\n"
313 " Set port based TX VLAN insertion.\n\n"
315 "tx_vlan reset (port_id)\n"
316 " Disable hardware insertion of a VLAN header in"
317 " packets sent on a port.\n\n"
319 "tx_checksum set (mask) (port_id)\n"
320 " Enable hardware insertion of checksum offload with"
321 " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
322 " bit 0 - insert ip checksum offload if set\n"
323 " bit 1 - insert udp checksum offload if set\n"
324 " bit 2 - insert tcp checksum offload if set\n"
325 " bit 3 - insert sctp checksum offload if set\n"
326 " bit 4 - insert inner ip checksum offload if set\n"
327 " bit 5 - insert inner udp checksum offload if set\n"
328 " bit 6 - insert inner tcp checksum offload if set\n"
329 " bit 7 - insert inner sctp checksum offload if set\n"
330 " Please check the NIC datasheet for HW limits.\n\n"
333 " Set packet forwarding mode.\n\n"
335 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
336 " Add a MAC address on port_id.\n\n"
338 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
339 " Remove a MAC address from port_id.\n\n"
341 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
342 " Add a MAC address for a VF on the port.\n\n"
344 "set port (port_id) uta (mac_address|all) (on|off)\n"
345 " Add/Remove a or all unicast hash filter(s)"
348 "set promisc (port_id|all) (on|off)\n"
349 " Set the promiscuous mode on port_id, or all.\n\n"
351 "set allmulti (port_id|all) (on|off)\n"
352 " Set the allmulti mode on port_id, or all.\n\n"
354 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
355 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
356 " (on|off) autoneg (on|off) (port_id)\n"
357 "set flow_ctrl rx (on|off) (portid)\n"
358 "set flow_ctrl tx (on|off) (portid)\n"
359 "set flow_ctrl high_water (high_water) (portid)\n"
360 "set flow_ctrl low_water (low_water) (portid)\n"
361 "set flow_ctrl pause_time (pause_time) (portid)\n"
362 "set flow_ctrl send_xon (send_xon) (portid)\n"
363 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
364 "set flow_ctrl autoneg (on|off) (port_id)\n"
365 " Set the link flow control parameter on a port.\n\n"
367 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
368 " (low_water) (pause_time) (priority) (port_id)\n"
369 " Set the priority flow control parameter on a"
372 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
373 " Set statistics mapping (qmapping 0..15) for RX/TX"
375 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
376 " on port 0 to mapping 5.\n\n"
378 "set port (port_id) vf (vf_id) rx|tx on|off\n"
379 " Enable/Disable a VF receive/tranmit from a port\n\n"
381 "set port (port_id) vf (vf_id) (mac_addr)"
382 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
383 " Add/Remove unicast or multicast MAC addr filter"
386 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
388 " AUPE:accepts untagged VLAN;"
389 "ROPE:accept unicast hash\n\n"
390 " BAM:accepts broadcast packets;"
391 "MPE:accepts all multicast packets\n\n"
392 " Enable/Disable a VF receive mode of a port\n\n"
394 "set port (port_id) queue (queue_id) rate (rate_num)\n"
395 " Set rate limit for a queue of a port\n\n"
397 "set port (port_id) vf (vf_id) rate (rate_num) "
398 "queue_mask (queue_mask_value)\n"
399 " Set rate limit for queues in VF of a port\n\n"
401 "set port (port_id) mirror-rule (rule_id)"
402 "(pool-mirror|vlan-mirror)\n"
403 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
404 " Set pool or vlan type mirror rule on a port.\n"
405 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
406 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
409 "set port (port_id) mirror-rule (rule_id)"
410 " (uplink-mirror|downlink-mirror) dst-pool"
411 " (pool_id) (on|off)\n"
412 " Set uplink or downlink type mirror rule on a port.\n"
413 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
414 " 0 on' enable mirror income traffic to pool 0.\n\n"
416 "reset port (port_id) mirror-rule (rule_id)\n"
417 " Reset a mirror rule.\n\n"
419 "set flush_rx (on|off)\n"
420 " Flush (default) or don't flush RX streams before"
421 " forwarding. Mainly used with PCAP drivers.\n\n"
423 #ifdef RTE_NIC_BYPASS
424 "set bypass mode (normal|bypass|isolate) (port_id)\n"
425 " Set the bypass mode for the lowest port on bypass enabled"
428 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
429 "mode (normal|bypass|isolate) (port_id)\n"
430 " Set the event required to initiate specified bypass mode for"
431 " the lowest port on a bypass enabled NIC where:\n"
432 " timeout = enable bypass after watchdog timeout.\n"
433 " os_on = enable bypass when OS/board is powered on.\n"
434 " os_off = enable bypass when OS/board is powered off.\n"
435 " power_on = enable bypass when power supply is turned on.\n"
436 " power_off = enable bypass when power supply is turned off."
439 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
440 " Set the bypass watchdog timeout to 'n' seconds"
441 " where 0 = instant.\n\n"
443 "show bypass config (port_id)\n"
444 " Show the bypass configuration for a bypass enabled NIC"
445 " using the lowest port on the NIC.\n\n"
447 #ifdef RTE_LIBRTE_PMD_BOND
448 "create bonded device (mode) (socket)\n"
449 " Create a new bonded device with specific bonding mode and socket.\n\n"
451 "add bonding slave (slave_id) (port_id)\n"
452 " Add a slave device to a bonded device.\n\n"
454 "remove bonding slave (slave_id) (port_id)\n"
455 " Remove a slave device from a bonded device.\n\n"
457 "set bonding mode (value) (port_id)\n"
458 " Set the bonding mode on a bonded device.\n\n"
460 "set bonding primary (slave_id) (port_id)\n"
461 " Set the primary slave for a bonded device.\n\n"
463 "show bonding config (port_id)\n"
464 " Show the bonding config for port_id.\n\n"
466 "set bonding mac_addr (port_id) (address)\n"
467 " Set the MAC address of a bonded device.\n\n"
469 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
470 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
472 "set bonding mon_period (port_id) (value)\n"
473 " Set the bonding link status monitoring polling period in ms.\n\n"
475 "set link-up port (port_id)\n"
476 " Set link up for a port.\n\n"
478 "set link-down port (port_id)\n"
479 " Set link down for a port.\n\n"
481 , list_pkt_forwarding_modes()
486 if (show_all || !strcmp(res->section, "flowdir")) {
491 "Flow director mode:\n"
492 "-------------------\n\n"
494 "add_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)"
498 " queue (queue_id)\n"
499 " Add a signature filter.\n\n"
501 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
502 " src (src_ip_address) (src_port)"
503 " dst (dst_ip_address) (dst_port)"
504 " flexbytes (flexbytes_values) vlan (vlan_id)"
505 " queue (queue_id)\n"
506 " Update a signature filter.\n\n"
508 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
509 " src (src_ip_address) (src_port)"
510 " dst (dst_ip_address) (dst_port)"
511 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
512 " Remove a signature filter.\n\n"
514 "add_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)"
518 " queue (queue_id) soft (soft_id)\n"
519 " Add a perfect filter.\n\n"
521 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
522 " src (src_ip_address) (src_port)"
523 " dst (dst_ip_address) (dst_port)"
524 " flexbytes (flexbytes_values) vlan (vlan_id)"
525 " queue (queue_id)\n"
526 " Update a perfect filter.\n\n"
528 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
529 " src (src_ip_address) (src_port)"
530 " dst (dst_ip_address) (dst_port)"
531 " flexbytes (flexbytes_values) vlan (vlan_id)"
533 " Remove a perfect filter.\n\n"
535 "set_masks_filter (port_id) only_ip_flow (0|1)"
536 " src_mask (ip_src_mask) (src_port_mask)"
537 " dst_mask (ip_dst_mask) (dst_port_mask)"
538 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
539 " Set IPv4 filter masks.\n\n"
541 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
542 " src_mask (ip_src_mask) (src_port_mask)"
543 " dst_mask (ip_dst_mask) (dst_port_mask)"
544 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
545 " compare_dst (0|1)\n"
546 " Set IPv6 filter masks.\n\n"
550 if (show_all || !strcmp(res->section, "ports")) {
556 "----------------\n\n"
558 "port start (port_id|all)\n"
559 " Start all ports or port_id.\n\n"
561 "port stop (port_id|all)\n"
562 " Stop all ports or port_id.\n\n"
564 "port close (port_id|all)\n"
565 " Close all ports or port_id.\n\n"
567 "port config (port_id|all)"
568 " speed (10|100|1000|10000|40000|auto)"
569 " duplex (half|full|auto)\n"
570 " Set speed and duplex for all ports or port_id\n\n"
572 "port config all (rxq|txq|rxd|txd) (value)\n"
573 " Set number for rxq/txq/rxd/txd.\n\n"
575 "port config all max-pkt-len (value)\n"
576 " Set the max packet length.\n\n"
578 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
580 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
583 "port config all rss (ip|udp|none)\n"
584 " Set the RSS mode.\n\n"
586 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
587 " Set the RSS redirection table.\n\n"
589 "port config (port_id) dcb vt (on|off) (traffic_class)"
591 " Set the DCB mode.\n\n"
593 "port config all burst (value)\n"
594 " Set the number of packets per burst.\n\n"
596 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
598 " Set the ring prefetch/host/writeback threshold"
599 " for tx/rx queue.\n\n"
601 "port config all (txfreet|txrst|rxfreet) (value)\n"
602 " Set free threshold for rx/tx, or set"
603 " tx rs bit threshold.\n\n"
604 "port config mtu X value\n"
605 " Set the MTU of port X to a given value\n\n"
607 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
608 " Start/stop a rx/tx queue of port X. Only take effect"
609 " when port X is started\n"
613 if (show_all || !strcmp(res->section, "registers")) {
621 "read reg (port_id) (address)\n"
622 " Display value of a port register.\n\n"
624 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
625 " Display a port register bit field.\n\n"
627 "read regbit (port_id) (address) (bit_x)\n"
628 " Display a single port register bit.\n\n"
630 "write reg (port_id) (address) (value)\n"
631 " Set value of a port register.\n\n"
633 "write regfield (port_id) (address) (bit_x) (bit_y)"
635 " Set bit field of a port register.\n\n"
637 "write regbit (port_id) (address) (bit_x) (value)\n"
638 " Set single bit value of a port register.\n\n"
641 if (show_all || !strcmp(res->section, "filters")) {
649 "add_ethertype_filter (port_id) ethertype (eth_value)"
650 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
651 " add an ethertype filter.\n\n"
653 "remove_ethertype_filter (port_id) index (idx)\n"
654 " remove an ethertype filter.\n\n"
656 "get_ethertype_filter (port_id) index (idx)\n"
657 " get info of a ethertype filter.\n\n"
659 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
660 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
661 " queue (queue_id) index (idx)\n"
662 " add a 2tuple filter.\n\n"
664 "remove_2tuple_filter (port_id) index (idx)\n"
665 " remove a 2tuple filter.\n\n"
667 "get_2tuple_filter (port_id) index (idx)\n"
668 " get info of a 2tuple filter.\n\n"
670 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
671 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
672 " mask (mask_value) flags (flags_value) priority (prio_value)"
673 " queue (queue_id) index (idx)\n"
674 " add a 5tuple filter.\n\n"
676 "remove_5tuple_filter (port_id) index (idx)\n"
677 " remove a 5tuple filter.\n\n"
679 "get_5tuple_filter (port_id) index (idx)\n"
680 " get info of a 5tuple filter.\n\n"
682 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
683 " add syn filter.\n\n"
685 "remove_syn_filter (port_id)"
686 " remove syn filter.\n\n"
688 "get_syn_filter (port_id) "
689 " get syn filter info.\n\n"
691 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
692 " priority (prio_value) queue (queue_id) index (idx)\n"
693 " add a flex filter.\n\n"
695 "remove_flex_filter (port_id) index (idx)\n"
696 " remove a flex filter.\n\n"
698 "get_flex_filter (port_id) index (idx)\n"
699 " get info of a flex filter.\n\n"
704 cmdline_parse_token_string_t cmd_help_long_help =
705 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
707 cmdline_parse_token_string_t cmd_help_long_section =
708 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
709 "all#control#display#config#flowdir#"
710 "ports#registers#filters");
712 cmdline_parse_inst_t cmd_help_long = {
713 .f = cmd_help_long_parsed,
715 .help_str = "show help",
717 (void *)&cmd_help_long_help,
718 (void *)&cmd_help_long_section,
724 /* *** start/stop/close all ports *** */
725 struct cmd_operate_port_result {
726 cmdline_fixed_string_t keyword;
727 cmdline_fixed_string_t name;
728 cmdline_fixed_string_t value;
731 static void cmd_operate_port_parsed(void *parsed_result,
732 __attribute__((unused)) struct cmdline *cl,
733 __attribute__((unused)) void *data)
735 struct cmd_operate_port_result *res = parsed_result;
737 if (!strcmp(res->name, "start"))
738 start_port(RTE_PORT_ALL);
739 else if (!strcmp(res->name, "stop"))
740 stop_port(RTE_PORT_ALL);
741 else if (!strcmp(res->name, "close"))
742 close_port(RTE_PORT_ALL);
744 printf("Unknown parameter\n");
747 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
748 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
750 cmdline_parse_token_string_t cmd_operate_port_all_port =
751 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
753 cmdline_parse_token_string_t cmd_operate_port_all_all =
754 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
756 cmdline_parse_inst_t cmd_operate_port = {
757 .f = cmd_operate_port_parsed,
759 .help_str = "port start|stop|close all: start/stop/close all ports",
761 (void *)&cmd_operate_port_all_cmd,
762 (void *)&cmd_operate_port_all_port,
763 (void *)&cmd_operate_port_all_all,
768 /* *** start/stop/close specific port *** */
769 struct cmd_operate_specific_port_result {
770 cmdline_fixed_string_t keyword;
771 cmdline_fixed_string_t name;
775 static void cmd_operate_specific_port_parsed(void *parsed_result,
776 __attribute__((unused)) struct cmdline *cl,
777 __attribute__((unused)) void *data)
779 struct cmd_operate_specific_port_result *res = parsed_result;
781 if (!strcmp(res->name, "start"))
782 start_port(res->value);
783 else if (!strcmp(res->name, "stop"))
784 stop_port(res->value);
785 else if (!strcmp(res->name, "close"))
786 close_port(res->value);
788 printf("Unknown parameter\n");
791 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
792 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
794 cmdline_parse_token_string_t cmd_operate_specific_port_port =
795 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
796 name, "start#stop#close");
797 cmdline_parse_token_num_t cmd_operate_specific_port_id =
798 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
801 cmdline_parse_inst_t cmd_operate_specific_port = {
802 .f = cmd_operate_specific_port_parsed,
804 .help_str = "port start|stop|close X: start/stop/close port X",
806 (void *)&cmd_operate_specific_port_cmd,
807 (void *)&cmd_operate_specific_port_port,
808 (void *)&cmd_operate_specific_port_id,
813 /* *** configure speed for all ports *** */
814 struct cmd_config_speed_all {
815 cmdline_fixed_string_t port;
816 cmdline_fixed_string_t keyword;
817 cmdline_fixed_string_t all;
818 cmdline_fixed_string_t item1;
819 cmdline_fixed_string_t item2;
820 cmdline_fixed_string_t value1;
821 cmdline_fixed_string_t value2;
825 cmd_config_speed_all_parsed(void *parsed_result,
826 __attribute__((unused)) struct cmdline *cl,
827 __attribute__((unused)) void *data)
829 struct cmd_config_speed_all *res = parsed_result;
830 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
831 uint16_t link_duplex = 0;
834 if (!all_ports_stopped()) {
835 printf("Please stop all ports first\n");
839 if (!strcmp(res->value1, "10"))
840 link_speed = ETH_LINK_SPEED_10;
841 else if (!strcmp(res->value1, "100"))
842 link_speed = ETH_LINK_SPEED_100;
843 else if (!strcmp(res->value1, "1000"))
844 link_speed = ETH_LINK_SPEED_1000;
845 else if (!strcmp(res->value1, "10000"))
846 link_speed = ETH_LINK_SPEED_10G;
847 else if (!strcmp(res->value1, "40000"))
848 link_speed = ETH_LINK_SPEED_40G;
849 else if (!strcmp(res->value1, "auto"))
850 link_speed = ETH_LINK_SPEED_AUTONEG;
852 printf("Unknown parameter\n");
856 if (!strcmp(res->value2, "half"))
857 link_duplex = ETH_LINK_HALF_DUPLEX;
858 else if (!strcmp(res->value2, "full"))
859 link_duplex = ETH_LINK_FULL_DUPLEX;
860 else if (!strcmp(res->value2, "auto"))
861 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
863 printf("Unknown parameter\n");
867 for (pid = 0; pid < nb_ports; pid++) {
868 ports[pid].dev_conf.link_speed = link_speed;
869 ports[pid].dev_conf.link_duplex = link_duplex;
872 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
875 cmdline_parse_token_string_t cmd_config_speed_all_port =
876 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
877 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
878 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
880 cmdline_parse_token_string_t cmd_config_speed_all_all =
881 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
882 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
883 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
884 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
885 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
886 "10#100#1000#10000#40000#auto");
887 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
888 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
889 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
890 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
893 cmdline_parse_inst_t cmd_config_speed_all = {
894 .f = cmd_config_speed_all_parsed,
896 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
899 (void *)&cmd_config_speed_all_port,
900 (void *)&cmd_config_speed_all_keyword,
901 (void *)&cmd_config_speed_all_all,
902 (void *)&cmd_config_speed_all_item1,
903 (void *)&cmd_config_speed_all_value1,
904 (void *)&cmd_config_speed_all_item2,
905 (void *)&cmd_config_speed_all_value2,
910 /* *** configure speed for specific port *** */
911 struct cmd_config_speed_specific {
912 cmdline_fixed_string_t port;
913 cmdline_fixed_string_t keyword;
915 cmdline_fixed_string_t item1;
916 cmdline_fixed_string_t item2;
917 cmdline_fixed_string_t value1;
918 cmdline_fixed_string_t value2;
922 cmd_config_speed_specific_parsed(void *parsed_result,
923 __attribute__((unused)) struct cmdline *cl,
924 __attribute__((unused)) void *data)
926 struct cmd_config_speed_specific *res = parsed_result;
927 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
928 uint16_t link_duplex = 0;
930 if (!all_ports_stopped()) {
931 printf("Please stop all ports first\n");
935 if (res->id >= nb_ports) {
936 printf("Port id %d must be less than %d\n", res->id, nb_ports);
940 if (!strcmp(res->value1, "10"))
941 link_speed = ETH_LINK_SPEED_10;
942 else if (!strcmp(res->value1, "100"))
943 link_speed = ETH_LINK_SPEED_100;
944 else if (!strcmp(res->value1, "1000"))
945 link_speed = ETH_LINK_SPEED_1000;
946 else if (!strcmp(res->value1, "10000"))
947 link_speed = ETH_LINK_SPEED_10000;
948 else if (!strcmp(res->value1, "40000"))
949 link_speed = ETH_LINK_SPEED_40G;
950 else if (!strcmp(res->value1, "auto"))
951 link_speed = ETH_LINK_SPEED_AUTONEG;
953 printf("Unknown parameter\n");
957 if (!strcmp(res->value2, "half"))
958 link_duplex = ETH_LINK_HALF_DUPLEX;
959 else if (!strcmp(res->value2, "full"))
960 link_duplex = ETH_LINK_FULL_DUPLEX;
961 else if (!strcmp(res->value2, "auto"))
962 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
964 printf("Unknown parameter\n");
968 ports[res->id].dev_conf.link_speed = link_speed;
969 ports[res->id].dev_conf.link_duplex = link_duplex;
971 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
975 cmdline_parse_token_string_t cmd_config_speed_specific_port =
976 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
978 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
979 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
981 cmdline_parse_token_num_t cmd_config_speed_specific_id =
982 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
983 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
986 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
988 "10#100#1000#10000#40000#auto");
989 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
992 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
993 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
996 cmdline_parse_inst_t cmd_config_speed_specific = {
997 .f = cmd_config_speed_specific_parsed,
999 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1002 (void *)&cmd_config_speed_specific_port,
1003 (void *)&cmd_config_speed_specific_keyword,
1004 (void *)&cmd_config_speed_specific_id,
1005 (void *)&cmd_config_speed_specific_item1,
1006 (void *)&cmd_config_speed_specific_value1,
1007 (void *)&cmd_config_speed_specific_item2,
1008 (void *)&cmd_config_speed_specific_value2,
1013 /* *** configure txq/rxq, txd/rxd *** */
1014 struct cmd_config_rx_tx {
1015 cmdline_fixed_string_t port;
1016 cmdline_fixed_string_t keyword;
1017 cmdline_fixed_string_t all;
1018 cmdline_fixed_string_t name;
1023 cmd_config_rx_tx_parsed(void *parsed_result,
1024 __attribute__((unused)) struct cmdline *cl,
1025 __attribute__((unused)) void *data)
1027 struct cmd_config_rx_tx *res = parsed_result;
1029 if (!all_ports_stopped()) {
1030 printf("Please stop all ports first\n");
1034 if (!strcmp(res->name, "rxq")) {
1035 if (res->value <= 0) {
1036 printf("rxq %d invalid - must be > 0\n", res->value);
1039 nb_rxq = res->value;
1041 else if (!strcmp(res->name, "txq")) {
1042 if (res->value <= 0) {
1043 printf("txq %d invalid - must be > 0\n", res->value);
1046 nb_txq = res->value;
1048 else if (!strcmp(res->name, "rxd")) {
1049 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1050 printf("rxd %d invalid - must be > 0 && <= %d\n",
1051 res->value, RTE_TEST_RX_DESC_MAX);
1054 nb_rxd = res->value;
1055 } else if (!strcmp(res->name, "txd")) {
1056 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1057 printf("txd %d invalid - must be > 0 && <= %d\n",
1058 res->value, RTE_TEST_TX_DESC_MAX);
1061 nb_txd = res->value;
1063 printf("Unknown parameter\n");
1069 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1072 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1073 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1074 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1075 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1076 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1077 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1078 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1079 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1081 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1082 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1084 cmdline_parse_inst_t cmd_config_rx_tx = {
1085 .f = cmd_config_rx_tx_parsed,
1087 .help_str = "port config all rxq|txq|rxd|txd value",
1089 (void *)&cmd_config_rx_tx_port,
1090 (void *)&cmd_config_rx_tx_keyword,
1091 (void *)&cmd_config_rx_tx_all,
1092 (void *)&cmd_config_rx_tx_name,
1093 (void *)&cmd_config_rx_tx_value,
1098 /* *** config max packet length *** */
1099 struct cmd_config_max_pkt_len_result {
1100 cmdline_fixed_string_t port;
1101 cmdline_fixed_string_t keyword;
1102 cmdline_fixed_string_t all;
1103 cmdline_fixed_string_t name;
1108 cmd_config_max_pkt_len_parsed(void *parsed_result,
1109 __attribute__((unused)) struct cmdline *cl,
1110 __attribute__((unused)) void *data)
1112 struct cmd_config_max_pkt_len_result *res = parsed_result;
1114 if (!all_ports_stopped()) {
1115 printf("Please stop all ports first\n");
1119 if (!strcmp(res->name, "max-pkt-len")) {
1120 if (res->value < ETHER_MIN_LEN) {
1121 printf("max-pkt-len can not be less than %d\n",
1125 if (res->value == rx_mode.max_rx_pkt_len)
1128 rx_mode.max_rx_pkt_len = res->value;
1129 if (res->value > ETHER_MAX_LEN)
1130 rx_mode.jumbo_frame = 1;
1132 rx_mode.jumbo_frame = 0;
1134 printf("Unknown parameter\n");
1140 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1143 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1146 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1149 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1152 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1155 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1156 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1159 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1160 .f = cmd_config_max_pkt_len_parsed,
1162 .help_str = "port config all max-pkt-len value",
1164 (void *)&cmd_config_max_pkt_len_port,
1165 (void *)&cmd_config_max_pkt_len_keyword,
1166 (void *)&cmd_config_max_pkt_len_all,
1167 (void *)&cmd_config_max_pkt_len_name,
1168 (void *)&cmd_config_max_pkt_len_value,
1173 /* *** configure port MTU *** */
1174 struct cmd_config_mtu_result {
1175 cmdline_fixed_string_t port;
1176 cmdline_fixed_string_t keyword;
1177 cmdline_fixed_string_t mtu;
1183 cmd_config_mtu_parsed(void *parsed_result,
1184 __attribute__((unused)) struct cmdline *cl,
1185 __attribute__((unused)) void *data)
1187 struct cmd_config_mtu_result *res = parsed_result;
1189 if (res->value < ETHER_MIN_LEN) {
1190 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1193 port_mtu_set(res->port_id, res->value);
1196 cmdline_parse_token_string_t cmd_config_mtu_port =
1197 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1199 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1200 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1202 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1203 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1205 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1206 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1207 cmdline_parse_token_num_t cmd_config_mtu_value =
1208 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1210 cmdline_parse_inst_t cmd_config_mtu = {
1211 .f = cmd_config_mtu_parsed,
1213 .help_str = "port config mtu value",
1215 (void *)&cmd_config_mtu_port,
1216 (void *)&cmd_config_mtu_keyword,
1217 (void *)&cmd_config_mtu_mtu,
1218 (void *)&cmd_config_mtu_port_id,
1219 (void *)&cmd_config_mtu_value,
1224 /* *** configure rx mode *** */
1225 struct cmd_config_rx_mode_flag {
1226 cmdline_fixed_string_t port;
1227 cmdline_fixed_string_t keyword;
1228 cmdline_fixed_string_t all;
1229 cmdline_fixed_string_t name;
1230 cmdline_fixed_string_t value;
1234 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1235 __attribute__((unused)) struct cmdline *cl,
1236 __attribute__((unused)) void *data)
1238 struct cmd_config_rx_mode_flag *res = parsed_result;
1240 if (!all_ports_stopped()) {
1241 printf("Please stop all ports first\n");
1245 if (!strcmp(res->name, "crc-strip")) {
1246 if (!strcmp(res->value, "on"))
1247 rx_mode.hw_strip_crc = 1;
1248 else if (!strcmp(res->value, "off"))
1249 rx_mode.hw_strip_crc = 0;
1251 printf("Unknown parameter\n");
1254 } else if (!strcmp(res->name, "rx-cksum")) {
1255 if (!strcmp(res->value, "on"))
1256 rx_mode.hw_ip_checksum = 1;
1257 else if (!strcmp(res->value, "off"))
1258 rx_mode.hw_ip_checksum = 0;
1260 printf("Unknown parameter\n");
1263 } else if (!strcmp(res->name, "hw-vlan")) {
1264 if (!strcmp(res->value, "on")) {
1265 rx_mode.hw_vlan_filter = 1;
1266 rx_mode.hw_vlan_strip = 1;
1268 else if (!strcmp(res->value, "off")) {
1269 rx_mode.hw_vlan_filter = 0;
1270 rx_mode.hw_vlan_strip = 0;
1273 printf("Unknown parameter\n");
1276 } else if (!strcmp(res->name, "drop-en")) {
1277 if (!strcmp(res->value, "on"))
1279 else if (!strcmp(res->value, "off"))
1282 printf("Unknown parameter\n");
1286 printf("Unknown parameter\n");
1292 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1295 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1296 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1297 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1298 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1300 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1301 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1302 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1303 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1304 "crc-strip#rx-cksum#hw-vlan");
1305 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1306 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1309 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1310 .f = cmd_config_rx_mode_flag_parsed,
1312 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1314 (void *)&cmd_config_rx_mode_flag_port,
1315 (void *)&cmd_config_rx_mode_flag_keyword,
1316 (void *)&cmd_config_rx_mode_flag_all,
1317 (void *)&cmd_config_rx_mode_flag_name,
1318 (void *)&cmd_config_rx_mode_flag_value,
1323 /* *** configure rss *** */
1324 struct cmd_config_rss {
1325 cmdline_fixed_string_t port;
1326 cmdline_fixed_string_t keyword;
1327 cmdline_fixed_string_t all;
1328 cmdline_fixed_string_t name;
1329 cmdline_fixed_string_t value;
1333 cmd_config_rss_parsed(void *parsed_result,
1334 __attribute__((unused)) struct cmdline *cl,
1335 __attribute__((unused)) void *data)
1337 struct cmd_config_rss *res = parsed_result;
1338 struct rte_eth_rss_conf rss_conf;
1341 if (!strcmp(res->value, "ip"))
1342 rss_conf.rss_hf = ETH_RSS_IP;
1343 else if (!strcmp(res->value, "udp"))
1344 rss_conf.rss_hf = ETH_RSS_UDP;
1345 else if (!strcmp(res->value, "none"))
1346 rss_conf.rss_hf = 0;
1348 printf("Unknown parameter\n");
1351 rss_conf.rss_key = NULL;
1352 for (i = 0; i < rte_eth_dev_count(); i++)
1353 rte_eth_dev_rss_hash_update(i, &rss_conf);
1356 cmdline_parse_token_string_t cmd_config_rss_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1358 cmdline_parse_token_string_t cmd_config_rss_keyword =
1359 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1360 cmdline_parse_token_string_t cmd_config_rss_all =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1362 cmdline_parse_token_string_t cmd_config_rss_name =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1364 cmdline_parse_token_string_t cmd_config_rss_value =
1365 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1367 cmdline_parse_inst_t cmd_config_rss = {
1368 .f = cmd_config_rss_parsed,
1370 .help_str = "port config all rss ip|udp|none",
1372 (void *)&cmd_config_rss_port,
1373 (void *)&cmd_config_rss_keyword,
1374 (void *)&cmd_config_rss_all,
1375 (void *)&cmd_config_rss_name,
1376 (void *)&cmd_config_rss_value,
1381 /* *** configure rss hash key *** */
1382 struct cmd_config_rss_hash_key {
1383 cmdline_fixed_string_t port;
1384 cmdline_fixed_string_t config;
1386 cmdline_fixed_string_t rss_hash_key;
1387 cmdline_fixed_string_t key;
1390 #define RSS_HASH_KEY_LENGTH 40
1392 hexa_digit_to_value(char hexa_digit)
1394 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1395 return (uint8_t) (hexa_digit - '0');
1396 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1397 return (uint8_t) ((hexa_digit - 'a') + 10);
1398 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1399 return (uint8_t) ((hexa_digit - 'A') + 10);
1400 /* Invalid hexa digit */
1405 parse_and_check_key_hexa_digit(char *key, int idx)
1409 hexa_v = hexa_digit_to_value(key[idx]);
1411 printf("invalid key: character %c at position %d is not a "
1412 "valid hexa digit\n", key[idx], idx);
1417 cmd_config_rss_hash_key_parsed(void *parsed_result,
1418 __attribute__((unused)) struct cmdline *cl,
1419 __attribute__((unused)) void *data)
1421 struct cmd_config_rss_hash_key *res = parsed_result;
1422 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1427 /* Check the length of the RSS hash key */
1428 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1429 printf("key length: %d invalid - key must be a string of %d"
1430 "hexa-decimal numbers\n", (int) strlen(res->key),
1431 RSS_HASH_KEY_LENGTH * 2);
1434 /* Translate RSS hash key into binary representation */
1435 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1436 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1439 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1442 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1444 port_rss_hash_key_update(res->port_id, hash_key);
1447 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1448 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1449 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1450 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1452 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1453 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1454 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1456 rss_hash_key, "rss-hash-key");
1457 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1460 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1461 .f = cmd_config_rss_hash_key_parsed,
1463 .help_str = "port config X rss-hash-key 80 hexa digits",
1465 (void *)&cmd_config_rss_hash_key_port,
1466 (void *)&cmd_config_rss_hash_key_config,
1467 (void *)&cmd_config_rss_hash_key_port_id,
1468 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1469 (void *)&cmd_config_rss_hash_key_value,
1474 /* *** configure port rxq/txq start/stop *** */
1475 struct cmd_config_rxtx_queue {
1476 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t rxtxq;
1480 cmdline_fixed_string_t opname;
1484 cmd_config_rxtx_queue_parsed(void *parsed_result,
1485 __attribute__((unused)) struct cmdline *cl,
1486 __attribute__((unused)) void *data)
1488 struct cmd_config_rxtx_queue *res = parsed_result;
1493 if (test_done == 0) {
1494 printf("Please stop forwarding first\n");
1498 if (port_id_is_invalid(res->portid))
1501 if (port_is_started(res->portid) != 1) {
1502 printf("Please start port %u first\n", res->portid);
1506 if (!strcmp(res->rxtxq, "rxq"))
1508 else if (!strcmp(res->rxtxq, "txq"))
1511 printf("Unknown parameter\n");
1515 if (isrx && rx_queue_id_is_invalid(res->qid))
1517 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1520 if (!strcmp(res->opname, "start"))
1522 else if (!strcmp(res->opname, "stop"))
1525 printf("Unknown parameter\n");
1529 if (isstart && isrx)
1530 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1531 else if (!isstart && isrx)
1532 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1533 else if (isstart && !isrx)
1534 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1536 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1538 if (ret == -ENOTSUP)
1539 printf("Function not supported in PMD driver\n");
1542 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1543 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1544 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1545 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1546 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1548 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1549 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1550 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1551 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1554 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1555 .f = cmd_config_rxtx_queue_parsed,
1557 .help_str = "port X rxq|txq ID start|stop",
1559 (void *)&cmd_config_speed_all_port,
1560 (void *)&cmd_config_rxtx_queue_portid,
1561 (void *)&cmd_config_rxtx_queue_rxtxq,
1562 (void *)&cmd_config_rxtx_queue_qid,
1563 (void *)&cmd_config_rxtx_queue_opname,
1568 /* *** Configure RSS RETA *** */
1569 struct cmd_config_rss_reta {
1570 cmdline_fixed_string_t port;
1571 cmdline_fixed_string_t keyword;
1573 cmdline_fixed_string_t name;
1574 cmdline_fixed_string_t list_name;
1575 cmdline_fixed_string_t list_of_items;
1579 parse_reta_config(const char *str,
1580 struct rte_eth_rss_reta_entry64 *reta_conf,
1581 uint16_t nb_entries)
1585 uint16_t hash_index, idx, shift;
1588 const char *p, *p0 = str;
1595 unsigned long int_fld[_NUM_FLD];
1596 char *str_fld[_NUM_FLD];
1598 while ((p = strchr(p0,'(')) != NULL) {
1600 if((p0 = strchr(p,')')) == NULL)
1604 if(size >= sizeof(s))
1607 snprintf(s, sizeof(s), "%.*s", size, p);
1608 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1610 for (i = 0; i < _NUM_FLD; i++) {
1612 int_fld[i] = strtoul(str_fld[i], &end, 0);
1613 if (errno != 0 || end == str_fld[i] ||
1618 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1619 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1621 if (hash_index >= nb_entries) {
1622 printf("Invalid RETA hash index=%d\n", hash_index);
1626 idx = hash_index / RTE_RETA_GROUP_SIZE;
1627 shift = hash_index % RTE_RETA_GROUP_SIZE;
1628 reta_conf[idx].mask |= (1ULL << shift);
1629 reta_conf[idx].reta[shift] = nb_queue;
1636 cmd_set_rss_reta_parsed(void *parsed_result,
1637 __attribute__((unused)) struct cmdline *cl,
1638 __attribute__((unused)) void *data)
1641 struct rte_eth_dev_info dev_info;
1642 struct rte_eth_rss_reta_entry64 reta_conf[8];
1643 struct cmd_config_rss_reta *res = parsed_result;
1645 memset(&dev_info, 0, sizeof(dev_info));
1646 rte_eth_dev_info_get(res->port_id, &dev_info);
1647 if (dev_info.reta_size == 0) {
1648 printf("Redirection table size is 0 which is "
1649 "invalid for RSS\n");
1652 printf("The reta size of port %d is %u\n",
1653 res->port_id, dev_info.reta_size);
1654 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1655 printf("Currently do not support more than %u entries of "
1656 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1660 memset(reta_conf, 0, sizeof(reta_conf));
1661 if (!strcmp(res->list_name, "reta")) {
1662 if (parse_reta_config(res->list_of_items, reta_conf,
1663 dev_info.reta_size)) {
1664 printf("Invalid RSS Redirection Table "
1665 "config entered\n");
1668 ret = rte_eth_dev_rss_reta_update(res->port_id,
1669 reta_conf, dev_info.reta_size);
1671 printf("Bad redirection table parameter, "
1672 "return code = %d \n", ret);
1676 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1678 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1680 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1681 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1682 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1683 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1684 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1685 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1686 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1689 cmdline_parse_inst_t cmd_config_rss_reta = {
1690 .f = cmd_set_rss_reta_parsed,
1692 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1694 (void *)&cmd_config_rss_reta_port,
1695 (void *)&cmd_config_rss_reta_keyword,
1696 (void *)&cmd_config_rss_reta_port_id,
1697 (void *)&cmd_config_rss_reta_name,
1698 (void *)&cmd_config_rss_reta_list_name,
1699 (void *)&cmd_config_rss_reta_list_of_items,
1704 /* *** SHOW PORT RETA INFO *** */
1705 struct cmd_showport_reta {
1706 cmdline_fixed_string_t show;
1707 cmdline_fixed_string_t port;
1709 cmdline_fixed_string_t rss;
1710 cmdline_fixed_string_t reta;
1712 cmdline_fixed_string_t list_of_items;
1716 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1717 uint16_t nb_entries,
1721 const char *p, *p0 = str;
1725 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1728 p = strchr(p0, '(');
1732 p0 = strchr(p, ')');
1736 if (size >= sizeof(s)) {
1737 printf("The string size exceeds the internal buffer size\n");
1740 snprintf(s, sizeof(s), "%.*s", size, p);
1741 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1742 if (ret <= 0 || ret != num) {
1743 printf("The bits of masks do not match the number of "
1744 "reta entries: %u\n", num);
1747 for (i = 0; i < ret; i++)
1748 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1754 cmd_showport_reta_parsed(void *parsed_result,
1755 __attribute__((unused)) struct cmdline *cl,
1756 __attribute__((unused)) void *data)
1758 struct cmd_showport_reta *res = parsed_result;
1759 struct rte_eth_rss_reta_entry64 reta_conf[8];
1760 struct rte_eth_dev_info dev_info;
1762 memset(&dev_info, 0, sizeof(dev_info));
1763 rte_eth_dev_info_get(res->port_id, &dev_info);
1764 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1765 res->size > ETH_RSS_RETA_SIZE_512) {
1766 printf("Invalid redirection table size: %u\n", res->size);
1770 memset(reta_conf, 0, sizeof(reta_conf));
1771 if (showport_parse_reta_config(reta_conf, res->size,
1772 res->list_of_items) < 0) {
1773 printf("Invalid string: %s for reta masks\n",
1774 res->list_of_items);
1777 port_rss_reta_info(res->port_id, reta_conf, res->size);
1780 cmdline_parse_token_string_t cmd_showport_reta_show =
1781 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1782 cmdline_parse_token_string_t cmd_showport_reta_port =
1783 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1784 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1785 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1786 cmdline_parse_token_string_t cmd_showport_reta_rss =
1787 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1788 cmdline_parse_token_string_t cmd_showport_reta_reta =
1789 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1790 cmdline_parse_token_num_t cmd_showport_reta_size =
1791 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1792 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1793 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1794 list_of_items, NULL);
1796 cmdline_parse_inst_t cmd_showport_reta = {
1797 .f = cmd_showport_reta_parsed,
1799 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1801 (void *)&cmd_showport_reta_show,
1802 (void *)&cmd_showport_reta_port,
1803 (void *)&cmd_showport_reta_port_id,
1804 (void *)&cmd_showport_reta_rss,
1805 (void *)&cmd_showport_reta_reta,
1806 (void *)&cmd_showport_reta_size,
1807 (void *)&cmd_showport_reta_list_of_items,
1812 /* *** Show RSS hash configuration *** */
1813 struct cmd_showport_rss_hash {
1814 cmdline_fixed_string_t show;
1815 cmdline_fixed_string_t port;
1817 cmdline_fixed_string_t rss_hash;
1818 cmdline_fixed_string_t key; /* optional argument */
1821 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1822 __attribute__((unused)) struct cmdline *cl,
1825 struct cmd_showport_rss_hash *res = parsed_result;
1827 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1830 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1831 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1832 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1833 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1834 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1835 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1836 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1837 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1839 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1840 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1842 cmdline_parse_inst_t cmd_showport_rss_hash = {
1843 .f = cmd_showport_rss_hash_parsed,
1845 .help_str = "show port X rss-hash (X = port number)\n",
1847 (void *)&cmd_showport_rss_hash_show,
1848 (void *)&cmd_showport_rss_hash_port,
1849 (void *)&cmd_showport_rss_hash_port_id,
1850 (void *)&cmd_showport_rss_hash_rss_hash,
1855 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1856 .f = cmd_showport_rss_hash_parsed,
1858 .help_str = "show port X rss-hash key (X = port number)\n",
1860 (void *)&cmd_showport_rss_hash_show,
1861 (void *)&cmd_showport_rss_hash_port,
1862 (void *)&cmd_showport_rss_hash_port_id,
1863 (void *)&cmd_showport_rss_hash_rss_hash,
1864 (void *)&cmd_showport_rss_hash_rss_key,
1869 /* *** Configure DCB *** */
1870 struct cmd_config_dcb {
1871 cmdline_fixed_string_t port;
1872 cmdline_fixed_string_t config;
1874 cmdline_fixed_string_t dcb;
1875 cmdline_fixed_string_t vt;
1876 cmdline_fixed_string_t vt_en;
1878 cmdline_fixed_string_t pfc;
1879 cmdline_fixed_string_t pfc_en;
1883 cmd_config_dcb_parsed(void *parsed_result,
1884 __attribute__((unused)) struct cmdline *cl,
1885 __attribute__((unused)) void *data)
1887 struct cmd_config_dcb *res = parsed_result;
1888 struct dcb_config dcb_conf;
1889 portid_t port_id = res->port_id;
1890 struct rte_port *port;
1892 port = &ports[port_id];
1893 /** Check if the port is not started **/
1894 if (port->port_status != RTE_PORT_STOPPED) {
1895 printf("Please stop port %d first\n",port_id);
1899 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1900 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1901 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1905 /* DCB in VT mode */
1906 if (!strncmp(res->vt_en, "on",2))
1907 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1909 dcb_conf.dcb_mode = DCB_ENABLED;
1911 if (!strncmp(res->pfc_en, "on",2)) {
1912 dcb_conf.pfc_en = 1;
1915 dcb_conf.pfc_en = 0;
1917 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1918 printf("Cannot initialize network ports\n");
1922 cmd_reconfig_device_queue(port_id, 1, 1);
1925 cmdline_parse_token_string_t cmd_config_dcb_port =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1927 cmdline_parse_token_string_t cmd_config_dcb_config =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1929 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1930 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1931 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1933 cmdline_parse_token_string_t cmd_config_dcb_vt =
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1935 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1937 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1938 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1939 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1941 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1944 cmdline_parse_inst_t cmd_config_dcb = {
1945 .f = cmd_config_dcb_parsed,
1947 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1949 (void *)&cmd_config_dcb_port,
1950 (void *)&cmd_config_dcb_config,
1951 (void *)&cmd_config_dcb_port_id,
1952 (void *)&cmd_config_dcb_dcb,
1953 (void *)&cmd_config_dcb_vt,
1954 (void *)&cmd_config_dcb_vt_en,
1955 (void *)&cmd_config_dcb_num_tcs,
1956 (void *)&cmd_config_dcb_pfc,
1957 (void *)&cmd_config_dcb_pfc_en,
1962 /* *** configure number of packets per burst *** */
1963 struct cmd_config_burst {
1964 cmdline_fixed_string_t port;
1965 cmdline_fixed_string_t keyword;
1966 cmdline_fixed_string_t all;
1967 cmdline_fixed_string_t name;
1972 cmd_config_burst_parsed(void *parsed_result,
1973 __attribute__((unused)) struct cmdline *cl,
1974 __attribute__((unused)) void *data)
1976 struct cmd_config_burst *res = parsed_result;
1978 if (!all_ports_stopped()) {
1979 printf("Please stop all ports first\n");
1983 if (!strcmp(res->name, "burst")) {
1984 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1985 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1988 nb_pkt_per_burst = res->value;
1990 printf("Unknown parameter\n");
1996 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1999 cmdline_parse_token_string_t cmd_config_burst_port =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2001 cmdline_parse_token_string_t cmd_config_burst_keyword =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2003 cmdline_parse_token_string_t cmd_config_burst_all =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2005 cmdline_parse_token_string_t cmd_config_burst_name =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2007 cmdline_parse_token_num_t cmd_config_burst_value =
2008 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2010 cmdline_parse_inst_t cmd_config_burst = {
2011 .f = cmd_config_burst_parsed,
2013 .help_str = "port config all burst value",
2015 (void *)&cmd_config_burst_port,
2016 (void *)&cmd_config_burst_keyword,
2017 (void *)&cmd_config_burst_all,
2018 (void *)&cmd_config_burst_name,
2019 (void *)&cmd_config_burst_value,
2024 /* *** configure rx/tx queues *** */
2025 struct cmd_config_thresh {
2026 cmdline_fixed_string_t port;
2027 cmdline_fixed_string_t keyword;
2028 cmdline_fixed_string_t all;
2029 cmdline_fixed_string_t name;
2034 cmd_config_thresh_parsed(void *parsed_result,
2035 __attribute__((unused)) struct cmdline *cl,
2036 __attribute__((unused)) void *data)
2038 struct cmd_config_thresh *res = parsed_result;
2040 if (!all_ports_stopped()) {
2041 printf("Please stop all ports first\n");
2045 if (!strcmp(res->name, "txpt"))
2046 tx_thresh.pthresh = res->value;
2047 else if(!strcmp(res->name, "txht"))
2048 tx_thresh.hthresh = res->value;
2049 else if(!strcmp(res->name, "txwt"))
2050 tx_thresh.wthresh = res->value;
2051 else if(!strcmp(res->name, "rxpt"))
2052 rx_thresh.pthresh = res->value;
2053 else if(!strcmp(res->name, "rxht"))
2054 rx_thresh.hthresh = res->value;
2055 else if(!strcmp(res->name, "rxwt"))
2056 rx_thresh.wthresh = res->value;
2058 printf("Unknown parameter\n");
2064 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2067 cmdline_parse_token_string_t cmd_config_thresh_port =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2069 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2071 cmdline_parse_token_string_t cmd_config_thresh_all =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2073 cmdline_parse_token_string_t cmd_config_thresh_name =
2074 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2075 "txpt#txht#txwt#rxpt#rxht#rxwt");
2076 cmdline_parse_token_num_t cmd_config_thresh_value =
2077 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2079 cmdline_parse_inst_t cmd_config_thresh = {
2080 .f = cmd_config_thresh_parsed,
2082 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2084 (void *)&cmd_config_thresh_port,
2085 (void *)&cmd_config_thresh_keyword,
2086 (void *)&cmd_config_thresh_all,
2087 (void *)&cmd_config_thresh_name,
2088 (void *)&cmd_config_thresh_value,
2093 /* *** configure free/rs threshold *** */
2094 struct cmd_config_threshold {
2095 cmdline_fixed_string_t port;
2096 cmdline_fixed_string_t keyword;
2097 cmdline_fixed_string_t all;
2098 cmdline_fixed_string_t name;
2103 cmd_config_threshold_parsed(void *parsed_result,
2104 __attribute__((unused)) struct cmdline *cl,
2105 __attribute__((unused)) void *data)
2107 struct cmd_config_threshold *res = parsed_result;
2109 if (!all_ports_stopped()) {
2110 printf("Please stop all ports first\n");
2114 if (!strcmp(res->name, "txfreet"))
2115 tx_free_thresh = res->value;
2116 else if (!strcmp(res->name, "txrst"))
2117 tx_rs_thresh = res->value;
2118 else if (!strcmp(res->name, "rxfreet"))
2119 rx_free_thresh = res->value;
2121 printf("Unknown parameter\n");
2127 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2130 cmdline_parse_token_string_t cmd_config_threshold_port =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2132 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2135 cmdline_parse_token_string_t cmd_config_threshold_all =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2137 cmdline_parse_token_string_t cmd_config_threshold_name =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2139 "txfreet#txrst#rxfreet");
2140 cmdline_parse_token_num_t cmd_config_threshold_value =
2141 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2143 cmdline_parse_inst_t cmd_config_threshold = {
2144 .f = cmd_config_threshold_parsed,
2146 .help_str = "port config all txfreet|txrst|rxfreet value",
2148 (void *)&cmd_config_threshold_port,
2149 (void *)&cmd_config_threshold_keyword,
2150 (void *)&cmd_config_threshold_all,
2151 (void *)&cmd_config_threshold_name,
2152 (void *)&cmd_config_threshold_value,
2158 struct cmd_stop_result {
2159 cmdline_fixed_string_t stop;
2162 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2163 __attribute__((unused)) struct cmdline *cl,
2164 __attribute__((unused)) void *data)
2166 stop_packet_forwarding();
2169 cmdline_parse_token_string_t cmd_stop_stop =
2170 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2172 cmdline_parse_inst_t cmd_stop = {
2173 .f = cmd_stop_parsed,
2175 .help_str = "stop - stop packet forwarding",
2177 (void *)&cmd_stop_stop,
2182 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2185 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2186 unsigned int *parsed_items, int check_unique_values)
2188 unsigned int nb_item;
2196 * First parse all items in the list and store their value.
2201 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2203 if ((c >= '0') && (c <= '9')) {
2204 value = (unsigned int) (value * 10 + (c - '0'));
2209 printf("character %c is not a decimal digit\n", c);
2213 printf("No valid value before comma\n");
2216 if (nb_item < max_items) {
2217 parsed_items[nb_item] = value;
2223 if (nb_item >= max_items) {
2224 printf("Number of %s = %u > %u (maximum items)\n",
2225 item_name, nb_item + 1, max_items);
2228 parsed_items[nb_item++] = value;
2229 if (! check_unique_values)
2233 * Then, check that all values in the list are differents.
2234 * No optimization here...
2236 for (i = 0; i < nb_item; i++) {
2237 for (j = i + 1; j < nb_item; j++) {
2238 if (parsed_items[j] == parsed_items[i]) {
2239 printf("duplicated %s %u at index %u and %u\n",
2240 item_name, parsed_items[i], i, j);
2248 struct cmd_set_list_result {
2249 cmdline_fixed_string_t cmd_keyword;
2250 cmdline_fixed_string_t list_name;
2251 cmdline_fixed_string_t list_of_items;
2254 static void cmd_set_list_parsed(void *parsed_result,
2255 __attribute__((unused)) struct cmdline *cl,
2256 __attribute__((unused)) void *data)
2258 struct cmd_set_list_result *res;
2260 unsigned int lcorelist[RTE_MAX_LCORE];
2261 unsigned int portlist[RTE_MAX_ETHPORTS];
2263 unsigned int nb_item;
2265 res = parsed_result;
2266 if (!strcmp(res->list_name, "corelist")) {
2267 nb_item = parse_item_list(res->list_of_items, "core",
2269 parsed_items.lcorelist, 1);
2271 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2274 if (!strcmp(res->list_name, "portlist")) {
2275 nb_item = parse_item_list(res->list_of_items, "port",
2277 parsed_items.portlist, 1);
2279 set_fwd_ports_list(parsed_items.portlist, nb_item);
2283 cmdline_parse_token_string_t cmd_set_list_keyword =
2284 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2286 cmdline_parse_token_string_t cmd_set_list_name =
2287 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2288 "corelist#portlist");
2289 cmdline_parse_token_string_t cmd_set_list_of_items =
2290 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2293 cmdline_parse_inst_t cmd_set_fwd_list = {
2294 .f = cmd_set_list_parsed,
2296 .help_str = "set corelist|portlist x[,y]*",
2298 (void *)&cmd_set_list_keyword,
2299 (void *)&cmd_set_list_name,
2300 (void *)&cmd_set_list_of_items,
2305 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2307 struct cmd_setmask_result {
2308 cmdline_fixed_string_t set;
2309 cmdline_fixed_string_t mask;
2313 static void cmd_set_mask_parsed(void *parsed_result,
2314 __attribute__((unused)) struct cmdline *cl,
2315 __attribute__((unused)) void *data)
2317 struct cmd_setmask_result *res = parsed_result;
2319 if (!strcmp(res->mask, "coremask"))
2320 set_fwd_lcores_mask(res->hexavalue);
2321 else if (!strcmp(res->mask, "portmask"))
2322 set_fwd_ports_mask(res->hexavalue);
2325 cmdline_parse_token_string_t cmd_setmask_set =
2326 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2327 cmdline_parse_token_string_t cmd_setmask_mask =
2328 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2329 "coremask#portmask");
2330 cmdline_parse_token_num_t cmd_setmask_value =
2331 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2333 cmdline_parse_inst_t cmd_set_fwd_mask = {
2334 .f = cmd_set_mask_parsed,
2336 .help_str = "set coremask|portmask hexadecimal value",
2338 (void *)&cmd_setmask_set,
2339 (void *)&cmd_setmask_mask,
2340 (void *)&cmd_setmask_value,
2346 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2348 struct cmd_set_result {
2349 cmdline_fixed_string_t set;
2350 cmdline_fixed_string_t what;
2354 static void cmd_set_parsed(void *parsed_result,
2355 __attribute__((unused)) struct cmdline *cl,
2356 __attribute__((unused)) void *data)
2358 struct cmd_set_result *res = parsed_result;
2359 if (!strcmp(res->what, "nbport"))
2360 set_fwd_ports_number(res->value);
2361 else if (!strcmp(res->what, "nbcore"))
2362 set_fwd_lcores_number(res->value);
2363 else if (!strcmp(res->what, "burst"))
2364 set_nb_pkt_per_burst(res->value);
2365 else if (!strcmp(res->what, "verbose"))
2366 set_verbose_level(res->value);
2369 cmdline_parse_token_string_t cmd_set_set =
2370 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2371 cmdline_parse_token_string_t cmd_set_what =
2372 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2373 "nbport#nbcore#burst#verbose");
2374 cmdline_parse_token_num_t cmd_set_value =
2375 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2377 cmdline_parse_inst_t cmd_set_numbers = {
2378 .f = cmd_set_parsed,
2380 .help_str = "set nbport|nbcore|burst|verbose value",
2382 (void *)&cmd_set_set,
2383 (void *)&cmd_set_what,
2384 (void *)&cmd_set_value,
2389 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2391 struct cmd_set_txpkts_result {
2392 cmdline_fixed_string_t cmd_keyword;
2393 cmdline_fixed_string_t txpkts;
2394 cmdline_fixed_string_t seg_lengths;
2398 cmd_set_txpkts_parsed(void *parsed_result,
2399 __attribute__((unused)) struct cmdline *cl,
2400 __attribute__((unused)) void *data)
2402 struct cmd_set_txpkts_result *res;
2403 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2404 unsigned int nb_segs;
2406 res = parsed_result;
2407 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2408 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2410 set_tx_pkt_segments(seg_lengths, nb_segs);
2413 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2414 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2415 cmd_keyword, "set");
2416 cmdline_parse_token_string_t cmd_set_txpkts_name =
2417 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2419 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2420 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2423 cmdline_parse_inst_t cmd_set_txpkts = {
2424 .f = cmd_set_txpkts_parsed,
2426 .help_str = "set txpkts x[,y]*",
2428 (void *)&cmd_set_txpkts_keyword,
2429 (void *)&cmd_set_txpkts_name,
2430 (void *)&cmd_set_txpkts_lengths,
2435 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2436 struct cmd_rx_vlan_filter_all_result {
2437 cmdline_fixed_string_t rx_vlan;
2438 cmdline_fixed_string_t what;
2439 cmdline_fixed_string_t all;
2444 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2445 __attribute__((unused)) struct cmdline *cl,
2446 __attribute__((unused)) void *data)
2448 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2450 if (!strcmp(res->what, "add"))
2451 rx_vlan_all_filter_set(res->port_id, 1);
2453 rx_vlan_all_filter_set(res->port_id, 0);
2456 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2457 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2458 rx_vlan, "rx_vlan");
2459 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2460 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2462 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2463 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2465 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2466 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2469 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2470 .f = cmd_rx_vlan_filter_all_parsed,
2472 .help_str = "add/remove all identifiers to/from the set of VLAN "
2473 "Identifiers filtered by a port",
2475 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2476 (void *)&cmd_rx_vlan_filter_all_what,
2477 (void *)&cmd_rx_vlan_filter_all_all,
2478 (void *)&cmd_rx_vlan_filter_all_portid,
2483 /* *** VLAN OFFLOAD SET ON A PORT *** */
2484 struct cmd_vlan_offload_result {
2485 cmdline_fixed_string_t vlan;
2486 cmdline_fixed_string_t set;
2487 cmdline_fixed_string_t what;
2488 cmdline_fixed_string_t on;
2489 cmdline_fixed_string_t port_id;
2493 cmd_vlan_offload_parsed(void *parsed_result,
2494 __attribute__((unused)) struct cmdline *cl,
2495 __attribute__((unused)) void *data)
2498 struct cmd_vlan_offload_result *res = parsed_result;
2501 portid_t port_id = 0;
2505 len = strnlen(str, STR_TOKEN_SIZE);
2507 /* Get port_id first */
2515 tmp = strtoul(str, NULL, 0);
2516 /* If port_id greater that what portid_t can represent, return */
2517 if(tmp >= RTE_MAX_ETHPORTS)
2519 port_id = (portid_t)tmp;
2521 if (!strcmp(res->on, "on"))
2526 if (!strcmp(res->what, "strip"))
2527 rx_vlan_strip_set(port_id, on);
2528 else if(!strcmp(res->what, "stripq")){
2529 uint16_t queue_id = 0;
2531 /* No queue_id, return */
2533 printf("must specify (port,queue_id)\n");
2536 tmp = strtoul(str + i + 1, NULL, 0);
2537 /* If queue_id greater that what 16-bits can represent, return */
2541 queue_id = (uint16_t)tmp;
2542 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2544 else if (!strcmp(res->what, "filter"))
2545 rx_vlan_filter_set(port_id, on);
2547 vlan_extend_set(port_id, on);
2552 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2553 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2555 cmdline_parse_token_string_t cmd_vlan_offload_set =
2556 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2558 cmdline_parse_token_string_t cmd_vlan_offload_what =
2559 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2560 what, "strip#filter#qinq#stripq");
2561 cmdline_parse_token_string_t cmd_vlan_offload_on =
2562 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2564 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2565 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2568 cmdline_parse_inst_t cmd_vlan_offload = {
2569 .f = cmd_vlan_offload_parsed,
2571 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2572 " qinq(extended) for both rx/tx sides ",
2574 (void *)&cmd_vlan_offload_vlan,
2575 (void *)&cmd_vlan_offload_set,
2576 (void *)&cmd_vlan_offload_what,
2577 (void *)&cmd_vlan_offload_on,
2578 (void *)&cmd_vlan_offload_portid,
2583 /* *** VLAN TPID SET ON A PORT *** */
2584 struct cmd_vlan_tpid_result {
2585 cmdline_fixed_string_t vlan;
2586 cmdline_fixed_string_t set;
2587 cmdline_fixed_string_t what;
2593 cmd_vlan_tpid_parsed(void *parsed_result,
2594 __attribute__((unused)) struct cmdline *cl,
2595 __attribute__((unused)) void *data)
2597 struct cmd_vlan_tpid_result *res = parsed_result;
2598 vlan_tpid_set(res->port_id, res->tp_id);
2602 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2603 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2605 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2606 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2608 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2609 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2611 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2612 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2614 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2615 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2618 cmdline_parse_inst_t cmd_vlan_tpid = {
2619 .f = cmd_vlan_tpid_parsed,
2621 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2623 (void *)&cmd_vlan_tpid_vlan,
2624 (void *)&cmd_vlan_tpid_set,
2625 (void *)&cmd_vlan_tpid_what,
2626 (void *)&cmd_vlan_tpid_tpid,
2627 (void *)&cmd_vlan_tpid_portid,
2632 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2633 struct cmd_rx_vlan_filter_result {
2634 cmdline_fixed_string_t rx_vlan;
2635 cmdline_fixed_string_t what;
2641 cmd_rx_vlan_filter_parsed(void *parsed_result,
2642 __attribute__((unused)) struct cmdline *cl,
2643 __attribute__((unused)) void *data)
2645 struct cmd_rx_vlan_filter_result *res = parsed_result;
2647 if (!strcmp(res->what, "add"))
2648 rx_vft_set(res->port_id, res->vlan_id, 1);
2650 rx_vft_set(res->port_id, res->vlan_id, 0);
2653 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2654 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2655 rx_vlan, "rx_vlan");
2656 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2657 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2659 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2660 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2662 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2663 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2666 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2667 .f = cmd_rx_vlan_filter_parsed,
2669 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2670 "Identifiers filtered by a port",
2672 (void *)&cmd_rx_vlan_filter_rx_vlan,
2673 (void *)&cmd_rx_vlan_filter_what,
2674 (void *)&cmd_rx_vlan_filter_vlanid,
2675 (void *)&cmd_rx_vlan_filter_portid,
2680 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2681 struct cmd_tx_vlan_set_result {
2682 cmdline_fixed_string_t tx_vlan;
2683 cmdline_fixed_string_t set;
2689 cmd_tx_vlan_set_parsed(void *parsed_result,
2690 __attribute__((unused)) struct cmdline *cl,
2691 __attribute__((unused)) void *data)
2693 struct cmd_tx_vlan_set_result *res = parsed_result;
2694 tx_vlan_set(res->port_id, res->vlan_id);
2697 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2698 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2699 tx_vlan, "tx_vlan");
2700 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2701 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2703 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2704 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2706 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2710 cmdline_parse_inst_t cmd_tx_vlan_set = {
2711 .f = cmd_tx_vlan_set_parsed,
2713 .help_str = "enable hardware insertion of a VLAN header with a given "
2714 "TAG Identifier in packets sent on a port",
2716 (void *)&cmd_tx_vlan_set_tx_vlan,
2717 (void *)&cmd_tx_vlan_set_set,
2718 (void *)&cmd_tx_vlan_set_vlanid,
2719 (void *)&cmd_tx_vlan_set_portid,
2724 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2725 struct cmd_tx_vlan_set_pvid_result {
2726 cmdline_fixed_string_t tx_vlan;
2727 cmdline_fixed_string_t set;
2728 cmdline_fixed_string_t pvid;
2731 cmdline_fixed_string_t mode;
2735 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2736 __attribute__((unused)) struct cmdline *cl,
2737 __attribute__((unused)) void *data)
2739 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2741 if (strcmp(res->mode, "on") == 0)
2742 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2744 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2747 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2748 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2749 tx_vlan, "tx_vlan");
2750 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2751 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2753 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2754 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2756 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2757 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2759 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2760 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2762 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2763 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2766 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2767 .f = cmd_tx_vlan_set_pvid_parsed,
2769 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2771 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2772 (void *)&cmd_tx_vlan_set_pvid_set,
2773 (void *)&cmd_tx_vlan_set_pvid_pvid,
2774 (void *)&cmd_tx_vlan_set_pvid_port_id,
2775 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2776 (void *)&cmd_tx_vlan_set_pvid_mode,
2781 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2782 struct cmd_tx_vlan_reset_result {
2783 cmdline_fixed_string_t tx_vlan;
2784 cmdline_fixed_string_t reset;
2789 cmd_tx_vlan_reset_parsed(void *parsed_result,
2790 __attribute__((unused)) struct cmdline *cl,
2791 __attribute__((unused)) void *data)
2793 struct cmd_tx_vlan_reset_result *res = parsed_result;
2795 tx_vlan_reset(res->port_id);
2798 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2799 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2800 tx_vlan, "tx_vlan");
2801 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2802 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2804 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2805 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2808 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2809 .f = cmd_tx_vlan_reset_parsed,
2811 .help_str = "disable hardware insertion of a VLAN header in packets "
2814 (void *)&cmd_tx_vlan_reset_tx_vlan,
2815 (void *)&cmd_tx_vlan_reset_reset,
2816 (void *)&cmd_tx_vlan_reset_portid,
2822 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2823 struct cmd_tx_cksum_set_result {
2824 cmdline_fixed_string_t tx_cksum;
2825 cmdline_fixed_string_t set;
2831 cmd_tx_cksum_set_parsed(void *parsed_result,
2832 __attribute__((unused)) struct cmdline *cl,
2833 __attribute__((unused)) void *data)
2835 struct cmd_tx_cksum_set_result *res = parsed_result;
2837 tx_cksum_set(res->port_id, res->cksum_mask);
2840 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2841 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2842 tx_cksum, "tx_checksum");
2843 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2844 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2846 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2847 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2849 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2850 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2853 cmdline_parse_inst_t cmd_tx_cksum_set = {
2854 .f = cmd_tx_cksum_set_parsed,
2856 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2857 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2858 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2859 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2861 (void *)&cmd_tx_cksum_set_tx_cksum,
2862 (void *)&cmd_tx_cksum_set_set,
2863 (void *)&cmd_tx_cksum_set_cksum_mask,
2864 (void *)&cmd_tx_cksum_set_portid,
2869 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2870 struct cmd_set_flush_rx {
2871 cmdline_fixed_string_t set;
2872 cmdline_fixed_string_t flush_rx;
2873 cmdline_fixed_string_t mode;
2877 cmd_set_flush_rx_parsed(void *parsed_result,
2878 __attribute__((unused)) struct cmdline *cl,
2879 __attribute__((unused)) void *data)
2881 struct cmd_set_flush_rx *res = parsed_result;
2882 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2885 cmdline_parse_token_string_t cmd_setflushrx_set =
2886 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2888 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2889 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2890 flush_rx, "flush_rx");
2891 cmdline_parse_token_string_t cmd_setflushrx_mode =
2892 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2896 cmdline_parse_inst_t cmd_set_flush_rx = {
2897 .f = cmd_set_flush_rx_parsed,
2898 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2901 (void *)&cmd_setflushrx_set,
2902 (void *)&cmd_setflushrx_flush_rx,
2903 (void *)&cmd_setflushrx_mode,
2908 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2909 struct cmd_set_link_check {
2910 cmdline_fixed_string_t set;
2911 cmdline_fixed_string_t link_check;
2912 cmdline_fixed_string_t mode;
2916 cmd_set_link_check_parsed(void *parsed_result,
2917 __attribute__((unused)) struct cmdline *cl,
2918 __attribute__((unused)) void *data)
2920 struct cmd_set_link_check *res = parsed_result;
2921 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2924 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2925 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2927 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2928 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2929 link_check, "link_check");
2930 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2931 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2935 cmdline_parse_inst_t cmd_set_link_check = {
2936 .f = cmd_set_link_check_parsed,
2937 .help_str = "set link_check on|off: enable/disable link status check "
2938 "when starting/stopping a port",
2941 (void *)&cmd_setlinkcheck_set,
2942 (void *)&cmd_setlinkcheck_link_check,
2943 (void *)&cmd_setlinkcheck_mode,
2948 #ifdef RTE_NIC_BYPASS
2949 /* *** SET NIC BYPASS MODE *** */
2950 struct cmd_set_bypass_mode_result {
2951 cmdline_fixed_string_t set;
2952 cmdline_fixed_string_t bypass;
2953 cmdline_fixed_string_t mode;
2954 cmdline_fixed_string_t value;
2959 cmd_set_bypass_mode_parsed(void *parsed_result,
2960 __attribute__((unused)) struct cmdline *cl,
2961 __attribute__((unused)) void *data)
2963 struct cmd_set_bypass_mode_result *res = parsed_result;
2964 portid_t port_id = res->port_id;
2965 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2967 if (!bypass_is_supported(port_id))
2970 if (!strcmp(res->value, "bypass"))
2971 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2972 else if (!strcmp(res->value, "isolate"))
2973 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2975 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2977 /* Set the bypass mode for the relevant port. */
2978 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2979 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2983 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2986 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2989 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2990 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2992 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2993 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2994 value, "normal#bypass#isolate");
2995 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2996 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2999 cmdline_parse_inst_t cmd_set_bypass_mode = {
3000 .f = cmd_set_bypass_mode_parsed,
3001 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3002 "Set the NIC bypass mode for port_id",
3005 (void *)&cmd_setbypass_mode_set,
3006 (void *)&cmd_setbypass_mode_bypass,
3007 (void *)&cmd_setbypass_mode_mode,
3008 (void *)&cmd_setbypass_mode_value,
3009 (void *)&cmd_setbypass_mode_port,
3014 /* *** SET NIC BYPASS EVENT *** */
3015 struct cmd_set_bypass_event_result {
3016 cmdline_fixed_string_t set;
3017 cmdline_fixed_string_t bypass;
3018 cmdline_fixed_string_t event;
3019 cmdline_fixed_string_t event_value;
3020 cmdline_fixed_string_t mode;
3021 cmdline_fixed_string_t mode_value;
3026 cmd_set_bypass_event_parsed(void *parsed_result,
3027 __attribute__((unused)) struct cmdline *cl,
3028 __attribute__((unused)) void *data)
3031 struct cmd_set_bypass_event_result *res = parsed_result;
3032 portid_t port_id = res->port_id;
3033 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3034 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3036 if (!bypass_is_supported(port_id))
3039 if (!strcmp(res->event_value, "timeout"))
3040 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3041 else if (!strcmp(res->event_value, "os_on"))
3042 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3043 else if (!strcmp(res->event_value, "os_off"))
3044 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3045 else if (!strcmp(res->event_value, "power_on"))
3046 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3047 else if (!strcmp(res->event_value, "power_off"))
3048 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3050 bypass_event = RTE_BYPASS_EVENT_NONE;
3052 if (!strcmp(res->mode_value, "bypass"))
3053 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3054 else if (!strcmp(res->mode_value, "isolate"))
3055 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3057 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3059 /* Set the watchdog timeout. */
3060 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3063 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3064 (rc = rte_eth_dev_wd_timeout_store(port_id,
3065 bypass_timeout)) != 0) {
3066 printf("Failed to set timeout value %u "
3067 "for port %d, errto code: %d.\n",
3068 bypass_timeout, port_id, rc);
3072 /* Set the bypass event to transition to bypass mode. */
3073 if (0 != rte_eth_dev_bypass_event_store(port_id,
3074 bypass_event, bypass_mode)) {
3075 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3080 cmdline_parse_token_string_t cmd_setbypass_event_set =
3081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3083 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3086 cmdline_parse_token_string_t cmd_setbypass_event_event =
3087 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3089 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3090 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3091 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3092 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3093 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3095 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3096 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3097 mode_value, "normal#bypass#isolate");
3098 cmdline_parse_token_num_t cmd_setbypass_event_port =
3099 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3102 cmdline_parse_inst_t cmd_set_bypass_event = {
3103 .f = cmd_set_bypass_event_parsed,
3104 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3105 "mode (normal|bypass|isolate) (port_id): "
3106 "Set the NIC bypass event mode for port_id",
3109 (void *)&cmd_setbypass_event_set,
3110 (void *)&cmd_setbypass_event_bypass,
3111 (void *)&cmd_setbypass_event_event,
3112 (void *)&cmd_setbypass_event_event_value,
3113 (void *)&cmd_setbypass_event_mode,
3114 (void *)&cmd_setbypass_event_mode_value,
3115 (void *)&cmd_setbypass_event_port,
3121 /* *** SET NIC BYPASS TIMEOUT *** */
3122 struct cmd_set_bypass_timeout_result {
3123 cmdline_fixed_string_t set;
3124 cmdline_fixed_string_t bypass;
3125 cmdline_fixed_string_t timeout;
3126 cmdline_fixed_string_t value;
3130 cmd_set_bypass_timeout_parsed(void *parsed_result,
3131 __attribute__((unused)) struct cmdline *cl,
3132 __attribute__((unused)) void *data)
3134 struct cmd_set_bypass_timeout_result *res = parsed_result;
3136 if (!strcmp(res->value, "1.5"))
3137 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3138 else if (!strcmp(res->value, "2"))
3139 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3140 else if (!strcmp(res->value, "3"))
3141 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3142 else if (!strcmp(res->value, "4"))
3143 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3144 else if (!strcmp(res->value, "8"))
3145 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3146 else if (!strcmp(res->value, "16"))
3147 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3148 else if (!strcmp(res->value, "32"))
3149 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3151 bypass_timeout = RTE_BYPASS_TMT_OFF;
3154 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3155 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3157 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3158 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3160 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3161 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3162 timeout, "timeout");
3163 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3164 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3165 value, "0#1.5#2#3#4#8#16#32");
3167 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3168 .f = cmd_set_bypass_timeout_parsed,
3169 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3170 "Set the NIC bypass watchdog timeout",
3173 (void *)&cmd_setbypass_timeout_set,
3174 (void *)&cmd_setbypass_timeout_bypass,
3175 (void *)&cmd_setbypass_timeout_timeout,
3176 (void *)&cmd_setbypass_timeout_value,
3181 /* *** SHOW NIC BYPASS MODE *** */
3182 struct cmd_show_bypass_config_result {
3183 cmdline_fixed_string_t show;
3184 cmdline_fixed_string_t bypass;
3185 cmdline_fixed_string_t config;
3190 cmd_show_bypass_config_parsed(void *parsed_result,
3191 __attribute__((unused)) struct cmdline *cl,
3192 __attribute__((unused)) void *data)
3194 struct cmd_show_bypass_config_result *res = parsed_result;
3195 uint32_t event_mode;
3196 uint32_t bypass_mode;
3197 portid_t port_id = res->port_id;
3198 uint32_t timeout = bypass_timeout;
3201 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3202 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3203 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3204 {"UNKNOWN", "normal", "bypass", "isolate"};
3205 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3212 int num_events = (sizeof events) / (sizeof events[0]);
3214 if (!bypass_is_supported(port_id))
3217 /* Display the bypass mode.*/
3218 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3219 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3223 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3224 bypass_mode = RTE_BYPASS_MODE_NONE;
3226 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3229 /* Display the bypass timeout.*/
3230 if (!RTE_BYPASS_TMT_VALID(timeout))
3231 timeout = RTE_BYPASS_TMT_OFF;
3233 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3235 /* Display the bypass events and associated modes. */
3236 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3238 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3239 printf("\tFailed to get bypass mode for event = %s\n",
3242 if (!RTE_BYPASS_MODE_VALID(event_mode))
3243 event_mode = RTE_BYPASS_MODE_NONE;
3245 printf("\tbypass event: %-16s = %s\n", events[i],
3251 cmdline_parse_token_string_t cmd_showbypass_config_show =
3252 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3254 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3255 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3257 cmdline_parse_token_string_t cmd_showbypass_config_config =
3258 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3260 cmdline_parse_token_num_t cmd_showbypass_config_port =
3261 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3264 cmdline_parse_inst_t cmd_show_bypass_config = {
3265 .f = cmd_show_bypass_config_parsed,
3266 .help_str = "show bypass config (port_id): "
3267 "Show the NIC bypass config for port_id",
3270 (void *)&cmd_showbypass_config_show,
3271 (void *)&cmd_showbypass_config_bypass,
3272 (void *)&cmd_showbypass_config_config,
3273 (void *)&cmd_showbypass_config_port,
3279 #ifdef RTE_LIBRTE_PMD_BOND
3280 /* *** SET BONDING MODE *** */
3281 struct cmd_set_bonding_mode_result {
3282 cmdline_fixed_string_t set;
3283 cmdline_fixed_string_t bonding;
3284 cmdline_fixed_string_t mode;
3289 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3290 __attribute__((unused)) struct cmdline *cl,
3291 __attribute__((unused)) void *data)
3293 struct cmd_set_bonding_mode_result *res = parsed_result;
3294 portid_t port_id = res->port_id;
3296 /* Set the bonding mode for the relevant port. */
3297 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3298 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3301 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3302 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3304 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3305 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3306 bonding, "bonding");
3307 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3308 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3310 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3311 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3313 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3314 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3317 cmdline_parse_inst_t cmd_set_bonding_mode = {
3318 .f = cmd_set_bonding_mode_parsed,
3319 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3322 (void *) &cmd_setbonding_mode_set,
3323 (void *) &cmd_setbonding_mode_bonding,
3324 (void *) &cmd_setbonding_mode_mode,
3325 (void *) &cmd_setbonding_mode_value,
3326 (void *) &cmd_setbonding_mode_port,
3331 /* *** SET BALANCE XMIT POLICY *** */
3332 struct cmd_set_bonding_balance_xmit_policy_result {
3333 cmdline_fixed_string_t set;
3334 cmdline_fixed_string_t bonding;
3335 cmdline_fixed_string_t balance_xmit_policy;
3337 cmdline_fixed_string_t policy;
3340 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3341 __attribute__((unused)) struct cmdline *cl,
3342 __attribute__((unused)) void *data)
3344 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3345 portid_t port_id = res->port_id;
3348 if (!strcmp(res->policy, "l2")) {
3349 policy = BALANCE_XMIT_POLICY_LAYER2;
3350 } else if (!strcmp(res->policy, "l23")) {
3351 policy = BALANCE_XMIT_POLICY_LAYER23;
3352 } else if (!strcmp(res->policy, "l34")) {
3353 policy = BALANCE_XMIT_POLICY_LAYER34;
3355 printf("\t Invalid xmit policy selection");
3359 /* Set the bonding mode for the relevant port. */
3360 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3361 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3366 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3367 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3369 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3370 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3371 bonding, "bonding");
3372 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3373 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3374 balance_xmit_policy, "balance_xmit_policy");
3375 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3376 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3378 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3379 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3380 policy, "l2#l23#l34");
3382 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3383 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3384 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3387 (void *)&cmd_setbonding_balance_xmit_policy_set,
3388 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3389 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3390 (void *)&cmd_setbonding_balance_xmit_policy_port,
3391 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3396 /* *** SHOW NIC BONDING CONFIGURATION *** */
3397 struct cmd_show_bonding_config_result {
3398 cmdline_fixed_string_t show;
3399 cmdline_fixed_string_t bonding;
3400 cmdline_fixed_string_t config;
3404 static void cmd_show_bonding_config_parsed(void *parsed_result,
3405 __attribute__((unused)) struct cmdline *cl,
3406 __attribute__((unused)) void *data)
3408 struct cmd_show_bonding_config_result *res = parsed_result;
3410 uint8_t slaves[RTE_MAX_ETHPORTS];
3411 int num_slaves, num_active_slaves;
3414 portid_t port_id = res->port_id;
3416 /* Display the bonding mode.*/
3417 bonding_mode = rte_eth_bond_mode_get(port_id);
3418 if (bonding_mode < 0) {
3419 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3422 printf("\tBonding mode: %d\n", bonding_mode);
3424 if (bonding_mode == BONDING_MODE_BALANCE) {
3425 int balance_xmit_policy;
3427 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3428 if (balance_xmit_policy < 0) {
3429 printf("\tFailed to get balance xmit policy for port = %d\n",
3433 printf("\tBalance Xmit Policy: ");
3435 switch (balance_xmit_policy) {
3436 case BALANCE_XMIT_POLICY_LAYER2:
3437 printf("BALANCE_XMIT_POLICY_LAYER2");
3439 case BALANCE_XMIT_POLICY_LAYER23:
3440 printf("BALANCE_XMIT_POLICY_LAYER23");
3442 case BALANCE_XMIT_POLICY_LAYER34:
3443 printf("BALANCE_XMIT_POLICY_LAYER34");
3450 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3452 if (num_slaves < 0) {
3453 printf("\tFailed to get slave list for port = %d\n", port_id);
3456 if (num_slaves > 0) {
3457 printf("\tSlaves (%d): [", num_slaves);
3458 for (i = 0; i < num_slaves - 1; i++)
3459 printf("%d ", slaves[i]);
3461 printf("%d]\n", slaves[num_slaves - 1]);
3463 printf("\tSlaves: []\n");
3467 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3470 if (num_active_slaves < 0) {
3471 printf("\tFailed to get active slave list for port = %d\n", port_id);
3474 if (num_active_slaves > 0) {
3475 printf("\tActive Slaves (%d): [", num_active_slaves);
3476 for (i = 0; i < num_active_slaves - 1; i++)
3477 printf("%d ", slaves[i]);
3479 printf("%d]\n", slaves[num_active_slaves - 1]);
3482 printf("\tActive Slaves: []\n");
3486 primary_id = rte_eth_bond_primary_get(port_id);
3487 if (primary_id < 0) {
3488 printf("\tFailed to get primary slave for port = %d\n", port_id);
3491 printf("\tPrimary: [%d]\n", primary_id);
3495 cmdline_parse_token_string_t cmd_showbonding_config_show =
3496 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3498 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3499 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3500 bonding, "bonding");
3501 cmdline_parse_token_string_t cmd_showbonding_config_config =
3502 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3504 cmdline_parse_token_num_t cmd_showbonding_config_port =
3505 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3508 cmdline_parse_inst_t cmd_show_bonding_config = {
3509 .f = cmd_show_bonding_config_parsed,
3510 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3513 (void *)&cmd_showbonding_config_show,
3514 (void *)&cmd_showbonding_config_bonding,
3515 (void *)&cmd_showbonding_config_config,
3516 (void *)&cmd_showbonding_config_port,
3521 /* *** SET BONDING PRIMARY *** */
3522 struct cmd_set_bonding_primary_result {
3523 cmdline_fixed_string_t set;
3524 cmdline_fixed_string_t bonding;
3525 cmdline_fixed_string_t primary;
3530 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3531 __attribute__((unused)) struct cmdline *cl,
3532 __attribute__((unused)) void *data)
3534 struct cmd_set_bonding_primary_result *res = parsed_result;
3535 portid_t master_port_id = res->port_id;
3536 portid_t slave_port_id = res->slave_id;
3538 /* Set the primary slave for a bonded device. */
3539 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3540 printf("\t Failed to set primary slave for port = %d.\n",
3547 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3550 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3551 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3552 bonding, "bonding");
3553 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3554 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3555 primary, "primary");
3556 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3557 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3559 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3560 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3563 cmdline_parse_inst_t cmd_set_bonding_primary = {
3564 .f = cmd_set_bonding_primary_parsed,
3565 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3568 (void *)&cmd_setbonding_primary_set,
3569 (void *)&cmd_setbonding_primary_bonding,
3570 (void *)&cmd_setbonding_primary_primary,
3571 (void *)&cmd_setbonding_primary_slave,
3572 (void *)&cmd_setbonding_primary_port,
3577 /* *** ADD SLAVE *** */
3578 struct cmd_add_bonding_slave_result {
3579 cmdline_fixed_string_t add;
3580 cmdline_fixed_string_t bonding;
3581 cmdline_fixed_string_t slave;
3586 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3587 __attribute__((unused)) struct cmdline *cl,
3588 __attribute__((unused)) void *data)
3590 struct cmd_add_bonding_slave_result *res = parsed_result;
3591 portid_t master_port_id = res->port_id;
3592 portid_t slave_port_id = res->slave_id;
3594 /* Set the primary slave for a bonded device. */
3595 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3596 printf("\t Failed to add slave %d to master port = %d.\n",
3597 slave_port_id, master_port_id);
3603 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3604 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3606 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3607 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3608 bonding, "bonding");
3609 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3610 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3612 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3613 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3615 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3616 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3619 cmdline_parse_inst_t cmd_add_bonding_slave = {
3620 .f = cmd_add_bonding_slave_parsed,
3621 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3624 (void *)&cmd_addbonding_slave_add,
3625 (void *)&cmd_addbonding_slave_bonding,
3626 (void *)&cmd_addbonding_slave_slave,
3627 (void *)&cmd_addbonding_slave_slaveid,
3628 (void *)&cmd_addbonding_slave_port,
3633 /* *** REMOVE SLAVE *** */
3634 struct cmd_remove_bonding_slave_result {
3635 cmdline_fixed_string_t remove;
3636 cmdline_fixed_string_t bonding;
3637 cmdline_fixed_string_t slave;
3642 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3643 __attribute__((unused)) struct cmdline *cl,
3644 __attribute__((unused)) void *data)
3646 struct cmd_remove_bonding_slave_result *res = parsed_result;
3647 portid_t master_port_id = res->port_id;
3648 portid_t slave_port_id = res->slave_id;
3650 /* Set the primary slave for a bonded device. */
3651 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3652 printf("\t Failed to remove slave %d from master port = %d.\n",
3653 slave_port_id, master_port_id);
3659 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3660 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3662 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3663 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3664 bonding, "bonding");
3665 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3666 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3668 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3669 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3671 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3672 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3675 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3676 .f = cmd_remove_bonding_slave_parsed,
3677 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3680 (void *)&cmd_removebonding_slave_remove,
3681 (void *)&cmd_removebonding_slave_bonding,
3682 (void *)&cmd_removebonding_slave_slave,
3683 (void *)&cmd_removebonding_slave_slaveid,
3684 (void *)&cmd_removebonding_slave_port,
3689 /* *** CREATE BONDED DEVICE *** */
3690 struct cmd_create_bonded_device_result {
3691 cmdline_fixed_string_t create;
3692 cmdline_fixed_string_t bonded;
3693 cmdline_fixed_string_t device;
3698 static int bond_dev_num = 0;
3700 static void cmd_create_bonded_device_parsed(void *parsed_result,
3701 __attribute__((unused)) struct cmdline *cl,
3702 __attribute__((unused)) void *data)
3704 struct cmd_create_bonded_device_result *res = parsed_result;
3705 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3708 if (test_done == 0) {
3709 printf("Please stop forwarding first\n");
3713 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3716 /* Create a new bonded device. */
3717 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3719 printf("\t Failed to create bonded device.\n");
3722 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3725 /* Update number of ports */
3726 nb_ports = rte_eth_dev_count();
3728 rte_eth_promiscuous_enable(port_id);
3733 cmdline_parse_token_string_t cmd_createbonded_device_create =
3734 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3736 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3737 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3739 cmdline_parse_token_string_t cmd_createbonded_device_device =
3740 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3742 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3743 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3745 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3746 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3749 cmdline_parse_inst_t cmd_create_bonded_device = {
3750 .f = cmd_create_bonded_device_parsed,
3751 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3754 (void *)&cmd_createbonded_device_create,
3755 (void *)&cmd_createbonded_device_bonded,
3756 (void *)&cmd_createbonded_device_device,
3757 (void *)&cmd_createbonded_device_mode,
3758 (void *)&cmd_createbonded_device_socket,
3763 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3764 struct cmd_set_bond_mac_addr_result {
3765 cmdline_fixed_string_t set;
3766 cmdline_fixed_string_t bonding;
3767 cmdline_fixed_string_t mac_addr;
3769 struct ether_addr address;
3772 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3773 __attribute__((unused)) struct cmdline *cl,
3774 __attribute__((unused)) void *data)
3776 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3779 if (res->port_num >= nb_ports) {
3780 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3784 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3786 /* check the return value and print it if is < 0 */
3788 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3791 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3793 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3796 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3797 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3799 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3800 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3801 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3802 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3804 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3805 .f = cmd_set_bond_mac_addr_parsed,
3807 .help_str = "set bonding mac_addr (port_id) (address): ",
3809 (void *)&cmd_set_bond_mac_addr_set,
3810 (void *)&cmd_set_bond_mac_addr_bonding,
3811 (void *)&cmd_set_bond_mac_addr_mac,
3812 (void *)&cmd_set_bond_mac_addr_portnum,
3813 (void *)&cmd_set_bond_mac_addr_addr,
3819 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3820 struct cmd_set_bond_mon_period_result {
3821 cmdline_fixed_string_t set;
3822 cmdline_fixed_string_t bonding;
3823 cmdline_fixed_string_t mon_period;
3828 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3829 __attribute__((unused)) struct cmdline *cl,
3830 __attribute__((unused)) void *data)
3832 struct cmd_set_bond_mon_period_result *res = parsed_result;
3835 if (res->port_num >= nb_ports) {
3836 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3840 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3842 /* check the return value and print it if is < 0 */
3844 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3847 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3850 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3852 bonding, "bonding");
3853 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3855 mon_period, "mon_period");
3856 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3857 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3859 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3860 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3863 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3864 .f = cmd_set_bond_mon_period_parsed,
3866 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3868 (void *)&cmd_set_bond_mon_period_set,
3869 (void *)&cmd_set_bond_mon_period_bonding,
3870 (void *)&cmd_set_bond_mon_period_mon_period,
3871 (void *)&cmd_set_bond_mon_period_portnum,
3872 (void *)&cmd_set_bond_mon_period_period_ms,
3877 #endif /* RTE_LIBRTE_PMD_BOND */
3879 /* *** SET FORWARDING MODE *** */
3880 struct cmd_set_fwd_mode_result {
3881 cmdline_fixed_string_t set;
3882 cmdline_fixed_string_t fwd;
3883 cmdline_fixed_string_t mode;
3886 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3887 __attribute__((unused)) struct cmdline *cl,
3888 __attribute__((unused)) void *data)
3890 struct cmd_set_fwd_mode_result *res = parsed_result;
3892 set_pkt_forwarding_mode(res->mode);
3895 cmdline_parse_token_string_t cmd_setfwd_set =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3897 cmdline_parse_token_string_t cmd_setfwd_fwd =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3899 cmdline_parse_token_string_t cmd_setfwd_mode =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3901 "" /* defined at init */);
3903 cmdline_parse_inst_t cmd_set_fwd_mode = {
3904 .f = cmd_set_fwd_mode_parsed,
3906 .help_str = NULL, /* defined at init */
3908 (void *)&cmd_setfwd_set,
3909 (void *)&cmd_setfwd_fwd,
3910 (void *)&cmd_setfwd_mode,
3915 static void cmd_set_fwd_mode_init(void)
3918 static char token[128];
3919 static char help[256];
3920 cmdline_parse_token_string_t *token_struct;
3922 modes = list_pkt_forwarding_modes();
3923 snprintf(help, sizeof help, "set fwd %s - "
3924 "set packet forwarding mode", modes);
3925 cmd_set_fwd_mode.help_str = help;
3927 /* string token separator is # */
3928 for (c = token; *modes != '\0'; modes++)
3933 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3934 token_struct->string_data.str = token;
3937 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3938 struct cmd_set_burst_tx_retry_result {
3939 cmdline_fixed_string_t set;
3940 cmdline_fixed_string_t burst;
3941 cmdline_fixed_string_t tx;
3942 cmdline_fixed_string_t delay;
3944 cmdline_fixed_string_t retry;
3948 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3949 __attribute__((unused)) struct cmdline *cl,
3950 __attribute__((unused)) void *data)
3952 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3954 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3955 && !strcmp(res->tx, "tx")) {
3956 if (!strcmp(res->delay, "delay"))
3957 burst_tx_delay_time = res->time;
3958 if (!strcmp(res->retry, "retry"))
3959 burst_tx_retry_num = res->retry_num;
3964 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3965 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3966 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3969 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3970 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3971 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3973 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3974 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3975 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3976 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3977 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3978 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3980 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3981 .f = cmd_set_burst_tx_retry_parsed,
3982 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3984 (void *)&cmd_set_burst_tx_retry_set,
3985 (void *)&cmd_set_burst_tx_retry_burst,
3986 (void *)&cmd_set_burst_tx_retry_tx,
3987 (void *)&cmd_set_burst_tx_retry_delay,
3988 (void *)&cmd_set_burst_tx_retry_time,
3989 (void *)&cmd_set_burst_tx_retry_retry,
3990 (void *)&cmd_set_burst_tx_retry_retry_num,
3995 /* *** SET PROMISC MODE *** */
3996 struct cmd_set_promisc_mode_result {
3997 cmdline_fixed_string_t set;
3998 cmdline_fixed_string_t promisc;
3999 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4000 uint8_t port_num; /* valid if "allports" argument == 0 */
4001 cmdline_fixed_string_t mode;
4004 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4005 __attribute__((unused)) struct cmdline *cl,
4008 struct cmd_set_promisc_mode_result *res = parsed_result;
4012 if (!strcmp(res->mode, "on"))
4019 for (i = 0; i < nb_ports; i++) {
4021 rte_eth_promiscuous_enable(i);
4023 rte_eth_promiscuous_disable(i);
4028 rte_eth_promiscuous_enable(res->port_num);
4030 rte_eth_promiscuous_disable(res->port_num);
4034 cmdline_parse_token_string_t cmd_setpromisc_set =
4035 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4036 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4039 cmdline_parse_token_string_t cmd_setpromisc_portall =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4042 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4043 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4045 cmdline_parse_token_string_t cmd_setpromisc_mode =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4049 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4050 .f = cmd_set_promisc_mode_parsed,
4052 .help_str = "set promisc all on|off: set promisc mode for all ports",
4054 (void *)&cmd_setpromisc_set,
4055 (void *)&cmd_setpromisc_promisc,
4056 (void *)&cmd_setpromisc_portall,
4057 (void *)&cmd_setpromisc_mode,
4062 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4063 .f = cmd_set_promisc_mode_parsed,
4065 .help_str = "set promisc X on|off: set promisc mode on port X",
4067 (void *)&cmd_setpromisc_set,
4068 (void *)&cmd_setpromisc_promisc,
4069 (void *)&cmd_setpromisc_portnum,
4070 (void *)&cmd_setpromisc_mode,
4075 /* *** SET ALLMULTI MODE *** */
4076 struct cmd_set_allmulti_mode_result {
4077 cmdline_fixed_string_t set;
4078 cmdline_fixed_string_t allmulti;
4079 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4080 uint8_t port_num; /* valid if "allports" argument == 0 */
4081 cmdline_fixed_string_t mode;
4084 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4085 __attribute__((unused)) struct cmdline *cl,
4088 struct cmd_set_allmulti_mode_result *res = parsed_result;
4092 if (!strcmp(res->mode, "on"))
4099 for (i = 0; i < nb_ports; i++) {
4101 rte_eth_allmulticast_enable(i);
4103 rte_eth_allmulticast_disable(i);
4108 rte_eth_allmulticast_enable(res->port_num);
4110 rte_eth_allmulticast_disable(res->port_num);
4114 cmdline_parse_token_string_t cmd_setallmulti_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4116 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4117 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4119 cmdline_parse_token_string_t cmd_setallmulti_portall =
4120 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4122 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4123 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4125 cmdline_parse_token_string_t cmd_setallmulti_mode =
4126 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4129 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4130 .f = cmd_set_allmulti_mode_parsed,
4132 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4134 (void *)&cmd_setallmulti_set,
4135 (void *)&cmd_setallmulti_allmulti,
4136 (void *)&cmd_setallmulti_portall,
4137 (void *)&cmd_setallmulti_mode,
4142 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4143 .f = cmd_set_allmulti_mode_parsed,
4145 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4147 (void *)&cmd_setallmulti_set,
4148 (void *)&cmd_setallmulti_allmulti,
4149 (void *)&cmd_setallmulti_portnum,
4150 (void *)&cmd_setallmulti_mode,
4155 /* *** ADD/REMOVE A PKT FILTER *** */
4156 struct cmd_pkt_filter_result {
4157 cmdline_fixed_string_t pkt_filter;
4159 cmdline_fixed_string_t protocol;
4160 cmdline_fixed_string_t src;
4161 cmdline_ipaddr_t ip_src;
4163 cmdline_fixed_string_t dst;
4164 cmdline_ipaddr_t ip_dst;
4166 cmdline_fixed_string_t flexbytes;
4167 uint16_t flexbytes_value;
4168 cmdline_fixed_string_t vlan;
4170 cmdline_fixed_string_t queue;
4172 cmdline_fixed_string_t soft;
4177 cmd_pkt_filter_parsed(void *parsed_result,
4178 __attribute__((unused)) struct cmdline *cl,
4179 __attribute__((unused)) void *data)
4181 struct rte_fdir_filter fdir_filter;
4182 struct cmd_pkt_filter_result *res = parsed_result;
4184 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4186 if (res->ip_src.family == AF_INET)
4187 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4189 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4190 &(res->ip_src.addr.ipv6),
4191 sizeof(struct in6_addr));
4193 if (res->ip_dst.family == AF_INET)
4194 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4196 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4197 &(res->ip_dst.addr.ipv6),
4198 sizeof(struct in6_addr));
4200 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4201 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4203 if (!strcmp(res->protocol, "udp"))
4204 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4205 else if (!strcmp(res->protocol, "tcp"))
4206 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4207 else if (!strcmp(res->protocol, "sctp"))
4208 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4209 else /* default only IP */
4210 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4212 if (res->ip_dst.family == AF_INET6)
4213 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4215 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4217 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4218 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4220 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4221 fdir_add_signature_filter(res->port_id, res->queue_id,
4223 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4224 fdir_update_signature_filter(res->port_id, res->queue_id,
4226 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4227 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4228 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4229 fdir_add_perfect_filter(res->port_id, res->soft_id,
4231 (uint8_t) (res->queue_id < 0),
4233 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4234 fdir_update_perfect_filter(res->port_id, res->soft_id,
4236 (uint8_t) (res->queue_id < 0),
4238 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4239 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4245 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4246 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4248 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4249 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4250 protocol, "ip#tcp#udp#sctp");
4251 cmdline_parse_token_string_t cmd_pkt_filter_src =
4252 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4254 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4255 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4257 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4258 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4260 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4261 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4263 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4264 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4266 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4267 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4269 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4270 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4271 flexbytes, "flexbytes");
4272 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4273 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4274 flexbytes_value, UINT16);
4275 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4276 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4278 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4279 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4281 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4282 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4284 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4285 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4287 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4288 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4290 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4291 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4295 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4296 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4297 pkt_filter, "add_signature_filter");
4298 cmdline_parse_inst_t cmd_add_signature_filter = {
4299 .f = cmd_pkt_filter_parsed,
4301 .help_str = "add a signature filter",
4303 (void *)&cmd_pkt_filter_add_signature_filter,
4304 (void *)&cmd_pkt_filter_port_id,
4305 (void *)&cmd_pkt_filter_protocol,
4306 (void *)&cmd_pkt_filter_src,
4307 (void *)&cmd_pkt_filter_ip_src,
4308 (void *)&cmd_pkt_filter_port_src,
4309 (void *)&cmd_pkt_filter_dst,
4310 (void *)&cmd_pkt_filter_ip_dst,
4311 (void *)&cmd_pkt_filter_port_dst,
4312 (void *)&cmd_pkt_filter_flexbytes,
4313 (void *)&cmd_pkt_filter_flexbytes_value,
4314 (void *)&cmd_pkt_filter_vlan,
4315 (void *)&cmd_pkt_filter_vlan_id,
4316 (void *)&cmd_pkt_filter_queue,
4317 (void *)&cmd_pkt_filter_queue_id,
4323 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4324 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4325 pkt_filter, "upd_signature_filter");
4326 cmdline_parse_inst_t cmd_upd_signature_filter = {
4327 .f = cmd_pkt_filter_parsed,
4329 .help_str = "update a signature filter",
4331 (void *)&cmd_pkt_filter_upd_signature_filter,
4332 (void *)&cmd_pkt_filter_port_id,
4333 (void *)&cmd_pkt_filter_protocol,
4334 (void *)&cmd_pkt_filter_src,
4335 (void *)&cmd_pkt_filter_ip_src,
4336 (void *)&cmd_pkt_filter_port_src,
4337 (void *)&cmd_pkt_filter_dst,
4338 (void *)&cmd_pkt_filter_ip_dst,
4339 (void *)&cmd_pkt_filter_port_dst,
4340 (void *)&cmd_pkt_filter_flexbytes,
4341 (void *)&cmd_pkt_filter_flexbytes_value,
4342 (void *)&cmd_pkt_filter_vlan,
4343 (void *)&cmd_pkt_filter_vlan_id,
4344 (void *)&cmd_pkt_filter_queue,
4345 (void *)&cmd_pkt_filter_queue_id,
4351 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4352 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4353 pkt_filter, "rm_signature_filter");
4354 cmdline_parse_inst_t cmd_rm_signature_filter = {
4355 .f = cmd_pkt_filter_parsed,
4357 .help_str = "remove a signature filter",
4359 (void *)&cmd_pkt_filter_rm_signature_filter,
4360 (void *)&cmd_pkt_filter_port_id,
4361 (void *)&cmd_pkt_filter_protocol,
4362 (void *)&cmd_pkt_filter_src,
4363 (void *)&cmd_pkt_filter_ip_src,
4364 (void *)&cmd_pkt_filter_port_src,
4365 (void *)&cmd_pkt_filter_dst,
4366 (void *)&cmd_pkt_filter_ip_dst,
4367 (void *)&cmd_pkt_filter_port_dst,
4368 (void *)&cmd_pkt_filter_flexbytes,
4369 (void *)&cmd_pkt_filter_flexbytes_value,
4370 (void *)&cmd_pkt_filter_vlan,
4371 (void *)&cmd_pkt_filter_vlan_id,
4377 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4378 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4379 pkt_filter, "add_perfect_filter");
4380 cmdline_parse_inst_t cmd_add_perfect_filter = {
4381 .f = cmd_pkt_filter_parsed,
4383 .help_str = "add a perfect filter",
4385 (void *)&cmd_pkt_filter_add_perfect_filter,
4386 (void *)&cmd_pkt_filter_port_id,
4387 (void *)&cmd_pkt_filter_protocol,
4388 (void *)&cmd_pkt_filter_src,
4389 (void *)&cmd_pkt_filter_ip_src,
4390 (void *)&cmd_pkt_filter_port_src,
4391 (void *)&cmd_pkt_filter_dst,
4392 (void *)&cmd_pkt_filter_ip_dst,
4393 (void *)&cmd_pkt_filter_port_dst,
4394 (void *)&cmd_pkt_filter_flexbytes,
4395 (void *)&cmd_pkt_filter_flexbytes_value,
4396 (void *)&cmd_pkt_filter_vlan,
4397 (void *)&cmd_pkt_filter_vlan_id,
4398 (void *)&cmd_pkt_filter_queue,
4399 (void *)&cmd_pkt_filter_queue_id,
4400 (void *)&cmd_pkt_filter_soft,
4401 (void *)&cmd_pkt_filter_soft_id,
4407 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4408 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4409 pkt_filter, "upd_perfect_filter");
4410 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4411 .f = cmd_pkt_filter_parsed,
4413 .help_str = "update a perfect filter",
4415 (void *)&cmd_pkt_filter_upd_perfect_filter,
4416 (void *)&cmd_pkt_filter_port_id,
4417 (void *)&cmd_pkt_filter_protocol,
4418 (void *)&cmd_pkt_filter_src,
4419 (void *)&cmd_pkt_filter_ip_src,
4420 (void *)&cmd_pkt_filter_port_src,
4421 (void *)&cmd_pkt_filter_dst,
4422 (void *)&cmd_pkt_filter_ip_dst,
4423 (void *)&cmd_pkt_filter_port_dst,
4424 (void *)&cmd_pkt_filter_flexbytes,
4425 (void *)&cmd_pkt_filter_flexbytes_value,
4426 (void *)&cmd_pkt_filter_vlan,
4427 (void *)&cmd_pkt_filter_vlan_id,
4428 (void *)&cmd_pkt_filter_queue,
4429 (void *)&cmd_pkt_filter_queue_id,
4430 (void *)&cmd_pkt_filter_soft,
4431 (void *)&cmd_pkt_filter_soft_id,
4437 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4438 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4439 pkt_filter, "rm_perfect_filter");
4440 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4441 .f = cmd_pkt_filter_parsed,
4443 .help_str = "remove a perfect filter",
4445 (void *)&cmd_pkt_filter_rm_perfect_filter,
4446 (void *)&cmd_pkt_filter_port_id,
4447 (void *)&cmd_pkt_filter_protocol,
4448 (void *)&cmd_pkt_filter_src,
4449 (void *)&cmd_pkt_filter_ip_src,
4450 (void *)&cmd_pkt_filter_port_src,
4451 (void *)&cmd_pkt_filter_dst,
4452 (void *)&cmd_pkt_filter_ip_dst,
4453 (void *)&cmd_pkt_filter_port_dst,
4454 (void *)&cmd_pkt_filter_flexbytes,
4455 (void *)&cmd_pkt_filter_flexbytes_value,
4456 (void *)&cmd_pkt_filter_vlan,
4457 (void *)&cmd_pkt_filter_vlan_id,
4458 (void *)&cmd_pkt_filter_soft,
4459 (void *)&cmd_pkt_filter_soft_id,
4464 /* *** SETUP MASKS FILTER *** */
4465 struct cmd_pkt_filter_masks_result {
4466 cmdline_fixed_string_t filter_mask;
4468 cmdline_fixed_string_t src_mask;
4469 uint32_t ip_src_mask;
4470 uint16_t ipv6_src_mask;
4471 uint16_t port_src_mask;
4472 cmdline_fixed_string_t dst_mask;
4473 uint32_t ip_dst_mask;
4474 uint16_t ipv6_dst_mask;
4475 uint16_t port_dst_mask;
4476 cmdline_fixed_string_t flexbytes;
4477 uint8_t flexbytes_value;
4478 cmdline_fixed_string_t vlan_id;
4479 uint8_t vlan_id_value;
4480 cmdline_fixed_string_t vlan_prio;
4481 uint8_t vlan_prio_value;
4482 cmdline_fixed_string_t only_ip_flow;
4483 uint8_t only_ip_flow_value;
4484 cmdline_fixed_string_t comp_ipv6_dst;
4485 uint8_t comp_ipv6_dst_value;
4489 cmd_pkt_filter_masks_parsed(void *parsed_result,
4490 __attribute__((unused)) struct cmdline *cl,
4491 __attribute__((unused)) void *data)
4493 struct rte_fdir_masks fdir_masks;
4494 struct cmd_pkt_filter_masks_result *res = parsed_result;
4496 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4498 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4499 fdir_masks.vlan_id = res->vlan_id_value;
4500 fdir_masks.vlan_prio = res->vlan_prio_value;
4501 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4502 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4503 fdir_masks.src_port_mask = res->port_src_mask;
4504 fdir_masks.dst_port_mask = res->port_dst_mask;
4505 fdir_masks.flexbytes = res->flexbytes_value;
4507 fdir_set_masks(res->port_id, &fdir_masks);
4510 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4511 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4512 filter_mask, "set_masks_filter");
4513 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4514 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4516 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4517 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4518 only_ip_flow, "only_ip_flow");
4519 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4520 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4521 only_ip_flow_value, UINT8);
4522 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4523 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4524 src_mask, "src_mask");
4525 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4526 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4527 ip_src_mask, UINT32);
4528 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4529 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4530 port_src_mask, UINT16);
4531 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4532 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4533 dst_mask, "dst_mask");
4534 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4535 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4536 ip_dst_mask, UINT32);
4537 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4538 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4539 port_dst_mask, UINT16);
4540 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4541 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4542 flexbytes, "flexbytes");
4543 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4544 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4545 flexbytes_value, UINT8);
4546 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4547 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4548 vlan_id, "vlan_id");
4549 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4550 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4551 vlan_id_value, UINT8);
4552 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4553 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4554 vlan_prio, "vlan_prio");
4555 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4556 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4557 vlan_prio_value, UINT8);
4559 cmdline_parse_inst_t cmd_set_masks_filter = {
4560 .f = cmd_pkt_filter_masks_parsed,
4562 .help_str = "setup masks filter",
4564 (void *)&cmd_pkt_filter_masks_filter_mask,
4565 (void *)&cmd_pkt_filter_masks_port_id,
4566 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4567 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4568 (void *)&cmd_pkt_filter_masks_src_mask,
4569 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4570 (void *)&cmd_pkt_filter_masks_port_src_mask,
4571 (void *)&cmd_pkt_filter_masks_dst_mask,
4572 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4573 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4574 (void *)&cmd_pkt_filter_masks_flexbytes,
4575 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4576 (void *)&cmd_pkt_filter_masks_vlan_id,
4577 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4578 (void *)&cmd_pkt_filter_masks_vlan_prio,
4579 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4585 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4586 __attribute__((unused)) struct cmdline *cl,
4587 __attribute__((unused)) void *data)
4589 struct rte_fdir_masks fdir_masks;
4590 struct cmd_pkt_filter_masks_result *res = parsed_result;
4592 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4594 fdir_masks.set_ipv6_mask = 1;
4595 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4596 fdir_masks.vlan_id = res->vlan_id_value;
4597 fdir_masks.vlan_prio = res->vlan_prio_value;
4598 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4599 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4600 fdir_masks.src_port_mask = res->port_src_mask;
4601 fdir_masks.dst_port_mask = res->port_dst_mask;
4602 fdir_masks.flexbytes = res->flexbytes_value;
4603 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4605 fdir_set_masks(res->port_id, &fdir_masks);
4608 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4609 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4610 filter_mask, "set_ipv6_masks_filter");
4611 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4612 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4613 ipv6_src_mask, UINT16);
4614 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4615 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4616 ipv6_dst_mask, UINT16);
4618 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4619 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4620 comp_ipv6_dst, "compare_dst");
4621 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4622 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4623 comp_ipv6_dst_value, UINT8);
4625 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4626 .f = cmd_pkt_filter_masks_ipv6_parsed,
4628 .help_str = "setup ipv6 masks filter",
4630 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4631 (void *)&cmd_pkt_filter_masks_port_id,
4632 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4633 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4634 (void *)&cmd_pkt_filter_masks_src_mask,
4635 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4636 (void *)&cmd_pkt_filter_masks_port_src_mask,
4637 (void *)&cmd_pkt_filter_masks_dst_mask,
4638 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4639 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4640 (void *)&cmd_pkt_filter_masks_flexbytes,
4641 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4642 (void *)&cmd_pkt_filter_masks_vlan_id,
4643 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4644 (void *)&cmd_pkt_filter_masks_vlan_prio,
4645 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4646 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4647 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4652 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4653 struct cmd_link_flow_ctrl_set_result {
4654 cmdline_fixed_string_t set;
4655 cmdline_fixed_string_t flow_ctrl;
4656 cmdline_fixed_string_t rx;
4657 cmdline_fixed_string_t rx_lfc_mode;
4658 cmdline_fixed_string_t tx;
4659 cmdline_fixed_string_t tx_lfc_mode;
4660 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4661 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4662 cmdline_fixed_string_t autoneg_str;
4663 cmdline_fixed_string_t autoneg;
4664 cmdline_fixed_string_t hw_str;
4665 uint32_t high_water;
4666 cmdline_fixed_string_t lw_str;
4668 cmdline_fixed_string_t pt_str;
4669 uint16_t pause_time;
4670 cmdline_fixed_string_t xon_str;
4675 cmdline_parse_token_string_t cmd_lfc_set_set =
4676 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4678 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4680 flow_ctrl, "flow_ctrl");
4681 cmdline_parse_token_string_t cmd_lfc_set_rx =
4682 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4684 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4686 rx_lfc_mode, "on#off");
4687 cmdline_parse_token_string_t cmd_lfc_set_tx =
4688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4690 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4692 tx_lfc_mode, "on#off");
4693 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4695 hw_str, "high_water");
4696 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4697 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4698 high_water, UINT32);
4699 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4700 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4701 lw_str, "low_water");
4702 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4703 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4705 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4707 pt_str, "pause_time");
4708 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4709 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4710 pause_time, UINT16);
4711 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4713 xon_str, "send_xon");
4714 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4715 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4717 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4718 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4719 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4720 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4721 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4722 mac_ctrl_frame_fwd_mode, "on#off");
4723 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4724 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4725 autoneg_str, "autoneg");
4726 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4727 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4729 cmdline_parse_token_num_t cmd_lfc_set_portid =
4730 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4733 /* forward declaration */
4735 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4738 cmdline_parse_inst_t cmd_link_flow_control_set = {
4739 .f = cmd_link_flow_ctrl_set_parsed,
4741 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4742 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4743 autoneg on|off port_id",
4745 (void *)&cmd_lfc_set_set,
4746 (void *)&cmd_lfc_set_flow_ctrl,
4747 (void *)&cmd_lfc_set_rx,
4748 (void *)&cmd_lfc_set_rx_mode,
4749 (void *)&cmd_lfc_set_tx,
4750 (void *)&cmd_lfc_set_tx_mode,
4751 (void *)&cmd_lfc_set_high_water,
4752 (void *)&cmd_lfc_set_low_water,
4753 (void *)&cmd_lfc_set_pause_time,
4754 (void *)&cmd_lfc_set_send_xon,
4755 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4756 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4757 (void *)&cmd_lfc_set_autoneg_str,
4758 (void *)&cmd_lfc_set_autoneg,
4759 (void *)&cmd_lfc_set_portid,
4764 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4765 .f = cmd_link_flow_ctrl_set_parsed,
4766 .data = (void *)&cmd_link_flow_control_set_rx,
4767 .help_str = "Change rx flow control parameter: set flow_ctrl "
4768 "rx on|off port_id",
4770 (void *)&cmd_lfc_set_set,
4771 (void *)&cmd_lfc_set_flow_ctrl,
4772 (void *)&cmd_lfc_set_rx,
4773 (void *)&cmd_lfc_set_rx_mode,
4774 (void *)&cmd_lfc_set_portid,
4779 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4780 .f = cmd_link_flow_ctrl_set_parsed,
4781 .data = (void *)&cmd_link_flow_control_set_tx,
4782 .help_str = "Change tx flow control parameter: set flow_ctrl "
4783 "tx on|off port_id",
4785 (void *)&cmd_lfc_set_set,
4786 (void *)&cmd_lfc_set_flow_ctrl,
4787 (void *)&cmd_lfc_set_tx,
4788 (void *)&cmd_lfc_set_tx_mode,
4789 (void *)&cmd_lfc_set_portid,
4794 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4795 .f = cmd_link_flow_ctrl_set_parsed,
4796 .data = (void *)&cmd_link_flow_control_set_hw,
4797 .help_str = "Change high water flow control parameter: set flow_ctrl "
4798 "high_water value port_id",
4800 (void *)&cmd_lfc_set_set,
4801 (void *)&cmd_lfc_set_flow_ctrl,
4802 (void *)&cmd_lfc_set_high_water_str,
4803 (void *)&cmd_lfc_set_high_water,
4804 (void *)&cmd_lfc_set_portid,
4809 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4810 .f = cmd_link_flow_ctrl_set_parsed,
4811 .data = (void *)&cmd_link_flow_control_set_lw,
4812 .help_str = "Change low water flow control parameter: set flow_ctrl "
4813 "low_water value port_id",
4815 (void *)&cmd_lfc_set_set,
4816 (void *)&cmd_lfc_set_flow_ctrl,
4817 (void *)&cmd_lfc_set_low_water_str,
4818 (void *)&cmd_lfc_set_low_water,
4819 (void *)&cmd_lfc_set_portid,
4824 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4825 .f = cmd_link_flow_ctrl_set_parsed,
4826 .data = (void *)&cmd_link_flow_control_set_pt,
4827 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4828 "pause_time value port_id",
4830 (void *)&cmd_lfc_set_set,
4831 (void *)&cmd_lfc_set_flow_ctrl,
4832 (void *)&cmd_lfc_set_pause_time_str,
4833 (void *)&cmd_lfc_set_pause_time,
4834 (void *)&cmd_lfc_set_portid,
4839 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4840 .f = cmd_link_flow_ctrl_set_parsed,
4841 .data = (void *)&cmd_link_flow_control_set_xon,
4842 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4843 "send_xon value port_id",
4845 (void *)&cmd_lfc_set_set,
4846 (void *)&cmd_lfc_set_flow_ctrl,
4847 (void *)&cmd_lfc_set_send_xon_str,
4848 (void *)&cmd_lfc_set_send_xon,
4849 (void *)&cmd_lfc_set_portid,
4854 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4855 .f = cmd_link_flow_ctrl_set_parsed,
4856 .data = (void *)&cmd_link_flow_control_set_macfwd,
4857 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4858 "mac_ctrl_frame_fwd on|off port_id",
4860 (void *)&cmd_lfc_set_set,
4861 (void *)&cmd_lfc_set_flow_ctrl,
4862 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4863 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4864 (void *)&cmd_lfc_set_portid,
4869 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4870 .f = cmd_link_flow_ctrl_set_parsed,
4871 .data = (void *)&cmd_link_flow_control_set_autoneg,
4872 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4873 "autoneg on|off port_id",
4875 (void *)&cmd_lfc_set_set,
4876 (void *)&cmd_lfc_set_flow_ctrl,
4877 (void *)&cmd_lfc_set_autoneg_str,
4878 (void *)&cmd_lfc_set_autoneg,
4879 (void *)&cmd_lfc_set_portid,
4885 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4886 __attribute__((unused)) struct cmdline *cl,
4889 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4890 cmdline_parse_inst_t *cmd = data;
4891 struct rte_eth_fc_conf fc_conf;
4892 int rx_fc_en, tx_fc_en;
4896 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4897 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4898 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4899 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4901 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4902 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4905 /* Partial command line, retrieve current configuration */
4907 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4909 printf("cannot get current flow ctrl parameters, return"
4910 "code = %d\n", ret);
4914 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4915 (fc_conf.mode == RTE_FC_FULL))
4917 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4918 (fc_conf.mode == RTE_FC_FULL))
4922 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4923 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4925 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4926 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4928 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4930 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4931 fc_conf.high_water = res->high_water;
4933 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4934 fc_conf.low_water = res->low_water;
4936 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4937 fc_conf.pause_time = res->pause_time;
4939 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4940 fc_conf.send_xon = res->send_xon;
4942 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4943 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4944 fc_conf.mac_ctrl_frame_fwd = 1;
4946 fc_conf.mac_ctrl_frame_fwd = 0;
4949 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4950 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4952 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4954 printf("bad flow contrl parameter, return code = %d \n", ret);
4957 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4958 struct cmd_priority_flow_ctrl_set_result {
4959 cmdline_fixed_string_t set;
4960 cmdline_fixed_string_t pfc_ctrl;
4961 cmdline_fixed_string_t rx;
4962 cmdline_fixed_string_t rx_pfc_mode;
4963 cmdline_fixed_string_t tx;
4964 cmdline_fixed_string_t tx_pfc_mode;
4965 uint32_t high_water;
4967 uint16_t pause_time;
4973 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4974 __attribute__((unused)) struct cmdline *cl,
4975 __attribute__((unused)) void *data)
4977 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
4978 struct rte_eth_pfc_conf pfc_conf;
4979 int rx_fc_enable, tx_fc_enable;
4983 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4984 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4985 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4986 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4988 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
4989 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
4992 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
4993 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
4994 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
4995 pfc_conf.fc.high_water = res->high_water;
4996 pfc_conf.fc.low_water = res->low_water;
4997 pfc_conf.fc.pause_time = res->pause_time;
4998 pfc_conf.priority = res->priority;
5000 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5002 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5005 cmdline_parse_token_string_t cmd_pfc_set_set =
5006 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5008 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5009 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5010 pfc_ctrl, "pfc_ctrl");
5011 cmdline_parse_token_string_t cmd_pfc_set_rx =
5012 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5014 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5015 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5016 rx_pfc_mode, "on#off");
5017 cmdline_parse_token_string_t cmd_pfc_set_tx =
5018 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5020 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5021 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5022 tx_pfc_mode, "on#off");
5023 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5024 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5025 high_water, UINT32);
5026 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5027 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5029 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5030 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5031 pause_time, UINT16);
5032 cmdline_parse_token_num_t cmd_pfc_set_priority =
5033 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5035 cmdline_parse_token_num_t cmd_pfc_set_portid =
5036 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5039 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5040 .f = cmd_priority_flow_ctrl_set_parsed,
5042 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5043 tx on|off high_water low_water pause_time priority port_id",
5045 (void *)&cmd_pfc_set_set,
5046 (void *)&cmd_pfc_set_flow_ctrl,
5047 (void *)&cmd_pfc_set_rx,
5048 (void *)&cmd_pfc_set_rx_mode,
5049 (void *)&cmd_pfc_set_tx,
5050 (void *)&cmd_pfc_set_tx_mode,
5051 (void *)&cmd_pfc_set_high_water,
5052 (void *)&cmd_pfc_set_low_water,
5053 (void *)&cmd_pfc_set_pause_time,
5054 (void *)&cmd_pfc_set_priority,
5055 (void *)&cmd_pfc_set_portid,
5060 /* *** RESET CONFIGURATION *** */
5061 struct cmd_reset_result {
5062 cmdline_fixed_string_t reset;
5063 cmdline_fixed_string_t def;
5066 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5068 __attribute__((unused)) void *data)
5070 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5071 set_def_fwd_config();
5074 cmdline_parse_token_string_t cmd_reset_set =
5075 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5076 cmdline_parse_token_string_t cmd_reset_def =
5077 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5080 cmdline_parse_inst_t cmd_reset = {
5081 .f = cmd_reset_parsed,
5083 .help_str = "set default: reset default forwarding configuration",
5085 (void *)&cmd_reset_set,
5086 (void *)&cmd_reset_def,
5091 /* *** START FORWARDING *** */
5092 struct cmd_start_result {
5093 cmdline_fixed_string_t start;
5096 cmdline_parse_token_string_t cmd_start_start =
5097 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5099 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5100 __attribute__((unused)) struct cmdline *cl,
5101 __attribute__((unused)) void *data)
5103 start_packet_forwarding(0);
5106 cmdline_parse_inst_t cmd_start = {
5107 .f = cmd_start_parsed,
5109 .help_str = "start packet forwarding",
5111 (void *)&cmd_start_start,
5116 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5117 struct cmd_start_tx_first_result {
5118 cmdline_fixed_string_t start;
5119 cmdline_fixed_string_t tx_first;
5123 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5124 __attribute__((unused)) struct cmdline *cl,
5125 __attribute__((unused)) void *data)
5127 start_packet_forwarding(1);
5130 cmdline_parse_token_string_t cmd_start_tx_first_start =
5131 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5133 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5134 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5135 tx_first, "tx_first");
5137 cmdline_parse_inst_t cmd_start_tx_first = {
5138 .f = cmd_start_tx_first_parsed,
5140 .help_str = "start packet forwarding, after sending 1 burst of packets",
5142 (void *)&cmd_start_tx_first_start,
5143 (void *)&cmd_start_tx_first_tx_first,
5148 /* *** SET LINK UP *** */
5149 struct cmd_set_link_up_result {
5150 cmdline_fixed_string_t set;
5151 cmdline_fixed_string_t link_up;
5152 cmdline_fixed_string_t port;
5156 cmdline_parse_token_string_t cmd_set_link_up_set =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5158 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5159 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5161 cmdline_parse_token_string_t cmd_set_link_up_port =
5162 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5163 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5164 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5166 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5167 __attribute__((unused)) struct cmdline *cl,
5168 __attribute__((unused)) void *data)
5170 struct cmd_set_link_up_result *res = parsed_result;
5171 dev_set_link_up(res->port_id);
5174 cmdline_parse_inst_t cmd_set_link_up = {
5175 .f = cmd_set_link_up_parsed,
5177 .help_str = "set link-up port (port id)",
5179 (void *)&cmd_set_link_up_set,
5180 (void *)&cmd_set_link_up_link_up,
5181 (void *)&cmd_set_link_up_port,
5182 (void *)&cmd_set_link_up_port_id,
5187 /* *** SET LINK DOWN *** */
5188 struct cmd_set_link_down_result {
5189 cmdline_fixed_string_t set;
5190 cmdline_fixed_string_t link_down;
5191 cmdline_fixed_string_t port;
5195 cmdline_parse_token_string_t cmd_set_link_down_set =
5196 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5197 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5198 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5200 cmdline_parse_token_string_t cmd_set_link_down_port =
5201 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5202 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5203 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5205 static void cmd_set_link_down_parsed(
5206 __attribute__((unused)) void *parsed_result,
5207 __attribute__((unused)) struct cmdline *cl,
5208 __attribute__((unused)) void *data)
5210 struct cmd_set_link_down_result *res = parsed_result;
5211 dev_set_link_down(res->port_id);
5214 cmdline_parse_inst_t cmd_set_link_down = {
5215 .f = cmd_set_link_down_parsed,
5217 .help_str = "set link-down port (port id)",
5219 (void *)&cmd_set_link_down_set,
5220 (void *)&cmd_set_link_down_link_down,
5221 (void *)&cmd_set_link_down_port,
5222 (void *)&cmd_set_link_down_port_id,
5227 /* *** SHOW CFG *** */
5228 struct cmd_showcfg_result {
5229 cmdline_fixed_string_t show;
5230 cmdline_fixed_string_t cfg;
5231 cmdline_fixed_string_t what;
5234 static void cmd_showcfg_parsed(void *parsed_result,
5235 __attribute__((unused)) struct cmdline *cl,
5236 __attribute__((unused)) void *data)
5238 struct cmd_showcfg_result *res = parsed_result;
5239 if (!strcmp(res->what, "rxtx"))
5240 rxtx_config_display();
5241 else if (!strcmp(res->what, "cores"))
5242 fwd_lcores_config_display();
5243 else if (!strcmp(res->what, "fwd"))
5244 fwd_config_display();
5247 cmdline_parse_token_string_t cmd_showcfg_show =
5248 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5249 cmdline_parse_token_string_t cmd_showcfg_port =
5250 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5251 cmdline_parse_token_string_t cmd_showcfg_what =
5252 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5255 cmdline_parse_inst_t cmd_showcfg = {
5256 .f = cmd_showcfg_parsed,
5258 .help_str = "show config rxtx|cores|fwd",
5260 (void *)&cmd_showcfg_show,
5261 (void *)&cmd_showcfg_port,
5262 (void *)&cmd_showcfg_what,
5267 /* *** SHOW ALL PORT INFO *** */
5268 struct cmd_showportall_result {
5269 cmdline_fixed_string_t show;
5270 cmdline_fixed_string_t port;
5271 cmdline_fixed_string_t what;
5272 cmdline_fixed_string_t all;
5275 static void cmd_showportall_parsed(void *parsed_result,
5276 __attribute__((unused)) struct cmdline *cl,
5277 __attribute__((unused)) void *data)
5281 struct cmd_showportall_result *res = parsed_result;
5282 if (!strcmp(res->show, "clear")) {
5283 if (!strcmp(res->what, "stats"))
5284 for (i = 0; i < nb_ports; i++)
5286 else if (!strcmp(res->what, "xstats"))
5287 for (i = 0; i < nb_ports; i++)
5288 nic_xstats_clear(i);
5289 } else if (!strcmp(res->what, "info"))
5290 for (i = 0; i < nb_ports; i++)
5291 port_infos_display(i);
5292 else if (!strcmp(res->what, "stats"))
5293 for (i = 0; i < nb_ports; i++)
5294 nic_stats_display(i);
5295 else if (!strcmp(res->what, "xstats"))
5296 for (i = 0; i < nb_ports; i++)
5297 nic_xstats_display(i);
5298 else if (!strcmp(res->what, "fdir"))
5299 for (i = 0; i < nb_ports; i++)
5301 else if (!strcmp(res->what, "stat_qmap"))
5302 for (i = 0; i < nb_ports; i++)
5303 nic_stats_mapping_display(i);
5306 cmdline_parse_token_string_t cmd_showportall_show =
5307 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5309 cmdline_parse_token_string_t cmd_showportall_port =
5310 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5311 cmdline_parse_token_string_t cmd_showportall_what =
5312 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5313 "info#stats#xstats#fdir#stat_qmap");
5314 cmdline_parse_token_string_t cmd_showportall_all =
5315 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5316 cmdline_parse_inst_t cmd_showportall = {
5317 .f = cmd_showportall_parsed,
5319 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5321 (void *)&cmd_showportall_show,
5322 (void *)&cmd_showportall_port,
5323 (void *)&cmd_showportall_what,
5324 (void *)&cmd_showportall_all,
5329 /* *** SHOW PORT INFO *** */
5330 struct cmd_showport_result {
5331 cmdline_fixed_string_t show;
5332 cmdline_fixed_string_t port;
5333 cmdline_fixed_string_t what;
5337 static void cmd_showport_parsed(void *parsed_result,
5338 __attribute__((unused)) struct cmdline *cl,
5339 __attribute__((unused)) void *data)
5341 struct cmd_showport_result *res = parsed_result;
5342 if (!strcmp(res->show, "clear")) {
5343 if (!strcmp(res->what, "stats"))
5344 nic_stats_clear(res->portnum);
5345 else if (!strcmp(res->what, "xstats"))
5346 nic_xstats_clear(res->portnum);
5347 } else if (!strcmp(res->what, "info"))
5348 port_infos_display(res->portnum);
5349 else if (!strcmp(res->what, "stats"))
5350 nic_stats_display(res->portnum);
5351 else if (!strcmp(res->what, "xstats"))
5352 nic_xstats_display(res->portnum);
5353 else if (!strcmp(res->what, "fdir"))
5354 fdir_get_infos(res->portnum);
5355 else if (!strcmp(res->what, "stat_qmap"))
5356 nic_stats_mapping_display(res->portnum);
5359 cmdline_parse_token_string_t cmd_showport_show =
5360 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5362 cmdline_parse_token_string_t cmd_showport_port =
5363 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5364 cmdline_parse_token_string_t cmd_showport_what =
5365 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5366 "info#stats#xstats#fdir#stat_qmap");
5367 cmdline_parse_token_num_t cmd_showport_portnum =
5368 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5370 cmdline_parse_inst_t cmd_showport = {
5371 .f = cmd_showport_parsed,
5373 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5375 (void *)&cmd_showport_show,
5376 (void *)&cmd_showport_port,
5377 (void *)&cmd_showport_what,
5378 (void *)&cmd_showport_portnum,
5383 /* *** READ PORT REGISTER *** */
5384 struct cmd_read_reg_result {
5385 cmdline_fixed_string_t read;
5386 cmdline_fixed_string_t reg;
5392 cmd_read_reg_parsed(void *parsed_result,
5393 __attribute__((unused)) struct cmdline *cl,
5394 __attribute__((unused)) void *data)
5396 struct cmd_read_reg_result *res = parsed_result;
5397 port_reg_display(res->port_id, res->reg_off);
5400 cmdline_parse_token_string_t cmd_read_reg_read =
5401 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5402 cmdline_parse_token_string_t cmd_read_reg_reg =
5403 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5404 cmdline_parse_token_num_t cmd_read_reg_port_id =
5405 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5406 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5407 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5409 cmdline_parse_inst_t cmd_read_reg = {
5410 .f = cmd_read_reg_parsed,
5412 .help_str = "read reg port_id reg_off",
5414 (void *)&cmd_read_reg_read,
5415 (void *)&cmd_read_reg_reg,
5416 (void *)&cmd_read_reg_port_id,
5417 (void *)&cmd_read_reg_reg_off,
5422 /* *** READ PORT REGISTER BIT FIELD *** */
5423 struct cmd_read_reg_bit_field_result {
5424 cmdline_fixed_string_t read;
5425 cmdline_fixed_string_t regfield;
5433 cmd_read_reg_bit_field_parsed(void *parsed_result,
5434 __attribute__((unused)) struct cmdline *cl,
5435 __attribute__((unused)) void *data)
5437 struct cmd_read_reg_bit_field_result *res = parsed_result;
5438 port_reg_bit_field_display(res->port_id, res->reg_off,
5439 res->bit1_pos, res->bit2_pos);
5442 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5443 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5445 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5446 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5447 regfield, "regfield");
5448 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5449 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5451 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5452 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5454 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5455 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5457 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5458 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5461 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5462 .f = cmd_read_reg_bit_field_parsed,
5464 .help_str = "read regfield port_id reg_off bit_x bit_y "
5465 "(read register bit field between bit_x and bit_y included)",
5467 (void *)&cmd_read_reg_bit_field_read,
5468 (void *)&cmd_read_reg_bit_field_regfield,
5469 (void *)&cmd_read_reg_bit_field_port_id,
5470 (void *)&cmd_read_reg_bit_field_reg_off,
5471 (void *)&cmd_read_reg_bit_field_bit1_pos,
5472 (void *)&cmd_read_reg_bit_field_bit2_pos,
5477 /* *** READ PORT REGISTER BIT *** */
5478 struct cmd_read_reg_bit_result {
5479 cmdline_fixed_string_t read;
5480 cmdline_fixed_string_t regbit;
5487 cmd_read_reg_bit_parsed(void *parsed_result,
5488 __attribute__((unused)) struct cmdline *cl,
5489 __attribute__((unused)) void *data)
5491 struct cmd_read_reg_bit_result *res = parsed_result;
5492 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5495 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5496 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5497 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5498 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5500 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5501 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5502 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5503 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5504 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5505 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5507 cmdline_parse_inst_t cmd_read_reg_bit = {
5508 .f = cmd_read_reg_bit_parsed,
5510 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5512 (void *)&cmd_read_reg_bit_read,
5513 (void *)&cmd_read_reg_bit_regbit,
5514 (void *)&cmd_read_reg_bit_port_id,
5515 (void *)&cmd_read_reg_bit_reg_off,
5516 (void *)&cmd_read_reg_bit_bit_pos,
5521 /* *** WRITE PORT REGISTER *** */
5522 struct cmd_write_reg_result {
5523 cmdline_fixed_string_t write;
5524 cmdline_fixed_string_t reg;
5531 cmd_write_reg_parsed(void *parsed_result,
5532 __attribute__((unused)) struct cmdline *cl,
5533 __attribute__((unused)) void *data)
5535 struct cmd_write_reg_result *res = parsed_result;
5536 port_reg_set(res->port_id, res->reg_off, res->value);
5539 cmdline_parse_token_string_t cmd_write_reg_write =
5540 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5541 cmdline_parse_token_string_t cmd_write_reg_reg =
5542 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5543 cmdline_parse_token_num_t cmd_write_reg_port_id =
5544 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5545 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5546 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5547 cmdline_parse_token_num_t cmd_write_reg_value =
5548 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5550 cmdline_parse_inst_t cmd_write_reg = {
5551 .f = cmd_write_reg_parsed,
5553 .help_str = "write reg port_id reg_off reg_value",
5555 (void *)&cmd_write_reg_write,
5556 (void *)&cmd_write_reg_reg,
5557 (void *)&cmd_write_reg_port_id,
5558 (void *)&cmd_write_reg_reg_off,
5559 (void *)&cmd_write_reg_value,
5564 /* *** WRITE PORT REGISTER BIT FIELD *** */
5565 struct cmd_write_reg_bit_field_result {
5566 cmdline_fixed_string_t write;
5567 cmdline_fixed_string_t regfield;
5576 cmd_write_reg_bit_field_parsed(void *parsed_result,
5577 __attribute__((unused)) struct cmdline *cl,
5578 __attribute__((unused)) void *data)
5580 struct cmd_write_reg_bit_field_result *res = parsed_result;
5581 port_reg_bit_field_set(res->port_id, res->reg_off,
5582 res->bit1_pos, res->bit2_pos, res->value);
5585 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5586 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5588 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5589 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5590 regfield, "regfield");
5591 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5592 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5594 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5595 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5597 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5598 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5600 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5601 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5603 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5604 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5607 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5608 .f = cmd_write_reg_bit_field_parsed,
5610 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5611 "(set register bit field between bit_x and bit_y included)",
5613 (void *)&cmd_write_reg_bit_field_write,
5614 (void *)&cmd_write_reg_bit_field_regfield,
5615 (void *)&cmd_write_reg_bit_field_port_id,
5616 (void *)&cmd_write_reg_bit_field_reg_off,
5617 (void *)&cmd_write_reg_bit_field_bit1_pos,
5618 (void *)&cmd_write_reg_bit_field_bit2_pos,
5619 (void *)&cmd_write_reg_bit_field_value,
5624 /* *** WRITE PORT REGISTER BIT *** */
5625 struct cmd_write_reg_bit_result {
5626 cmdline_fixed_string_t write;
5627 cmdline_fixed_string_t regbit;
5635 cmd_write_reg_bit_parsed(void *parsed_result,
5636 __attribute__((unused)) struct cmdline *cl,
5637 __attribute__((unused)) void *data)
5639 struct cmd_write_reg_bit_result *res = parsed_result;
5640 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5643 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5644 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5646 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5647 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5649 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5650 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5651 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5652 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5653 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5654 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5655 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5656 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5658 cmdline_parse_inst_t cmd_write_reg_bit = {
5659 .f = cmd_write_reg_bit_parsed,
5661 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5663 (void *)&cmd_write_reg_bit_write,
5664 (void *)&cmd_write_reg_bit_regbit,
5665 (void *)&cmd_write_reg_bit_port_id,
5666 (void *)&cmd_write_reg_bit_reg_off,
5667 (void *)&cmd_write_reg_bit_bit_pos,
5668 (void *)&cmd_write_reg_bit_value,
5673 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5674 struct cmd_read_rxd_txd_result {
5675 cmdline_fixed_string_t read;
5676 cmdline_fixed_string_t rxd_txd;
5683 cmd_read_rxd_txd_parsed(void *parsed_result,
5684 __attribute__((unused)) struct cmdline *cl,
5685 __attribute__((unused)) void *data)
5687 struct cmd_read_rxd_txd_result *res = parsed_result;
5689 if (!strcmp(res->rxd_txd, "rxd"))
5690 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5691 else if (!strcmp(res->rxd_txd, "txd"))
5692 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5695 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5696 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5697 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5698 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5700 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5701 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5702 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5703 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5704 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5705 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5707 cmdline_parse_inst_t cmd_read_rxd_txd = {
5708 .f = cmd_read_rxd_txd_parsed,
5710 .help_str = "read rxd|txd port_id queue_id rxd_id",
5712 (void *)&cmd_read_rxd_txd_read,
5713 (void *)&cmd_read_rxd_txd_rxd_txd,
5714 (void *)&cmd_read_rxd_txd_port_id,
5715 (void *)&cmd_read_rxd_txd_queue_id,
5716 (void *)&cmd_read_rxd_txd_desc_id,
5722 struct cmd_quit_result {
5723 cmdline_fixed_string_t quit;
5726 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5728 __attribute__((unused)) void *data)
5734 cmdline_parse_token_string_t cmd_quit_quit =
5735 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5737 cmdline_parse_inst_t cmd_quit = {
5738 .f = cmd_quit_parsed,
5740 .help_str = "exit application",
5742 (void *)&cmd_quit_quit,
5747 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5748 struct cmd_mac_addr_result {
5749 cmdline_fixed_string_t mac_addr_cmd;
5750 cmdline_fixed_string_t what;
5752 struct ether_addr address;
5755 static void cmd_mac_addr_parsed(void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5759 struct cmd_mac_addr_result *res = parsed_result;
5762 if (strcmp(res->what, "add") == 0)
5763 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5765 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5767 /* check the return value and print it if is < 0 */
5769 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5773 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5774 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5776 cmdline_parse_token_string_t cmd_mac_addr_what =
5777 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5779 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5780 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5781 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5782 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5784 cmdline_parse_inst_t cmd_mac_addr = {
5785 .f = cmd_mac_addr_parsed,
5787 .help_str = "mac_addr add|remove X <address>: "
5788 "add/remove MAC address on port X",
5790 (void *)&cmd_mac_addr_cmd,
5791 (void *)&cmd_mac_addr_what,
5792 (void *)&cmd_mac_addr_portnum,
5793 (void *)&cmd_mac_addr_addr,
5799 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5800 struct cmd_set_qmap_result {
5801 cmdline_fixed_string_t set;
5802 cmdline_fixed_string_t qmap;
5803 cmdline_fixed_string_t what;
5810 cmd_set_qmap_parsed(void *parsed_result,
5811 __attribute__((unused)) struct cmdline *cl,
5812 __attribute__((unused)) void *data)
5814 struct cmd_set_qmap_result *res = parsed_result;
5815 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5817 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5820 cmdline_parse_token_string_t cmd_setqmap_set =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5823 cmdline_parse_token_string_t cmd_setqmap_qmap =
5824 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5826 cmdline_parse_token_string_t cmd_setqmap_what =
5827 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5829 cmdline_parse_token_num_t cmd_setqmap_portid =
5830 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5832 cmdline_parse_token_num_t cmd_setqmap_queueid =
5833 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5835 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5836 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5839 cmdline_parse_inst_t cmd_set_qmap = {
5840 .f = cmd_set_qmap_parsed,
5842 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5844 (void *)&cmd_setqmap_set,
5845 (void *)&cmd_setqmap_qmap,
5846 (void *)&cmd_setqmap_what,
5847 (void *)&cmd_setqmap_portid,
5848 (void *)&cmd_setqmap_queueid,
5849 (void *)&cmd_setqmap_mapvalue,
5854 /* *** CONFIGURE UNICAST HASH TABLE *** */
5855 struct cmd_set_uc_hash_table {
5856 cmdline_fixed_string_t set;
5857 cmdline_fixed_string_t port;
5859 cmdline_fixed_string_t what;
5860 struct ether_addr address;
5861 cmdline_fixed_string_t mode;
5865 cmd_set_uc_hash_parsed(void *parsed_result,
5866 __attribute__((unused)) struct cmdline *cl,
5867 __attribute__((unused)) void *data)
5870 struct cmd_set_uc_hash_table *res = parsed_result;
5872 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5874 if (strcmp(res->what, "uta") == 0)
5875 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5876 &res->address,(uint8_t)is_on);
5878 printf("bad unicast hash table parameter, return code = %d \n", ret);
5882 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5885 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5886 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5888 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5889 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5891 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5892 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5894 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5897 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5898 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5901 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5902 .f = cmd_set_uc_hash_parsed,
5904 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5906 (void *)&cmd_set_uc_hash_set,
5907 (void *)&cmd_set_uc_hash_port,
5908 (void *)&cmd_set_uc_hash_portid,
5909 (void *)&cmd_set_uc_hash_what,
5910 (void *)&cmd_set_uc_hash_mac,
5911 (void *)&cmd_set_uc_hash_mode,
5916 struct cmd_set_uc_all_hash_table {
5917 cmdline_fixed_string_t set;
5918 cmdline_fixed_string_t port;
5920 cmdline_fixed_string_t what;
5921 cmdline_fixed_string_t value;
5922 cmdline_fixed_string_t mode;
5926 cmd_set_uc_all_hash_parsed(void *parsed_result,
5927 __attribute__((unused)) struct cmdline *cl,
5928 __attribute__((unused)) void *data)
5931 struct cmd_set_uc_all_hash_table *res = parsed_result;
5933 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5935 if ((strcmp(res->what, "uta") == 0) &&
5936 (strcmp(res->value, "all") == 0))
5937 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5939 printf("bad unicast hash table parameter,"
5940 "return code = %d \n", ret);
5943 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5944 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5946 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5947 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5949 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5950 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5952 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5955 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5956 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5958 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5962 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5963 .f = cmd_set_uc_all_hash_parsed,
5965 .help_str = "set port X uta all on|off (X = port number)",
5967 (void *)&cmd_set_uc_all_hash_set,
5968 (void *)&cmd_set_uc_all_hash_port,
5969 (void *)&cmd_set_uc_all_hash_portid,
5970 (void *)&cmd_set_uc_all_hash_what,
5971 (void *)&cmd_set_uc_all_hash_value,
5972 (void *)&cmd_set_uc_all_hash_mode,
5977 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
5978 struct cmd_set_vf_macvlan_filter {
5979 cmdline_fixed_string_t set;
5980 cmdline_fixed_string_t port;
5982 cmdline_fixed_string_t vf;
5984 struct ether_addr address;
5985 cmdline_fixed_string_t filter_type;
5986 cmdline_fixed_string_t mode;
5990 cmd_set_vf_macvlan_parsed(void *parsed_result,
5991 __attribute__((unused)) struct cmdline *cl,
5992 __attribute__((unused)) void *data)
5995 struct cmd_set_vf_macvlan_filter *res = parsed_result;
5996 struct rte_eth_mac_filter filter;
5998 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6000 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6002 /* set VF MAC filter */
6006 filter.dst_id = res->vf_id;
6008 if (!strcmp(res->filter_type, "exact-mac"))
6009 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6010 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6011 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6012 else if (!strcmp(res->filter_type, "hashmac"))
6013 filter.filter_type = RTE_MAC_HASH_MATCH;
6014 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6015 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6017 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6020 ret = rte_eth_dev_filter_ctrl(res->port_id,
6021 RTE_ETH_FILTER_MACVLAN,
6025 ret = rte_eth_dev_filter_ctrl(res->port_id,
6026 RTE_ETH_FILTER_MACVLAN,
6027 RTE_ETH_FILTER_DELETE,
6031 printf("bad set MAC hash parameter, return code = %d\n", ret);
6035 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6036 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6038 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6039 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6041 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6042 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6044 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6045 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6047 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6048 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6050 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6051 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6053 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6055 filter_type, "exact-mac#exact-mac-vlan"
6056 "#hashmac#hashmac-vlan");
6057 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6058 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6061 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6062 .f = cmd_set_vf_macvlan_parsed,
6064 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6065 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6067 "exact match rule:exact match of MAC or MAC and VLAN; "
6068 "hash match rule: hash match of MAC and exact match "
6071 (void *)&cmd_set_vf_macvlan_set,
6072 (void *)&cmd_set_vf_macvlan_port,
6073 (void *)&cmd_set_vf_macvlan_portid,
6074 (void *)&cmd_set_vf_macvlan_vf,
6075 (void *)&cmd_set_vf_macvlan_vf_id,
6076 (void *)&cmd_set_vf_macvlan_mac,
6077 (void *)&cmd_set_vf_macvlan_filter_type,
6078 (void *)&cmd_set_vf_macvlan_mode,
6083 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6084 struct cmd_set_vf_traffic {
6085 cmdline_fixed_string_t set;
6086 cmdline_fixed_string_t port;
6088 cmdline_fixed_string_t vf;
6090 cmdline_fixed_string_t what;
6091 cmdline_fixed_string_t mode;
6095 cmd_set_vf_traffic_parsed(void *parsed_result,
6096 __attribute__((unused)) struct cmdline *cl,
6097 __attribute__((unused)) void *data)
6099 struct cmd_set_vf_traffic *res = parsed_result;
6100 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6101 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6103 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6106 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6109 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6112 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6113 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6115 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6116 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6118 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6121 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6124 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6125 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6128 cmdline_parse_inst_t cmd_set_vf_traffic = {
6129 .f = cmd_set_vf_traffic_parsed,
6131 .help_str = "set port X vf Y rx|tx on|off"
6132 "(X = port number,Y = vf id)",
6134 (void *)&cmd_setvf_traffic_set,
6135 (void *)&cmd_setvf_traffic_port,
6136 (void *)&cmd_setvf_traffic_portid,
6137 (void *)&cmd_setvf_traffic_vf,
6138 (void *)&cmd_setvf_traffic_vfid,
6139 (void *)&cmd_setvf_traffic_what,
6140 (void *)&cmd_setvf_traffic_mode,
6145 /* *** CONFIGURE VF RECEIVE MODE *** */
6146 struct cmd_set_vf_rxmode {
6147 cmdline_fixed_string_t set;
6148 cmdline_fixed_string_t port;
6150 cmdline_fixed_string_t vf;
6152 cmdline_fixed_string_t what;
6153 cmdline_fixed_string_t mode;
6154 cmdline_fixed_string_t on;
6158 cmd_set_vf_rxmode_parsed(void *parsed_result,
6159 __attribute__((unused)) struct cmdline *cl,
6160 __attribute__((unused)) void *data)
6163 uint16_t rx_mode = 0;
6164 struct cmd_set_vf_rxmode *res = parsed_result;
6166 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6167 if (!strcmp(res->what,"rxmode")) {
6168 if (!strcmp(res->mode, "AUPE"))
6169 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6170 else if (!strcmp(res->mode, "ROPE"))
6171 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6172 else if (!strcmp(res->mode, "BAM"))
6173 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6174 else if (!strncmp(res->mode, "MPE",3))
6175 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6178 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6180 printf("bad VF receive mode parameter, return code = %d \n",
6184 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6185 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6187 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6188 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6190 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6191 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6193 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6194 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6196 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6197 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6199 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6200 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6202 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6204 mode, "AUPE#ROPE#BAM#MPE");
6205 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6206 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6209 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6210 .f = cmd_set_vf_rxmode_parsed,
6212 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6214 (void *)&cmd_set_vf_rxmode_set,
6215 (void *)&cmd_set_vf_rxmode_port,
6216 (void *)&cmd_set_vf_rxmode_portid,
6217 (void *)&cmd_set_vf_rxmode_vf,
6218 (void *)&cmd_set_vf_rxmode_vfid,
6219 (void *)&cmd_set_vf_rxmode_what,
6220 (void *)&cmd_set_vf_rxmode_mode,
6221 (void *)&cmd_set_vf_rxmode_on,
6226 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6227 struct cmd_vf_mac_addr_result {
6228 cmdline_fixed_string_t mac_addr_cmd;
6229 cmdline_fixed_string_t what;
6230 cmdline_fixed_string_t port;
6232 cmdline_fixed_string_t vf;
6234 struct ether_addr address;
6237 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6238 __attribute__((unused)) struct cmdline *cl,
6239 __attribute__((unused)) void *data)
6241 struct cmd_vf_mac_addr_result *res = parsed_result;
6244 if (strcmp(res->what, "add") == 0)
6245 ret = rte_eth_dev_mac_addr_add(res->port_num,
6246 &res->address, res->vf_num);
6248 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6252 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6253 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6254 mac_addr_cmd,"mac_addr");
6255 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6256 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6258 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6259 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6261 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6262 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6264 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6265 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6267 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6268 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6270 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6271 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6274 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6275 .f = cmd_vf_mac_addr_parsed,
6277 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6278 "Y = VF number)add MAC address filtering for a VF on port X",
6280 (void *)&cmd_vf_mac_addr_cmd,
6281 (void *)&cmd_vf_mac_addr_what,
6282 (void *)&cmd_vf_mac_addr_port,
6283 (void *)&cmd_vf_mac_addr_portnum,
6284 (void *)&cmd_vf_mac_addr_vf,
6285 (void *)&cmd_vf_mac_addr_vfnum,
6286 (void *)&cmd_vf_mac_addr_addr,
6291 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6292 struct cmd_vf_rx_vlan_filter {
6293 cmdline_fixed_string_t rx_vlan;
6294 cmdline_fixed_string_t what;
6296 cmdline_fixed_string_t port;
6298 cmdline_fixed_string_t vf;
6303 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6304 __attribute__((unused)) struct cmdline *cl,
6305 __attribute__((unused)) void *data)
6307 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6309 if (!strcmp(res->what, "add"))
6310 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6312 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6315 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6316 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6317 rx_vlan, "rx_vlan");
6318 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6319 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6321 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6322 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6324 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6325 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6327 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6328 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6330 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6331 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6333 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6334 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6337 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6338 .f = cmd_vf_rx_vlan_filter_parsed,
6340 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6341 "Y = port number,Z = hexadecimal VF mask)",
6343 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6344 (void *)&cmd_vf_rx_vlan_filter_what,
6345 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6346 (void *)&cmd_vf_rx_vlan_filter_port,
6347 (void *)&cmd_vf_rx_vlan_filter_portid,
6348 (void *)&cmd_vf_rx_vlan_filter_vf,
6349 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6354 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6355 struct cmd_queue_rate_limit_result {
6356 cmdline_fixed_string_t set;
6357 cmdline_fixed_string_t port;
6359 cmdline_fixed_string_t queue;
6361 cmdline_fixed_string_t rate;
6365 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6366 __attribute__((unused)) struct cmdline *cl,
6367 __attribute__((unused)) void *data)
6369 struct cmd_queue_rate_limit_result *res = parsed_result;
6372 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6373 && (strcmp(res->queue, "queue") == 0)
6374 && (strcmp(res->rate, "rate") == 0))
6375 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6378 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6382 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6383 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6385 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6386 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6388 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6389 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6391 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6392 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6394 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6395 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6397 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6398 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6400 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6401 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6404 cmdline_parse_inst_t cmd_queue_rate_limit = {
6405 .f = cmd_queue_rate_limit_parsed,
6407 .help_str = "set port X queue Y rate Z:(X = port number,"
6408 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6410 (void *)&cmd_queue_rate_limit_set,
6411 (void *)&cmd_queue_rate_limit_port,
6412 (void *)&cmd_queue_rate_limit_portnum,
6413 (void *)&cmd_queue_rate_limit_queue,
6414 (void *)&cmd_queue_rate_limit_queuenum,
6415 (void *)&cmd_queue_rate_limit_rate,
6416 (void *)&cmd_queue_rate_limit_ratenum,
6421 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6422 struct cmd_vf_rate_limit_result {
6423 cmdline_fixed_string_t set;
6424 cmdline_fixed_string_t port;
6426 cmdline_fixed_string_t vf;
6428 cmdline_fixed_string_t rate;
6430 cmdline_fixed_string_t q_msk;
6434 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6435 __attribute__((unused)) struct cmdline *cl,
6436 __attribute__((unused)) void *data)
6438 struct cmd_vf_rate_limit_result *res = parsed_result;
6441 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6442 && (strcmp(res->vf, "vf") == 0)
6443 && (strcmp(res->rate, "rate") == 0)
6444 && (strcmp(res->q_msk, "queue_mask") == 0))
6445 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6446 res->rate_num, res->q_msk_val);
6448 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6452 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6453 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6455 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6456 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6458 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6459 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6461 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6462 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6464 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6465 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6467 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6468 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6470 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6471 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6473 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6474 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6475 q_msk, "queue_mask");
6476 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6477 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6480 cmdline_parse_inst_t cmd_vf_rate_limit = {
6481 .f = cmd_vf_rate_limit_parsed,
6483 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6484 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6485 "for queues of VF on port X",
6487 (void *)&cmd_vf_rate_limit_set,
6488 (void *)&cmd_vf_rate_limit_port,
6489 (void *)&cmd_vf_rate_limit_portnum,
6490 (void *)&cmd_vf_rate_limit_vf,
6491 (void *)&cmd_vf_rate_limit_vfnum,
6492 (void *)&cmd_vf_rate_limit_rate,
6493 (void *)&cmd_vf_rate_limit_ratenum,
6494 (void *)&cmd_vf_rate_limit_q_msk,
6495 (void *)&cmd_vf_rate_limit_q_msk_val,
6500 /* *** ADD TUNNEL FILTER OF A PORT *** */
6501 struct cmd_tunnel_filter_result {
6502 cmdline_fixed_string_t cmd;
6503 cmdline_fixed_string_t what;
6505 struct ether_addr outer_mac;
6506 struct ether_addr inner_mac;
6507 cmdline_ipaddr_t ip_value;
6508 uint16_t inner_vlan;
6509 cmdline_fixed_string_t tunnel_type;
6510 cmdline_fixed_string_t filter_type;
6516 cmd_tunnel_filter_parsed(void *parsed_result,
6517 __attribute__((unused)) struct cmdline *cl,
6518 __attribute__((unused)) void *data)
6520 struct cmd_tunnel_filter_result *res = parsed_result;
6521 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6524 tunnel_filter_conf.outer_mac = &res->outer_mac;
6525 tunnel_filter_conf.inner_mac = &res->inner_mac;
6526 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6528 if (res->ip_value.family == AF_INET) {
6529 tunnel_filter_conf.ip_addr.ipv4_addr =
6530 res->ip_value.addr.ipv4.s_addr;
6531 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6533 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6534 &(res->ip_value.addr.ipv6),
6535 sizeof(struct in6_addr));
6536 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6539 if (!strcmp(res->filter_type, "imac-ivlan"))
6540 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6541 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6542 tunnel_filter_conf.filter_type =
6543 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6544 else if (!strcmp(res->filter_type, "imac-tenid"))
6545 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6546 else if (!strcmp(res->filter_type, "imac"))
6547 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6548 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6549 tunnel_filter_conf.filter_type =
6550 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6552 printf("The filter type is not supported");
6556 if (!strcmp(res->tunnel_type, "vxlan"))
6557 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6559 printf("Only VXLAN is supported now.\n");
6563 tunnel_filter_conf.tenant_id = res->tenant_id;
6564 tunnel_filter_conf.queue_id = res->queue_num;
6565 if (!strcmp(res->what, "add"))
6566 ret = rte_eth_dev_filter_ctrl(res->port_id,
6567 RTE_ETH_FILTER_TUNNEL,
6569 &tunnel_filter_conf);
6571 ret = rte_eth_dev_filter_ctrl(res->port_id,
6572 RTE_ETH_FILTER_TUNNEL,
6573 RTE_ETH_FILTER_DELETE,
6574 &tunnel_filter_conf);
6576 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6580 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6581 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6582 cmd, "tunnel_filter");
6583 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6584 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6586 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6587 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6589 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6590 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6592 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6593 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6595 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6596 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6597 inner_vlan, UINT16);
6598 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6599 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6601 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6602 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6603 tunnel_type, "vxlan");
6605 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6606 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6607 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6608 "imac#omac-imac-tenid");
6609 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6610 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6612 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6613 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6616 cmdline_parse_inst_t cmd_tunnel_filter = {
6617 .f = cmd_tunnel_filter_parsed,
6619 .help_str = "add/rm tunnel filter of a port: "
6620 "tunnel_filter add port_id outer_mac inner_mac ip "
6621 "inner_vlan tunnel_type(vxlan) filter_type "
6622 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6623 "imac|omac-imac-tenid) "
6624 "tenant_id queue_num",
6626 (void *)&cmd_tunnel_filter_cmd,
6627 (void *)&cmd_tunnel_filter_what,
6628 (void *)&cmd_tunnel_filter_port_id,
6629 (void *)&cmd_tunnel_filter_outer_mac,
6630 (void *)&cmd_tunnel_filter_inner_mac,
6631 (void *)&cmd_tunnel_filter_ip_value,
6632 (void *)&cmd_tunnel_filter_innner_vlan,
6633 (void *)&cmd_tunnel_filter_tunnel_type,
6634 (void *)&cmd_tunnel_filter_filter_type,
6635 (void *)&cmd_tunnel_filter_tenant_id,
6636 (void *)&cmd_tunnel_filter_queue_num,
6641 /* *** CONFIGURE TUNNEL UDP PORT *** */
6642 struct cmd_tunnel_udp_config {
6643 cmdline_fixed_string_t cmd;
6644 cmdline_fixed_string_t what;
6650 cmd_tunnel_udp_config_parsed(void *parsed_result,
6651 __attribute__((unused)) struct cmdline *cl,
6652 __attribute__((unused)) void *data)
6654 struct cmd_tunnel_udp_config *res = parsed_result;
6655 struct rte_eth_udp_tunnel tunnel_udp;
6658 tunnel_udp.udp_port = res->udp_port;
6660 if (!strcmp(res->cmd, "rx_vxlan_port"))
6661 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6663 if (!strcmp(res->what, "add"))
6664 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6666 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6669 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6672 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6673 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6674 cmd, "rx_vxlan_port");
6675 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6676 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6678 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6679 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6681 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6682 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6685 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6686 .f = cmd_tunnel_udp_config_parsed,
6688 .help_str = "add/rm an tunneling UDP port filter: "
6689 "rx_vxlan_port add udp_port port_id",
6691 (void *)&cmd_tunnel_udp_config_cmd,
6692 (void *)&cmd_tunnel_udp_config_what,
6693 (void *)&cmd_tunnel_udp_config_udp_port,
6694 (void *)&cmd_tunnel_udp_config_port_id,
6699 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6700 struct cmd_set_mirror_mask_result {
6701 cmdline_fixed_string_t set;
6702 cmdline_fixed_string_t port;
6704 cmdline_fixed_string_t mirror;
6706 cmdline_fixed_string_t what;
6707 cmdline_fixed_string_t value;
6708 cmdline_fixed_string_t dstpool;
6710 cmdline_fixed_string_t on;
6713 cmdline_parse_token_string_t cmd_mirror_mask_set =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6716 cmdline_parse_token_string_t cmd_mirror_mask_port =
6717 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6719 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6720 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6722 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6723 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6724 mirror, "mirror-rule");
6725 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6726 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6728 cmdline_parse_token_string_t cmd_mirror_mask_what =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6730 what, "pool-mirror#vlan-mirror");
6731 cmdline_parse_token_string_t cmd_mirror_mask_value =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6734 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6736 dstpool, "dst-pool");
6737 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6738 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6740 cmdline_parse_token_string_t cmd_mirror_mask_on =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6745 cmd_set_mirror_mask_parsed(void *parsed_result,
6746 __attribute__((unused)) struct cmdline *cl,
6747 __attribute__((unused)) void *data)
6750 struct cmd_set_mirror_mask_result *res = parsed_result;
6751 struct rte_eth_vmdq_mirror_conf mr_conf;
6753 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6755 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6757 mr_conf.dst_pool = res->dstpool_id;
6759 if (!strcmp(res->what, "pool-mirror")) {
6760 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6761 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6762 } else if(!strcmp(res->what, "vlan-mirror")) {
6763 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6764 nb_item = parse_item_list(res->value, "core",
6765 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6769 for(i=0; i < nb_item; i++) {
6770 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6771 printf("Invalid vlan_id: must be < 4096\n");
6775 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6776 mr_conf.vlan.vlan_mask |= 1ULL << i;
6780 if(!strcmp(res->on, "on"))
6781 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6784 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6787 printf("mirror rule add error: (%s)\n", strerror(-ret));
6790 cmdline_parse_inst_t cmd_set_mirror_mask = {
6791 .f = cmd_set_mirror_mask_parsed,
6793 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6794 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6796 (void *)&cmd_mirror_mask_set,
6797 (void *)&cmd_mirror_mask_port,
6798 (void *)&cmd_mirror_mask_portid,
6799 (void *)&cmd_mirror_mask_mirror,
6800 (void *)&cmd_mirror_mask_ruleid,
6801 (void *)&cmd_mirror_mask_what,
6802 (void *)&cmd_mirror_mask_value,
6803 (void *)&cmd_mirror_mask_dstpool,
6804 (void *)&cmd_mirror_mask_poolid,
6805 (void *)&cmd_mirror_mask_on,
6810 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6811 struct cmd_set_mirror_link_result {
6812 cmdline_fixed_string_t set;
6813 cmdline_fixed_string_t port;
6815 cmdline_fixed_string_t mirror;
6817 cmdline_fixed_string_t what;
6818 cmdline_fixed_string_t dstpool;
6820 cmdline_fixed_string_t on;
6823 cmdline_parse_token_string_t cmd_mirror_link_set =
6824 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6826 cmdline_parse_token_string_t cmd_mirror_link_port =
6827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6829 cmdline_parse_token_num_t cmd_mirror_link_portid =
6830 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6832 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6834 mirror, "mirror-rule");
6835 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6836 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6838 cmdline_parse_token_string_t cmd_mirror_link_what =
6839 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6840 what, "uplink-mirror#downlink-mirror");
6841 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6842 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6843 dstpool, "dst-pool");
6844 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6845 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6847 cmdline_parse_token_string_t cmd_mirror_link_on =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6852 cmd_set_mirror_link_parsed(void *parsed_result,
6853 __attribute__((unused)) struct cmdline *cl,
6854 __attribute__((unused)) void *data)
6857 struct cmd_set_mirror_link_result *res = parsed_result;
6858 struct rte_eth_vmdq_mirror_conf mr_conf;
6860 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6861 if(!strcmp(res->what, "uplink-mirror")) {
6862 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6863 }else if(!strcmp(res->what, "downlink-mirror"))
6864 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6866 mr_conf.dst_pool = res->dstpool_id;
6868 if(!strcmp(res->on, "on"))
6869 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6872 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6875 /* check the return value and print it if is < 0 */
6877 printf("mirror rule add error: (%s)\n", strerror(-ret));
6881 cmdline_parse_inst_t cmd_set_mirror_link = {
6882 .f = cmd_set_mirror_link_parsed,
6884 .help_str = "set port X mirror-rule Y uplink-mirror|"
6885 "downlink-mirror dst-pool Z on|off",
6887 (void *)&cmd_mirror_link_set,
6888 (void *)&cmd_mirror_link_port,
6889 (void *)&cmd_mirror_link_portid,
6890 (void *)&cmd_mirror_link_mirror,
6891 (void *)&cmd_mirror_link_ruleid,
6892 (void *)&cmd_mirror_link_what,
6893 (void *)&cmd_mirror_link_dstpool,
6894 (void *)&cmd_mirror_link_poolid,
6895 (void *)&cmd_mirror_link_on,
6900 /* *** RESET VM MIRROR RULE *** */
6901 struct cmd_rm_mirror_rule_result {
6902 cmdline_fixed_string_t reset;
6903 cmdline_fixed_string_t port;
6905 cmdline_fixed_string_t mirror;
6909 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6910 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6912 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6913 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6915 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6916 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6918 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6919 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6920 mirror, "mirror-rule");
6921 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6922 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6926 cmd_reset_mirror_rule_parsed(void *parsed_result,
6927 __attribute__((unused)) struct cmdline *cl,
6928 __attribute__((unused)) void *data)
6931 struct cmd_set_mirror_link_result *res = parsed_result;
6933 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6935 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6938 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6939 .f = cmd_reset_mirror_rule_parsed,
6941 .help_str = "reset port X mirror-rule Y",
6943 (void *)&cmd_rm_mirror_rule_reset,
6944 (void *)&cmd_rm_mirror_rule_port,
6945 (void *)&cmd_rm_mirror_rule_portid,
6946 (void *)&cmd_rm_mirror_rule_mirror,
6947 (void *)&cmd_rm_mirror_rule_ruleid,
6952 /* ******************************************************************************** */
6954 struct cmd_dump_result {
6955 cmdline_fixed_string_t dump;
6959 dump_struct_sizes(void)
6961 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6962 DUMP_SIZE(struct rte_mbuf);
6963 DUMP_SIZE(struct rte_mempool);
6964 DUMP_SIZE(struct rte_ring);
6968 static void cmd_dump_parsed(void *parsed_result,
6969 __attribute__((unused)) struct cmdline *cl,
6970 __attribute__((unused)) void *data)
6972 struct cmd_dump_result *res = parsed_result;
6974 if (!strcmp(res->dump, "dump_physmem"))
6975 rte_dump_physmem_layout(stdout);
6976 else if (!strcmp(res->dump, "dump_memzone"))
6977 rte_memzone_dump(stdout);
6978 else if (!strcmp(res->dump, "dump_log_history"))
6979 rte_log_dump_history(stdout);
6980 else if (!strcmp(res->dump, "dump_struct_sizes"))
6981 dump_struct_sizes();
6982 else if (!strcmp(res->dump, "dump_ring"))
6983 rte_ring_list_dump(stdout);
6984 else if (!strcmp(res->dump, "dump_mempool"))
6985 rte_mempool_list_dump(stdout);
6986 else if (!strcmp(res->dump, "dump_devargs"))
6987 rte_eal_devargs_dump(stdout);
6990 cmdline_parse_token_string_t cmd_dump_dump =
6991 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
6995 "dump_struct_sizes#"
7000 cmdline_parse_inst_t cmd_dump = {
7001 .f = cmd_dump_parsed, /* function to call */
7002 .data = NULL, /* 2nd arg of func */
7003 .help_str = "dump status",
7004 .tokens = { /* token list, NULL terminated */
7005 (void *)&cmd_dump_dump,
7010 /* ******************************************************************************** */
7012 struct cmd_dump_one_result {
7013 cmdline_fixed_string_t dump;
7014 cmdline_fixed_string_t name;
7017 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7018 __attribute__((unused)) void *data)
7020 struct cmd_dump_one_result *res = parsed_result;
7022 if (!strcmp(res->dump, "dump_ring")) {
7024 r = rte_ring_lookup(res->name);
7026 cmdline_printf(cl, "Cannot find ring\n");
7029 rte_ring_dump(stdout, r);
7030 } else if (!strcmp(res->dump, "dump_mempool")) {
7031 struct rte_mempool *mp;
7032 mp = rte_mempool_lookup(res->name);
7034 cmdline_printf(cl, "Cannot find mempool\n");
7037 rte_mempool_dump(stdout, mp);
7041 cmdline_parse_token_string_t cmd_dump_one_dump =
7042 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7043 "dump_ring#dump_mempool");
7045 cmdline_parse_token_string_t cmd_dump_one_name =
7046 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7048 cmdline_parse_inst_t cmd_dump_one = {
7049 .f = cmd_dump_one_parsed, /* function to call */
7050 .data = NULL, /* 2nd arg of func */
7051 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7052 .tokens = { /* token list, NULL terminated */
7053 (void *)&cmd_dump_one_dump,
7054 (void *)&cmd_dump_one_name,
7059 /* *** ADD/REMOVE an ethertype FILTER *** */
7060 struct cmd_ethertype_filter_result {
7061 cmdline_fixed_string_t filter;
7063 cmdline_fixed_string_t ethertype;
7064 uint16_t ethertype_value;
7065 cmdline_fixed_string_t priority;
7066 cmdline_fixed_string_t priority_en;
7067 uint8_t priority_value;
7068 cmdline_fixed_string_t queue;
7070 cmdline_fixed_string_t index;
7071 uint16_t index_value;
7075 cmd_ethertype_filter_parsed(void *parsed_result,
7076 __attribute__((unused)) struct cmdline *cl,
7077 __attribute__((unused)) void *data)
7080 struct cmd_ethertype_filter_result *res = parsed_result;
7081 struct rte_ethertype_filter filter;
7083 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7084 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7085 filter.priority = res->priority_value;
7087 if (!strcmp(res->priority_en, "enable"))
7088 filter.priority_en = 1;
7089 if (!strcmp(res->filter, "add_ethertype_filter"))
7090 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7092 &filter, res->queue_id);
7093 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7094 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7096 else if (!strcmp(res->filter, "get_ethertype_filter"))
7097 get_ethertype_filter(res->port_id, res->index_value);
7100 printf("ethertype filter setting error: (%s)\n",
7104 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7105 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7107 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7108 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7109 ethertype, "ethertype");
7110 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7111 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7112 ethertype_value, UINT16);
7113 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7114 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7115 priority, "priority");
7116 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7117 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7118 priority_en, "enable#disable");
7119 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7120 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7121 priority_value, UINT8);
7122 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7123 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7125 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7126 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7128 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7129 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7131 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7132 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7133 index_value, UINT16);
7134 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7135 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7136 filter, "add_ethertype_filter");
7137 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7138 .f = cmd_ethertype_filter_parsed,
7140 .help_str = "add an ethertype filter",
7142 (void *)&cmd_ethertype_filter_add_filter,
7143 (void *)&cmd_ethertype_filter_port_id,
7144 (void *)&cmd_ethertype_filter_ethertype,
7145 (void *)&cmd_ethertype_filter_ethertype_value,
7146 (void *)&cmd_ethertype_filter_priority,
7147 (void *)&cmd_ethertype_filter_priority_en,
7148 (void *)&cmd_ethertype_filter_priority_value,
7149 (void *)&cmd_ethertype_filter_queue,
7150 (void *)&cmd_ethertype_filter_queue_id,
7151 (void *)&cmd_ethertype_filter_index,
7152 (void *)&cmd_ethertype_filter_index_value,
7157 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7158 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7159 filter, "remove_ethertype_filter");
7160 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7161 .f = cmd_ethertype_filter_parsed,
7163 .help_str = "remove an ethertype filter",
7165 (void *)&cmd_ethertype_filter_remove_filter,
7166 (void *)&cmd_ethertype_filter_port_id,
7167 (void *)&cmd_ethertype_filter_index,
7168 (void *)&cmd_ethertype_filter_index_value,
7172 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7173 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7174 filter, "get_ethertype_filter");
7175 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7176 .f = cmd_ethertype_filter_parsed,
7178 .help_str = "get an ethertype filter",
7180 (void *)&cmd_ethertype_filter_get_filter,
7181 (void *)&cmd_ethertype_filter_port_id,
7182 (void *)&cmd_ethertype_filter_index,
7183 (void *)&cmd_ethertype_filter_index_value,
7188 /* *** set SYN filter *** */
7189 struct cmd_set_syn_filter_result {
7190 cmdline_fixed_string_t filter;
7192 cmdline_fixed_string_t priority;
7193 cmdline_fixed_string_t high;
7194 cmdline_fixed_string_t queue;
7199 cmd_set_syn_filter_parsed(void *parsed_result,
7200 __attribute__((unused)) struct cmdline *cl,
7201 __attribute__((unused)) void *data)
7204 struct cmd_set_syn_filter_result *res = parsed_result;
7205 struct rte_syn_filter filter;
7207 if (!strcmp(res->filter, "add_syn_filter")) {
7208 if (!strcmp(res->high, "high"))
7212 ret = rte_eth_dev_add_syn_filter(res->port_id,
7213 &filter, res->queue_id);
7214 } else if (!strcmp(res->filter, "remove_syn_filter"))
7215 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7216 else if (!strcmp(res->filter, "get_syn_filter"))
7217 get_syn_filter(res->port_id);
7219 printf("syn filter setting error: (%s)\n", strerror(-ret));
7222 cmdline_parse_token_num_t cmd_syn_filter_portid =
7223 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7225 cmdline_parse_token_string_t cmd_syn_filter_priority =
7226 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7227 priority, "priority");
7228 cmdline_parse_token_string_t cmd_syn_filter_high =
7229 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7231 cmdline_parse_token_string_t cmd_syn_filter_queue =
7232 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7234 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7235 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7237 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7238 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7239 filter, "add_syn_filter");
7240 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7241 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7242 filter, "remove_syn_filter");
7243 cmdline_parse_inst_t cmd_add_syn_filter = {
7244 .f = cmd_set_syn_filter_parsed,
7246 .help_str = "add syn filter",
7248 (void *)&cmd_syn_filter_add_filter,
7249 (void *)&cmd_syn_filter_portid,
7250 (void *)&cmd_syn_filter_priority,
7251 (void *)&cmd_syn_filter_high,
7252 (void *)&cmd_syn_filter_queue,
7253 (void *)&cmd_syn_filter_queue_id,
7257 cmdline_parse_inst_t cmd_remove_syn_filter = {
7258 .f = cmd_set_syn_filter_parsed,
7260 .help_str = "remove syn filter",
7262 (void *)&cmd_syn_filter_remove_filter,
7263 (void *)&cmd_syn_filter_portid,
7268 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7269 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7270 filter, "get_syn_filter");
7272 cmdline_parse_inst_t cmd_get_syn_filter = {
7273 .f = cmd_set_syn_filter_parsed,
7275 .help_str = "get syn filter",
7277 (void *)&cmd_syn_filter_get_filter,
7278 (void *)&cmd_syn_filter_portid,
7283 /* *** ADD/REMOVE A 2tuple FILTER *** */
7284 struct cmd_2tuple_filter_result {
7285 cmdline_fixed_string_t filter;
7287 cmdline_fixed_string_t protocol;
7288 uint8_t protocol_value;
7289 uint8_t protocol_mask;
7290 cmdline_fixed_string_t dst_port;
7291 uint16_t dst_port_value;
7292 uint16_t dst_port_mask;
7293 cmdline_fixed_string_t flags;
7294 uint8_t flags_value;
7295 cmdline_fixed_string_t priority;
7296 uint8_t priority_value;
7297 cmdline_fixed_string_t queue;
7299 cmdline_fixed_string_t index;
7300 uint16_t index_value;
7304 cmd_2tuple_filter_parsed(void *parsed_result,
7305 __attribute__((unused)) struct cmdline *cl,
7306 __attribute__((unused)) void *data)
7309 struct rte_2tuple_filter filter;
7310 struct cmd_2tuple_filter_result *res = parsed_result;
7312 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7314 if (!strcmp(res->filter, "add_2tuple_filter")) {
7315 /* need convert to big endian. */
7316 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7317 filter.protocol = res->protocol_value;
7318 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7319 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7320 filter.priority = res->priority_value;
7321 filter.tcp_flags = res->flags_value;
7322 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7323 res->index_value, &filter, res->queue_id);
7324 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7325 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7327 else if (!strcmp(res->filter, "get_2tuple_filter"))
7328 get_2tuple_filter(res->port_id, res->index_value);
7331 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7334 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7335 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7337 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7338 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7339 protocol, "protocol");
7340 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7341 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7342 protocol_value, UINT8);
7343 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7344 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7345 protocol_mask, UINT8);
7346 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7347 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7348 dst_port, "dst_port");
7349 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7350 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7351 dst_port_value, UINT16);
7352 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7353 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7354 dst_port_mask, UINT16);
7355 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7356 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7358 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7359 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7360 flags_value, UINT8);
7361 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7362 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7363 priority, "priority");
7364 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7365 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7366 priority_value, UINT8);
7367 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7368 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7370 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7371 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7373 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7374 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7376 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7377 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7378 index_value, UINT16);
7379 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7380 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7381 filter, "add_2tuple_filter");
7382 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7383 .f = cmd_2tuple_filter_parsed,
7385 .help_str = "add a 2tuple filter",
7387 (void *)&cmd_2tuple_filter_add_filter,
7388 (void *)&cmd_2tuple_filter_port_id,
7389 (void *)&cmd_2tuple_filter_protocol,
7390 (void *)&cmd_2tuple_filter_protocol_value,
7391 (void *)&cmd_2tuple_filter_protocol_mask,
7392 (void *)&cmd_2tuple_filter_dst_port,
7393 (void *)&cmd_2tuple_filter_dst_port_value,
7394 (void *)&cmd_2tuple_filter_dst_port_mask,
7395 (void *)&cmd_2tuple_filter_flags,
7396 (void *)&cmd_2tuple_filter_flags_value,
7397 (void *)&cmd_2tuple_filter_priority,
7398 (void *)&cmd_2tuple_filter_priority_value,
7399 (void *)&cmd_2tuple_filter_queue,
7400 (void *)&cmd_2tuple_filter_queue_id,
7401 (void *)&cmd_2tuple_filter_index,
7402 (void *)&cmd_2tuple_filter_index_value,
7407 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7408 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7409 filter, "remove_2tuple_filter");
7410 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7411 .f = cmd_2tuple_filter_parsed,
7413 .help_str = "remove a 2tuple filter",
7415 (void *)&cmd_2tuple_filter_remove_filter,
7416 (void *)&cmd_2tuple_filter_port_id,
7417 (void *)&cmd_2tuple_filter_index,
7418 (void *)&cmd_2tuple_filter_index_value,
7422 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7423 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7424 filter, "get_2tuple_filter");
7425 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7426 .f = cmd_2tuple_filter_parsed,
7428 .help_str = "get a 2tuple filter",
7430 (void *)&cmd_2tuple_filter_get_filter,
7431 (void *)&cmd_2tuple_filter_port_id,
7432 (void *)&cmd_2tuple_filter_index,
7433 (void *)&cmd_2tuple_filter_index_value,
7438 /* *** ADD/REMOVE A 5tuple FILTER *** */
7439 struct cmd_5tuple_filter_result {
7440 cmdline_fixed_string_t filter;
7442 cmdline_fixed_string_t dst_ip;
7443 cmdline_ipaddr_t dst_ip_value;
7444 cmdline_fixed_string_t src_ip;
7445 cmdline_ipaddr_t src_ip_value;
7446 cmdline_fixed_string_t dst_port;
7447 uint16_t dst_port_value;
7448 cmdline_fixed_string_t src_port;
7449 uint16_t src_port_value;
7450 cmdline_fixed_string_t protocol;
7451 uint8_t protocol_value;
7452 cmdline_fixed_string_t mask;
7454 cmdline_fixed_string_t flags;
7455 uint8_t flags_value;
7456 cmdline_fixed_string_t priority;
7457 uint8_t priority_value;
7458 cmdline_fixed_string_t queue;
7460 cmdline_fixed_string_t index;
7461 uint16_t index_value;
7465 cmd_5tuple_filter_parsed(void *parsed_result,
7466 __attribute__((unused)) struct cmdline *cl,
7467 __attribute__((unused)) void *data)
7470 struct rte_5tuple_filter filter;
7471 struct cmd_5tuple_filter_result *res = parsed_result;
7473 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7475 if (!strcmp(res->filter, "add_5tuple_filter")) {
7476 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7477 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7478 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7479 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7480 filter.protocol = res->protocol_value;
7481 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7482 filter.priority = res->priority_value;
7483 filter.tcp_flags = res->flags_value;
7485 if (res->dst_ip_value.family == AF_INET)
7486 /* no need to convert, already big endian. */
7487 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7489 if (filter.dst_ip_mask == 0) {
7490 printf("can not support ipv6 involved compare.\n");
7496 if (res->src_ip_value.family == AF_INET)
7497 /* no need to convert, already big endian. */
7498 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7500 if (filter.src_ip_mask == 0) {
7501 printf("can not support ipv6 involved compare.\n");
7506 /* need convert to big endian. */
7507 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7508 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7510 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7511 res->index_value, &filter, res->queue_id);
7512 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7513 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7515 else if (!strcmp(res->filter, "get_5tuple_filter"))
7516 get_5tuple_filter(res->port_id, res->index_value);
7518 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7522 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7523 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7525 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7526 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7528 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7529 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7531 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7532 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7534 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7535 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7537 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7538 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7539 dst_port, "dst_port");
7540 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7541 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7542 dst_port_value, UINT16);
7543 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7544 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7545 src_port, "src_port");
7546 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7547 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7548 src_port_value, UINT16);
7549 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7550 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7551 protocol, "protocol");
7552 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7553 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7554 protocol_value, UINT8);
7555 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7556 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7558 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7559 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7561 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7562 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7564 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7565 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7566 flags_value, UINT8);
7567 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7568 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7569 priority, "priority");
7570 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7571 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7572 priority_value, UINT8);
7573 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7574 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7576 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7577 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7579 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7580 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7582 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7583 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7584 index_value, UINT16);
7586 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7587 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7588 filter, "add_5tuple_filter");
7589 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7590 .f = cmd_5tuple_filter_parsed,
7592 .help_str = "add a 5tuple filter",
7594 (void *)&cmd_5tuple_filter_add_filter,
7595 (void *)&cmd_5tuple_filter_port_id,
7596 (void *)&cmd_5tuple_filter_dst_ip,
7597 (void *)&cmd_5tuple_filter_dst_ip_value,
7598 (void *)&cmd_5tuple_filter_src_ip,
7599 (void *)&cmd_5tuple_filter_src_ip_value,
7600 (void *)&cmd_5tuple_filter_dst_port,
7601 (void *)&cmd_5tuple_filter_dst_port_value,
7602 (void *)&cmd_5tuple_filter_src_port,
7603 (void *)&cmd_5tuple_filter_src_port_value,
7604 (void *)&cmd_5tuple_filter_protocol,
7605 (void *)&cmd_5tuple_filter_protocol_value,
7606 (void *)&cmd_5tuple_filter_mask,
7607 (void *)&cmd_5tuple_filter_mask_value,
7608 (void *)&cmd_5tuple_filter_flags,
7609 (void *)&cmd_5tuple_filter_flags_value,
7610 (void *)&cmd_5tuple_filter_priority,
7611 (void *)&cmd_5tuple_filter_priority_value,
7612 (void *)&cmd_5tuple_filter_queue,
7613 (void *)&cmd_5tuple_filter_queue_id,
7614 (void *)&cmd_5tuple_filter_index,
7615 (void *)&cmd_5tuple_filter_index_value,
7620 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7621 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7622 filter, "remove_5tuple_filter");
7623 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7624 .f = cmd_5tuple_filter_parsed,
7626 .help_str = "remove a 5tuple filter",
7628 (void *)&cmd_5tuple_filter_remove_filter,
7629 (void *)&cmd_5tuple_filter_port_id,
7630 (void *)&cmd_5tuple_filter_index,
7631 (void *)&cmd_5tuple_filter_index_value,
7636 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7637 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7638 filter, "get_5tuple_filter");
7639 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7640 .f = cmd_5tuple_filter_parsed,
7642 .help_str = "get a 5tuple filter",
7644 (void *)&cmd_5tuple_filter_get_filter,
7645 (void *)&cmd_5tuple_filter_port_id,
7646 (void *)&cmd_5tuple_filter_index,
7647 (void *)&cmd_5tuple_filter_index_value,
7652 /* *** ADD/REMOVE A flex FILTER *** */
7653 struct cmd_flex_filter_result {
7654 cmdline_fixed_string_t filter;
7656 cmdline_fixed_string_t len;
7658 cmdline_fixed_string_t bytes;
7659 cmdline_fixed_string_t bytes_value;
7660 cmdline_fixed_string_t mask;
7661 cmdline_fixed_string_t mask_value;
7662 cmdline_fixed_string_t priority;
7663 uint8_t priority_value;
7664 cmdline_fixed_string_t queue;
7666 cmdline_fixed_string_t index;
7667 uint16_t index_value;
7670 static int xdigit2val(unsigned char c)
7675 else if (isupper(c))
7683 cmd_flex_filter_parsed(void *parsed_result,
7684 __attribute__((unused)) struct cmdline *cl,
7685 __attribute__((unused)) void *data)
7688 struct rte_flex_filter filter;
7689 struct cmd_flex_filter_result *res = parsed_result;
7690 char *bytes_ptr, *mask_ptr;
7698 if (!strcmp(res->filter, "add_flex_filter")) {
7699 if (res->len_value > 128) {
7700 printf("the len exceed the max length 128\n");
7703 memset(&filter, 0, sizeof(struct rte_flex_filter));
7704 filter.len = res->len_value;
7705 filter.priority = res->priority_value;
7706 bytes_ptr = res->bytes_value;
7707 mask_ptr = res->mask_value;
7710 /* translate bytes string to uint_32 array. */
7711 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7712 (bytes_ptr[1] == 'X')))
7714 len = strnlen(bytes_ptr, res->len_value * 2);
7715 if (len == 0 || (len % 8 != 0)) {
7716 printf("please check len and bytes input\n");
7719 for (i = 0; i < len; i++) {
7721 if (isxdigit(c) == 0) {
7722 /* invalid characters. */
7723 printf("invalid input\n");
7726 val = xdigit2val(c);
7730 dword |= byte << (4 * mod - 4);
7735 filter.dwords[j] = dword;
7736 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7742 /* translate mask string to uint8_t array. */
7744 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7745 (mask_ptr[1] == 'X')))
7747 len = strnlen(mask_ptr, (res->len_value+3)/4);
7749 printf("invalid input\n");
7752 for (i = 0; i < len; i++) {
7754 if (isxdigit(c) == 0) {
7755 /* invalid characters. */
7756 printf("invalid input\n");
7759 val = xdigit2val(c);
7760 hex |= (uint8_t)(val & 0x8) >> 3;
7761 hex |= (uint8_t)(val & 0x4) >> 1;
7762 hex |= (uint8_t)(val & 0x2) << 1;
7763 hex |= (uint8_t)(val & 0x1) << 3;
7766 filter.mask[j] = byte;
7767 printf("mask[%d]:%02x ", j, filter.mask[j]);
7775 printf("call function rte_eth_dev_add_flex_filter: "
7776 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7777 res->index_value, res->queue_id,
7778 filter.len, filter.priority);
7779 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7780 &filter, res->queue_id);
7782 } else if (!strcmp(res->filter, "remove_flex_filter"))
7783 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7785 else if (!strcmp(res->filter, "get_flex_filter"))
7786 get_flex_filter(res->port_id, res->index_value);
7789 printf("flex filter setting error: (%s)\n", strerror(-ret));
7792 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7793 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7795 cmdline_parse_token_string_t cmd_flex_filter_len =
7796 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7798 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7799 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7801 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7802 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7804 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7805 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7807 cmdline_parse_token_string_t cmd_flex_filter_mask =
7808 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7810 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7811 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7813 cmdline_parse_token_string_t cmd_flex_filter_priority =
7814 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7815 priority, "priority");
7816 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7817 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7818 priority_value, UINT8);
7819 cmdline_parse_token_string_t cmd_flex_filter_queue =
7820 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7822 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7823 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7825 cmdline_parse_token_string_t cmd_flex_filter_index =
7826 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7828 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7829 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7830 index_value, UINT16);
7831 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7832 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7833 filter, "add_flex_filter");
7834 cmdline_parse_inst_t cmd_add_flex_filter = {
7835 .f = cmd_flex_filter_parsed,
7837 .help_str = "add a flex filter",
7839 (void *)&cmd_flex_filter_add_filter,
7840 (void *)&cmd_flex_filter_port_id,
7841 (void *)&cmd_flex_filter_len,
7842 (void *)&cmd_flex_filter_len_value,
7843 (void *)&cmd_flex_filter_bytes,
7844 (void *)&cmd_flex_filter_bytes_value,
7845 (void *)&cmd_flex_filter_mask,
7846 (void *)&cmd_flex_filter_mask_value,
7847 (void *)&cmd_flex_filter_priority,
7848 (void *)&cmd_flex_filter_priority_value,
7849 (void *)&cmd_flex_filter_queue,
7850 (void *)&cmd_flex_filter_queue_id,
7851 (void *)&cmd_flex_filter_index,
7852 (void *)&cmd_flex_filter_index_value,
7857 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7858 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7859 filter, "remove_flex_filter");
7860 cmdline_parse_inst_t cmd_remove_flex_filter = {
7861 .f = cmd_flex_filter_parsed,
7863 .help_str = "remove a flex filter",
7865 (void *)&cmd_flex_filter_remove_filter,
7866 (void *)&cmd_flex_filter_port_id,
7867 (void *)&cmd_flex_filter_index,
7868 (void *)&cmd_flex_filter_index_value,
7873 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7874 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7875 filter, "get_flex_filter");
7876 cmdline_parse_inst_t cmd_get_flex_filter = {
7877 .f = cmd_flex_filter_parsed,
7879 .help_str = "get a flex filter",
7881 (void *)&cmd_flex_filter_get_filter,
7882 (void *)&cmd_flex_filter_port_id,
7883 (void *)&cmd_flex_filter_index,
7884 (void *)&cmd_flex_filter_index_value,
7889 /* ******************************************************************************** */
7891 /* list of instructions */
7892 cmdline_parse_ctx_t main_ctx[] = {
7893 (cmdline_parse_inst_t *)&cmd_help_brief,
7894 (cmdline_parse_inst_t *)&cmd_help_long,
7895 (cmdline_parse_inst_t *)&cmd_quit,
7896 (cmdline_parse_inst_t *)&cmd_showport,
7897 (cmdline_parse_inst_t *)&cmd_showportall,
7898 (cmdline_parse_inst_t *)&cmd_showcfg,
7899 (cmdline_parse_inst_t *)&cmd_start,
7900 (cmdline_parse_inst_t *)&cmd_start_tx_first,
7901 (cmdline_parse_inst_t *)&cmd_set_link_up,
7902 (cmdline_parse_inst_t *)&cmd_set_link_down,
7903 (cmdline_parse_inst_t *)&cmd_reset,
7904 (cmdline_parse_inst_t *)&cmd_set_numbers,
7905 (cmdline_parse_inst_t *)&cmd_set_txpkts,
7906 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
7907 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
7908 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
7909 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
7910 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
7911 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
7912 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
7913 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
7914 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
7915 (cmdline_parse_inst_t *)&cmd_set_link_check,
7916 #ifdef RTE_NIC_BYPASS
7917 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
7918 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
7919 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
7920 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
7922 #ifdef RTE_LIBRTE_PMD_BOND
7923 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
7924 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
7925 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
7926 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
7927 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
7928 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
7929 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
7930 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
7931 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
7933 (cmdline_parse_inst_t *)&cmd_vlan_offload,
7934 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
7935 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
7936 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
7937 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
7938 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
7939 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
7940 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
7941 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
7942 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
7943 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
7944 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
7945 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
7946 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
7947 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
7948 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
7949 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
7950 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
7951 (cmdline_parse_inst_t *)&cmd_config_dcb,
7952 (cmdline_parse_inst_t *)&cmd_read_reg,
7953 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
7954 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
7955 (cmdline_parse_inst_t *)&cmd_write_reg,
7956 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
7957 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
7958 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
7959 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
7960 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
7961 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
7962 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
7963 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
7964 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
7965 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
7966 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
7967 (cmdline_parse_inst_t *)&cmd_stop,
7968 (cmdline_parse_inst_t *)&cmd_mac_addr,
7969 (cmdline_parse_inst_t *)&cmd_set_qmap,
7970 (cmdline_parse_inst_t *)&cmd_operate_port,
7971 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
7972 (cmdline_parse_inst_t *)&cmd_config_speed_all,
7973 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
7974 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
7975 (cmdline_parse_inst_t *)&cmd_config_mtu,
7976 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
7977 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
7978 (cmdline_parse_inst_t *)&cmd_config_rss,
7979 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
7980 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
7981 (cmdline_parse_inst_t *)&cmd_showport_reta,
7982 (cmdline_parse_inst_t *)&cmd_config_burst,
7983 (cmdline_parse_inst_t *)&cmd_config_thresh,
7984 (cmdline_parse_inst_t *)&cmd_config_threshold,
7985 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
7986 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
7987 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
7988 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
7989 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
7990 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
7991 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
7992 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
7993 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
7994 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
7995 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
7996 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
7997 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
7998 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
7999 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8000 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8001 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8002 (cmdline_parse_inst_t *)&cmd_dump,
8003 (cmdline_parse_inst_t *)&cmd_dump_one,
8004 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8005 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8006 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8007 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8008 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8009 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8010 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8011 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8012 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8013 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8014 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8015 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8016 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8017 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8018 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8022 /* prompt function, called from main on MASTER lcore */
8028 /* initialize non-constant commands */
8029 cmd_set_fwd_mode_init();
8031 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8035 cmdline_interact(cl);
8036 cmdline_stdin_exit(cl);
8040 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8042 if (id < nb_ports) {
8043 /* check if need_reconfig has been set to 1 */
8044 if (ports[id].need_reconfig == 0)
8045 ports[id].need_reconfig = dev;
8046 /* check if need_reconfig_queues has been set to 1 */
8047 if (ports[id].need_reconfig_queues == 0)
8048 ports[id].need_reconfig_queues = queue;
8052 for (pid = 0; pid < nb_ports; pid++) {
8053 /* check if need_reconfig has been set to 1 */
8054 if (ports[pid].need_reconfig == 0)
8055 ports[pid].need_reconfig = dev;
8056 /* check if need_reconfig_queues has been set to 1 */
8057 if (ports[pid].need_reconfig_queues == 0)
8058 ports[pid].need_reconfig_queues = queue;
8063 #ifdef RTE_NIC_BYPASS
8065 bypass_is_supported(portid_t port_id)
8067 struct rte_port *port;
8068 struct rte_pci_id *pci_id;
8070 if (port_id >= nb_ports) {
8071 printf("\tPort id must be less than %d.\n", nb_ports);
8075 /* Get the device id. */
8076 port = &ports[port_id];
8077 pci_id = &port->dev_info.pci_dev->id;
8079 /* Check if NIC supports bypass. */
8080 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8084 printf("\tBypass not supported for port_id = %d.\n", port_id);