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"
701 "flow_director_filter (port_id) (add|del)"
702 " flow (ip4|ip4-frag|ip6|ip6-frag)"
703 " src (src_ip_address) dst (dst_ip_address)"
704 " flexbytes (flexbytes_value)"
705 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
706 " Add/Del an IP type flow director filter.\n\n"
708 "flow_director_filter (port_id) (add|del)"
709 " flow (udp4|tcp4|udp6|tcp6)"
710 " src (src_ip_address) (src_port)"
711 " dst (dst_ip_address) (dst_port)"
712 " flexbytes (flexbytes_value)"
713 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
714 " Add/Del an UDP/TCP type flow director filter.\n\n"
716 "flow_director_filter (port_id) (add|del)"
717 " flow (sctp4|sctp6)"
718 " src (src_ip_address) dst (dst_ip_address)"
719 " tag (verification_tag)"
720 " flexbytes (flexbytes_value) (drop|fwd)"
721 " queue (queue_id) fd_id (fd_id_value)\n"
722 " Add/Del a SCTP type flow director filter.\n\n"
724 "flush_flow_director (port_id)\n"
725 " Flush all flow director entries of a device.\n\n"
727 "flow_director_flex_mask (port_id)"
728 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
730 " Configure mask of flex payload.\n\n"
735 cmdline_parse_token_string_t cmd_help_long_help =
736 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
738 cmdline_parse_token_string_t cmd_help_long_section =
739 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
740 "all#control#display#config#flowdir#"
741 "ports#registers#filters");
743 cmdline_parse_inst_t cmd_help_long = {
744 .f = cmd_help_long_parsed,
746 .help_str = "show help",
748 (void *)&cmd_help_long_help,
749 (void *)&cmd_help_long_section,
755 /* *** start/stop/close all ports *** */
756 struct cmd_operate_port_result {
757 cmdline_fixed_string_t keyword;
758 cmdline_fixed_string_t name;
759 cmdline_fixed_string_t value;
762 static void cmd_operate_port_parsed(void *parsed_result,
763 __attribute__((unused)) struct cmdline *cl,
764 __attribute__((unused)) void *data)
766 struct cmd_operate_port_result *res = parsed_result;
768 if (!strcmp(res->name, "start"))
769 start_port(RTE_PORT_ALL);
770 else if (!strcmp(res->name, "stop"))
771 stop_port(RTE_PORT_ALL);
772 else if (!strcmp(res->name, "close"))
773 close_port(RTE_PORT_ALL);
775 printf("Unknown parameter\n");
778 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
779 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
781 cmdline_parse_token_string_t cmd_operate_port_all_port =
782 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
784 cmdline_parse_token_string_t cmd_operate_port_all_all =
785 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
787 cmdline_parse_inst_t cmd_operate_port = {
788 .f = cmd_operate_port_parsed,
790 .help_str = "port start|stop|close all: start/stop/close all ports",
792 (void *)&cmd_operate_port_all_cmd,
793 (void *)&cmd_operate_port_all_port,
794 (void *)&cmd_operate_port_all_all,
799 /* *** start/stop/close specific port *** */
800 struct cmd_operate_specific_port_result {
801 cmdline_fixed_string_t keyword;
802 cmdline_fixed_string_t name;
806 static void cmd_operate_specific_port_parsed(void *parsed_result,
807 __attribute__((unused)) struct cmdline *cl,
808 __attribute__((unused)) void *data)
810 struct cmd_operate_specific_port_result *res = parsed_result;
812 if (!strcmp(res->name, "start"))
813 start_port(res->value);
814 else if (!strcmp(res->name, "stop"))
815 stop_port(res->value);
816 else if (!strcmp(res->name, "close"))
817 close_port(res->value);
819 printf("Unknown parameter\n");
822 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
823 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
825 cmdline_parse_token_string_t cmd_operate_specific_port_port =
826 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
827 name, "start#stop#close");
828 cmdline_parse_token_num_t cmd_operate_specific_port_id =
829 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
832 cmdline_parse_inst_t cmd_operate_specific_port = {
833 .f = cmd_operate_specific_port_parsed,
835 .help_str = "port start|stop|close X: start/stop/close port X",
837 (void *)&cmd_operate_specific_port_cmd,
838 (void *)&cmd_operate_specific_port_port,
839 (void *)&cmd_operate_specific_port_id,
844 /* *** configure speed for all ports *** */
845 struct cmd_config_speed_all {
846 cmdline_fixed_string_t port;
847 cmdline_fixed_string_t keyword;
848 cmdline_fixed_string_t all;
849 cmdline_fixed_string_t item1;
850 cmdline_fixed_string_t item2;
851 cmdline_fixed_string_t value1;
852 cmdline_fixed_string_t value2;
856 cmd_config_speed_all_parsed(void *parsed_result,
857 __attribute__((unused)) struct cmdline *cl,
858 __attribute__((unused)) void *data)
860 struct cmd_config_speed_all *res = parsed_result;
861 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
862 uint16_t link_duplex = 0;
865 if (!all_ports_stopped()) {
866 printf("Please stop all ports first\n");
870 if (!strcmp(res->value1, "10"))
871 link_speed = ETH_LINK_SPEED_10;
872 else if (!strcmp(res->value1, "100"))
873 link_speed = ETH_LINK_SPEED_100;
874 else if (!strcmp(res->value1, "1000"))
875 link_speed = ETH_LINK_SPEED_1000;
876 else if (!strcmp(res->value1, "10000"))
877 link_speed = ETH_LINK_SPEED_10G;
878 else if (!strcmp(res->value1, "40000"))
879 link_speed = ETH_LINK_SPEED_40G;
880 else if (!strcmp(res->value1, "auto"))
881 link_speed = ETH_LINK_SPEED_AUTONEG;
883 printf("Unknown parameter\n");
887 if (!strcmp(res->value2, "half"))
888 link_duplex = ETH_LINK_HALF_DUPLEX;
889 else if (!strcmp(res->value2, "full"))
890 link_duplex = ETH_LINK_FULL_DUPLEX;
891 else if (!strcmp(res->value2, "auto"))
892 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
894 printf("Unknown parameter\n");
898 for (pid = 0; pid < nb_ports; pid++) {
899 ports[pid].dev_conf.link_speed = link_speed;
900 ports[pid].dev_conf.link_duplex = link_duplex;
903 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
906 cmdline_parse_token_string_t cmd_config_speed_all_port =
907 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
908 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
909 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
911 cmdline_parse_token_string_t cmd_config_speed_all_all =
912 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
913 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
914 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
915 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
917 "10#100#1000#10000#40000#auto");
918 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
919 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
920 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
921 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
924 cmdline_parse_inst_t cmd_config_speed_all = {
925 .f = cmd_config_speed_all_parsed,
927 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
930 (void *)&cmd_config_speed_all_port,
931 (void *)&cmd_config_speed_all_keyword,
932 (void *)&cmd_config_speed_all_all,
933 (void *)&cmd_config_speed_all_item1,
934 (void *)&cmd_config_speed_all_value1,
935 (void *)&cmd_config_speed_all_item2,
936 (void *)&cmd_config_speed_all_value2,
941 /* *** configure speed for specific port *** */
942 struct cmd_config_speed_specific {
943 cmdline_fixed_string_t port;
944 cmdline_fixed_string_t keyword;
946 cmdline_fixed_string_t item1;
947 cmdline_fixed_string_t item2;
948 cmdline_fixed_string_t value1;
949 cmdline_fixed_string_t value2;
953 cmd_config_speed_specific_parsed(void *parsed_result,
954 __attribute__((unused)) struct cmdline *cl,
955 __attribute__((unused)) void *data)
957 struct cmd_config_speed_specific *res = parsed_result;
958 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
959 uint16_t link_duplex = 0;
961 if (!all_ports_stopped()) {
962 printf("Please stop all ports first\n");
966 if (res->id >= nb_ports) {
967 printf("Port id %d must be less than %d\n", res->id, nb_ports);
971 if (!strcmp(res->value1, "10"))
972 link_speed = ETH_LINK_SPEED_10;
973 else if (!strcmp(res->value1, "100"))
974 link_speed = ETH_LINK_SPEED_100;
975 else if (!strcmp(res->value1, "1000"))
976 link_speed = ETH_LINK_SPEED_1000;
977 else if (!strcmp(res->value1, "10000"))
978 link_speed = ETH_LINK_SPEED_10000;
979 else if (!strcmp(res->value1, "40000"))
980 link_speed = ETH_LINK_SPEED_40G;
981 else if (!strcmp(res->value1, "auto"))
982 link_speed = ETH_LINK_SPEED_AUTONEG;
984 printf("Unknown parameter\n");
988 if (!strcmp(res->value2, "half"))
989 link_duplex = ETH_LINK_HALF_DUPLEX;
990 else if (!strcmp(res->value2, "full"))
991 link_duplex = ETH_LINK_FULL_DUPLEX;
992 else if (!strcmp(res->value2, "auto"))
993 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
995 printf("Unknown parameter\n");
999 ports[res->id].dev_conf.link_speed = link_speed;
1000 ports[res->id].dev_conf.link_duplex = link_duplex;
1002 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1006 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1007 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1009 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1010 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1012 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1013 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1014 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1015 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1017 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1018 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1019 "10#100#1000#10000#40000#auto");
1020 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1021 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1023 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1024 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1027 cmdline_parse_inst_t cmd_config_speed_specific = {
1028 .f = cmd_config_speed_specific_parsed,
1030 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1033 (void *)&cmd_config_speed_specific_port,
1034 (void *)&cmd_config_speed_specific_keyword,
1035 (void *)&cmd_config_speed_specific_id,
1036 (void *)&cmd_config_speed_specific_item1,
1037 (void *)&cmd_config_speed_specific_value1,
1038 (void *)&cmd_config_speed_specific_item2,
1039 (void *)&cmd_config_speed_specific_value2,
1044 /* *** configure txq/rxq, txd/rxd *** */
1045 struct cmd_config_rx_tx {
1046 cmdline_fixed_string_t port;
1047 cmdline_fixed_string_t keyword;
1048 cmdline_fixed_string_t all;
1049 cmdline_fixed_string_t name;
1054 cmd_config_rx_tx_parsed(void *parsed_result,
1055 __attribute__((unused)) struct cmdline *cl,
1056 __attribute__((unused)) void *data)
1058 struct cmd_config_rx_tx *res = parsed_result;
1060 if (!all_ports_stopped()) {
1061 printf("Please stop all ports first\n");
1065 if (!strcmp(res->name, "rxq")) {
1066 if (res->value <= 0) {
1067 printf("rxq %d invalid - must be > 0\n", res->value);
1070 nb_rxq = res->value;
1072 else if (!strcmp(res->name, "txq")) {
1073 if (res->value <= 0) {
1074 printf("txq %d invalid - must be > 0\n", res->value);
1077 nb_txq = res->value;
1079 else if (!strcmp(res->name, "rxd")) {
1080 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1081 printf("rxd %d invalid - must be > 0 && <= %d\n",
1082 res->value, RTE_TEST_RX_DESC_MAX);
1085 nb_rxd = res->value;
1086 } else if (!strcmp(res->name, "txd")) {
1087 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1088 printf("txd %d invalid - must be > 0 && <= %d\n",
1089 res->value, RTE_TEST_TX_DESC_MAX);
1092 nb_txd = res->value;
1094 printf("Unknown parameter\n");
1100 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1103 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1104 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1105 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1106 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1107 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1108 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1109 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1112 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1113 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1115 cmdline_parse_inst_t cmd_config_rx_tx = {
1116 .f = cmd_config_rx_tx_parsed,
1118 .help_str = "port config all rxq|txq|rxd|txd value",
1120 (void *)&cmd_config_rx_tx_port,
1121 (void *)&cmd_config_rx_tx_keyword,
1122 (void *)&cmd_config_rx_tx_all,
1123 (void *)&cmd_config_rx_tx_name,
1124 (void *)&cmd_config_rx_tx_value,
1129 /* *** config max packet length *** */
1130 struct cmd_config_max_pkt_len_result {
1131 cmdline_fixed_string_t port;
1132 cmdline_fixed_string_t keyword;
1133 cmdline_fixed_string_t all;
1134 cmdline_fixed_string_t name;
1139 cmd_config_max_pkt_len_parsed(void *parsed_result,
1140 __attribute__((unused)) struct cmdline *cl,
1141 __attribute__((unused)) void *data)
1143 struct cmd_config_max_pkt_len_result *res = parsed_result;
1145 if (!all_ports_stopped()) {
1146 printf("Please stop all ports first\n");
1150 if (!strcmp(res->name, "max-pkt-len")) {
1151 if (res->value < ETHER_MIN_LEN) {
1152 printf("max-pkt-len can not be less than %d\n",
1156 if (res->value == rx_mode.max_rx_pkt_len)
1159 rx_mode.max_rx_pkt_len = res->value;
1160 if (res->value > ETHER_MAX_LEN)
1161 rx_mode.jumbo_frame = 1;
1163 rx_mode.jumbo_frame = 0;
1165 printf("Unknown parameter\n");
1171 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1174 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1175 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1177 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1180 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1183 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1184 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1186 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1187 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1190 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1191 .f = cmd_config_max_pkt_len_parsed,
1193 .help_str = "port config all max-pkt-len value",
1195 (void *)&cmd_config_max_pkt_len_port,
1196 (void *)&cmd_config_max_pkt_len_keyword,
1197 (void *)&cmd_config_max_pkt_len_all,
1198 (void *)&cmd_config_max_pkt_len_name,
1199 (void *)&cmd_config_max_pkt_len_value,
1204 /* *** configure port MTU *** */
1205 struct cmd_config_mtu_result {
1206 cmdline_fixed_string_t port;
1207 cmdline_fixed_string_t keyword;
1208 cmdline_fixed_string_t mtu;
1214 cmd_config_mtu_parsed(void *parsed_result,
1215 __attribute__((unused)) struct cmdline *cl,
1216 __attribute__((unused)) void *data)
1218 struct cmd_config_mtu_result *res = parsed_result;
1220 if (res->value < ETHER_MIN_LEN) {
1221 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1224 port_mtu_set(res->port_id, res->value);
1227 cmdline_parse_token_string_t cmd_config_mtu_port =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1230 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1231 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1233 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1234 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1236 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1237 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1238 cmdline_parse_token_num_t cmd_config_mtu_value =
1239 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1241 cmdline_parse_inst_t cmd_config_mtu = {
1242 .f = cmd_config_mtu_parsed,
1244 .help_str = "port config mtu value",
1246 (void *)&cmd_config_mtu_port,
1247 (void *)&cmd_config_mtu_keyword,
1248 (void *)&cmd_config_mtu_mtu,
1249 (void *)&cmd_config_mtu_port_id,
1250 (void *)&cmd_config_mtu_value,
1255 /* *** configure rx mode *** */
1256 struct cmd_config_rx_mode_flag {
1257 cmdline_fixed_string_t port;
1258 cmdline_fixed_string_t keyword;
1259 cmdline_fixed_string_t all;
1260 cmdline_fixed_string_t name;
1261 cmdline_fixed_string_t value;
1265 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1266 __attribute__((unused)) struct cmdline *cl,
1267 __attribute__((unused)) void *data)
1269 struct cmd_config_rx_mode_flag *res = parsed_result;
1271 if (!all_ports_stopped()) {
1272 printf("Please stop all ports first\n");
1276 if (!strcmp(res->name, "crc-strip")) {
1277 if (!strcmp(res->value, "on"))
1278 rx_mode.hw_strip_crc = 1;
1279 else if (!strcmp(res->value, "off"))
1280 rx_mode.hw_strip_crc = 0;
1282 printf("Unknown parameter\n");
1285 } else if (!strcmp(res->name, "rx-cksum")) {
1286 if (!strcmp(res->value, "on"))
1287 rx_mode.hw_ip_checksum = 1;
1288 else if (!strcmp(res->value, "off"))
1289 rx_mode.hw_ip_checksum = 0;
1291 printf("Unknown parameter\n");
1294 } else if (!strcmp(res->name, "hw-vlan")) {
1295 if (!strcmp(res->value, "on")) {
1296 rx_mode.hw_vlan_filter = 1;
1297 rx_mode.hw_vlan_strip = 1;
1299 else if (!strcmp(res->value, "off")) {
1300 rx_mode.hw_vlan_filter = 0;
1301 rx_mode.hw_vlan_strip = 0;
1304 printf("Unknown parameter\n");
1307 } else if (!strcmp(res->name, "drop-en")) {
1308 if (!strcmp(res->value, "on"))
1310 else if (!strcmp(res->value, "off"))
1313 printf("Unknown parameter\n");
1317 printf("Unknown parameter\n");
1323 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1326 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1328 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1329 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1331 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1332 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1333 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1335 "crc-strip#rx-cksum#hw-vlan");
1336 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1337 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1340 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1341 .f = cmd_config_rx_mode_flag_parsed,
1343 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1345 (void *)&cmd_config_rx_mode_flag_port,
1346 (void *)&cmd_config_rx_mode_flag_keyword,
1347 (void *)&cmd_config_rx_mode_flag_all,
1348 (void *)&cmd_config_rx_mode_flag_name,
1349 (void *)&cmd_config_rx_mode_flag_value,
1354 /* *** configure rss *** */
1355 struct cmd_config_rss {
1356 cmdline_fixed_string_t port;
1357 cmdline_fixed_string_t keyword;
1358 cmdline_fixed_string_t all;
1359 cmdline_fixed_string_t name;
1360 cmdline_fixed_string_t value;
1364 cmd_config_rss_parsed(void *parsed_result,
1365 __attribute__((unused)) struct cmdline *cl,
1366 __attribute__((unused)) void *data)
1368 struct cmd_config_rss *res = parsed_result;
1369 struct rte_eth_rss_conf rss_conf;
1372 if (!strcmp(res->value, "ip"))
1373 rss_conf.rss_hf = ETH_RSS_IP;
1374 else if (!strcmp(res->value, "udp"))
1375 rss_conf.rss_hf = ETH_RSS_UDP;
1376 else if (!strcmp(res->value, "none"))
1377 rss_conf.rss_hf = 0;
1379 printf("Unknown parameter\n");
1382 rss_conf.rss_key = NULL;
1383 for (i = 0; i < rte_eth_dev_count(); i++)
1384 rte_eth_dev_rss_hash_update(i, &rss_conf);
1387 cmdline_parse_token_string_t cmd_config_rss_port =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1389 cmdline_parse_token_string_t cmd_config_rss_keyword =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1391 cmdline_parse_token_string_t cmd_config_rss_all =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1393 cmdline_parse_token_string_t cmd_config_rss_name =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1395 cmdline_parse_token_string_t cmd_config_rss_value =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1398 cmdline_parse_inst_t cmd_config_rss = {
1399 .f = cmd_config_rss_parsed,
1401 .help_str = "port config all rss ip|udp|none",
1403 (void *)&cmd_config_rss_port,
1404 (void *)&cmd_config_rss_keyword,
1405 (void *)&cmd_config_rss_all,
1406 (void *)&cmd_config_rss_name,
1407 (void *)&cmd_config_rss_value,
1412 /* *** configure rss hash key *** */
1413 struct cmd_config_rss_hash_key {
1414 cmdline_fixed_string_t port;
1415 cmdline_fixed_string_t config;
1417 cmdline_fixed_string_t rss_hash_key;
1418 cmdline_fixed_string_t key;
1421 #define RSS_HASH_KEY_LENGTH 40
1423 hexa_digit_to_value(char hexa_digit)
1425 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1426 return (uint8_t) (hexa_digit - '0');
1427 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1428 return (uint8_t) ((hexa_digit - 'a') + 10);
1429 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1430 return (uint8_t) ((hexa_digit - 'A') + 10);
1431 /* Invalid hexa digit */
1436 parse_and_check_key_hexa_digit(char *key, int idx)
1440 hexa_v = hexa_digit_to_value(key[idx]);
1442 printf("invalid key: character %c at position %d is not a "
1443 "valid hexa digit\n", key[idx], idx);
1448 cmd_config_rss_hash_key_parsed(void *parsed_result,
1449 __attribute__((unused)) struct cmdline *cl,
1450 __attribute__((unused)) void *data)
1452 struct cmd_config_rss_hash_key *res = parsed_result;
1453 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1458 /* Check the length of the RSS hash key */
1459 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1460 printf("key length: %d invalid - key must be a string of %d"
1461 "hexa-decimal numbers\n", (int) strlen(res->key),
1462 RSS_HASH_KEY_LENGTH * 2);
1465 /* Translate RSS hash key into binary representation */
1466 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1467 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1470 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1473 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1475 port_rss_hash_key_update(res->port_id, hash_key);
1478 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1480 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1483 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1484 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1485 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1487 rss_hash_key, "rss-hash-key");
1488 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1491 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1492 .f = cmd_config_rss_hash_key_parsed,
1494 .help_str = "port config X rss-hash-key 80 hexa digits",
1496 (void *)&cmd_config_rss_hash_key_port,
1497 (void *)&cmd_config_rss_hash_key_config,
1498 (void *)&cmd_config_rss_hash_key_port_id,
1499 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1500 (void *)&cmd_config_rss_hash_key_value,
1505 /* *** configure port rxq/txq start/stop *** */
1506 struct cmd_config_rxtx_queue {
1507 cmdline_fixed_string_t port;
1509 cmdline_fixed_string_t rxtxq;
1511 cmdline_fixed_string_t opname;
1515 cmd_config_rxtx_queue_parsed(void *parsed_result,
1516 __attribute__((unused)) struct cmdline *cl,
1517 __attribute__((unused)) void *data)
1519 struct cmd_config_rxtx_queue *res = parsed_result;
1524 if (test_done == 0) {
1525 printf("Please stop forwarding first\n");
1529 if (port_id_is_invalid(res->portid))
1532 if (port_is_started(res->portid) != 1) {
1533 printf("Please start port %u first\n", res->portid);
1537 if (!strcmp(res->rxtxq, "rxq"))
1539 else if (!strcmp(res->rxtxq, "txq"))
1542 printf("Unknown parameter\n");
1546 if (isrx && rx_queue_id_is_invalid(res->qid))
1548 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1551 if (!strcmp(res->opname, "start"))
1553 else if (!strcmp(res->opname, "stop"))
1556 printf("Unknown parameter\n");
1560 if (isstart && isrx)
1561 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1562 else if (!isstart && isrx)
1563 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1564 else if (isstart && !isrx)
1565 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1567 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1569 if (ret == -ENOTSUP)
1570 printf("Function not supported in PMD driver\n");
1573 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1575 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1576 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1577 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1579 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1580 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1581 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1585 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1586 .f = cmd_config_rxtx_queue_parsed,
1588 .help_str = "port X rxq|txq ID start|stop",
1590 (void *)&cmd_config_speed_all_port,
1591 (void *)&cmd_config_rxtx_queue_portid,
1592 (void *)&cmd_config_rxtx_queue_rxtxq,
1593 (void *)&cmd_config_rxtx_queue_qid,
1594 (void *)&cmd_config_rxtx_queue_opname,
1599 /* *** Configure RSS RETA *** */
1600 struct cmd_config_rss_reta {
1601 cmdline_fixed_string_t port;
1602 cmdline_fixed_string_t keyword;
1604 cmdline_fixed_string_t name;
1605 cmdline_fixed_string_t list_name;
1606 cmdline_fixed_string_t list_of_items;
1610 parse_reta_config(const char *str,
1611 struct rte_eth_rss_reta_entry64 *reta_conf,
1612 uint16_t nb_entries)
1616 uint16_t hash_index, idx, shift;
1619 const char *p, *p0 = str;
1626 unsigned long int_fld[_NUM_FLD];
1627 char *str_fld[_NUM_FLD];
1629 while ((p = strchr(p0,'(')) != NULL) {
1631 if((p0 = strchr(p,')')) == NULL)
1635 if(size >= sizeof(s))
1638 snprintf(s, sizeof(s), "%.*s", size, p);
1639 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1641 for (i = 0; i < _NUM_FLD; i++) {
1643 int_fld[i] = strtoul(str_fld[i], &end, 0);
1644 if (errno != 0 || end == str_fld[i] ||
1649 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1650 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1652 if (hash_index >= nb_entries) {
1653 printf("Invalid RETA hash index=%d\n", hash_index);
1657 idx = hash_index / RTE_RETA_GROUP_SIZE;
1658 shift = hash_index % RTE_RETA_GROUP_SIZE;
1659 reta_conf[idx].mask |= (1ULL << shift);
1660 reta_conf[idx].reta[shift] = nb_queue;
1667 cmd_set_rss_reta_parsed(void *parsed_result,
1668 __attribute__((unused)) struct cmdline *cl,
1669 __attribute__((unused)) void *data)
1672 struct rte_eth_dev_info dev_info;
1673 struct rte_eth_rss_reta_entry64 reta_conf[8];
1674 struct cmd_config_rss_reta *res = parsed_result;
1676 memset(&dev_info, 0, sizeof(dev_info));
1677 rte_eth_dev_info_get(res->port_id, &dev_info);
1678 if (dev_info.reta_size == 0) {
1679 printf("Redirection table size is 0 which is "
1680 "invalid for RSS\n");
1683 printf("The reta size of port %d is %u\n",
1684 res->port_id, dev_info.reta_size);
1685 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1686 printf("Currently do not support more than %u entries of "
1687 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1691 memset(reta_conf, 0, sizeof(reta_conf));
1692 if (!strcmp(res->list_name, "reta")) {
1693 if (parse_reta_config(res->list_of_items, reta_conf,
1694 dev_info.reta_size)) {
1695 printf("Invalid RSS Redirection Table "
1696 "config entered\n");
1699 ret = rte_eth_dev_rss_reta_update(res->port_id,
1700 reta_conf, dev_info.reta_size);
1702 printf("Bad redirection table parameter, "
1703 "return code = %d \n", ret);
1707 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1709 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1711 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1712 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1713 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1715 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1717 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1720 cmdline_parse_inst_t cmd_config_rss_reta = {
1721 .f = cmd_set_rss_reta_parsed,
1723 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1725 (void *)&cmd_config_rss_reta_port,
1726 (void *)&cmd_config_rss_reta_keyword,
1727 (void *)&cmd_config_rss_reta_port_id,
1728 (void *)&cmd_config_rss_reta_name,
1729 (void *)&cmd_config_rss_reta_list_name,
1730 (void *)&cmd_config_rss_reta_list_of_items,
1735 /* *** SHOW PORT RETA INFO *** */
1736 struct cmd_showport_reta {
1737 cmdline_fixed_string_t show;
1738 cmdline_fixed_string_t port;
1740 cmdline_fixed_string_t rss;
1741 cmdline_fixed_string_t reta;
1743 cmdline_fixed_string_t list_of_items;
1747 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1748 uint16_t nb_entries,
1752 const char *p, *p0 = str;
1756 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1759 p = strchr(p0, '(');
1763 p0 = strchr(p, ')');
1767 if (size >= sizeof(s)) {
1768 printf("The string size exceeds the internal buffer size\n");
1771 snprintf(s, sizeof(s), "%.*s", size, p);
1772 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1773 if (ret <= 0 || ret != num) {
1774 printf("The bits of masks do not match the number of "
1775 "reta entries: %u\n", num);
1778 for (i = 0; i < ret; i++)
1779 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1785 cmd_showport_reta_parsed(void *parsed_result,
1786 __attribute__((unused)) struct cmdline *cl,
1787 __attribute__((unused)) void *data)
1789 struct cmd_showport_reta *res = parsed_result;
1790 struct rte_eth_rss_reta_entry64 reta_conf[8];
1791 struct rte_eth_dev_info dev_info;
1793 memset(&dev_info, 0, sizeof(dev_info));
1794 rte_eth_dev_info_get(res->port_id, &dev_info);
1795 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1796 res->size > ETH_RSS_RETA_SIZE_512) {
1797 printf("Invalid redirection table size: %u\n", res->size);
1801 memset(reta_conf, 0, sizeof(reta_conf));
1802 if (showport_parse_reta_config(reta_conf, res->size,
1803 res->list_of_items) < 0) {
1804 printf("Invalid string: %s for reta masks\n",
1805 res->list_of_items);
1808 port_rss_reta_info(res->port_id, reta_conf, res->size);
1811 cmdline_parse_token_string_t cmd_showport_reta_show =
1812 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1813 cmdline_parse_token_string_t cmd_showport_reta_port =
1814 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1815 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1816 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1817 cmdline_parse_token_string_t cmd_showport_reta_rss =
1818 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1819 cmdline_parse_token_string_t cmd_showport_reta_reta =
1820 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1821 cmdline_parse_token_num_t cmd_showport_reta_size =
1822 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1823 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1824 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1825 list_of_items, NULL);
1827 cmdline_parse_inst_t cmd_showport_reta = {
1828 .f = cmd_showport_reta_parsed,
1830 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1832 (void *)&cmd_showport_reta_show,
1833 (void *)&cmd_showport_reta_port,
1834 (void *)&cmd_showport_reta_port_id,
1835 (void *)&cmd_showport_reta_rss,
1836 (void *)&cmd_showport_reta_reta,
1837 (void *)&cmd_showport_reta_size,
1838 (void *)&cmd_showport_reta_list_of_items,
1843 /* *** Show RSS hash configuration *** */
1844 struct cmd_showport_rss_hash {
1845 cmdline_fixed_string_t show;
1846 cmdline_fixed_string_t port;
1848 cmdline_fixed_string_t rss_hash;
1849 cmdline_fixed_string_t key; /* optional argument */
1852 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1853 __attribute__((unused)) struct cmdline *cl,
1856 struct cmd_showport_rss_hash *res = parsed_result;
1858 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1861 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1862 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1863 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1864 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1865 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1866 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1867 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1868 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1870 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1871 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1873 cmdline_parse_inst_t cmd_showport_rss_hash = {
1874 .f = cmd_showport_rss_hash_parsed,
1876 .help_str = "show port X rss-hash (X = port number)\n",
1878 (void *)&cmd_showport_rss_hash_show,
1879 (void *)&cmd_showport_rss_hash_port,
1880 (void *)&cmd_showport_rss_hash_port_id,
1881 (void *)&cmd_showport_rss_hash_rss_hash,
1886 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1887 .f = cmd_showport_rss_hash_parsed,
1889 .help_str = "show port X rss-hash key (X = port number)\n",
1891 (void *)&cmd_showport_rss_hash_show,
1892 (void *)&cmd_showport_rss_hash_port,
1893 (void *)&cmd_showport_rss_hash_port_id,
1894 (void *)&cmd_showport_rss_hash_rss_hash,
1895 (void *)&cmd_showport_rss_hash_rss_key,
1900 /* *** Configure DCB *** */
1901 struct cmd_config_dcb {
1902 cmdline_fixed_string_t port;
1903 cmdline_fixed_string_t config;
1905 cmdline_fixed_string_t dcb;
1906 cmdline_fixed_string_t vt;
1907 cmdline_fixed_string_t vt_en;
1909 cmdline_fixed_string_t pfc;
1910 cmdline_fixed_string_t pfc_en;
1914 cmd_config_dcb_parsed(void *parsed_result,
1915 __attribute__((unused)) struct cmdline *cl,
1916 __attribute__((unused)) void *data)
1918 struct cmd_config_dcb *res = parsed_result;
1919 struct dcb_config dcb_conf;
1920 portid_t port_id = res->port_id;
1921 struct rte_port *port;
1923 port = &ports[port_id];
1924 /** Check if the port is not started **/
1925 if (port->port_status != RTE_PORT_STOPPED) {
1926 printf("Please stop port %d first\n",port_id);
1930 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1931 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1932 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1936 /* DCB in VT mode */
1937 if (!strncmp(res->vt_en, "on",2))
1938 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1940 dcb_conf.dcb_mode = DCB_ENABLED;
1942 if (!strncmp(res->pfc_en, "on",2)) {
1943 dcb_conf.pfc_en = 1;
1946 dcb_conf.pfc_en = 0;
1948 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1949 printf("Cannot initialize network ports\n");
1953 cmd_reconfig_device_queue(port_id, 1, 1);
1956 cmdline_parse_token_string_t cmd_config_dcb_port =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1958 cmdline_parse_token_string_t cmd_config_dcb_config =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1960 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1961 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1962 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1964 cmdline_parse_token_string_t cmd_config_dcb_vt =
1965 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1966 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1968 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1969 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1970 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1972 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1973 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1975 cmdline_parse_inst_t cmd_config_dcb = {
1976 .f = cmd_config_dcb_parsed,
1978 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1980 (void *)&cmd_config_dcb_port,
1981 (void *)&cmd_config_dcb_config,
1982 (void *)&cmd_config_dcb_port_id,
1983 (void *)&cmd_config_dcb_dcb,
1984 (void *)&cmd_config_dcb_vt,
1985 (void *)&cmd_config_dcb_vt_en,
1986 (void *)&cmd_config_dcb_num_tcs,
1987 (void *)&cmd_config_dcb_pfc,
1988 (void *)&cmd_config_dcb_pfc_en,
1993 /* *** configure number of packets per burst *** */
1994 struct cmd_config_burst {
1995 cmdline_fixed_string_t port;
1996 cmdline_fixed_string_t keyword;
1997 cmdline_fixed_string_t all;
1998 cmdline_fixed_string_t name;
2003 cmd_config_burst_parsed(void *parsed_result,
2004 __attribute__((unused)) struct cmdline *cl,
2005 __attribute__((unused)) void *data)
2007 struct cmd_config_burst *res = parsed_result;
2009 if (!all_ports_stopped()) {
2010 printf("Please stop all ports first\n");
2014 if (!strcmp(res->name, "burst")) {
2015 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2016 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2019 nb_pkt_per_burst = res->value;
2021 printf("Unknown parameter\n");
2027 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2030 cmdline_parse_token_string_t cmd_config_burst_port =
2031 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2032 cmdline_parse_token_string_t cmd_config_burst_keyword =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2034 cmdline_parse_token_string_t cmd_config_burst_all =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2036 cmdline_parse_token_string_t cmd_config_burst_name =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2038 cmdline_parse_token_num_t cmd_config_burst_value =
2039 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2041 cmdline_parse_inst_t cmd_config_burst = {
2042 .f = cmd_config_burst_parsed,
2044 .help_str = "port config all burst value",
2046 (void *)&cmd_config_burst_port,
2047 (void *)&cmd_config_burst_keyword,
2048 (void *)&cmd_config_burst_all,
2049 (void *)&cmd_config_burst_name,
2050 (void *)&cmd_config_burst_value,
2055 /* *** configure rx/tx queues *** */
2056 struct cmd_config_thresh {
2057 cmdline_fixed_string_t port;
2058 cmdline_fixed_string_t keyword;
2059 cmdline_fixed_string_t all;
2060 cmdline_fixed_string_t name;
2065 cmd_config_thresh_parsed(void *parsed_result,
2066 __attribute__((unused)) struct cmdline *cl,
2067 __attribute__((unused)) void *data)
2069 struct cmd_config_thresh *res = parsed_result;
2071 if (!all_ports_stopped()) {
2072 printf("Please stop all ports first\n");
2076 if (!strcmp(res->name, "txpt"))
2077 tx_thresh.pthresh = res->value;
2078 else if(!strcmp(res->name, "txht"))
2079 tx_thresh.hthresh = res->value;
2080 else if(!strcmp(res->name, "txwt"))
2081 tx_thresh.wthresh = res->value;
2082 else if(!strcmp(res->name, "rxpt"))
2083 rx_thresh.pthresh = res->value;
2084 else if(!strcmp(res->name, "rxht"))
2085 rx_thresh.hthresh = res->value;
2086 else if(!strcmp(res->name, "rxwt"))
2087 rx_thresh.wthresh = res->value;
2089 printf("Unknown parameter\n");
2095 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2098 cmdline_parse_token_string_t cmd_config_thresh_port =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2100 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2101 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2102 cmdline_parse_token_string_t cmd_config_thresh_all =
2103 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2104 cmdline_parse_token_string_t cmd_config_thresh_name =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2106 "txpt#txht#txwt#rxpt#rxht#rxwt");
2107 cmdline_parse_token_num_t cmd_config_thresh_value =
2108 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2110 cmdline_parse_inst_t cmd_config_thresh = {
2111 .f = cmd_config_thresh_parsed,
2113 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2115 (void *)&cmd_config_thresh_port,
2116 (void *)&cmd_config_thresh_keyword,
2117 (void *)&cmd_config_thresh_all,
2118 (void *)&cmd_config_thresh_name,
2119 (void *)&cmd_config_thresh_value,
2124 /* *** configure free/rs threshold *** */
2125 struct cmd_config_threshold {
2126 cmdline_fixed_string_t port;
2127 cmdline_fixed_string_t keyword;
2128 cmdline_fixed_string_t all;
2129 cmdline_fixed_string_t name;
2134 cmd_config_threshold_parsed(void *parsed_result,
2135 __attribute__((unused)) struct cmdline *cl,
2136 __attribute__((unused)) void *data)
2138 struct cmd_config_threshold *res = parsed_result;
2140 if (!all_ports_stopped()) {
2141 printf("Please stop all ports first\n");
2145 if (!strcmp(res->name, "txfreet"))
2146 tx_free_thresh = res->value;
2147 else if (!strcmp(res->name, "txrst"))
2148 tx_rs_thresh = res->value;
2149 else if (!strcmp(res->name, "rxfreet"))
2150 rx_free_thresh = res->value;
2152 printf("Unknown parameter\n");
2158 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2161 cmdline_parse_token_string_t cmd_config_threshold_port =
2162 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2163 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2166 cmdline_parse_token_string_t cmd_config_threshold_all =
2167 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2168 cmdline_parse_token_string_t cmd_config_threshold_name =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2170 "txfreet#txrst#rxfreet");
2171 cmdline_parse_token_num_t cmd_config_threshold_value =
2172 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2174 cmdline_parse_inst_t cmd_config_threshold = {
2175 .f = cmd_config_threshold_parsed,
2177 .help_str = "port config all txfreet|txrst|rxfreet value",
2179 (void *)&cmd_config_threshold_port,
2180 (void *)&cmd_config_threshold_keyword,
2181 (void *)&cmd_config_threshold_all,
2182 (void *)&cmd_config_threshold_name,
2183 (void *)&cmd_config_threshold_value,
2189 struct cmd_stop_result {
2190 cmdline_fixed_string_t stop;
2193 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2194 __attribute__((unused)) struct cmdline *cl,
2195 __attribute__((unused)) void *data)
2197 stop_packet_forwarding();
2200 cmdline_parse_token_string_t cmd_stop_stop =
2201 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2203 cmdline_parse_inst_t cmd_stop = {
2204 .f = cmd_stop_parsed,
2206 .help_str = "stop - stop packet forwarding",
2208 (void *)&cmd_stop_stop,
2213 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2216 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2217 unsigned int *parsed_items, int check_unique_values)
2219 unsigned int nb_item;
2227 * First parse all items in the list and store their value.
2232 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2234 if ((c >= '0') && (c <= '9')) {
2235 value = (unsigned int) (value * 10 + (c - '0'));
2240 printf("character %c is not a decimal digit\n", c);
2244 printf("No valid value before comma\n");
2247 if (nb_item < max_items) {
2248 parsed_items[nb_item] = value;
2254 if (nb_item >= max_items) {
2255 printf("Number of %s = %u > %u (maximum items)\n",
2256 item_name, nb_item + 1, max_items);
2259 parsed_items[nb_item++] = value;
2260 if (! check_unique_values)
2264 * Then, check that all values in the list are differents.
2265 * No optimization here...
2267 for (i = 0; i < nb_item; i++) {
2268 for (j = i + 1; j < nb_item; j++) {
2269 if (parsed_items[j] == parsed_items[i]) {
2270 printf("duplicated %s %u at index %u and %u\n",
2271 item_name, parsed_items[i], i, j);
2279 struct cmd_set_list_result {
2280 cmdline_fixed_string_t cmd_keyword;
2281 cmdline_fixed_string_t list_name;
2282 cmdline_fixed_string_t list_of_items;
2285 static void cmd_set_list_parsed(void *parsed_result,
2286 __attribute__((unused)) struct cmdline *cl,
2287 __attribute__((unused)) void *data)
2289 struct cmd_set_list_result *res;
2291 unsigned int lcorelist[RTE_MAX_LCORE];
2292 unsigned int portlist[RTE_MAX_ETHPORTS];
2294 unsigned int nb_item;
2296 res = parsed_result;
2297 if (!strcmp(res->list_name, "corelist")) {
2298 nb_item = parse_item_list(res->list_of_items, "core",
2300 parsed_items.lcorelist, 1);
2302 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2305 if (!strcmp(res->list_name, "portlist")) {
2306 nb_item = parse_item_list(res->list_of_items, "port",
2308 parsed_items.portlist, 1);
2310 set_fwd_ports_list(parsed_items.portlist, nb_item);
2314 cmdline_parse_token_string_t cmd_set_list_keyword =
2315 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2317 cmdline_parse_token_string_t cmd_set_list_name =
2318 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2319 "corelist#portlist");
2320 cmdline_parse_token_string_t cmd_set_list_of_items =
2321 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2324 cmdline_parse_inst_t cmd_set_fwd_list = {
2325 .f = cmd_set_list_parsed,
2327 .help_str = "set corelist|portlist x[,y]*",
2329 (void *)&cmd_set_list_keyword,
2330 (void *)&cmd_set_list_name,
2331 (void *)&cmd_set_list_of_items,
2336 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2338 struct cmd_setmask_result {
2339 cmdline_fixed_string_t set;
2340 cmdline_fixed_string_t mask;
2344 static void cmd_set_mask_parsed(void *parsed_result,
2345 __attribute__((unused)) struct cmdline *cl,
2346 __attribute__((unused)) void *data)
2348 struct cmd_setmask_result *res = parsed_result;
2350 if (!strcmp(res->mask, "coremask"))
2351 set_fwd_lcores_mask(res->hexavalue);
2352 else if (!strcmp(res->mask, "portmask"))
2353 set_fwd_ports_mask(res->hexavalue);
2356 cmdline_parse_token_string_t cmd_setmask_set =
2357 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2358 cmdline_parse_token_string_t cmd_setmask_mask =
2359 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2360 "coremask#portmask");
2361 cmdline_parse_token_num_t cmd_setmask_value =
2362 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2364 cmdline_parse_inst_t cmd_set_fwd_mask = {
2365 .f = cmd_set_mask_parsed,
2367 .help_str = "set coremask|portmask hexadecimal value",
2369 (void *)&cmd_setmask_set,
2370 (void *)&cmd_setmask_mask,
2371 (void *)&cmd_setmask_value,
2377 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2379 struct cmd_set_result {
2380 cmdline_fixed_string_t set;
2381 cmdline_fixed_string_t what;
2385 static void cmd_set_parsed(void *parsed_result,
2386 __attribute__((unused)) struct cmdline *cl,
2387 __attribute__((unused)) void *data)
2389 struct cmd_set_result *res = parsed_result;
2390 if (!strcmp(res->what, "nbport"))
2391 set_fwd_ports_number(res->value);
2392 else if (!strcmp(res->what, "nbcore"))
2393 set_fwd_lcores_number(res->value);
2394 else if (!strcmp(res->what, "burst"))
2395 set_nb_pkt_per_burst(res->value);
2396 else if (!strcmp(res->what, "verbose"))
2397 set_verbose_level(res->value);
2400 cmdline_parse_token_string_t cmd_set_set =
2401 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2402 cmdline_parse_token_string_t cmd_set_what =
2403 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2404 "nbport#nbcore#burst#verbose");
2405 cmdline_parse_token_num_t cmd_set_value =
2406 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2408 cmdline_parse_inst_t cmd_set_numbers = {
2409 .f = cmd_set_parsed,
2411 .help_str = "set nbport|nbcore|burst|verbose value",
2413 (void *)&cmd_set_set,
2414 (void *)&cmd_set_what,
2415 (void *)&cmd_set_value,
2420 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2422 struct cmd_set_txpkts_result {
2423 cmdline_fixed_string_t cmd_keyword;
2424 cmdline_fixed_string_t txpkts;
2425 cmdline_fixed_string_t seg_lengths;
2429 cmd_set_txpkts_parsed(void *parsed_result,
2430 __attribute__((unused)) struct cmdline *cl,
2431 __attribute__((unused)) void *data)
2433 struct cmd_set_txpkts_result *res;
2434 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2435 unsigned int nb_segs;
2437 res = parsed_result;
2438 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2439 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2441 set_tx_pkt_segments(seg_lengths, nb_segs);
2444 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2445 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2446 cmd_keyword, "set");
2447 cmdline_parse_token_string_t cmd_set_txpkts_name =
2448 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2450 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2451 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2454 cmdline_parse_inst_t cmd_set_txpkts = {
2455 .f = cmd_set_txpkts_parsed,
2457 .help_str = "set txpkts x[,y]*",
2459 (void *)&cmd_set_txpkts_keyword,
2460 (void *)&cmd_set_txpkts_name,
2461 (void *)&cmd_set_txpkts_lengths,
2466 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2467 struct cmd_rx_vlan_filter_all_result {
2468 cmdline_fixed_string_t rx_vlan;
2469 cmdline_fixed_string_t what;
2470 cmdline_fixed_string_t all;
2475 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2476 __attribute__((unused)) struct cmdline *cl,
2477 __attribute__((unused)) void *data)
2479 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2481 if (!strcmp(res->what, "add"))
2482 rx_vlan_all_filter_set(res->port_id, 1);
2484 rx_vlan_all_filter_set(res->port_id, 0);
2487 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2488 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2489 rx_vlan, "rx_vlan");
2490 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2491 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2493 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2494 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2496 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2497 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2500 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2501 .f = cmd_rx_vlan_filter_all_parsed,
2503 .help_str = "add/remove all identifiers to/from the set of VLAN "
2504 "Identifiers filtered by a port",
2506 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2507 (void *)&cmd_rx_vlan_filter_all_what,
2508 (void *)&cmd_rx_vlan_filter_all_all,
2509 (void *)&cmd_rx_vlan_filter_all_portid,
2514 /* *** VLAN OFFLOAD SET ON A PORT *** */
2515 struct cmd_vlan_offload_result {
2516 cmdline_fixed_string_t vlan;
2517 cmdline_fixed_string_t set;
2518 cmdline_fixed_string_t what;
2519 cmdline_fixed_string_t on;
2520 cmdline_fixed_string_t port_id;
2524 cmd_vlan_offload_parsed(void *parsed_result,
2525 __attribute__((unused)) struct cmdline *cl,
2526 __attribute__((unused)) void *data)
2529 struct cmd_vlan_offload_result *res = parsed_result;
2532 portid_t port_id = 0;
2536 len = strnlen(str, STR_TOKEN_SIZE);
2538 /* Get port_id first */
2546 tmp = strtoul(str, NULL, 0);
2547 /* If port_id greater that what portid_t can represent, return */
2548 if(tmp >= RTE_MAX_ETHPORTS)
2550 port_id = (portid_t)tmp;
2552 if (!strcmp(res->on, "on"))
2557 if (!strcmp(res->what, "strip"))
2558 rx_vlan_strip_set(port_id, on);
2559 else if(!strcmp(res->what, "stripq")){
2560 uint16_t queue_id = 0;
2562 /* No queue_id, return */
2564 printf("must specify (port,queue_id)\n");
2567 tmp = strtoul(str + i + 1, NULL, 0);
2568 /* If queue_id greater that what 16-bits can represent, return */
2572 queue_id = (uint16_t)tmp;
2573 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2575 else if (!strcmp(res->what, "filter"))
2576 rx_vlan_filter_set(port_id, on);
2578 vlan_extend_set(port_id, on);
2583 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2584 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2586 cmdline_parse_token_string_t cmd_vlan_offload_set =
2587 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2589 cmdline_parse_token_string_t cmd_vlan_offload_what =
2590 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2591 what, "strip#filter#qinq#stripq");
2592 cmdline_parse_token_string_t cmd_vlan_offload_on =
2593 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2595 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2596 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2599 cmdline_parse_inst_t cmd_vlan_offload = {
2600 .f = cmd_vlan_offload_parsed,
2602 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2603 " qinq(extended) for both rx/tx sides ",
2605 (void *)&cmd_vlan_offload_vlan,
2606 (void *)&cmd_vlan_offload_set,
2607 (void *)&cmd_vlan_offload_what,
2608 (void *)&cmd_vlan_offload_on,
2609 (void *)&cmd_vlan_offload_portid,
2614 /* *** VLAN TPID SET ON A PORT *** */
2615 struct cmd_vlan_tpid_result {
2616 cmdline_fixed_string_t vlan;
2617 cmdline_fixed_string_t set;
2618 cmdline_fixed_string_t what;
2624 cmd_vlan_tpid_parsed(void *parsed_result,
2625 __attribute__((unused)) struct cmdline *cl,
2626 __attribute__((unused)) void *data)
2628 struct cmd_vlan_tpid_result *res = parsed_result;
2629 vlan_tpid_set(res->port_id, res->tp_id);
2633 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2634 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2636 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2637 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2639 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2640 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2642 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2643 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2645 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2646 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2649 cmdline_parse_inst_t cmd_vlan_tpid = {
2650 .f = cmd_vlan_tpid_parsed,
2652 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2654 (void *)&cmd_vlan_tpid_vlan,
2655 (void *)&cmd_vlan_tpid_set,
2656 (void *)&cmd_vlan_tpid_what,
2657 (void *)&cmd_vlan_tpid_tpid,
2658 (void *)&cmd_vlan_tpid_portid,
2663 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2664 struct cmd_rx_vlan_filter_result {
2665 cmdline_fixed_string_t rx_vlan;
2666 cmdline_fixed_string_t what;
2672 cmd_rx_vlan_filter_parsed(void *parsed_result,
2673 __attribute__((unused)) struct cmdline *cl,
2674 __attribute__((unused)) void *data)
2676 struct cmd_rx_vlan_filter_result *res = parsed_result;
2678 if (!strcmp(res->what, "add"))
2679 rx_vft_set(res->port_id, res->vlan_id, 1);
2681 rx_vft_set(res->port_id, res->vlan_id, 0);
2684 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2685 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2686 rx_vlan, "rx_vlan");
2687 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2688 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2690 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2691 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2693 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2694 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2697 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2698 .f = cmd_rx_vlan_filter_parsed,
2700 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2701 "Identifiers filtered by a port",
2703 (void *)&cmd_rx_vlan_filter_rx_vlan,
2704 (void *)&cmd_rx_vlan_filter_what,
2705 (void *)&cmd_rx_vlan_filter_vlanid,
2706 (void *)&cmd_rx_vlan_filter_portid,
2711 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2712 struct cmd_tx_vlan_set_result {
2713 cmdline_fixed_string_t tx_vlan;
2714 cmdline_fixed_string_t set;
2720 cmd_tx_vlan_set_parsed(void *parsed_result,
2721 __attribute__((unused)) struct cmdline *cl,
2722 __attribute__((unused)) void *data)
2724 struct cmd_tx_vlan_set_result *res = parsed_result;
2725 tx_vlan_set(res->port_id, res->vlan_id);
2728 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2729 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2730 tx_vlan, "tx_vlan");
2731 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2732 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2734 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2735 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2737 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2738 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2741 cmdline_parse_inst_t cmd_tx_vlan_set = {
2742 .f = cmd_tx_vlan_set_parsed,
2744 .help_str = "enable hardware insertion of a VLAN header with a given "
2745 "TAG Identifier in packets sent on a port",
2747 (void *)&cmd_tx_vlan_set_tx_vlan,
2748 (void *)&cmd_tx_vlan_set_set,
2749 (void *)&cmd_tx_vlan_set_vlanid,
2750 (void *)&cmd_tx_vlan_set_portid,
2755 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2756 struct cmd_tx_vlan_set_pvid_result {
2757 cmdline_fixed_string_t tx_vlan;
2758 cmdline_fixed_string_t set;
2759 cmdline_fixed_string_t pvid;
2762 cmdline_fixed_string_t mode;
2766 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2767 __attribute__((unused)) struct cmdline *cl,
2768 __attribute__((unused)) void *data)
2770 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2772 if (strcmp(res->mode, "on") == 0)
2773 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2775 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2778 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2779 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2780 tx_vlan, "tx_vlan");
2781 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2782 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2784 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2785 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2787 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2788 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2790 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2791 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2793 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2794 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2797 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2798 .f = cmd_tx_vlan_set_pvid_parsed,
2800 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2802 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2803 (void *)&cmd_tx_vlan_set_pvid_set,
2804 (void *)&cmd_tx_vlan_set_pvid_pvid,
2805 (void *)&cmd_tx_vlan_set_pvid_port_id,
2806 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2807 (void *)&cmd_tx_vlan_set_pvid_mode,
2812 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2813 struct cmd_tx_vlan_reset_result {
2814 cmdline_fixed_string_t tx_vlan;
2815 cmdline_fixed_string_t reset;
2820 cmd_tx_vlan_reset_parsed(void *parsed_result,
2821 __attribute__((unused)) struct cmdline *cl,
2822 __attribute__((unused)) void *data)
2824 struct cmd_tx_vlan_reset_result *res = parsed_result;
2826 tx_vlan_reset(res->port_id);
2829 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2830 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2831 tx_vlan, "tx_vlan");
2832 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2833 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2835 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2836 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2839 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2840 .f = cmd_tx_vlan_reset_parsed,
2842 .help_str = "disable hardware insertion of a VLAN header in packets "
2845 (void *)&cmd_tx_vlan_reset_tx_vlan,
2846 (void *)&cmd_tx_vlan_reset_reset,
2847 (void *)&cmd_tx_vlan_reset_portid,
2853 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2854 struct cmd_tx_cksum_set_result {
2855 cmdline_fixed_string_t tx_cksum;
2856 cmdline_fixed_string_t set;
2862 cmd_tx_cksum_set_parsed(void *parsed_result,
2863 __attribute__((unused)) struct cmdline *cl,
2864 __attribute__((unused)) void *data)
2866 struct cmd_tx_cksum_set_result *res = parsed_result;
2868 tx_cksum_set(res->port_id, res->cksum_mask);
2871 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2872 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2873 tx_cksum, "tx_checksum");
2874 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2875 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2877 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2878 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2880 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2881 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2884 cmdline_parse_inst_t cmd_tx_cksum_set = {
2885 .f = cmd_tx_cksum_set_parsed,
2887 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2888 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2889 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2890 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2892 (void *)&cmd_tx_cksum_set_tx_cksum,
2893 (void *)&cmd_tx_cksum_set_set,
2894 (void *)&cmd_tx_cksum_set_cksum_mask,
2895 (void *)&cmd_tx_cksum_set_portid,
2900 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2901 struct cmd_set_flush_rx {
2902 cmdline_fixed_string_t set;
2903 cmdline_fixed_string_t flush_rx;
2904 cmdline_fixed_string_t mode;
2908 cmd_set_flush_rx_parsed(void *parsed_result,
2909 __attribute__((unused)) struct cmdline *cl,
2910 __attribute__((unused)) void *data)
2912 struct cmd_set_flush_rx *res = parsed_result;
2913 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2916 cmdline_parse_token_string_t cmd_setflushrx_set =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2919 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2920 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2921 flush_rx, "flush_rx");
2922 cmdline_parse_token_string_t cmd_setflushrx_mode =
2923 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2927 cmdline_parse_inst_t cmd_set_flush_rx = {
2928 .f = cmd_set_flush_rx_parsed,
2929 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2932 (void *)&cmd_setflushrx_set,
2933 (void *)&cmd_setflushrx_flush_rx,
2934 (void *)&cmd_setflushrx_mode,
2939 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2940 struct cmd_set_link_check {
2941 cmdline_fixed_string_t set;
2942 cmdline_fixed_string_t link_check;
2943 cmdline_fixed_string_t mode;
2947 cmd_set_link_check_parsed(void *parsed_result,
2948 __attribute__((unused)) struct cmdline *cl,
2949 __attribute__((unused)) void *data)
2951 struct cmd_set_link_check *res = parsed_result;
2952 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2955 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2956 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2958 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2959 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2960 link_check, "link_check");
2961 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2962 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2966 cmdline_parse_inst_t cmd_set_link_check = {
2967 .f = cmd_set_link_check_parsed,
2968 .help_str = "set link_check on|off: enable/disable link status check "
2969 "when starting/stopping a port",
2972 (void *)&cmd_setlinkcheck_set,
2973 (void *)&cmd_setlinkcheck_link_check,
2974 (void *)&cmd_setlinkcheck_mode,
2979 #ifdef RTE_NIC_BYPASS
2980 /* *** SET NIC BYPASS MODE *** */
2981 struct cmd_set_bypass_mode_result {
2982 cmdline_fixed_string_t set;
2983 cmdline_fixed_string_t bypass;
2984 cmdline_fixed_string_t mode;
2985 cmdline_fixed_string_t value;
2990 cmd_set_bypass_mode_parsed(void *parsed_result,
2991 __attribute__((unused)) struct cmdline *cl,
2992 __attribute__((unused)) void *data)
2994 struct cmd_set_bypass_mode_result *res = parsed_result;
2995 portid_t port_id = res->port_id;
2996 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2998 if (!bypass_is_supported(port_id))
3001 if (!strcmp(res->value, "bypass"))
3002 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3003 else if (!strcmp(res->value, "isolate"))
3004 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3006 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3008 /* Set the bypass mode for the relevant port. */
3009 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3010 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3014 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3015 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3017 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3018 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3020 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3021 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3023 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3024 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3025 value, "normal#bypass#isolate");
3026 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3027 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3030 cmdline_parse_inst_t cmd_set_bypass_mode = {
3031 .f = cmd_set_bypass_mode_parsed,
3032 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3033 "Set the NIC bypass mode for port_id",
3036 (void *)&cmd_setbypass_mode_set,
3037 (void *)&cmd_setbypass_mode_bypass,
3038 (void *)&cmd_setbypass_mode_mode,
3039 (void *)&cmd_setbypass_mode_value,
3040 (void *)&cmd_setbypass_mode_port,
3045 /* *** SET NIC BYPASS EVENT *** */
3046 struct cmd_set_bypass_event_result {
3047 cmdline_fixed_string_t set;
3048 cmdline_fixed_string_t bypass;
3049 cmdline_fixed_string_t event;
3050 cmdline_fixed_string_t event_value;
3051 cmdline_fixed_string_t mode;
3052 cmdline_fixed_string_t mode_value;
3057 cmd_set_bypass_event_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3059 __attribute__((unused)) void *data)
3062 struct cmd_set_bypass_event_result *res = parsed_result;
3063 portid_t port_id = res->port_id;
3064 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3065 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3067 if (!bypass_is_supported(port_id))
3070 if (!strcmp(res->event_value, "timeout"))
3071 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3072 else if (!strcmp(res->event_value, "os_on"))
3073 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3074 else if (!strcmp(res->event_value, "os_off"))
3075 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3076 else if (!strcmp(res->event_value, "power_on"))
3077 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3078 else if (!strcmp(res->event_value, "power_off"))
3079 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3081 bypass_event = RTE_BYPASS_EVENT_NONE;
3083 if (!strcmp(res->mode_value, "bypass"))
3084 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3085 else if (!strcmp(res->mode_value, "isolate"))
3086 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3088 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3090 /* Set the watchdog timeout. */
3091 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3094 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3095 (rc = rte_eth_dev_wd_timeout_store(port_id,
3096 bypass_timeout)) != 0) {
3097 printf("Failed to set timeout value %u "
3098 "for port %d, errto code: %d.\n",
3099 bypass_timeout, port_id, rc);
3103 /* Set the bypass event to transition to bypass mode. */
3104 if (0 != rte_eth_dev_bypass_event_store(port_id,
3105 bypass_event, bypass_mode)) {
3106 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3111 cmdline_parse_token_string_t cmd_setbypass_event_set =
3112 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3114 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3115 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3117 cmdline_parse_token_string_t cmd_setbypass_event_event =
3118 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3120 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3121 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3122 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3123 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3124 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3126 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3127 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3128 mode_value, "normal#bypass#isolate");
3129 cmdline_parse_token_num_t cmd_setbypass_event_port =
3130 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3133 cmdline_parse_inst_t cmd_set_bypass_event = {
3134 .f = cmd_set_bypass_event_parsed,
3135 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3136 "mode (normal|bypass|isolate) (port_id): "
3137 "Set the NIC bypass event mode for port_id",
3140 (void *)&cmd_setbypass_event_set,
3141 (void *)&cmd_setbypass_event_bypass,
3142 (void *)&cmd_setbypass_event_event,
3143 (void *)&cmd_setbypass_event_event_value,
3144 (void *)&cmd_setbypass_event_mode,
3145 (void *)&cmd_setbypass_event_mode_value,
3146 (void *)&cmd_setbypass_event_port,
3152 /* *** SET NIC BYPASS TIMEOUT *** */
3153 struct cmd_set_bypass_timeout_result {
3154 cmdline_fixed_string_t set;
3155 cmdline_fixed_string_t bypass;
3156 cmdline_fixed_string_t timeout;
3157 cmdline_fixed_string_t value;
3161 cmd_set_bypass_timeout_parsed(void *parsed_result,
3162 __attribute__((unused)) struct cmdline *cl,
3163 __attribute__((unused)) void *data)
3165 struct cmd_set_bypass_timeout_result *res = parsed_result;
3167 if (!strcmp(res->value, "1.5"))
3168 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3169 else if (!strcmp(res->value, "2"))
3170 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3171 else if (!strcmp(res->value, "3"))
3172 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3173 else if (!strcmp(res->value, "4"))
3174 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3175 else if (!strcmp(res->value, "8"))
3176 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3177 else if (!strcmp(res->value, "16"))
3178 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3179 else if (!strcmp(res->value, "32"))
3180 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3182 bypass_timeout = RTE_BYPASS_TMT_OFF;
3185 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3186 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3188 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3189 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3191 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3192 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3193 timeout, "timeout");
3194 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3195 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3196 value, "0#1.5#2#3#4#8#16#32");
3198 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3199 .f = cmd_set_bypass_timeout_parsed,
3200 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3201 "Set the NIC bypass watchdog timeout",
3204 (void *)&cmd_setbypass_timeout_set,
3205 (void *)&cmd_setbypass_timeout_bypass,
3206 (void *)&cmd_setbypass_timeout_timeout,
3207 (void *)&cmd_setbypass_timeout_value,
3212 /* *** SHOW NIC BYPASS MODE *** */
3213 struct cmd_show_bypass_config_result {
3214 cmdline_fixed_string_t show;
3215 cmdline_fixed_string_t bypass;
3216 cmdline_fixed_string_t config;
3221 cmd_show_bypass_config_parsed(void *parsed_result,
3222 __attribute__((unused)) struct cmdline *cl,
3223 __attribute__((unused)) void *data)
3225 struct cmd_show_bypass_config_result *res = parsed_result;
3226 uint32_t event_mode;
3227 uint32_t bypass_mode;
3228 portid_t port_id = res->port_id;
3229 uint32_t timeout = bypass_timeout;
3232 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3233 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3234 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3235 {"UNKNOWN", "normal", "bypass", "isolate"};
3236 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3243 int num_events = (sizeof events) / (sizeof events[0]);
3245 if (!bypass_is_supported(port_id))
3248 /* Display the bypass mode.*/
3249 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3250 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3254 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3255 bypass_mode = RTE_BYPASS_MODE_NONE;
3257 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3260 /* Display the bypass timeout.*/
3261 if (!RTE_BYPASS_TMT_VALID(timeout))
3262 timeout = RTE_BYPASS_TMT_OFF;
3264 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3266 /* Display the bypass events and associated modes. */
3267 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3269 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3270 printf("\tFailed to get bypass mode for event = %s\n",
3273 if (!RTE_BYPASS_MODE_VALID(event_mode))
3274 event_mode = RTE_BYPASS_MODE_NONE;
3276 printf("\tbypass event: %-16s = %s\n", events[i],
3282 cmdline_parse_token_string_t cmd_showbypass_config_show =
3283 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3285 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3286 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3288 cmdline_parse_token_string_t cmd_showbypass_config_config =
3289 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3291 cmdline_parse_token_num_t cmd_showbypass_config_port =
3292 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3295 cmdline_parse_inst_t cmd_show_bypass_config = {
3296 .f = cmd_show_bypass_config_parsed,
3297 .help_str = "show bypass config (port_id): "
3298 "Show the NIC bypass config for port_id",
3301 (void *)&cmd_showbypass_config_show,
3302 (void *)&cmd_showbypass_config_bypass,
3303 (void *)&cmd_showbypass_config_config,
3304 (void *)&cmd_showbypass_config_port,
3310 #ifdef RTE_LIBRTE_PMD_BOND
3311 /* *** SET BONDING MODE *** */
3312 struct cmd_set_bonding_mode_result {
3313 cmdline_fixed_string_t set;
3314 cmdline_fixed_string_t bonding;
3315 cmdline_fixed_string_t mode;
3320 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3321 __attribute__((unused)) struct cmdline *cl,
3322 __attribute__((unused)) void *data)
3324 struct cmd_set_bonding_mode_result *res = parsed_result;
3325 portid_t port_id = res->port_id;
3327 /* Set the bonding mode for the relevant port. */
3328 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3329 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3332 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3333 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3335 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3336 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3337 bonding, "bonding");
3338 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3341 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3342 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3344 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3345 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3348 cmdline_parse_inst_t cmd_set_bonding_mode = {
3349 .f = cmd_set_bonding_mode_parsed,
3350 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3353 (void *) &cmd_setbonding_mode_set,
3354 (void *) &cmd_setbonding_mode_bonding,
3355 (void *) &cmd_setbonding_mode_mode,
3356 (void *) &cmd_setbonding_mode_value,
3357 (void *) &cmd_setbonding_mode_port,
3362 /* *** SET BALANCE XMIT POLICY *** */
3363 struct cmd_set_bonding_balance_xmit_policy_result {
3364 cmdline_fixed_string_t set;
3365 cmdline_fixed_string_t bonding;
3366 cmdline_fixed_string_t balance_xmit_policy;
3368 cmdline_fixed_string_t policy;
3371 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3372 __attribute__((unused)) struct cmdline *cl,
3373 __attribute__((unused)) void *data)
3375 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3376 portid_t port_id = res->port_id;
3379 if (!strcmp(res->policy, "l2")) {
3380 policy = BALANCE_XMIT_POLICY_LAYER2;
3381 } else if (!strcmp(res->policy, "l23")) {
3382 policy = BALANCE_XMIT_POLICY_LAYER23;
3383 } else if (!strcmp(res->policy, "l34")) {
3384 policy = BALANCE_XMIT_POLICY_LAYER34;
3386 printf("\t Invalid xmit policy selection");
3390 /* Set the bonding mode for the relevant port. */
3391 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3392 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3397 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3398 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3400 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3401 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3402 bonding, "bonding");
3403 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3404 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3405 balance_xmit_policy, "balance_xmit_policy");
3406 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3407 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3409 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3411 policy, "l2#l23#l34");
3413 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3414 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3415 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3418 (void *)&cmd_setbonding_balance_xmit_policy_set,
3419 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3420 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3421 (void *)&cmd_setbonding_balance_xmit_policy_port,
3422 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3427 /* *** SHOW NIC BONDING CONFIGURATION *** */
3428 struct cmd_show_bonding_config_result {
3429 cmdline_fixed_string_t show;
3430 cmdline_fixed_string_t bonding;
3431 cmdline_fixed_string_t config;
3435 static void cmd_show_bonding_config_parsed(void *parsed_result,
3436 __attribute__((unused)) struct cmdline *cl,
3437 __attribute__((unused)) void *data)
3439 struct cmd_show_bonding_config_result *res = parsed_result;
3441 uint8_t slaves[RTE_MAX_ETHPORTS];
3442 int num_slaves, num_active_slaves;
3445 portid_t port_id = res->port_id;
3447 /* Display the bonding mode.*/
3448 bonding_mode = rte_eth_bond_mode_get(port_id);
3449 if (bonding_mode < 0) {
3450 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3453 printf("\tBonding mode: %d\n", bonding_mode);
3455 if (bonding_mode == BONDING_MODE_BALANCE) {
3456 int balance_xmit_policy;
3458 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3459 if (balance_xmit_policy < 0) {
3460 printf("\tFailed to get balance xmit policy for port = %d\n",
3464 printf("\tBalance Xmit Policy: ");
3466 switch (balance_xmit_policy) {
3467 case BALANCE_XMIT_POLICY_LAYER2:
3468 printf("BALANCE_XMIT_POLICY_LAYER2");
3470 case BALANCE_XMIT_POLICY_LAYER23:
3471 printf("BALANCE_XMIT_POLICY_LAYER23");
3473 case BALANCE_XMIT_POLICY_LAYER34:
3474 printf("BALANCE_XMIT_POLICY_LAYER34");
3481 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3483 if (num_slaves < 0) {
3484 printf("\tFailed to get slave list for port = %d\n", port_id);
3487 if (num_slaves > 0) {
3488 printf("\tSlaves (%d): [", num_slaves);
3489 for (i = 0; i < num_slaves - 1; i++)
3490 printf("%d ", slaves[i]);
3492 printf("%d]\n", slaves[num_slaves - 1]);
3494 printf("\tSlaves: []\n");
3498 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3501 if (num_active_slaves < 0) {
3502 printf("\tFailed to get active slave list for port = %d\n", port_id);
3505 if (num_active_slaves > 0) {
3506 printf("\tActive Slaves (%d): [", num_active_slaves);
3507 for (i = 0; i < num_active_slaves - 1; i++)
3508 printf("%d ", slaves[i]);
3510 printf("%d]\n", slaves[num_active_slaves - 1]);
3513 printf("\tActive Slaves: []\n");
3517 primary_id = rte_eth_bond_primary_get(port_id);
3518 if (primary_id < 0) {
3519 printf("\tFailed to get primary slave for port = %d\n", port_id);
3522 printf("\tPrimary: [%d]\n", primary_id);
3526 cmdline_parse_token_string_t cmd_showbonding_config_show =
3527 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3529 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3530 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3531 bonding, "bonding");
3532 cmdline_parse_token_string_t cmd_showbonding_config_config =
3533 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3535 cmdline_parse_token_num_t cmd_showbonding_config_port =
3536 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3539 cmdline_parse_inst_t cmd_show_bonding_config = {
3540 .f = cmd_show_bonding_config_parsed,
3541 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3544 (void *)&cmd_showbonding_config_show,
3545 (void *)&cmd_showbonding_config_bonding,
3546 (void *)&cmd_showbonding_config_config,
3547 (void *)&cmd_showbonding_config_port,
3552 /* *** SET BONDING PRIMARY *** */
3553 struct cmd_set_bonding_primary_result {
3554 cmdline_fixed_string_t set;
3555 cmdline_fixed_string_t bonding;
3556 cmdline_fixed_string_t primary;
3561 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3562 __attribute__((unused)) struct cmdline *cl,
3563 __attribute__((unused)) void *data)
3565 struct cmd_set_bonding_primary_result *res = parsed_result;
3566 portid_t master_port_id = res->port_id;
3567 portid_t slave_port_id = res->slave_id;
3569 /* Set the primary slave for a bonded device. */
3570 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3571 printf("\t Failed to set primary slave for port = %d.\n",
3578 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3579 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3581 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3582 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3583 bonding, "bonding");
3584 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3585 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3586 primary, "primary");
3587 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3588 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3590 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3591 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3594 cmdline_parse_inst_t cmd_set_bonding_primary = {
3595 .f = cmd_set_bonding_primary_parsed,
3596 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3599 (void *)&cmd_setbonding_primary_set,
3600 (void *)&cmd_setbonding_primary_bonding,
3601 (void *)&cmd_setbonding_primary_primary,
3602 (void *)&cmd_setbonding_primary_slave,
3603 (void *)&cmd_setbonding_primary_port,
3608 /* *** ADD SLAVE *** */
3609 struct cmd_add_bonding_slave_result {
3610 cmdline_fixed_string_t add;
3611 cmdline_fixed_string_t bonding;
3612 cmdline_fixed_string_t slave;
3617 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3618 __attribute__((unused)) struct cmdline *cl,
3619 __attribute__((unused)) void *data)
3621 struct cmd_add_bonding_slave_result *res = parsed_result;
3622 portid_t master_port_id = res->port_id;
3623 portid_t slave_port_id = res->slave_id;
3625 /* Set the primary slave for a bonded device. */
3626 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3627 printf("\t Failed to add slave %d to master port = %d.\n",
3628 slave_port_id, master_port_id);
3634 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3635 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3637 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3638 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3639 bonding, "bonding");
3640 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3641 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3643 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3644 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3646 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3647 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3650 cmdline_parse_inst_t cmd_add_bonding_slave = {
3651 .f = cmd_add_bonding_slave_parsed,
3652 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3655 (void *)&cmd_addbonding_slave_add,
3656 (void *)&cmd_addbonding_slave_bonding,
3657 (void *)&cmd_addbonding_slave_slave,
3658 (void *)&cmd_addbonding_slave_slaveid,
3659 (void *)&cmd_addbonding_slave_port,
3664 /* *** REMOVE SLAVE *** */
3665 struct cmd_remove_bonding_slave_result {
3666 cmdline_fixed_string_t remove;
3667 cmdline_fixed_string_t bonding;
3668 cmdline_fixed_string_t slave;
3673 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3674 __attribute__((unused)) struct cmdline *cl,
3675 __attribute__((unused)) void *data)
3677 struct cmd_remove_bonding_slave_result *res = parsed_result;
3678 portid_t master_port_id = res->port_id;
3679 portid_t slave_port_id = res->slave_id;
3681 /* Set the primary slave for a bonded device. */
3682 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3683 printf("\t Failed to remove slave %d from master port = %d.\n",
3684 slave_port_id, master_port_id);
3690 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3691 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3693 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3694 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3695 bonding, "bonding");
3696 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3697 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3699 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3700 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3702 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3703 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3706 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3707 .f = cmd_remove_bonding_slave_parsed,
3708 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3711 (void *)&cmd_removebonding_slave_remove,
3712 (void *)&cmd_removebonding_slave_bonding,
3713 (void *)&cmd_removebonding_slave_slave,
3714 (void *)&cmd_removebonding_slave_slaveid,
3715 (void *)&cmd_removebonding_slave_port,
3720 /* *** CREATE BONDED DEVICE *** */
3721 struct cmd_create_bonded_device_result {
3722 cmdline_fixed_string_t create;
3723 cmdline_fixed_string_t bonded;
3724 cmdline_fixed_string_t device;
3729 static int bond_dev_num = 0;
3731 static void cmd_create_bonded_device_parsed(void *parsed_result,
3732 __attribute__((unused)) struct cmdline *cl,
3733 __attribute__((unused)) void *data)
3735 struct cmd_create_bonded_device_result *res = parsed_result;
3736 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3739 if (test_done == 0) {
3740 printf("Please stop forwarding first\n");
3744 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3747 /* Create a new bonded device. */
3748 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3750 printf("\t Failed to create bonded device.\n");
3753 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3756 /* Update number of ports */
3757 nb_ports = rte_eth_dev_count();
3759 rte_eth_promiscuous_enable(port_id);
3764 cmdline_parse_token_string_t cmd_createbonded_device_create =
3765 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3767 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3768 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3770 cmdline_parse_token_string_t cmd_createbonded_device_device =
3771 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3773 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3774 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3776 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3777 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3780 cmdline_parse_inst_t cmd_create_bonded_device = {
3781 .f = cmd_create_bonded_device_parsed,
3782 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3785 (void *)&cmd_createbonded_device_create,
3786 (void *)&cmd_createbonded_device_bonded,
3787 (void *)&cmd_createbonded_device_device,
3788 (void *)&cmd_createbonded_device_mode,
3789 (void *)&cmd_createbonded_device_socket,
3794 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3795 struct cmd_set_bond_mac_addr_result {
3796 cmdline_fixed_string_t set;
3797 cmdline_fixed_string_t bonding;
3798 cmdline_fixed_string_t mac_addr;
3800 struct ether_addr address;
3803 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3804 __attribute__((unused)) struct cmdline *cl,
3805 __attribute__((unused)) void *data)
3807 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3810 if (res->port_num >= nb_ports) {
3811 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3815 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3817 /* check the return value and print it if is < 0 */
3819 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3822 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3824 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3825 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3827 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3830 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3831 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3832 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3833 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3835 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3836 .f = cmd_set_bond_mac_addr_parsed,
3838 .help_str = "set bonding mac_addr (port_id) (address): ",
3840 (void *)&cmd_set_bond_mac_addr_set,
3841 (void *)&cmd_set_bond_mac_addr_bonding,
3842 (void *)&cmd_set_bond_mac_addr_mac,
3843 (void *)&cmd_set_bond_mac_addr_portnum,
3844 (void *)&cmd_set_bond_mac_addr_addr,
3850 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3851 struct cmd_set_bond_mon_period_result {
3852 cmdline_fixed_string_t set;
3853 cmdline_fixed_string_t bonding;
3854 cmdline_fixed_string_t mon_period;
3859 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3860 __attribute__((unused)) struct cmdline *cl,
3861 __attribute__((unused)) void *data)
3863 struct cmd_set_bond_mon_period_result *res = parsed_result;
3866 if (res->port_num >= nb_ports) {
3867 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3871 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3873 /* check the return value and print it if is < 0 */
3875 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3878 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3879 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3881 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3882 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3883 bonding, "bonding");
3884 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3885 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3886 mon_period, "mon_period");
3887 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3888 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3890 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3891 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3894 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3895 .f = cmd_set_bond_mon_period_parsed,
3897 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3899 (void *)&cmd_set_bond_mon_period_set,
3900 (void *)&cmd_set_bond_mon_period_bonding,
3901 (void *)&cmd_set_bond_mon_period_mon_period,
3902 (void *)&cmd_set_bond_mon_period_portnum,
3903 (void *)&cmd_set_bond_mon_period_period_ms,
3908 #endif /* RTE_LIBRTE_PMD_BOND */
3910 /* *** SET FORWARDING MODE *** */
3911 struct cmd_set_fwd_mode_result {
3912 cmdline_fixed_string_t set;
3913 cmdline_fixed_string_t fwd;
3914 cmdline_fixed_string_t mode;
3917 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3918 __attribute__((unused)) struct cmdline *cl,
3919 __attribute__((unused)) void *data)
3921 struct cmd_set_fwd_mode_result *res = parsed_result;
3923 set_pkt_forwarding_mode(res->mode);
3926 cmdline_parse_token_string_t cmd_setfwd_set =
3927 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3928 cmdline_parse_token_string_t cmd_setfwd_fwd =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3930 cmdline_parse_token_string_t cmd_setfwd_mode =
3931 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3932 "" /* defined at init */);
3934 cmdline_parse_inst_t cmd_set_fwd_mode = {
3935 .f = cmd_set_fwd_mode_parsed,
3937 .help_str = NULL, /* defined at init */
3939 (void *)&cmd_setfwd_set,
3940 (void *)&cmd_setfwd_fwd,
3941 (void *)&cmd_setfwd_mode,
3946 static void cmd_set_fwd_mode_init(void)
3949 static char token[128];
3950 static char help[256];
3951 cmdline_parse_token_string_t *token_struct;
3953 modes = list_pkt_forwarding_modes();
3954 snprintf(help, sizeof help, "set fwd %s - "
3955 "set packet forwarding mode", modes);
3956 cmd_set_fwd_mode.help_str = help;
3958 /* string token separator is # */
3959 for (c = token; *modes != '\0'; modes++)
3964 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3965 token_struct->string_data.str = token;
3968 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3969 struct cmd_set_burst_tx_retry_result {
3970 cmdline_fixed_string_t set;
3971 cmdline_fixed_string_t burst;
3972 cmdline_fixed_string_t tx;
3973 cmdline_fixed_string_t delay;
3975 cmdline_fixed_string_t retry;
3979 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3980 __attribute__((unused)) struct cmdline *cl,
3981 __attribute__((unused)) void *data)
3983 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3985 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3986 && !strcmp(res->tx, "tx")) {
3987 if (!strcmp(res->delay, "delay"))
3988 burst_tx_delay_time = res->time;
3989 if (!strcmp(res->retry, "retry"))
3990 burst_tx_retry_num = res->retry_num;
3995 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3997 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3998 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4000 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4001 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4002 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4003 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4004 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4005 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4006 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4008 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4009 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4011 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4012 .f = cmd_set_burst_tx_retry_parsed,
4013 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4015 (void *)&cmd_set_burst_tx_retry_set,
4016 (void *)&cmd_set_burst_tx_retry_burst,
4017 (void *)&cmd_set_burst_tx_retry_tx,
4018 (void *)&cmd_set_burst_tx_retry_delay,
4019 (void *)&cmd_set_burst_tx_retry_time,
4020 (void *)&cmd_set_burst_tx_retry_retry,
4021 (void *)&cmd_set_burst_tx_retry_retry_num,
4026 /* *** SET PROMISC MODE *** */
4027 struct cmd_set_promisc_mode_result {
4028 cmdline_fixed_string_t set;
4029 cmdline_fixed_string_t promisc;
4030 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4031 uint8_t port_num; /* valid if "allports" argument == 0 */
4032 cmdline_fixed_string_t mode;
4035 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4036 __attribute__((unused)) struct cmdline *cl,
4039 struct cmd_set_promisc_mode_result *res = parsed_result;
4043 if (!strcmp(res->mode, "on"))
4050 for (i = 0; i < nb_ports; i++) {
4052 rte_eth_promiscuous_enable(i);
4054 rte_eth_promiscuous_disable(i);
4059 rte_eth_promiscuous_enable(res->port_num);
4061 rte_eth_promiscuous_disable(res->port_num);
4065 cmdline_parse_token_string_t cmd_setpromisc_set =
4066 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4067 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4068 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4070 cmdline_parse_token_string_t cmd_setpromisc_portall =
4071 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4073 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4074 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4076 cmdline_parse_token_string_t cmd_setpromisc_mode =
4077 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4080 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4081 .f = cmd_set_promisc_mode_parsed,
4083 .help_str = "set promisc all on|off: set promisc mode for all ports",
4085 (void *)&cmd_setpromisc_set,
4086 (void *)&cmd_setpromisc_promisc,
4087 (void *)&cmd_setpromisc_portall,
4088 (void *)&cmd_setpromisc_mode,
4093 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4094 .f = cmd_set_promisc_mode_parsed,
4096 .help_str = "set promisc X on|off: set promisc mode on port X",
4098 (void *)&cmd_setpromisc_set,
4099 (void *)&cmd_setpromisc_promisc,
4100 (void *)&cmd_setpromisc_portnum,
4101 (void *)&cmd_setpromisc_mode,
4106 /* *** SET ALLMULTI MODE *** */
4107 struct cmd_set_allmulti_mode_result {
4108 cmdline_fixed_string_t set;
4109 cmdline_fixed_string_t allmulti;
4110 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4111 uint8_t port_num; /* valid if "allports" argument == 0 */
4112 cmdline_fixed_string_t mode;
4115 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4116 __attribute__((unused)) struct cmdline *cl,
4119 struct cmd_set_allmulti_mode_result *res = parsed_result;
4123 if (!strcmp(res->mode, "on"))
4130 for (i = 0; i < nb_ports; i++) {
4132 rte_eth_allmulticast_enable(i);
4134 rte_eth_allmulticast_disable(i);
4139 rte_eth_allmulticast_enable(res->port_num);
4141 rte_eth_allmulticast_disable(res->port_num);
4145 cmdline_parse_token_string_t cmd_setallmulti_set =
4146 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4147 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4148 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4150 cmdline_parse_token_string_t cmd_setallmulti_portall =
4151 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4153 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4154 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4156 cmdline_parse_token_string_t cmd_setallmulti_mode =
4157 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4160 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4161 .f = cmd_set_allmulti_mode_parsed,
4163 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4165 (void *)&cmd_setallmulti_set,
4166 (void *)&cmd_setallmulti_allmulti,
4167 (void *)&cmd_setallmulti_portall,
4168 (void *)&cmd_setallmulti_mode,
4173 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4174 .f = cmd_set_allmulti_mode_parsed,
4176 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4178 (void *)&cmd_setallmulti_set,
4179 (void *)&cmd_setallmulti_allmulti,
4180 (void *)&cmd_setallmulti_portnum,
4181 (void *)&cmd_setallmulti_mode,
4186 /* *** ADD/REMOVE A PKT FILTER *** */
4187 struct cmd_pkt_filter_result {
4188 cmdline_fixed_string_t pkt_filter;
4190 cmdline_fixed_string_t protocol;
4191 cmdline_fixed_string_t src;
4192 cmdline_ipaddr_t ip_src;
4194 cmdline_fixed_string_t dst;
4195 cmdline_ipaddr_t ip_dst;
4197 cmdline_fixed_string_t flexbytes;
4198 uint16_t flexbytes_value;
4199 cmdline_fixed_string_t vlan;
4201 cmdline_fixed_string_t queue;
4203 cmdline_fixed_string_t soft;
4208 cmd_pkt_filter_parsed(void *parsed_result,
4209 __attribute__((unused)) struct cmdline *cl,
4210 __attribute__((unused)) void *data)
4212 struct rte_fdir_filter fdir_filter;
4213 struct cmd_pkt_filter_result *res = parsed_result;
4215 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4217 if (res->ip_src.family == AF_INET)
4218 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4220 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4221 &(res->ip_src.addr.ipv6),
4222 sizeof(struct in6_addr));
4224 if (res->ip_dst.family == AF_INET)
4225 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4227 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4228 &(res->ip_dst.addr.ipv6),
4229 sizeof(struct in6_addr));
4231 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4232 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4234 if (!strcmp(res->protocol, "udp"))
4235 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4236 else if (!strcmp(res->protocol, "tcp"))
4237 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4238 else if (!strcmp(res->protocol, "sctp"))
4239 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4240 else /* default only IP */
4241 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4243 if (res->ip_dst.family == AF_INET6)
4244 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4246 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4248 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4249 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4251 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4252 fdir_add_signature_filter(res->port_id, res->queue_id,
4254 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4255 fdir_update_signature_filter(res->port_id, res->queue_id,
4257 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4258 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4259 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4260 fdir_add_perfect_filter(res->port_id, res->soft_id,
4262 (uint8_t) (res->queue_id < 0),
4264 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4265 fdir_update_perfect_filter(res->port_id, res->soft_id,
4267 (uint8_t) (res->queue_id < 0),
4269 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4270 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4276 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4277 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4279 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4280 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4281 protocol, "ip#tcp#udp#sctp");
4282 cmdline_parse_token_string_t cmd_pkt_filter_src =
4283 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4285 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4286 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4288 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4289 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4291 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4292 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4294 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4295 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4297 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4298 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4300 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4301 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4302 flexbytes, "flexbytes");
4303 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4304 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4305 flexbytes_value, UINT16);
4306 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4307 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4309 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4310 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4312 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4313 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4315 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4316 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4318 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4319 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4321 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4322 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4326 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4327 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4328 pkt_filter, "add_signature_filter");
4329 cmdline_parse_inst_t cmd_add_signature_filter = {
4330 .f = cmd_pkt_filter_parsed,
4332 .help_str = "add a signature filter",
4334 (void *)&cmd_pkt_filter_add_signature_filter,
4335 (void *)&cmd_pkt_filter_port_id,
4336 (void *)&cmd_pkt_filter_protocol,
4337 (void *)&cmd_pkt_filter_src,
4338 (void *)&cmd_pkt_filter_ip_src,
4339 (void *)&cmd_pkt_filter_port_src,
4340 (void *)&cmd_pkt_filter_dst,
4341 (void *)&cmd_pkt_filter_ip_dst,
4342 (void *)&cmd_pkt_filter_port_dst,
4343 (void *)&cmd_pkt_filter_flexbytes,
4344 (void *)&cmd_pkt_filter_flexbytes_value,
4345 (void *)&cmd_pkt_filter_vlan,
4346 (void *)&cmd_pkt_filter_vlan_id,
4347 (void *)&cmd_pkt_filter_queue,
4348 (void *)&cmd_pkt_filter_queue_id,
4354 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4355 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4356 pkt_filter, "upd_signature_filter");
4357 cmdline_parse_inst_t cmd_upd_signature_filter = {
4358 .f = cmd_pkt_filter_parsed,
4360 .help_str = "update a signature filter",
4362 (void *)&cmd_pkt_filter_upd_signature_filter,
4363 (void *)&cmd_pkt_filter_port_id,
4364 (void *)&cmd_pkt_filter_protocol,
4365 (void *)&cmd_pkt_filter_src,
4366 (void *)&cmd_pkt_filter_ip_src,
4367 (void *)&cmd_pkt_filter_port_src,
4368 (void *)&cmd_pkt_filter_dst,
4369 (void *)&cmd_pkt_filter_ip_dst,
4370 (void *)&cmd_pkt_filter_port_dst,
4371 (void *)&cmd_pkt_filter_flexbytes,
4372 (void *)&cmd_pkt_filter_flexbytes_value,
4373 (void *)&cmd_pkt_filter_vlan,
4374 (void *)&cmd_pkt_filter_vlan_id,
4375 (void *)&cmd_pkt_filter_queue,
4376 (void *)&cmd_pkt_filter_queue_id,
4382 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4383 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4384 pkt_filter, "rm_signature_filter");
4385 cmdline_parse_inst_t cmd_rm_signature_filter = {
4386 .f = cmd_pkt_filter_parsed,
4388 .help_str = "remove a signature filter",
4390 (void *)&cmd_pkt_filter_rm_signature_filter,
4391 (void *)&cmd_pkt_filter_port_id,
4392 (void *)&cmd_pkt_filter_protocol,
4393 (void *)&cmd_pkt_filter_src,
4394 (void *)&cmd_pkt_filter_ip_src,
4395 (void *)&cmd_pkt_filter_port_src,
4396 (void *)&cmd_pkt_filter_dst,
4397 (void *)&cmd_pkt_filter_ip_dst,
4398 (void *)&cmd_pkt_filter_port_dst,
4399 (void *)&cmd_pkt_filter_flexbytes,
4400 (void *)&cmd_pkt_filter_flexbytes_value,
4401 (void *)&cmd_pkt_filter_vlan,
4402 (void *)&cmd_pkt_filter_vlan_id,
4408 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4409 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4410 pkt_filter, "add_perfect_filter");
4411 cmdline_parse_inst_t cmd_add_perfect_filter = {
4412 .f = cmd_pkt_filter_parsed,
4414 .help_str = "add a perfect filter",
4416 (void *)&cmd_pkt_filter_add_perfect_filter,
4417 (void *)&cmd_pkt_filter_port_id,
4418 (void *)&cmd_pkt_filter_protocol,
4419 (void *)&cmd_pkt_filter_src,
4420 (void *)&cmd_pkt_filter_ip_src,
4421 (void *)&cmd_pkt_filter_port_src,
4422 (void *)&cmd_pkt_filter_dst,
4423 (void *)&cmd_pkt_filter_ip_dst,
4424 (void *)&cmd_pkt_filter_port_dst,
4425 (void *)&cmd_pkt_filter_flexbytes,
4426 (void *)&cmd_pkt_filter_flexbytes_value,
4427 (void *)&cmd_pkt_filter_vlan,
4428 (void *)&cmd_pkt_filter_vlan_id,
4429 (void *)&cmd_pkt_filter_queue,
4430 (void *)&cmd_pkt_filter_queue_id,
4431 (void *)&cmd_pkt_filter_soft,
4432 (void *)&cmd_pkt_filter_soft_id,
4438 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4439 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4440 pkt_filter, "upd_perfect_filter");
4441 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4442 .f = cmd_pkt_filter_parsed,
4444 .help_str = "update a perfect filter",
4446 (void *)&cmd_pkt_filter_upd_perfect_filter,
4447 (void *)&cmd_pkt_filter_port_id,
4448 (void *)&cmd_pkt_filter_protocol,
4449 (void *)&cmd_pkt_filter_src,
4450 (void *)&cmd_pkt_filter_ip_src,
4451 (void *)&cmd_pkt_filter_port_src,
4452 (void *)&cmd_pkt_filter_dst,
4453 (void *)&cmd_pkt_filter_ip_dst,
4454 (void *)&cmd_pkt_filter_port_dst,
4455 (void *)&cmd_pkt_filter_flexbytes,
4456 (void *)&cmd_pkt_filter_flexbytes_value,
4457 (void *)&cmd_pkt_filter_vlan,
4458 (void *)&cmd_pkt_filter_vlan_id,
4459 (void *)&cmd_pkt_filter_queue,
4460 (void *)&cmd_pkt_filter_queue_id,
4461 (void *)&cmd_pkt_filter_soft,
4462 (void *)&cmd_pkt_filter_soft_id,
4468 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4469 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4470 pkt_filter, "rm_perfect_filter");
4471 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4472 .f = cmd_pkt_filter_parsed,
4474 .help_str = "remove a perfect filter",
4476 (void *)&cmd_pkt_filter_rm_perfect_filter,
4477 (void *)&cmd_pkt_filter_port_id,
4478 (void *)&cmd_pkt_filter_protocol,
4479 (void *)&cmd_pkt_filter_src,
4480 (void *)&cmd_pkt_filter_ip_src,
4481 (void *)&cmd_pkt_filter_port_src,
4482 (void *)&cmd_pkt_filter_dst,
4483 (void *)&cmd_pkt_filter_ip_dst,
4484 (void *)&cmd_pkt_filter_port_dst,
4485 (void *)&cmd_pkt_filter_flexbytes,
4486 (void *)&cmd_pkt_filter_flexbytes_value,
4487 (void *)&cmd_pkt_filter_vlan,
4488 (void *)&cmd_pkt_filter_vlan_id,
4489 (void *)&cmd_pkt_filter_soft,
4490 (void *)&cmd_pkt_filter_soft_id,
4495 /* *** SETUP MASKS FILTER *** */
4496 struct cmd_pkt_filter_masks_result {
4497 cmdline_fixed_string_t filter_mask;
4499 cmdline_fixed_string_t src_mask;
4500 uint32_t ip_src_mask;
4501 uint16_t ipv6_src_mask;
4502 uint16_t port_src_mask;
4503 cmdline_fixed_string_t dst_mask;
4504 uint32_t ip_dst_mask;
4505 uint16_t ipv6_dst_mask;
4506 uint16_t port_dst_mask;
4507 cmdline_fixed_string_t flexbytes;
4508 uint8_t flexbytes_value;
4509 cmdline_fixed_string_t vlan_id;
4510 uint8_t vlan_id_value;
4511 cmdline_fixed_string_t vlan_prio;
4512 uint8_t vlan_prio_value;
4513 cmdline_fixed_string_t only_ip_flow;
4514 uint8_t only_ip_flow_value;
4515 cmdline_fixed_string_t comp_ipv6_dst;
4516 uint8_t comp_ipv6_dst_value;
4520 cmd_pkt_filter_masks_parsed(void *parsed_result,
4521 __attribute__((unused)) struct cmdline *cl,
4522 __attribute__((unused)) void *data)
4524 struct rte_fdir_masks fdir_masks;
4525 struct cmd_pkt_filter_masks_result *res = parsed_result;
4527 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4529 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4530 fdir_masks.vlan_id = res->vlan_id_value;
4531 fdir_masks.vlan_prio = res->vlan_prio_value;
4532 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4533 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4534 fdir_masks.src_port_mask = res->port_src_mask;
4535 fdir_masks.dst_port_mask = res->port_dst_mask;
4536 fdir_masks.flexbytes = res->flexbytes_value;
4538 fdir_set_masks(res->port_id, &fdir_masks);
4541 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4542 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4543 filter_mask, "set_masks_filter");
4544 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4545 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4547 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4548 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4549 only_ip_flow, "only_ip_flow");
4550 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4551 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4552 only_ip_flow_value, UINT8);
4553 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4554 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4555 src_mask, "src_mask");
4556 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4557 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4558 ip_src_mask, UINT32);
4559 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4560 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4561 port_src_mask, UINT16);
4562 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4563 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4564 dst_mask, "dst_mask");
4565 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4566 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4567 ip_dst_mask, UINT32);
4568 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4569 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4570 port_dst_mask, UINT16);
4571 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4572 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4573 flexbytes, "flexbytes");
4574 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4575 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4576 flexbytes_value, UINT8);
4577 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4578 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4579 vlan_id, "vlan_id");
4580 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4581 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4582 vlan_id_value, UINT8);
4583 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4584 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4585 vlan_prio, "vlan_prio");
4586 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4587 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4588 vlan_prio_value, UINT8);
4590 cmdline_parse_inst_t cmd_set_masks_filter = {
4591 .f = cmd_pkt_filter_masks_parsed,
4593 .help_str = "setup masks filter",
4595 (void *)&cmd_pkt_filter_masks_filter_mask,
4596 (void *)&cmd_pkt_filter_masks_port_id,
4597 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4598 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4599 (void *)&cmd_pkt_filter_masks_src_mask,
4600 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4601 (void *)&cmd_pkt_filter_masks_port_src_mask,
4602 (void *)&cmd_pkt_filter_masks_dst_mask,
4603 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4604 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4605 (void *)&cmd_pkt_filter_masks_flexbytes,
4606 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4607 (void *)&cmd_pkt_filter_masks_vlan_id,
4608 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4609 (void *)&cmd_pkt_filter_masks_vlan_prio,
4610 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4616 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4617 __attribute__((unused)) struct cmdline *cl,
4618 __attribute__((unused)) void *data)
4620 struct rte_fdir_masks fdir_masks;
4621 struct cmd_pkt_filter_masks_result *res = parsed_result;
4623 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4625 fdir_masks.set_ipv6_mask = 1;
4626 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4627 fdir_masks.vlan_id = res->vlan_id_value;
4628 fdir_masks.vlan_prio = res->vlan_prio_value;
4629 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4630 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4631 fdir_masks.src_port_mask = res->port_src_mask;
4632 fdir_masks.dst_port_mask = res->port_dst_mask;
4633 fdir_masks.flexbytes = res->flexbytes_value;
4634 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4636 fdir_set_masks(res->port_id, &fdir_masks);
4639 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4640 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4641 filter_mask, "set_ipv6_masks_filter");
4642 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4643 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4644 ipv6_src_mask, UINT16);
4645 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4646 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4647 ipv6_dst_mask, UINT16);
4649 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4650 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4651 comp_ipv6_dst, "compare_dst");
4652 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4653 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4654 comp_ipv6_dst_value, UINT8);
4656 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4657 .f = cmd_pkt_filter_masks_ipv6_parsed,
4659 .help_str = "setup ipv6 masks filter",
4661 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4662 (void *)&cmd_pkt_filter_masks_port_id,
4663 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4664 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4665 (void *)&cmd_pkt_filter_masks_src_mask,
4666 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4667 (void *)&cmd_pkt_filter_masks_port_src_mask,
4668 (void *)&cmd_pkt_filter_masks_dst_mask,
4669 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4670 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4671 (void *)&cmd_pkt_filter_masks_flexbytes,
4672 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4673 (void *)&cmd_pkt_filter_masks_vlan_id,
4674 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4675 (void *)&cmd_pkt_filter_masks_vlan_prio,
4676 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4677 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4678 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4683 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4684 struct cmd_link_flow_ctrl_set_result {
4685 cmdline_fixed_string_t set;
4686 cmdline_fixed_string_t flow_ctrl;
4687 cmdline_fixed_string_t rx;
4688 cmdline_fixed_string_t rx_lfc_mode;
4689 cmdline_fixed_string_t tx;
4690 cmdline_fixed_string_t tx_lfc_mode;
4691 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4692 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4693 cmdline_fixed_string_t autoneg_str;
4694 cmdline_fixed_string_t autoneg;
4695 cmdline_fixed_string_t hw_str;
4696 uint32_t high_water;
4697 cmdline_fixed_string_t lw_str;
4699 cmdline_fixed_string_t pt_str;
4700 uint16_t pause_time;
4701 cmdline_fixed_string_t xon_str;
4706 cmdline_parse_token_string_t cmd_lfc_set_set =
4707 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4709 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4710 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4711 flow_ctrl, "flow_ctrl");
4712 cmdline_parse_token_string_t cmd_lfc_set_rx =
4713 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4715 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4716 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4717 rx_lfc_mode, "on#off");
4718 cmdline_parse_token_string_t cmd_lfc_set_tx =
4719 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4721 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4722 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4723 tx_lfc_mode, "on#off");
4724 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4725 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4726 hw_str, "high_water");
4727 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4728 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4729 high_water, UINT32);
4730 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4731 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4732 lw_str, "low_water");
4733 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4734 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4736 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4737 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4738 pt_str, "pause_time");
4739 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4740 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4741 pause_time, UINT16);
4742 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4743 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4744 xon_str, "send_xon");
4745 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4746 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4748 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4749 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4750 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4751 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4752 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4753 mac_ctrl_frame_fwd_mode, "on#off");
4754 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4755 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4756 autoneg_str, "autoneg");
4757 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4758 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4760 cmdline_parse_token_num_t cmd_lfc_set_portid =
4761 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4764 /* forward declaration */
4766 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4769 cmdline_parse_inst_t cmd_link_flow_control_set = {
4770 .f = cmd_link_flow_ctrl_set_parsed,
4772 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4773 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4774 autoneg on|off port_id",
4776 (void *)&cmd_lfc_set_set,
4777 (void *)&cmd_lfc_set_flow_ctrl,
4778 (void *)&cmd_lfc_set_rx,
4779 (void *)&cmd_lfc_set_rx_mode,
4780 (void *)&cmd_lfc_set_tx,
4781 (void *)&cmd_lfc_set_tx_mode,
4782 (void *)&cmd_lfc_set_high_water,
4783 (void *)&cmd_lfc_set_low_water,
4784 (void *)&cmd_lfc_set_pause_time,
4785 (void *)&cmd_lfc_set_send_xon,
4786 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4787 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4788 (void *)&cmd_lfc_set_autoneg_str,
4789 (void *)&cmd_lfc_set_autoneg,
4790 (void *)&cmd_lfc_set_portid,
4795 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4796 .f = cmd_link_flow_ctrl_set_parsed,
4797 .data = (void *)&cmd_link_flow_control_set_rx,
4798 .help_str = "Change rx flow control parameter: set flow_ctrl "
4799 "rx on|off port_id",
4801 (void *)&cmd_lfc_set_set,
4802 (void *)&cmd_lfc_set_flow_ctrl,
4803 (void *)&cmd_lfc_set_rx,
4804 (void *)&cmd_lfc_set_rx_mode,
4805 (void *)&cmd_lfc_set_portid,
4810 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4811 .f = cmd_link_flow_ctrl_set_parsed,
4812 .data = (void *)&cmd_link_flow_control_set_tx,
4813 .help_str = "Change tx flow control parameter: set flow_ctrl "
4814 "tx on|off port_id",
4816 (void *)&cmd_lfc_set_set,
4817 (void *)&cmd_lfc_set_flow_ctrl,
4818 (void *)&cmd_lfc_set_tx,
4819 (void *)&cmd_lfc_set_tx_mode,
4820 (void *)&cmd_lfc_set_portid,
4825 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4826 .f = cmd_link_flow_ctrl_set_parsed,
4827 .data = (void *)&cmd_link_flow_control_set_hw,
4828 .help_str = "Change high water flow control parameter: set flow_ctrl "
4829 "high_water value port_id",
4831 (void *)&cmd_lfc_set_set,
4832 (void *)&cmd_lfc_set_flow_ctrl,
4833 (void *)&cmd_lfc_set_high_water_str,
4834 (void *)&cmd_lfc_set_high_water,
4835 (void *)&cmd_lfc_set_portid,
4840 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4841 .f = cmd_link_flow_ctrl_set_parsed,
4842 .data = (void *)&cmd_link_flow_control_set_lw,
4843 .help_str = "Change low water flow control parameter: set flow_ctrl "
4844 "low_water value port_id",
4846 (void *)&cmd_lfc_set_set,
4847 (void *)&cmd_lfc_set_flow_ctrl,
4848 (void *)&cmd_lfc_set_low_water_str,
4849 (void *)&cmd_lfc_set_low_water,
4850 (void *)&cmd_lfc_set_portid,
4855 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4856 .f = cmd_link_flow_ctrl_set_parsed,
4857 .data = (void *)&cmd_link_flow_control_set_pt,
4858 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4859 "pause_time value port_id",
4861 (void *)&cmd_lfc_set_set,
4862 (void *)&cmd_lfc_set_flow_ctrl,
4863 (void *)&cmd_lfc_set_pause_time_str,
4864 (void *)&cmd_lfc_set_pause_time,
4865 (void *)&cmd_lfc_set_portid,
4870 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4871 .f = cmd_link_flow_ctrl_set_parsed,
4872 .data = (void *)&cmd_link_flow_control_set_xon,
4873 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4874 "send_xon value port_id",
4876 (void *)&cmd_lfc_set_set,
4877 (void *)&cmd_lfc_set_flow_ctrl,
4878 (void *)&cmd_lfc_set_send_xon_str,
4879 (void *)&cmd_lfc_set_send_xon,
4880 (void *)&cmd_lfc_set_portid,
4885 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4886 .f = cmd_link_flow_ctrl_set_parsed,
4887 .data = (void *)&cmd_link_flow_control_set_macfwd,
4888 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4889 "mac_ctrl_frame_fwd on|off port_id",
4891 (void *)&cmd_lfc_set_set,
4892 (void *)&cmd_lfc_set_flow_ctrl,
4893 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4894 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4895 (void *)&cmd_lfc_set_portid,
4900 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4901 .f = cmd_link_flow_ctrl_set_parsed,
4902 .data = (void *)&cmd_link_flow_control_set_autoneg,
4903 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4904 "autoneg on|off port_id",
4906 (void *)&cmd_lfc_set_set,
4907 (void *)&cmd_lfc_set_flow_ctrl,
4908 (void *)&cmd_lfc_set_autoneg_str,
4909 (void *)&cmd_lfc_set_autoneg,
4910 (void *)&cmd_lfc_set_portid,
4916 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4917 __attribute__((unused)) struct cmdline *cl,
4920 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4921 cmdline_parse_inst_t *cmd = data;
4922 struct rte_eth_fc_conf fc_conf;
4923 int rx_fc_en, tx_fc_en;
4927 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4928 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4929 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4930 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4932 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4933 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4936 /* Partial command line, retrieve current configuration */
4938 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4940 printf("cannot get current flow ctrl parameters, return"
4941 "code = %d\n", ret);
4945 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4946 (fc_conf.mode == RTE_FC_FULL))
4948 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4949 (fc_conf.mode == RTE_FC_FULL))
4953 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4954 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4956 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4957 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4959 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4961 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4962 fc_conf.high_water = res->high_water;
4964 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4965 fc_conf.low_water = res->low_water;
4967 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4968 fc_conf.pause_time = res->pause_time;
4970 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4971 fc_conf.send_xon = res->send_xon;
4973 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4974 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4975 fc_conf.mac_ctrl_frame_fwd = 1;
4977 fc_conf.mac_ctrl_frame_fwd = 0;
4980 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4981 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4983 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4985 printf("bad flow contrl parameter, return code = %d \n", ret);
4988 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4989 struct cmd_priority_flow_ctrl_set_result {
4990 cmdline_fixed_string_t set;
4991 cmdline_fixed_string_t pfc_ctrl;
4992 cmdline_fixed_string_t rx;
4993 cmdline_fixed_string_t rx_pfc_mode;
4994 cmdline_fixed_string_t tx;
4995 cmdline_fixed_string_t tx_pfc_mode;
4996 uint32_t high_water;
4998 uint16_t pause_time;
5004 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5005 __attribute__((unused)) struct cmdline *cl,
5006 __attribute__((unused)) void *data)
5008 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5009 struct rte_eth_pfc_conf pfc_conf;
5010 int rx_fc_enable, tx_fc_enable;
5014 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5015 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5016 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5017 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5019 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5020 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5023 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5024 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5025 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5026 pfc_conf.fc.high_water = res->high_water;
5027 pfc_conf.fc.low_water = res->low_water;
5028 pfc_conf.fc.pause_time = res->pause_time;
5029 pfc_conf.priority = res->priority;
5031 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5033 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5036 cmdline_parse_token_string_t cmd_pfc_set_set =
5037 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5039 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5040 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5041 pfc_ctrl, "pfc_ctrl");
5042 cmdline_parse_token_string_t cmd_pfc_set_rx =
5043 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5045 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5046 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5047 rx_pfc_mode, "on#off");
5048 cmdline_parse_token_string_t cmd_pfc_set_tx =
5049 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5051 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5052 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5053 tx_pfc_mode, "on#off");
5054 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5055 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5056 high_water, UINT32);
5057 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5058 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5060 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5061 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5062 pause_time, UINT16);
5063 cmdline_parse_token_num_t cmd_pfc_set_priority =
5064 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5066 cmdline_parse_token_num_t cmd_pfc_set_portid =
5067 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5070 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5071 .f = cmd_priority_flow_ctrl_set_parsed,
5073 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5074 tx on|off high_water low_water pause_time priority port_id",
5076 (void *)&cmd_pfc_set_set,
5077 (void *)&cmd_pfc_set_flow_ctrl,
5078 (void *)&cmd_pfc_set_rx,
5079 (void *)&cmd_pfc_set_rx_mode,
5080 (void *)&cmd_pfc_set_tx,
5081 (void *)&cmd_pfc_set_tx_mode,
5082 (void *)&cmd_pfc_set_high_water,
5083 (void *)&cmd_pfc_set_low_water,
5084 (void *)&cmd_pfc_set_pause_time,
5085 (void *)&cmd_pfc_set_priority,
5086 (void *)&cmd_pfc_set_portid,
5091 /* *** RESET CONFIGURATION *** */
5092 struct cmd_reset_result {
5093 cmdline_fixed_string_t reset;
5094 cmdline_fixed_string_t def;
5097 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5099 __attribute__((unused)) void *data)
5101 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5102 set_def_fwd_config();
5105 cmdline_parse_token_string_t cmd_reset_set =
5106 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5107 cmdline_parse_token_string_t cmd_reset_def =
5108 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5111 cmdline_parse_inst_t cmd_reset = {
5112 .f = cmd_reset_parsed,
5114 .help_str = "set default: reset default forwarding configuration",
5116 (void *)&cmd_reset_set,
5117 (void *)&cmd_reset_def,
5122 /* *** START FORWARDING *** */
5123 struct cmd_start_result {
5124 cmdline_fixed_string_t start;
5127 cmdline_parse_token_string_t cmd_start_start =
5128 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5130 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5131 __attribute__((unused)) struct cmdline *cl,
5132 __attribute__((unused)) void *data)
5134 start_packet_forwarding(0);
5137 cmdline_parse_inst_t cmd_start = {
5138 .f = cmd_start_parsed,
5140 .help_str = "start packet forwarding",
5142 (void *)&cmd_start_start,
5147 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5148 struct cmd_start_tx_first_result {
5149 cmdline_fixed_string_t start;
5150 cmdline_fixed_string_t tx_first;
5154 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5155 __attribute__((unused)) struct cmdline *cl,
5156 __attribute__((unused)) void *data)
5158 start_packet_forwarding(1);
5161 cmdline_parse_token_string_t cmd_start_tx_first_start =
5162 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5164 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5165 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5166 tx_first, "tx_first");
5168 cmdline_parse_inst_t cmd_start_tx_first = {
5169 .f = cmd_start_tx_first_parsed,
5171 .help_str = "start packet forwarding, after sending 1 burst of packets",
5173 (void *)&cmd_start_tx_first_start,
5174 (void *)&cmd_start_tx_first_tx_first,
5179 /* *** SET LINK UP *** */
5180 struct cmd_set_link_up_result {
5181 cmdline_fixed_string_t set;
5182 cmdline_fixed_string_t link_up;
5183 cmdline_fixed_string_t port;
5187 cmdline_parse_token_string_t cmd_set_link_up_set =
5188 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5189 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5192 cmdline_parse_token_string_t cmd_set_link_up_port =
5193 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5194 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5195 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5197 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5198 __attribute__((unused)) struct cmdline *cl,
5199 __attribute__((unused)) void *data)
5201 struct cmd_set_link_up_result *res = parsed_result;
5202 dev_set_link_up(res->port_id);
5205 cmdline_parse_inst_t cmd_set_link_up = {
5206 .f = cmd_set_link_up_parsed,
5208 .help_str = "set link-up port (port id)",
5210 (void *)&cmd_set_link_up_set,
5211 (void *)&cmd_set_link_up_link_up,
5212 (void *)&cmd_set_link_up_port,
5213 (void *)&cmd_set_link_up_port_id,
5218 /* *** SET LINK DOWN *** */
5219 struct cmd_set_link_down_result {
5220 cmdline_fixed_string_t set;
5221 cmdline_fixed_string_t link_down;
5222 cmdline_fixed_string_t port;
5226 cmdline_parse_token_string_t cmd_set_link_down_set =
5227 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5228 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5229 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5231 cmdline_parse_token_string_t cmd_set_link_down_port =
5232 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5233 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5234 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5236 static void cmd_set_link_down_parsed(
5237 __attribute__((unused)) void *parsed_result,
5238 __attribute__((unused)) struct cmdline *cl,
5239 __attribute__((unused)) void *data)
5241 struct cmd_set_link_down_result *res = parsed_result;
5242 dev_set_link_down(res->port_id);
5245 cmdline_parse_inst_t cmd_set_link_down = {
5246 .f = cmd_set_link_down_parsed,
5248 .help_str = "set link-down port (port id)",
5250 (void *)&cmd_set_link_down_set,
5251 (void *)&cmd_set_link_down_link_down,
5252 (void *)&cmd_set_link_down_port,
5253 (void *)&cmd_set_link_down_port_id,
5258 /* *** SHOW CFG *** */
5259 struct cmd_showcfg_result {
5260 cmdline_fixed_string_t show;
5261 cmdline_fixed_string_t cfg;
5262 cmdline_fixed_string_t what;
5265 static void cmd_showcfg_parsed(void *parsed_result,
5266 __attribute__((unused)) struct cmdline *cl,
5267 __attribute__((unused)) void *data)
5269 struct cmd_showcfg_result *res = parsed_result;
5270 if (!strcmp(res->what, "rxtx"))
5271 rxtx_config_display();
5272 else if (!strcmp(res->what, "cores"))
5273 fwd_lcores_config_display();
5274 else if (!strcmp(res->what, "fwd"))
5275 fwd_config_display();
5278 cmdline_parse_token_string_t cmd_showcfg_show =
5279 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5280 cmdline_parse_token_string_t cmd_showcfg_port =
5281 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5282 cmdline_parse_token_string_t cmd_showcfg_what =
5283 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5286 cmdline_parse_inst_t cmd_showcfg = {
5287 .f = cmd_showcfg_parsed,
5289 .help_str = "show config rxtx|cores|fwd",
5291 (void *)&cmd_showcfg_show,
5292 (void *)&cmd_showcfg_port,
5293 (void *)&cmd_showcfg_what,
5298 /* *** SHOW ALL PORT INFO *** */
5299 struct cmd_showportall_result {
5300 cmdline_fixed_string_t show;
5301 cmdline_fixed_string_t port;
5302 cmdline_fixed_string_t what;
5303 cmdline_fixed_string_t all;
5306 static void cmd_showportall_parsed(void *parsed_result,
5307 __attribute__((unused)) struct cmdline *cl,
5308 __attribute__((unused)) void *data)
5312 struct cmd_showportall_result *res = parsed_result;
5313 if (!strcmp(res->show, "clear")) {
5314 if (!strcmp(res->what, "stats"))
5315 for (i = 0; i < nb_ports; i++)
5317 else if (!strcmp(res->what, "xstats"))
5318 for (i = 0; i < nb_ports; i++)
5319 nic_xstats_clear(i);
5320 } else if (!strcmp(res->what, "info"))
5321 for (i = 0; i < nb_ports; i++)
5322 port_infos_display(i);
5323 else if (!strcmp(res->what, "stats"))
5324 for (i = 0; i < nb_ports; i++)
5325 nic_stats_display(i);
5326 else if (!strcmp(res->what, "xstats"))
5327 for (i = 0; i < nb_ports; i++)
5328 nic_xstats_display(i);
5329 else if (!strcmp(res->what, "fdir"))
5330 for (i = 0; i < nb_ports; i++)
5332 else if (!strcmp(res->what, "stat_qmap"))
5333 for (i = 0; i < nb_ports; i++)
5334 nic_stats_mapping_display(i);
5337 cmdline_parse_token_string_t cmd_showportall_show =
5338 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5340 cmdline_parse_token_string_t cmd_showportall_port =
5341 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5342 cmdline_parse_token_string_t cmd_showportall_what =
5343 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5344 "info#stats#xstats#fdir#stat_qmap");
5345 cmdline_parse_token_string_t cmd_showportall_all =
5346 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5347 cmdline_parse_inst_t cmd_showportall = {
5348 .f = cmd_showportall_parsed,
5350 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5352 (void *)&cmd_showportall_show,
5353 (void *)&cmd_showportall_port,
5354 (void *)&cmd_showportall_what,
5355 (void *)&cmd_showportall_all,
5360 /* *** SHOW PORT INFO *** */
5361 struct cmd_showport_result {
5362 cmdline_fixed_string_t show;
5363 cmdline_fixed_string_t port;
5364 cmdline_fixed_string_t what;
5368 static void cmd_showport_parsed(void *parsed_result,
5369 __attribute__((unused)) struct cmdline *cl,
5370 __attribute__((unused)) void *data)
5372 struct cmd_showport_result *res = parsed_result;
5373 if (!strcmp(res->show, "clear")) {
5374 if (!strcmp(res->what, "stats"))
5375 nic_stats_clear(res->portnum);
5376 else if (!strcmp(res->what, "xstats"))
5377 nic_xstats_clear(res->portnum);
5378 } else if (!strcmp(res->what, "info"))
5379 port_infos_display(res->portnum);
5380 else if (!strcmp(res->what, "stats"))
5381 nic_stats_display(res->portnum);
5382 else if (!strcmp(res->what, "xstats"))
5383 nic_xstats_display(res->portnum);
5384 else if (!strcmp(res->what, "fdir"))
5385 fdir_get_infos(res->portnum);
5386 else if (!strcmp(res->what, "stat_qmap"))
5387 nic_stats_mapping_display(res->portnum);
5390 cmdline_parse_token_string_t cmd_showport_show =
5391 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5393 cmdline_parse_token_string_t cmd_showport_port =
5394 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5395 cmdline_parse_token_string_t cmd_showport_what =
5396 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5397 "info#stats#xstats#fdir#stat_qmap");
5398 cmdline_parse_token_num_t cmd_showport_portnum =
5399 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5401 cmdline_parse_inst_t cmd_showport = {
5402 .f = cmd_showport_parsed,
5404 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5406 (void *)&cmd_showport_show,
5407 (void *)&cmd_showport_port,
5408 (void *)&cmd_showport_what,
5409 (void *)&cmd_showport_portnum,
5414 /* *** READ PORT REGISTER *** */
5415 struct cmd_read_reg_result {
5416 cmdline_fixed_string_t read;
5417 cmdline_fixed_string_t reg;
5423 cmd_read_reg_parsed(void *parsed_result,
5424 __attribute__((unused)) struct cmdline *cl,
5425 __attribute__((unused)) void *data)
5427 struct cmd_read_reg_result *res = parsed_result;
5428 port_reg_display(res->port_id, res->reg_off);
5431 cmdline_parse_token_string_t cmd_read_reg_read =
5432 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5433 cmdline_parse_token_string_t cmd_read_reg_reg =
5434 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5435 cmdline_parse_token_num_t cmd_read_reg_port_id =
5436 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5437 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5438 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5440 cmdline_parse_inst_t cmd_read_reg = {
5441 .f = cmd_read_reg_parsed,
5443 .help_str = "read reg port_id reg_off",
5445 (void *)&cmd_read_reg_read,
5446 (void *)&cmd_read_reg_reg,
5447 (void *)&cmd_read_reg_port_id,
5448 (void *)&cmd_read_reg_reg_off,
5453 /* *** READ PORT REGISTER BIT FIELD *** */
5454 struct cmd_read_reg_bit_field_result {
5455 cmdline_fixed_string_t read;
5456 cmdline_fixed_string_t regfield;
5464 cmd_read_reg_bit_field_parsed(void *parsed_result,
5465 __attribute__((unused)) struct cmdline *cl,
5466 __attribute__((unused)) void *data)
5468 struct cmd_read_reg_bit_field_result *res = parsed_result;
5469 port_reg_bit_field_display(res->port_id, res->reg_off,
5470 res->bit1_pos, res->bit2_pos);
5473 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5474 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5476 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5477 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5478 regfield, "regfield");
5479 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5480 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5482 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5483 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5485 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5486 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5488 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5489 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5492 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5493 .f = cmd_read_reg_bit_field_parsed,
5495 .help_str = "read regfield port_id reg_off bit_x bit_y "
5496 "(read register bit field between bit_x and bit_y included)",
5498 (void *)&cmd_read_reg_bit_field_read,
5499 (void *)&cmd_read_reg_bit_field_regfield,
5500 (void *)&cmd_read_reg_bit_field_port_id,
5501 (void *)&cmd_read_reg_bit_field_reg_off,
5502 (void *)&cmd_read_reg_bit_field_bit1_pos,
5503 (void *)&cmd_read_reg_bit_field_bit2_pos,
5508 /* *** READ PORT REGISTER BIT *** */
5509 struct cmd_read_reg_bit_result {
5510 cmdline_fixed_string_t read;
5511 cmdline_fixed_string_t regbit;
5518 cmd_read_reg_bit_parsed(void *parsed_result,
5519 __attribute__((unused)) struct cmdline *cl,
5520 __attribute__((unused)) void *data)
5522 struct cmd_read_reg_bit_result *res = parsed_result;
5523 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5526 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5527 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5528 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5529 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5531 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5532 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5533 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5534 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5535 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5536 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5538 cmdline_parse_inst_t cmd_read_reg_bit = {
5539 .f = cmd_read_reg_bit_parsed,
5541 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5543 (void *)&cmd_read_reg_bit_read,
5544 (void *)&cmd_read_reg_bit_regbit,
5545 (void *)&cmd_read_reg_bit_port_id,
5546 (void *)&cmd_read_reg_bit_reg_off,
5547 (void *)&cmd_read_reg_bit_bit_pos,
5552 /* *** WRITE PORT REGISTER *** */
5553 struct cmd_write_reg_result {
5554 cmdline_fixed_string_t write;
5555 cmdline_fixed_string_t reg;
5562 cmd_write_reg_parsed(void *parsed_result,
5563 __attribute__((unused)) struct cmdline *cl,
5564 __attribute__((unused)) void *data)
5566 struct cmd_write_reg_result *res = parsed_result;
5567 port_reg_set(res->port_id, res->reg_off, res->value);
5570 cmdline_parse_token_string_t cmd_write_reg_write =
5571 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5572 cmdline_parse_token_string_t cmd_write_reg_reg =
5573 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5574 cmdline_parse_token_num_t cmd_write_reg_port_id =
5575 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5576 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5577 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5578 cmdline_parse_token_num_t cmd_write_reg_value =
5579 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5581 cmdline_parse_inst_t cmd_write_reg = {
5582 .f = cmd_write_reg_parsed,
5584 .help_str = "write reg port_id reg_off reg_value",
5586 (void *)&cmd_write_reg_write,
5587 (void *)&cmd_write_reg_reg,
5588 (void *)&cmd_write_reg_port_id,
5589 (void *)&cmd_write_reg_reg_off,
5590 (void *)&cmd_write_reg_value,
5595 /* *** WRITE PORT REGISTER BIT FIELD *** */
5596 struct cmd_write_reg_bit_field_result {
5597 cmdline_fixed_string_t write;
5598 cmdline_fixed_string_t regfield;
5607 cmd_write_reg_bit_field_parsed(void *parsed_result,
5608 __attribute__((unused)) struct cmdline *cl,
5609 __attribute__((unused)) void *data)
5611 struct cmd_write_reg_bit_field_result *res = parsed_result;
5612 port_reg_bit_field_set(res->port_id, res->reg_off,
5613 res->bit1_pos, res->bit2_pos, res->value);
5616 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5617 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5619 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5620 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5621 regfield, "regfield");
5622 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5623 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5625 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5626 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5628 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5629 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5631 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5632 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5634 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5635 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5638 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5639 .f = cmd_write_reg_bit_field_parsed,
5641 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5642 "(set register bit field between bit_x and bit_y included)",
5644 (void *)&cmd_write_reg_bit_field_write,
5645 (void *)&cmd_write_reg_bit_field_regfield,
5646 (void *)&cmd_write_reg_bit_field_port_id,
5647 (void *)&cmd_write_reg_bit_field_reg_off,
5648 (void *)&cmd_write_reg_bit_field_bit1_pos,
5649 (void *)&cmd_write_reg_bit_field_bit2_pos,
5650 (void *)&cmd_write_reg_bit_field_value,
5655 /* *** WRITE PORT REGISTER BIT *** */
5656 struct cmd_write_reg_bit_result {
5657 cmdline_fixed_string_t write;
5658 cmdline_fixed_string_t regbit;
5666 cmd_write_reg_bit_parsed(void *parsed_result,
5667 __attribute__((unused)) struct cmdline *cl,
5668 __attribute__((unused)) void *data)
5670 struct cmd_write_reg_bit_result *res = parsed_result;
5671 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5674 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5675 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5677 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5678 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5680 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5681 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5682 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5683 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5684 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5685 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5686 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5687 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5689 cmdline_parse_inst_t cmd_write_reg_bit = {
5690 .f = cmd_write_reg_bit_parsed,
5692 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5694 (void *)&cmd_write_reg_bit_write,
5695 (void *)&cmd_write_reg_bit_regbit,
5696 (void *)&cmd_write_reg_bit_port_id,
5697 (void *)&cmd_write_reg_bit_reg_off,
5698 (void *)&cmd_write_reg_bit_bit_pos,
5699 (void *)&cmd_write_reg_bit_value,
5704 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5705 struct cmd_read_rxd_txd_result {
5706 cmdline_fixed_string_t read;
5707 cmdline_fixed_string_t rxd_txd;
5714 cmd_read_rxd_txd_parsed(void *parsed_result,
5715 __attribute__((unused)) struct cmdline *cl,
5716 __attribute__((unused)) void *data)
5718 struct cmd_read_rxd_txd_result *res = parsed_result;
5720 if (!strcmp(res->rxd_txd, "rxd"))
5721 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5722 else if (!strcmp(res->rxd_txd, "txd"))
5723 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5726 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5727 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5728 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5729 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5731 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5732 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5733 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5734 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5735 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5736 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5738 cmdline_parse_inst_t cmd_read_rxd_txd = {
5739 .f = cmd_read_rxd_txd_parsed,
5741 .help_str = "read rxd|txd port_id queue_id rxd_id",
5743 (void *)&cmd_read_rxd_txd_read,
5744 (void *)&cmd_read_rxd_txd_rxd_txd,
5745 (void *)&cmd_read_rxd_txd_port_id,
5746 (void *)&cmd_read_rxd_txd_queue_id,
5747 (void *)&cmd_read_rxd_txd_desc_id,
5753 struct cmd_quit_result {
5754 cmdline_fixed_string_t quit;
5757 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5759 __attribute__((unused)) void *data)
5765 cmdline_parse_token_string_t cmd_quit_quit =
5766 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5768 cmdline_parse_inst_t cmd_quit = {
5769 .f = cmd_quit_parsed,
5771 .help_str = "exit application",
5773 (void *)&cmd_quit_quit,
5778 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5779 struct cmd_mac_addr_result {
5780 cmdline_fixed_string_t mac_addr_cmd;
5781 cmdline_fixed_string_t what;
5783 struct ether_addr address;
5786 static void cmd_mac_addr_parsed(void *parsed_result,
5787 __attribute__((unused)) struct cmdline *cl,
5788 __attribute__((unused)) void *data)
5790 struct cmd_mac_addr_result *res = parsed_result;
5793 if (strcmp(res->what, "add") == 0)
5794 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5796 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5798 /* check the return value and print it if is < 0 */
5800 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5804 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5805 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5807 cmdline_parse_token_string_t cmd_mac_addr_what =
5808 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5810 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5811 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5812 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5813 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5815 cmdline_parse_inst_t cmd_mac_addr = {
5816 .f = cmd_mac_addr_parsed,
5818 .help_str = "mac_addr add|remove X <address>: "
5819 "add/remove MAC address on port X",
5821 (void *)&cmd_mac_addr_cmd,
5822 (void *)&cmd_mac_addr_what,
5823 (void *)&cmd_mac_addr_portnum,
5824 (void *)&cmd_mac_addr_addr,
5830 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5831 struct cmd_set_qmap_result {
5832 cmdline_fixed_string_t set;
5833 cmdline_fixed_string_t qmap;
5834 cmdline_fixed_string_t what;
5841 cmd_set_qmap_parsed(void *parsed_result,
5842 __attribute__((unused)) struct cmdline *cl,
5843 __attribute__((unused)) void *data)
5845 struct cmd_set_qmap_result *res = parsed_result;
5846 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5848 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5851 cmdline_parse_token_string_t cmd_setqmap_set =
5852 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5854 cmdline_parse_token_string_t cmd_setqmap_qmap =
5855 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5857 cmdline_parse_token_string_t cmd_setqmap_what =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5860 cmdline_parse_token_num_t cmd_setqmap_portid =
5861 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5863 cmdline_parse_token_num_t cmd_setqmap_queueid =
5864 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5866 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5867 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5870 cmdline_parse_inst_t cmd_set_qmap = {
5871 .f = cmd_set_qmap_parsed,
5873 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5875 (void *)&cmd_setqmap_set,
5876 (void *)&cmd_setqmap_qmap,
5877 (void *)&cmd_setqmap_what,
5878 (void *)&cmd_setqmap_portid,
5879 (void *)&cmd_setqmap_queueid,
5880 (void *)&cmd_setqmap_mapvalue,
5885 /* *** CONFIGURE UNICAST HASH TABLE *** */
5886 struct cmd_set_uc_hash_table {
5887 cmdline_fixed_string_t set;
5888 cmdline_fixed_string_t port;
5890 cmdline_fixed_string_t what;
5891 struct ether_addr address;
5892 cmdline_fixed_string_t mode;
5896 cmd_set_uc_hash_parsed(void *parsed_result,
5897 __attribute__((unused)) struct cmdline *cl,
5898 __attribute__((unused)) void *data)
5901 struct cmd_set_uc_hash_table *res = parsed_result;
5903 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5905 if (strcmp(res->what, "uta") == 0)
5906 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5907 &res->address,(uint8_t)is_on);
5909 printf("bad unicast hash table parameter, return code = %d \n", ret);
5913 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5916 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5919 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5920 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5922 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5923 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5925 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5926 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5928 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5932 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5933 .f = cmd_set_uc_hash_parsed,
5935 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5937 (void *)&cmd_set_uc_hash_set,
5938 (void *)&cmd_set_uc_hash_port,
5939 (void *)&cmd_set_uc_hash_portid,
5940 (void *)&cmd_set_uc_hash_what,
5941 (void *)&cmd_set_uc_hash_mac,
5942 (void *)&cmd_set_uc_hash_mode,
5947 struct cmd_set_uc_all_hash_table {
5948 cmdline_fixed_string_t set;
5949 cmdline_fixed_string_t port;
5951 cmdline_fixed_string_t what;
5952 cmdline_fixed_string_t value;
5953 cmdline_fixed_string_t mode;
5957 cmd_set_uc_all_hash_parsed(void *parsed_result,
5958 __attribute__((unused)) struct cmdline *cl,
5959 __attribute__((unused)) void *data)
5962 struct cmd_set_uc_all_hash_table *res = parsed_result;
5964 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5966 if ((strcmp(res->what, "uta") == 0) &&
5967 (strcmp(res->value, "all") == 0))
5968 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5970 printf("bad unicast hash table parameter,"
5971 "return code = %d \n", ret);
5974 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5977 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5980 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5981 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5983 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5984 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5986 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5987 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5989 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5990 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5993 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5994 .f = cmd_set_uc_all_hash_parsed,
5996 .help_str = "set port X uta all on|off (X = port number)",
5998 (void *)&cmd_set_uc_all_hash_set,
5999 (void *)&cmd_set_uc_all_hash_port,
6000 (void *)&cmd_set_uc_all_hash_portid,
6001 (void *)&cmd_set_uc_all_hash_what,
6002 (void *)&cmd_set_uc_all_hash_value,
6003 (void *)&cmd_set_uc_all_hash_mode,
6008 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6009 struct cmd_set_vf_macvlan_filter {
6010 cmdline_fixed_string_t set;
6011 cmdline_fixed_string_t port;
6013 cmdline_fixed_string_t vf;
6015 struct ether_addr address;
6016 cmdline_fixed_string_t filter_type;
6017 cmdline_fixed_string_t mode;
6021 cmd_set_vf_macvlan_parsed(void *parsed_result,
6022 __attribute__((unused)) struct cmdline *cl,
6023 __attribute__((unused)) void *data)
6026 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6027 struct rte_eth_mac_filter filter;
6029 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6031 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6033 /* set VF MAC filter */
6037 filter.dst_id = res->vf_id;
6039 if (!strcmp(res->filter_type, "exact-mac"))
6040 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6041 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6042 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6043 else if (!strcmp(res->filter_type, "hashmac"))
6044 filter.filter_type = RTE_MAC_HASH_MATCH;
6045 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6046 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6048 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6051 ret = rte_eth_dev_filter_ctrl(res->port_id,
6052 RTE_ETH_FILTER_MACVLAN,
6056 ret = rte_eth_dev_filter_ctrl(res->port_id,
6057 RTE_ETH_FILTER_MACVLAN,
6058 RTE_ETH_FILTER_DELETE,
6062 printf("bad set MAC hash parameter, return code = %d\n", ret);
6066 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6069 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6072 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6073 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6075 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6076 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6078 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6079 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6081 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6082 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6084 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6086 filter_type, "exact-mac#exact-mac-vlan"
6087 "#hashmac#hashmac-vlan");
6088 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6092 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6093 .f = cmd_set_vf_macvlan_parsed,
6095 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6096 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6098 "exact match rule:exact match of MAC or MAC and VLAN; "
6099 "hash match rule: hash match of MAC and exact match "
6102 (void *)&cmd_set_vf_macvlan_set,
6103 (void *)&cmd_set_vf_macvlan_port,
6104 (void *)&cmd_set_vf_macvlan_portid,
6105 (void *)&cmd_set_vf_macvlan_vf,
6106 (void *)&cmd_set_vf_macvlan_vf_id,
6107 (void *)&cmd_set_vf_macvlan_mac,
6108 (void *)&cmd_set_vf_macvlan_filter_type,
6109 (void *)&cmd_set_vf_macvlan_mode,
6114 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6115 struct cmd_set_vf_traffic {
6116 cmdline_fixed_string_t set;
6117 cmdline_fixed_string_t port;
6119 cmdline_fixed_string_t vf;
6121 cmdline_fixed_string_t what;
6122 cmdline_fixed_string_t mode;
6126 cmd_set_vf_traffic_parsed(void *parsed_result,
6127 __attribute__((unused)) struct cmdline *cl,
6128 __attribute__((unused)) void *data)
6130 struct cmd_set_vf_traffic *res = parsed_result;
6131 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6132 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6134 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6137 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6138 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6140 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6141 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6143 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6144 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6146 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6147 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6149 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6150 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6152 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6153 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6155 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6156 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6159 cmdline_parse_inst_t cmd_set_vf_traffic = {
6160 .f = cmd_set_vf_traffic_parsed,
6162 .help_str = "set port X vf Y rx|tx on|off"
6163 "(X = port number,Y = vf id)",
6165 (void *)&cmd_setvf_traffic_set,
6166 (void *)&cmd_setvf_traffic_port,
6167 (void *)&cmd_setvf_traffic_portid,
6168 (void *)&cmd_setvf_traffic_vf,
6169 (void *)&cmd_setvf_traffic_vfid,
6170 (void *)&cmd_setvf_traffic_what,
6171 (void *)&cmd_setvf_traffic_mode,
6176 /* *** CONFIGURE VF RECEIVE MODE *** */
6177 struct cmd_set_vf_rxmode {
6178 cmdline_fixed_string_t set;
6179 cmdline_fixed_string_t port;
6181 cmdline_fixed_string_t vf;
6183 cmdline_fixed_string_t what;
6184 cmdline_fixed_string_t mode;
6185 cmdline_fixed_string_t on;
6189 cmd_set_vf_rxmode_parsed(void *parsed_result,
6190 __attribute__((unused)) struct cmdline *cl,
6191 __attribute__((unused)) void *data)
6194 uint16_t rx_mode = 0;
6195 struct cmd_set_vf_rxmode *res = parsed_result;
6197 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6198 if (!strcmp(res->what,"rxmode")) {
6199 if (!strcmp(res->mode, "AUPE"))
6200 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6201 else if (!strcmp(res->mode, "ROPE"))
6202 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6203 else if (!strcmp(res->mode, "BAM"))
6204 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6205 else if (!strncmp(res->mode, "MPE",3))
6206 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6209 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6211 printf("bad VF receive mode parameter, return code = %d \n",
6215 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6216 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6218 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6219 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6221 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6222 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6224 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6227 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6228 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6230 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6231 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6233 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6235 mode, "AUPE#ROPE#BAM#MPE");
6236 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6237 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6240 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6241 .f = cmd_set_vf_rxmode_parsed,
6243 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6245 (void *)&cmd_set_vf_rxmode_set,
6246 (void *)&cmd_set_vf_rxmode_port,
6247 (void *)&cmd_set_vf_rxmode_portid,
6248 (void *)&cmd_set_vf_rxmode_vf,
6249 (void *)&cmd_set_vf_rxmode_vfid,
6250 (void *)&cmd_set_vf_rxmode_what,
6251 (void *)&cmd_set_vf_rxmode_mode,
6252 (void *)&cmd_set_vf_rxmode_on,
6257 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6258 struct cmd_vf_mac_addr_result {
6259 cmdline_fixed_string_t mac_addr_cmd;
6260 cmdline_fixed_string_t what;
6261 cmdline_fixed_string_t port;
6263 cmdline_fixed_string_t vf;
6265 struct ether_addr address;
6268 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6269 __attribute__((unused)) struct cmdline *cl,
6270 __attribute__((unused)) void *data)
6272 struct cmd_vf_mac_addr_result *res = parsed_result;
6275 if (strcmp(res->what, "add") == 0)
6276 ret = rte_eth_dev_mac_addr_add(res->port_num,
6277 &res->address, res->vf_num);
6279 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6283 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6284 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6285 mac_addr_cmd,"mac_addr");
6286 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6287 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6289 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6290 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6292 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6293 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6295 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6296 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6298 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6299 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6301 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6302 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6305 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6306 .f = cmd_vf_mac_addr_parsed,
6308 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6309 "Y = VF number)add MAC address filtering for a VF on port X",
6311 (void *)&cmd_vf_mac_addr_cmd,
6312 (void *)&cmd_vf_mac_addr_what,
6313 (void *)&cmd_vf_mac_addr_port,
6314 (void *)&cmd_vf_mac_addr_portnum,
6315 (void *)&cmd_vf_mac_addr_vf,
6316 (void *)&cmd_vf_mac_addr_vfnum,
6317 (void *)&cmd_vf_mac_addr_addr,
6322 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6323 struct cmd_vf_rx_vlan_filter {
6324 cmdline_fixed_string_t rx_vlan;
6325 cmdline_fixed_string_t what;
6327 cmdline_fixed_string_t port;
6329 cmdline_fixed_string_t vf;
6334 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6335 __attribute__((unused)) struct cmdline *cl,
6336 __attribute__((unused)) void *data)
6338 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6340 if (!strcmp(res->what, "add"))
6341 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6343 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6346 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6347 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6348 rx_vlan, "rx_vlan");
6349 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6350 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6352 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6353 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6355 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6356 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6358 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6359 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6361 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6362 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6364 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6365 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6368 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6369 .f = cmd_vf_rx_vlan_filter_parsed,
6371 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6372 "Y = port number,Z = hexadecimal VF mask)",
6374 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6375 (void *)&cmd_vf_rx_vlan_filter_what,
6376 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6377 (void *)&cmd_vf_rx_vlan_filter_port,
6378 (void *)&cmd_vf_rx_vlan_filter_portid,
6379 (void *)&cmd_vf_rx_vlan_filter_vf,
6380 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6385 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6386 struct cmd_queue_rate_limit_result {
6387 cmdline_fixed_string_t set;
6388 cmdline_fixed_string_t port;
6390 cmdline_fixed_string_t queue;
6392 cmdline_fixed_string_t rate;
6396 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6397 __attribute__((unused)) struct cmdline *cl,
6398 __attribute__((unused)) void *data)
6400 struct cmd_queue_rate_limit_result *res = parsed_result;
6403 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6404 && (strcmp(res->queue, "queue") == 0)
6405 && (strcmp(res->rate, "rate") == 0))
6406 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6409 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6413 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6414 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6416 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6417 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6419 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6420 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6422 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6423 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6425 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6426 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6428 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6429 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6431 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6432 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6435 cmdline_parse_inst_t cmd_queue_rate_limit = {
6436 .f = cmd_queue_rate_limit_parsed,
6438 .help_str = "set port X queue Y rate Z:(X = port number,"
6439 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6441 (void *)&cmd_queue_rate_limit_set,
6442 (void *)&cmd_queue_rate_limit_port,
6443 (void *)&cmd_queue_rate_limit_portnum,
6444 (void *)&cmd_queue_rate_limit_queue,
6445 (void *)&cmd_queue_rate_limit_queuenum,
6446 (void *)&cmd_queue_rate_limit_rate,
6447 (void *)&cmd_queue_rate_limit_ratenum,
6452 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6453 struct cmd_vf_rate_limit_result {
6454 cmdline_fixed_string_t set;
6455 cmdline_fixed_string_t port;
6457 cmdline_fixed_string_t vf;
6459 cmdline_fixed_string_t rate;
6461 cmdline_fixed_string_t q_msk;
6465 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6466 __attribute__((unused)) struct cmdline *cl,
6467 __attribute__((unused)) void *data)
6469 struct cmd_vf_rate_limit_result *res = parsed_result;
6472 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6473 && (strcmp(res->vf, "vf") == 0)
6474 && (strcmp(res->rate, "rate") == 0)
6475 && (strcmp(res->q_msk, "queue_mask") == 0))
6476 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6477 res->rate_num, res->q_msk_val);
6479 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6483 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6484 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6486 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6487 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6489 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6490 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6492 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6493 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6495 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6496 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6498 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6499 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6501 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6502 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6504 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6505 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6506 q_msk, "queue_mask");
6507 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6508 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6511 cmdline_parse_inst_t cmd_vf_rate_limit = {
6512 .f = cmd_vf_rate_limit_parsed,
6514 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6515 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6516 "for queues of VF on port X",
6518 (void *)&cmd_vf_rate_limit_set,
6519 (void *)&cmd_vf_rate_limit_port,
6520 (void *)&cmd_vf_rate_limit_portnum,
6521 (void *)&cmd_vf_rate_limit_vf,
6522 (void *)&cmd_vf_rate_limit_vfnum,
6523 (void *)&cmd_vf_rate_limit_rate,
6524 (void *)&cmd_vf_rate_limit_ratenum,
6525 (void *)&cmd_vf_rate_limit_q_msk,
6526 (void *)&cmd_vf_rate_limit_q_msk_val,
6531 /* *** ADD TUNNEL FILTER OF A PORT *** */
6532 struct cmd_tunnel_filter_result {
6533 cmdline_fixed_string_t cmd;
6534 cmdline_fixed_string_t what;
6536 struct ether_addr outer_mac;
6537 struct ether_addr inner_mac;
6538 cmdline_ipaddr_t ip_value;
6539 uint16_t inner_vlan;
6540 cmdline_fixed_string_t tunnel_type;
6541 cmdline_fixed_string_t filter_type;
6547 cmd_tunnel_filter_parsed(void *parsed_result,
6548 __attribute__((unused)) struct cmdline *cl,
6549 __attribute__((unused)) void *data)
6551 struct cmd_tunnel_filter_result *res = parsed_result;
6552 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6555 tunnel_filter_conf.outer_mac = &res->outer_mac;
6556 tunnel_filter_conf.inner_mac = &res->inner_mac;
6557 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6559 if (res->ip_value.family == AF_INET) {
6560 tunnel_filter_conf.ip_addr.ipv4_addr =
6561 res->ip_value.addr.ipv4.s_addr;
6562 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6564 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6565 &(res->ip_value.addr.ipv6),
6566 sizeof(struct in6_addr));
6567 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6570 if (!strcmp(res->filter_type, "imac-ivlan"))
6571 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6572 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6573 tunnel_filter_conf.filter_type =
6574 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6575 else if (!strcmp(res->filter_type, "imac-tenid"))
6576 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6577 else if (!strcmp(res->filter_type, "imac"))
6578 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6579 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6580 tunnel_filter_conf.filter_type =
6581 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6583 printf("The filter type is not supported");
6587 if (!strcmp(res->tunnel_type, "vxlan"))
6588 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6590 printf("Only VXLAN is supported now.\n");
6594 tunnel_filter_conf.tenant_id = res->tenant_id;
6595 tunnel_filter_conf.queue_id = res->queue_num;
6596 if (!strcmp(res->what, "add"))
6597 ret = rte_eth_dev_filter_ctrl(res->port_id,
6598 RTE_ETH_FILTER_TUNNEL,
6600 &tunnel_filter_conf);
6602 ret = rte_eth_dev_filter_ctrl(res->port_id,
6603 RTE_ETH_FILTER_TUNNEL,
6604 RTE_ETH_FILTER_DELETE,
6605 &tunnel_filter_conf);
6607 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6611 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6612 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6613 cmd, "tunnel_filter");
6614 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6615 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6617 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6618 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6620 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6623 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6624 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6626 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6627 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6628 inner_vlan, UINT16);
6629 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6630 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6632 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6633 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6634 tunnel_type, "vxlan");
6636 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6637 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6638 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6639 "imac#omac-imac-tenid");
6640 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6641 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6643 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6644 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6647 cmdline_parse_inst_t cmd_tunnel_filter = {
6648 .f = cmd_tunnel_filter_parsed,
6650 .help_str = "add/rm tunnel filter of a port: "
6651 "tunnel_filter add port_id outer_mac inner_mac ip "
6652 "inner_vlan tunnel_type(vxlan) filter_type "
6653 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6654 "imac|omac-imac-tenid) "
6655 "tenant_id queue_num",
6657 (void *)&cmd_tunnel_filter_cmd,
6658 (void *)&cmd_tunnel_filter_what,
6659 (void *)&cmd_tunnel_filter_port_id,
6660 (void *)&cmd_tunnel_filter_outer_mac,
6661 (void *)&cmd_tunnel_filter_inner_mac,
6662 (void *)&cmd_tunnel_filter_ip_value,
6663 (void *)&cmd_tunnel_filter_innner_vlan,
6664 (void *)&cmd_tunnel_filter_tunnel_type,
6665 (void *)&cmd_tunnel_filter_filter_type,
6666 (void *)&cmd_tunnel_filter_tenant_id,
6667 (void *)&cmd_tunnel_filter_queue_num,
6672 /* *** CONFIGURE TUNNEL UDP PORT *** */
6673 struct cmd_tunnel_udp_config {
6674 cmdline_fixed_string_t cmd;
6675 cmdline_fixed_string_t what;
6681 cmd_tunnel_udp_config_parsed(void *parsed_result,
6682 __attribute__((unused)) struct cmdline *cl,
6683 __attribute__((unused)) void *data)
6685 struct cmd_tunnel_udp_config *res = parsed_result;
6686 struct rte_eth_udp_tunnel tunnel_udp;
6689 tunnel_udp.udp_port = res->udp_port;
6691 if (!strcmp(res->cmd, "rx_vxlan_port"))
6692 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6694 if (!strcmp(res->what, "add"))
6695 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6697 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6700 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6703 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6704 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6705 cmd, "rx_vxlan_port");
6706 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6707 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6709 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6710 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6712 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6713 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6716 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6717 .f = cmd_tunnel_udp_config_parsed,
6719 .help_str = "add/rm an tunneling UDP port filter: "
6720 "rx_vxlan_port add udp_port port_id",
6722 (void *)&cmd_tunnel_udp_config_cmd,
6723 (void *)&cmd_tunnel_udp_config_what,
6724 (void *)&cmd_tunnel_udp_config_udp_port,
6725 (void *)&cmd_tunnel_udp_config_port_id,
6730 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6731 struct cmd_set_mirror_mask_result {
6732 cmdline_fixed_string_t set;
6733 cmdline_fixed_string_t port;
6735 cmdline_fixed_string_t mirror;
6737 cmdline_fixed_string_t what;
6738 cmdline_fixed_string_t value;
6739 cmdline_fixed_string_t dstpool;
6741 cmdline_fixed_string_t on;
6744 cmdline_parse_token_string_t cmd_mirror_mask_set =
6745 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6747 cmdline_parse_token_string_t cmd_mirror_mask_port =
6748 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6750 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6751 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6753 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6754 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6755 mirror, "mirror-rule");
6756 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6757 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6759 cmdline_parse_token_string_t cmd_mirror_mask_what =
6760 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6761 what, "pool-mirror#vlan-mirror");
6762 cmdline_parse_token_string_t cmd_mirror_mask_value =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6765 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6767 dstpool, "dst-pool");
6768 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6769 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6771 cmdline_parse_token_string_t cmd_mirror_mask_on =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6776 cmd_set_mirror_mask_parsed(void *parsed_result,
6777 __attribute__((unused)) struct cmdline *cl,
6778 __attribute__((unused)) void *data)
6781 struct cmd_set_mirror_mask_result *res = parsed_result;
6782 struct rte_eth_vmdq_mirror_conf mr_conf;
6784 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6786 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6788 mr_conf.dst_pool = res->dstpool_id;
6790 if (!strcmp(res->what, "pool-mirror")) {
6791 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6792 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6793 } else if(!strcmp(res->what, "vlan-mirror")) {
6794 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6795 nb_item = parse_item_list(res->value, "core",
6796 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6800 for(i=0; i < nb_item; i++) {
6801 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6802 printf("Invalid vlan_id: must be < 4096\n");
6806 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6807 mr_conf.vlan.vlan_mask |= 1ULL << i;
6811 if(!strcmp(res->on, "on"))
6812 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6815 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6818 printf("mirror rule add error: (%s)\n", strerror(-ret));
6821 cmdline_parse_inst_t cmd_set_mirror_mask = {
6822 .f = cmd_set_mirror_mask_parsed,
6824 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6825 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6827 (void *)&cmd_mirror_mask_set,
6828 (void *)&cmd_mirror_mask_port,
6829 (void *)&cmd_mirror_mask_portid,
6830 (void *)&cmd_mirror_mask_mirror,
6831 (void *)&cmd_mirror_mask_ruleid,
6832 (void *)&cmd_mirror_mask_what,
6833 (void *)&cmd_mirror_mask_value,
6834 (void *)&cmd_mirror_mask_dstpool,
6835 (void *)&cmd_mirror_mask_poolid,
6836 (void *)&cmd_mirror_mask_on,
6841 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6842 struct cmd_set_mirror_link_result {
6843 cmdline_fixed_string_t set;
6844 cmdline_fixed_string_t port;
6846 cmdline_fixed_string_t mirror;
6848 cmdline_fixed_string_t what;
6849 cmdline_fixed_string_t dstpool;
6851 cmdline_fixed_string_t on;
6854 cmdline_parse_token_string_t cmd_mirror_link_set =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6857 cmdline_parse_token_string_t cmd_mirror_link_port =
6858 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6860 cmdline_parse_token_num_t cmd_mirror_link_portid =
6861 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6863 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6864 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6865 mirror, "mirror-rule");
6866 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6867 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6869 cmdline_parse_token_string_t cmd_mirror_link_what =
6870 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6871 what, "uplink-mirror#downlink-mirror");
6872 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6873 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6874 dstpool, "dst-pool");
6875 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6876 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6878 cmdline_parse_token_string_t cmd_mirror_link_on =
6879 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6883 cmd_set_mirror_link_parsed(void *parsed_result,
6884 __attribute__((unused)) struct cmdline *cl,
6885 __attribute__((unused)) void *data)
6888 struct cmd_set_mirror_link_result *res = parsed_result;
6889 struct rte_eth_vmdq_mirror_conf mr_conf;
6891 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6892 if(!strcmp(res->what, "uplink-mirror")) {
6893 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6894 }else if(!strcmp(res->what, "downlink-mirror"))
6895 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6897 mr_conf.dst_pool = res->dstpool_id;
6899 if(!strcmp(res->on, "on"))
6900 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6903 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6906 /* check the return value and print it if is < 0 */
6908 printf("mirror rule add error: (%s)\n", strerror(-ret));
6912 cmdline_parse_inst_t cmd_set_mirror_link = {
6913 .f = cmd_set_mirror_link_parsed,
6915 .help_str = "set port X mirror-rule Y uplink-mirror|"
6916 "downlink-mirror dst-pool Z on|off",
6918 (void *)&cmd_mirror_link_set,
6919 (void *)&cmd_mirror_link_port,
6920 (void *)&cmd_mirror_link_portid,
6921 (void *)&cmd_mirror_link_mirror,
6922 (void *)&cmd_mirror_link_ruleid,
6923 (void *)&cmd_mirror_link_what,
6924 (void *)&cmd_mirror_link_dstpool,
6925 (void *)&cmd_mirror_link_poolid,
6926 (void *)&cmd_mirror_link_on,
6931 /* *** RESET VM MIRROR RULE *** */
6932 struct cmd_rm_mirror_rule_result {
6933 cmdline_fixed_string_t reset;
6934 cmdline_fixed_string_t port;
6936 cmdline_fixed_string_t mirror;
6940 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6941 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6943 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6944 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6946 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6947 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6949 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6950 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6951 mirror, "mirror-rule");
6952 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6953 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6957 cmd_reset_mirror_rule_parsed(void *parsed_result,
6958 __attribute__((unused)) struct cmdline *cl,
6959 __attribute__((unused)) void *data)
6962 struct cmd_set_mirror_link_result *res = parsed_result;
6964 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6966 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6969 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6970 .f = cmd_reset_mirror_rule_parsed,
6972 .help_str = "reset port X mirror-rule Y",
6974 (void *)&cmd_rm_mirror_rule_reset,
6975 (void *)&cmd_rm_mirror_rule_port,
6976 (void *)&cmd_rm_mirror_rule_portid,
6977 (void *)&cmd_rm_mirror_rule_mirror,
6978 (void *)&cmd_rm_mirror_rule_ruleid,
6983 /* ******************************************************************************** */
6985 struct cmd_dump_result {
6986 cmdline_fixed_string_t dump;
6990 dump_struct_sizes(void)
6992 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6993 DUMP_SIZE(struct rte_mbuf);
6994 DUMP_SIZE(struct rte_mempool);
6995 DUMP_SIZE(struct rte_ring);
6999 static void cmd_dump_parsed(void *parsed_result,
7000 __attribute__((unused)) struct cmdline *cl,
7001 __attribute__((unused)) void *data)
7003 struct cmd_dump_result *res = parsed_result;
7005 if (!strcmp(res->dump, "dump_physmem"))
7006 rte_dump_physmem_layout(stdout);
7007 else if (!strcmp(res->dump, "dump_memzone"))
7008 rte_memzone_dump(stdout);
7009 else if (!strcmp(res->dump, "dump_log_history"))
7010 rte_log_dump_history(stdout);
7011 else if (!strcmp(res->dump, "dump_struct_sizes"))
7012 dump_struct_sizes();
7013 else if (!strcmp(res->dump, "dump_ring"))
7014 rte_ring_list_dump(stdout);
7015 else if (!strcmp(res->dump, "dump_mempool"))
7016 rte_mempool_list_dump(stdout);
7017 else if (!strcmp(res->dump, "dump_devargs"))
7018 rte_eal_devargs_dump(stdout);
7021 cmdline_parse_token_string_t cmd_dump_dump =
7022 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7026 "dump_struct_sizes#"
7031 cmdline_parse_inst_t cmd_dump = {
7032 .f = cmd_dump_parsed, /* function to call */
7033 .data = NULL, /* 2nd arg of func */
7034 .help_str = "dump status",
7035 .tokens = { /* token list, NULL terminated */
7036 (void *)&cmd_dump_dump,
7041 /* ******************************************************************************** */
7043 struct cmd_dump_one_result {
7044 cmdline_fixed_string_t dump;
7045 cmdline_fixed_string_t name;
7048 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7049 __attribute__((unused)) void *data)
7051 struct cmd_dump_one_result *res = parsed_result;
7053 if (!strcmp(res->dump, "dump_ring")) {
7055 r = rte_ring_lookup(res->name);
7057 cmdline_printf(cl, "Cannot find ring\n");
7060 rte_ring_dump(stdout, r);
7061 } else if (!strcmp(res->dump, "dump_mempool")) {
7062 struct rte_mempool *mp;
7063 mp = rte_mempool_lookup(res->name);
7065 cmdline_printf(cl, "Cannot find mempool\n");
7068 rte_mempool_dump(stdout, mp);
7072 cmdline_parse_token_string_t cmd_dump_one_dump =
7073 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7074 "dump_ring#dump_mempool");
7076 cmdline_parse_token_string_t cmd_dump_one_name =
7077 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7079 cmdline_parse_inst_t cmd_dump_one = {
7080 .f = cmd_dump_one_parsed, /* function to call */
7081 .data = NULL, /* 2nd arg of func */
7082 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7083 .tokens = { /* token list, NULL terminated */
7084 (void *)&cmd_dump_one_dump,
7085 (void *)&cmd_dump_one_name,
7090 /* *** ADD/REMOVE an ethertype FILTER *** */
7091 struct cmd_ethertype_filter_result {
7092 cmdline_fixed_string_t filter;
7094 cmdline_fixed_string_t ethertype;
7095 uint16_t ethertype_value;
7096 cmdline_fixed_string_t priority;
7097 cmdline_fixed_string_t priority_en;
7098 uint8_t priority_value;
7099 cmdline_fixed_string_t queue;
7101 cmdline_fixed_string_t index;
7102 uint16_t index_value;
7106 cmd_ethertype_filter_parsed(void *parsed_result,
7107 __attribute__((unused)) struct cmdline *cl,
7108 __attribute__((unused)) void *data)
7111 struct cmd_ethertype_filter_result *res = parsed_result;
7112 struct rte_ethertype_filter filter;
7114 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7115 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7116 filter.priority = res->priority_value;
7118 if (!strcmp(res->priority_en, "enable"))
7119 filter.priority_en = 1;
7120 if (!strcmp(res->filter, "add_ethertype_filter"))
7121 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7123 &filter, res->queue_id);
7124 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7125 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7127 else if (!strcmp(res->filter, "get_ethertype_filter"))
7128 get_ethertype_filter(res->port_id, res->index_value);
7131 printf("ethertype filter setting error: (%s)\n",
7135 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7136 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7138 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7139 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7140 ethertype, "ethertype");
7141 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7142 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7143 ethertype_value, UINT16);
7144 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7145 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7146 priority, "priority");
7147 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7148 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7149 priority_en, "enable#disable");
7150 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7151 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7152 priority_value, UINT8);
7153 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7154 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7156 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7157 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7159 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7160 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7162 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7163 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7164 index_value, UINT16);
7165 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7166 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7167 filter, "add_ethertype_filter");
7168 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7169 .f = cmd_ethertype_filter_parsed,
7171 .help_str = "add an ethertype filter",
7173 (void *)&cmd_ethertype_filter_add_filter,
7174 (void *)&cmd_ethertype_filter_port_id,
7175 (void *)&cmd_ethertype_filter_ethertype,
7176 (void *)&cmd_ethertype_filter_ethertype_value,
7177 (void *)&cmd_ethertype_filter_priority,
7178 (void *)&cmd_ethertype_filter_priority_en,
7179 (void *)&cmd_ethertype_filter_priority_value,
7180 (void *)&cmd_ethertype_filter_queue,
7181 (void *)&cmd_ethertype_filter_queue_id,
7182 (void *)&cmd_ethertype_filter_index,
7183 (void *)&cmd_ethertype_filter_index_value,
7188 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7189 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7190 filter, "remove_ethertype_filter");
7191 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7192 .f = cmd_ethertype_filter_parsed,
7194 .help_str = "remove an ethertype filter",
7196 (void *)&cmd_ethertype_filter_remove_filter,
7197 (void *)&cmd_ethertype_filter_port_id,
7198 (void *)&cmd_ethertype_filter_index,
7199 (void *)&cmd_ethertype_filter_index_value,
7203 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7204 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7205 filter, "get_ethertype_filter");
7206 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7207 .f = cmd_ethertype_filter_parsed,
7209 .help_str = "get an ethertype filter",
7211 (void *)&cmd_ethertype_filter_get_filter,
7212 (void *)&cmd_ethertype_filter_port_id,
7213 (void *)&cmd_ethertype_filter_index,
7214 (void *)&cmd_ethertype_filter_index_value,
7219 /* *** set SYN filter *** */
7220 struct cmd_set_syn_filter_result {
7221 cmdline_fixed_string_t filter;
7223 cmdline_fixed_string_t priority;
7224 cmdline_fixed_string_t high;
7225 cmdline_fixed_string_t queue;
7230 cmd_set_syn_filter_parsed(void *parsed_result,
7231 __attribute__((unused)) struct cmdline *cl,
7232 __attribute__((unused)) void *data)
7235 struct cmd_set_syn_filter_result *res = parsed_result;
7236 struct rte_syn_filter filter;
7238 if (!strcmp(res->filter, "add_syn_filter")) {
7239 if (!strcmp(res->high, "high"))
7243 ret = rte_eth_dev_add_syn_filter(res->port_id,
7244 &filter, res->queue_id);
7245 } else if (!strcmp(res->filter, "remove_syn_filter"))
7246 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7247 else if (!strcmp(res->filter, "get_syn_filter"))
7248 get_syn_filter(res->port_id);
7250 printf("syn filter setting error: (%s)\n", strerror(-ret));
7253 cmdline_parse_token_num_t cmd_syn_filter_portid =
7254 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7256 cmdline_parse_token_string_t cmd_syn_filter_priority =
7257 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7258 priority, "priority");
7259 cmdline_parse_token_string_t cmd_syn_filter_high =
7260 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7262 cmdline_parse_token_string_t cmd_syn_filter_queue =
7263 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7265 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7266 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7268 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7269 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7270 filter, "add_syn_filter");
7271 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7272 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7273 filter, "remove_syn_filter");
7274 cmdline_parse_inst_t cmd_add_syn_filter = {
7275 .f = cmd_set_syn_filter_parsed,
7277 .help_str = "add syn filter",
7279 (void *)&cmd_syn_filter_add_filter,
7280 (void *)&cmd_syn_filter_portid,
7281 (void *)&cmd_syn_filter_priority,
7282 (void *)&cmd_syn_filter_high,
7283 (void *)&cmd_syn_filter_queue,
7284 (void *)&cmd_syn_filter_queue_id,
7288 cmdline_parse_inst_t cmd_remove_syn_filter = {
7289 .f = cmd_set_syn_filter_parsed,
7291 .help_str = "remove syn filter",
7293 (void *)&cmd_syn_filter_remove_filter,
7294 (void *)&cmd_syn_filter_portid,
7299 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7300 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7301 filter, "get_syn_filter");
7303 cmdline_parse_inst_t cmd_get_syn_filter = {
7304 .f = cmd_set_syn_filter_parsed,
7306 .help_str = "get syn filter",
7308 (void *)&cmd_syn_filter_get_filter,
7309 (void *)&cmd_syn_filter_portid,
7314 /* *** ADD/REMOVE A 2tuple FILTER *** */
7315 struct cmd_2tuple_filter_result {
7316 cmdline_fixed_string_t filter;
7318 cmdline_fixed_string_t protocol;
7319 uint8_t protocol_value;
7320 uint8_t protocol_mask;
7321 cmdline_fixed_string_t dst_port;
7322 uint16_t dst_port_value;
7323 uint16_t dst_port_mask;
7324 cmdline_fixed_string_t flags;
7325 uint8_t flags_value;
7326 cmdline_fixed_string_t priority;
7327 uint8_t priority_value;
7328 cmdline_fixed_string_t queue;
7330 cmdline_fixed_string_t index;
7331 uint16_t index_value;
7335 cmd_2tuple_filter_parsed(void *parsed_result,
7336 __attribute__((unused)) struct cmdline *cl,
7337 __attribute__((unused)) void *data)
7340 struct rte_2tuple_filter filter;
7341 struct cmd_2tuple_filter_result *res = parsed_result;
7343 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7345 if (!strcmp(res->filter, "add_2tuple_filter")) {
7346 /* need convert to big endian. */
7347 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7348 filter.protocol = res->protocol_value;
7349 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7350 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7351 filter.priority = res->priority_value;
7352 filter.tcp_flags = res->flags_value;
7353 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7354 res->index_value, &filter, res->queue_id);
7355 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7356 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7358 else if (!strcmp(res->filter, "get_2tuple_filter"))
7359 get_2tuple_filter(res->port_id, res->index_value);
7362 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7365 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7366 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7368 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7369 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7370 protocol, "protocol");
7371 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7372 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7373 protocol_value, UINT8);
7374 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7375 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7376 protocol_mask, UINT8);
7377 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7378 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7379 dst_port, "dst_port");
7380 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7381 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7382 dst_port_value, UINT16);
7383 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7384 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7385 dst_port_mask, UINT16);
7386 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7387 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7389 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7390 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7391 flags_value, UINT8);
7392 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7393 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7394 priority, "priority");
7395 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7396 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7397 priority_value, UINT8);
7398 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7399 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7401 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7402 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7404 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7405 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7407 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7408 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7409 index_value, UINT16);
7410 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7411 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7412 filter, "add_2tuple_filter");
7413 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7414 .f = cmd_2tuple_filter_parsed,
7416 .help_str = "add a 2tuple filter",
7418 (void *)&cmd_2tuple_filter_add_filter,
7419 (void *)&cmd_2tuple_filter_port_id,
7420 (void *)&cmd_2tuple_filter_protocol,
7421 (void *)&cmd_2tuple_filter_protocol_value,
7422 (void *)&cmd_2tuple_filter_protocol_mask,
7423 (void *)&cmd_2tuple_filter_dst_port,
7424 (void *)&cmd_2tuple_filter_dst_port_value,
7425 (void *)&cmd_2tuple_filter_dst_port_mask,
7426 (void *)&cmd_2tuple_filter_flags,
7427 (void *)&cmd_2tuple_filter_flags_value,
7428 (void *)&cmd_2tuple_filter_priority,
7429 (void *)&cmd_2tuple_filter_priority_value,
7430 (void *)&cmd_2tuple_filter_queue,
7431 (void *)&cmd_2tuple_filter_queue_id,
7432 (void *)&cmd_2tuple_filter_index,
7433 (void *)&cmd_2tuple_filter_index_value,
7438 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7439 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7440 filter, "remove_2tuple_filter");
7441 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7442 .f = cmd_2tuple_filter_parsed,
7444 .help_str = "remove a 2tuple filter",
7446 (void *)&cmd_2tuple_filter_remove_filter,
7447 (void *)&cmd_2tuple_filter_port_id,
7448 (void *)&cmd_2tuple_filter_index,
7449 (void *)&cmd_2tuple_filter_index_value,
7453 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7454 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7455 filter, "get_2tuple_filter");
7456 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7457 .f = cmd_2tuple_filter_parsed,
7459 .help_str = "get a 2tuple filter",
7461 (void *)&cmd_2tuple_filter_get_filter,
7462 (void *)&cmd_2tuple_filter_port_id,
7463 (void *)&cmd_2tuple_filter_index,
7464 (void *)&cmd_2tuple_filter_index_value,
7469 /* *** ADD/REMOVE A 5tuple FILTER *** */
7470 struct cmd_5tuple_filter_result {
7471 cmdline_fixed_string_t filter;
7473 cmdline_fixed_string_t dst_ip;
7474 cmdline_ipaddr_t dst_ip_value;
7475 cmdline_fixed_string_t src_ip;
7476 cmdline_ipaddr_t src_ip_value;
7477 cmdline_fixed_string_t dst_port;
7478 uint16_t dst_port_value;
7479 cmdline_fixed_string_t src_port;
7480 uint16_t src_port_value;
7481 cmdline_fixed_string_t protocol;
7482 uint8_t protocol_value;
7483 cmdline_fixed_string_t mask;
7485 cmdline_fixed_string_t flags;
7486 uint8_t flags_value;
7487 cmdline_fixed_string_t priority;
7488 uint8_t priority_value;
7489 cmdline_fixed_string_t queue;
7491 cmdline_fixed_string_t index;
7492 uint16_t index_value;
7496 cmd_5tuple_filter_parsed(void *parsed_result,
7497 __attribute__((unused)) struct cmdline *cl,
7498 __attribute__((unused)) void *data)
7501 struct rte_5tuple_filter filter;
7502 struct cmd_5tuple_filter_result *res = parsed_result;
7504 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7506 if (!strcmp(res->filter, "add_5tuple_filter")) {
7507 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7508 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7509 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7510 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7511 filter.protocol = res->protocol_value;
7512 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7513 filter.priority = res->priority_value;
7514 filter.tcp_flags = res->flags_value;
7516 if (res->dst_ip_value.family == AF_INET)
7517 /* no need to convert, already big endian. */
7518 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7520 if (filter.dst_ip_mask == 0) {
7521 printf("can not support ipv6 involved compare.\n");
7527 if (res->src_ip_value.family == AF_INET)
7528 /* no need to convert, already big endian. */
7529 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7531 if (filter.src_ip_mask == 0) {
7532 printf("can not support ipv6 involved compare.\n");
7537 /* need convert to big endian. */
7538 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7539 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7541 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7542 res->index_value, &filter, res->queue_id);
7543 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7544 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7546 else if (!strcmp(res->filter, "get_5tuple_filter"))
7547 get_5tuple_filter(res->port_id, res->index_value);
7549 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7553 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7554 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7556 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7557 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7559 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7560 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7562 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7563 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7565 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7566 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7568 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7569 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7570 dst_port, "dst_port");
7571 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7572 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7573 dst_port_value, UINT16);
7574 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7575 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7576 src_port, "src_port");
7577 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7578 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7579 src_port_value, UINT16);
7580 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7581 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7582 protocol, "protocol");
7583 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7584 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7585 protocol_value, UINT8);
7586 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7587 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7589 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7590 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7592 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7593 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7595 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7596 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7597 flags_value, UINT8);
7598 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7599 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7600 priority, "priority");
7601 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7602 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7603 priority_value, UINT8);
7604 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7605 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7607 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7608 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7610 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7611 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7613 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7614 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7615 index_value, UINT16);
7617 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7618 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7619 filter, "add_5tuple_filter");
7620 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7621 .f = cmd_5tuple_filter_parsed,
7623 .help_str = "add a 5tuple filter",
7625 (void *)&cmd_5tuple_filter_add_filter,
7626 (void *)&cmd_5tuple_filter_port_id,
7627 (void *)&cmd_5tuple_filter_dst_ip,
7628 (void *)&cmd_5tuple_filter_dst_ip_value,
7629 (void *)&cmd_5tuple_filter_src_ip,
7630 (void *)&cmd_5tuple_filter_src_ip_value,
7631 (void *)&cmd_5tuple_filter_dst_port,
7632 (void *)&cmd_5tuple_filter_dst_port_value,
7633 (void *)&cmd_5tuple_filter_src_port,
7634 (void *)&cmd_5tuple_filter_src_port_value,
7635 (void *)&cmd_5tuple_filter_protocol,
7636 (void *)&cmd_5tuple_filter_protocol_value,
7637 (void *)&cmd_5tuple_filter_mask,
7638 (void *)&cmd_5tuple_filter_mask_value,
7639 (void *)&cmd_5tuple_filter_flags,
7640 (void *)&cmd_5tuple_filter_flags_value,
7641 (void *)&cmd_5tuple_filter_priority,
7642 (void *)&cmd_5tuple_filter_priority_value,
7643 (void *)&cmd_5tuple_filter_queue,
7644 (void *)&cmd_5tuple_filter_queue_id,
7645 (void *)&cmd_5tuple_filter_index,
7646 (void *)&cmd_5tuple_filter_index_value,
7651 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7652 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7653 filter, "remove_5tuple_filter");
7654 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7655 .f = cmd_5tuple_filter_parsed,
7657 .help_str = "remove a 5tuple filter",
7659 (void *)&cmd_5tuple_filter_remove_filter,
7660 (void *)&cmd_5tuple_filter_port_id,
7661 (void *)&cmd_5tuple_filter_index,
7662 (void *)&cmd_5tuple_filter_index_value,
7667 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7668 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7669 filter, "get_5tuple_filter");
7670 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7671 .f = cmd_5tuple_filter_parsed,
7673 .help_str = "get a 5tuple filter",
7675 (void *)&cmd_5tuple_filter_get_filter,
7676 (void *)&cmd_5tuple_filter_port_id,
7677 (void *)&cmd_5tuple_filter_index,
7678 (void *)&cmd_5tuple_filter_index_value,
7683 /* *** ADD/REMOVE A flex FILTER *** */
7684 struct cmd_flex_filter_result {
7685 cmdline_fixed_string_t filter;
7687 cmdline_fixed_string_t len;
7689 cmdline_fixed_string_t bytes;
7690 cmdline_fixed_string_t bytes_value;
7691 cmdline_fixed_string_t mask;
7692 cmdline_fixed_string_t mask_value;
7693 cmdline_fixed_string_t priority;
7694 uint8_t priority_value;
7695 cmdline_fixed_string_t queue;
7697 cmdline_fixed_string_t index;
7698 uint16_t index_value;
7701 static int xdigit2val(unsigned char c)
7706 else if (isupper(c))
7714 cmd_flex_filter_parsed(void *parsed_result,
7715 __attribute__((unused)) struct cmdline *cl,
7716 __attribute__((unused)) void *data)
7719 struct rte_flex_filter filter;
7720 struct cmd_flex_filter_result *res = parsed_result;
7721 char *bytes_ptr, *mask_ptr;
7729 if (!strcmp(res->filter, "add_flex_filter")) {
7730 if (res->len_value > 128) {
7731 printf("the len exceed the max length 128\n");
7734 memset(&filter, 0, sizeof(struct rte_flex_filter));
7735 filter.len = res->len_value;
7736 filter.priority = res->priority_value;
7737 bytes_ptr = res->bytes_value;
7738 mask_ptr = res->mask_value;
7741 /* translate bytes string to uint_32 array. */
7742 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7743 (bytes_ptr[1] == 'X')))
7745 len = strnlen(bytes_ptr, res->len_value * 2);
7746 if (len == 0 || (len % 8 != 0)) {
7747 printf("please check len and bytes input\n");
7750 for (i = 0; i < len; i++) {
7752 if (isxdigit(c) == 0) {
7753 /* invalid characters. */
7754 printf("invalid input\n");
7757 val = xdigit2val(c);
7761 dword |= byte << (4 * mod - 4);
7766 filter.dwords[j] = dword;
7767 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7773 /* translate mask string to uint8_t array. */
7775 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7776 (mask_ptr[1] == 'X')))
7778 len = strnlen(mask_ptr, (res->len_value+3)/4);
7780 printf("invalid input\n");
7783 for (i = 0; i < len; i++) {
7785 if (isxdigit(c) == 0) {
7786 /* invalid characters. */
7787 printf("invalid input\n");
7790 val = xdigit2val(c);
7791 hex |= (uint8_t)(val & 0x8) >> 3;
7792 hex |= (uint8_t)(val & 0x4) >> 1;
7793 hex |= (uint8_t)(val & 0x2) << 1;
7794 hex |= (uint8_t)(val & 0x1) << 3;
7797 filter.mask[j] = byte;
7798 printf("mask[%d]:%02x ", j, filter.mask[j]);
7806 printf("call function rte_eth_dev_add_flex_filter: "
7807 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7808 res->index_value, res->queue_id,
7809 filter.len, filter.priority);
7810 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7811 &filter, res->queue_id);
7813 } else if (!strcmp(res->filter, "remove_flex_filter"))
7814 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7816 else if (!strcmp(res->filter, "get_flex_filter"))
7817 get_flex_filter(res->port_id, res->index_value);
7820 printf("flex filter setting error: (%s)\n", strerror(-ret));
7823 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7824 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7826 cmdline_parse_token_string_t cmd_flex_filter_len =
7827 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7829 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7830 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7832 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7833 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7835 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7836 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7838 cmdline_parse_token_string_t cmd_flex_filter_mask =
7839 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7841 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7842 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7844 cmdline_parse_token_string_t cmd_flex_filter_priority =
7845 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7846 priority, "priority");
7847 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7848 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7849 priority_value, UINT8);
7850 cmdline_parse_token_string_t cmd_flex_filter_queue =
7851 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7853 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7854 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7856 cmdline_parse_token_string_t cmd_flex_filter_index =
7857 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7859 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7860 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7861 index_value, UINT16);
7862 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7863 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7864 filter, "add_flex_filter");
7865 cmdline_parse_inst_t cmd_add_flex_filter = {
7866 .f = cmd_flex_filter_parsed,
7868 .help_str = "add a flex filter",
7870 (void *)&cmd_flex_filter_add_filter,
7871 (void *)&cmd_flex_filter_port_id,
7872 (void *)&cmd_flex_filter_len,
7873 (void *)&cmd_flex_filter_len_value,
7874 (void *)&cmd_flex_filter_bytes,
7875 (void *)&cmd_flex_filter_bytes_value,
7876 (void *)&cmd_flex_filter_mask,
7877 (void *)&cmd_flex_filter_mask_value,
7878 (void *)&cmd_flex_filter_priority,
7879 (void *)&cmd_flex_filter_priority_value,
7880 (void *)&cmd_flex_filter_queue,
7881 (void *)&cmd_flex_filter_queue_id,
7882 (void *)&cmd_flex_filter_index,
7883 (void *)&cmd_flex_filter_index_value,
7888 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7889 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7890 filter, "remove_flex_filter");
7891 cmdline_parse_inst_t cmd_remove_flex_filter = {
7892 .f = cmd_flex_filter_parsed,
7894 .help_str = "remove a flex filter",
7896 (void *)&cmd_flex_filter_remove_filter,
7897 (void *)&cmd_flex_filter_port_id,
7898 (void *)&cmd_flex_filter_index,
7899 (void *)&cmd_flex_filter_index_value,
7904 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7905 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7906 filter, "get_flex_filter");
7907 cmdline_parse_inst_t cmd_get_flex_filter = {
7908 .f = cmd_flex_filter_parsed,
7910 .help_str = "get a flex filter",
7912 (void *)&cmd_flex_filter_get_filter,
7913 (void *)&cmd_flex_filter_port_id,
7914 (void *)&cmd_flex_filter_index,
7915 (void *)&cmd_flex_filter_index_value,
7920 /* *** Filters Control *** */
7922 /* *** deal with flow director filter *** */
7923 struct cmd_flow_director_result {
7924 cmdline_fixed_string_t flow_director_filter;
7926 cmdline_fixed_string_t ops;
7927 cmdline_fixed_string_t flow;
7928 cmdline_fixed_string_t flow_type;
7929 cmdline_fixed_string_t src;
7930 cmdline_ipaddr_t ip_src;
7932 cmdline_fixed_string_t dst;
7933 cmdline_ipaddr_t ip_dst;
7935 cmdline_fixed_string_t verify_tag;
7936 uint32_t verify_tag_value;
7937 cmdline_fixed_string_t flexbytes;
7938 cmdline_fixed_string_t flexbytes_value;
7939 cmdline_fixed_string_t drop;
7940 cmdline_fixed_string_t queue;
7942 cmdline_fixed_string_t fd_id;
7943 uint32_t fd_id_value;
7947 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7950 const char *p, *p0 = q_arg;
7952 unsigned long int_fld;
7953 char *str_fld[max_num];
7958 p = strchr(p0, '(');
7962 p0 = strchr(p, ')');
7967 if (size >= sizeof(s))
7970 snprintf(s, sizeof(s), "%.*s", size, p);
7971 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7972 if (ret < 0 || ret > max_num)
7974 for (i = 0; i < ret; i++) {
7976 int_fld = strtoul(str_fld[i], &end, 0);
7977 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7979 flexbytes[i] = (uint8_t)int_fld;
7984 static enum rte_eth_flow_type
7985 str2flowtype(char *string)
7988 static const struct {
7990 enum rte_eth_flow_type type;
7991 } flowtype_str[] = {
7992 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7993 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7994 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7995 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7996 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7997 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7998 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7999 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8000 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8001 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8004 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8005 if (!strcmp(flowtype_str[i].str, string))
8006 return flowtype_str[i].type;
8008 return RTE_ETH_FLOW_TYPE_NONE;
8011 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8013 if ((ip_addr).family == AF_INET) \
8014 (ip) = (ip_addr).addr.ipv4.s_addr; \
8016 printf("invalid parameter.\n"); \
8021 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8023 if ((ip_addr).family == AF_INET6) \
8024 (void)rte_memcpy(&(ip), \
8025 &((ip_addr).addr.ipv6), \
8026 sizeof(struct in6_addr)); \
8028 printf("invalid parameter.\n"); \
8034 cmd_flow_director_filter_parsed(void *parsed_result,
8035 __attribute__((unused)) struct cmdline *cl,
8036 __attribute__((unused)) void *data)
8038 struct cmd_flow_director_result *res = parsed_result;
8039 struct rte_eth_fdir_filter entry;
8040 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8043 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8045 printf("flow director is not supported on port %u.\n",
8049 memset(flexbytes, 0, sizeof(flexbytes));
8050 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8051 ret = parse_flexbytes(res->flexbytes_value,
8053 RTE_ETH_FDIR_MAX_FLEXLEN);
8055 printf("error: Cannot parse flexbytes input.\n");
8059 entry.input.flow_type = str2flowtype(res->flow_type);
8060 switch (entry.input.flow_type) {
8061 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8062 case RTE_ETH_FLOW_TYPE_UDPV4:
8063 case RTE_ETH_FLOW_TYPE_TCPV4:
8064 IPV4_ADDR_TO_UINT(res->ip_dst,
8065 entry.input.flow.ip4_flow.dst_ip);
8066 IPV4_ADDR_TO_UINT(res->ip_src,
8067 entry.input.flow.ip4_flow.src_ip);
8068 /* need convert to big endian. */
8069 entry.input.flow.udp4_flow.dst_port =
8070 rte_cpu_to_be_16(res->port_dst);
8071 entry.input.flow.udp4_flow.src_port =
8072 rte_cpu_to_be_16(res->port_src);
8074 case RTE_ETH_FLOW_TYPE_SCTPV4:
8075 IPV4_ADDR_TO_UINT(res->ip_dst,
8076 entry.input.flow.sctp4_flow.ip.dst_ip);
8077 IPV4_ADDR_TO_UINT(res->ip_src,
8078 entry.input.flow.sctp4_flow.ip.src_ip);
8079 /* need convert to big endian. */
8080 entry.input.flow.sctp4_flow.verify_tag =
8081 rte_cpu_to_be_32(res->verify_tag_value);
8083 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8084 case RTE_ETH_FLOW_TYPE_UDPV6:
8085 case RTE_ETH_FLOW_TYPE_TCPV6:
8086 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8087 entry.input.flow.ip6_flow.dst_ip);
8088 IPV6_ADDR_TO_ARRAY(res->ip_src,
8089 entry.input.flow.ip6_flow.src_ip);
8090 /* need convert to big endian. */
8091 entry.input.flow.udp6_flow.dst_port =
8092 rte_cpu_to_be_16(res->port_dst);
8093 entry.input.flow.udp6_flow.src_port =
8094 rte_cpu_to_be_16(res->port_src);
8096 case RTE_ETH_FLOW_TYPE_SCTPV6:
8097 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8098 entry.input.flow.sctp6_flow.ip.dst_ip);
8099 IPV6_ADDR_TO_ARRAY(res->ip_src,
8100 entry.input.flow.sctp6_flow.ip.src_ip);
8101 /* need convert to big endian. */
8102 entry.input.flow.sctp6_flow.verify_tag =
8103 rte_cpu_to_be_32(res->verify_tag_value);
8106 printf("invalid parameter.\n");
8109 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8111 RTE_ETH_FDIR_MAX_FLEXLEN);
8113 entry.action.flex_off = 0; /*use 0 by default */
8114 if (!strcmp(res->drop, "drop"))
8115 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8117 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8118 /* set to report FD ID by default */
8119 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8120 entry.action.rx_queue = res->queue_id;
8121 entry.soft_id = res->fd_id_value;
8122 if (!strcmp(res->ops, "add"))
8123 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8124 RTE_ETH_FILTER_ADD, &entry);
8126 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8127 RTE_ETH_FILTER_DELETE, &entry);
8129 printf("flow director programming error: (%s)\n",
8133 cmdline_parse_token_string_t cmd_flow_director_filter =
8134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8135 flow_director_filter, "flow_director_filter");
8136 cmdline_parse_token_num_t cmd_flow_director_port_id =
8137 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8139 cmdline_parse_token_string_t cmd_flow_director_ops =
8140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8142 cmdline_parse_token_string_t cmd_flow_director_flow =
8143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8145 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8148 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8149 "ip6#ip6-frag#tcp6#udp6#sctp6");
8150 cmdline_parse_token_string_t cmd_flow_director_src =
8151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8153 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8154 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8156 cmdline_parse_token_num_t cmd_flow_director_port_src =
8157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8159 cmdline_parse_token_string_t cmd_flow_director_dst =
8160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8162 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8163 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8165 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8166 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8168 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8170 verify_tag, "verify_tag");
8171 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8172 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8173 verify_tag_value, UINT32);
8174 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8175 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8176 flexbytes, "flexbytes");
8177 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8179 flexbytes_value, NULL);
8180 cmdline_parse_token_string_t cmd_flow_director_drop =
8181 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8183 cmdline_parse_token_string_t cmd_flow_director_queue =
8184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8186 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8187 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8189 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8192 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8193 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8194 fd_id_value, UINT32);
8196 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8197 .f = cmd_flow_director_filter_parsed,
8199 .help_str = "add or delete an ip flow director entry on NIC",
8201 (void *)&cmd_flow_director_filter,
8202 (void *)&cmd_flow_director_port_id,
8203 (void *)&cmd_flow_director_ops,
8204 (void *)&cmd_flow_director_flow,
8205 (void *)&cmd_flow_director_flow_type,
8206 (void *)&cmd_flow_director_src,
8207 (void *)&cmd_flow_director_ip_src,
8208 (void *)&cmd_flow_director_dst,
8209 (void *)&cmd_flow_director_ip_dst,
8210 (void *)&cmd_flow_director_flexbytes,
8211 (void *)&cmd_flow_director_flexbytes_value,
8212 (void *)&cmd_flow_director_drop,
8213 (void *)&cmd_flow_director_queue,
8214 (void *)&cmd_flow_director_queue_id,
8215 (void *)&cmd_flow_director_fd_id,
8216 (void *)&cmd_flow_director_fd_id_value,
8221 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8222 .f = cmd_flow_director_filter_parsed,
8224 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8226 (void *)&cmd_flow_director_filter,
8227 (void *)&cmd_flow_director_port_id,
8228 (void *)&cmd_flow_director_ops,
8229 (void *)&cmd_flow_director_flow,
8230 (void *)&cmd_flow_director_flow_type,
8231 (void *)&cmd_flow_director_src,
8232 (void *)&cmd_flow_director_ip_src,
8233 (void *)&cmd_flow_director_port_src,
8234 (void *)&cmd_flow_director_dst,
8235 (void *)&cmd_flow_director_ip_dst,
8236 (void *)&cmd_flow_director_port_dst,
8237 (void *)&cmd_flow_director_flexbytes,
8238 (void *)&cmd_flow_director_flexbytes_value,
8239 (void *)&cmd_flow_director_drop,
8240 (void *)&cmd_flow_director_queue,
8241 (void *)&cmd_flow_director_queue_id,
8242 (void *)&cmd_flow_director_fd_id,
8243 (void *)&cmd_flow_director_fd_id_value,
8248 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8249 .f = cmd_flow_director_filter_parsed,
8251 .help_str = "add or delete a sctp flow director entry on NIC",
8253 (void *)&cmd_flow_director_filter,
8254 (void *)&cmd_flow_director_port_id,
8255 (void *)&cmd_flow_director_ops,
8256 (void *)&cmd_flow_director_flow,
8257 (void *)&cmd_flow_director_flow_type,
8258 (void *)&cmd_flow_director_src,
8259 (void *)&cmd_flow_director_ip_src,
8260 (void *)&cmd_flow_director_dst,
8261 (void *)&cmd_flow_director_ip_dst,
8262 (void *)&cmd_flow_director_verify_tag,
8263 (void *)&cmd_flow_director_verify_tag_value,
8264 (void *)&cmd_flow_director_flexbytes,
8265 (void *)&cmd_flow_director_flexbytes_value,
8266 (void *)&cmd_flow_director_drop,
8267 (void *)&cmd_flow_director_queue,
8268 (void *)&cmd_flow_director_queue_id,
8269 (void *)&cmd_flow_director_fd_id,
8270 (void *)&cmd_flow_director_fd_id_value,
8275 struct cmd_flush_flow_director_result {
8276 cmdline_fixed_string_t flush_flow_director;
8280 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8281 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8282 flush_flow_director, "flush_flow_director");
8283 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8284 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8288 cmd_flush_flow_director_parsed(void *parsed_result,
8289 __attribute__((unused)) struct cmdline *cl,
8290 __attribute__((unused)) void *data)
8292 struct cmd_flow_director_result *res = parsed_result;
8295 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8297 printf("flow director is not supported on port %u.\n",
8302 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8303 RTE_ETH_FILTER_FLUSH, NULL);
8305 printf("flow director table flushing error: (%s)\n",
8309 cmdline_parse_inst_t cmd_flush_flow_director = {
8310 .f = cmd_flush_flow_director_parsed,
8312 .help_str = "flush all flow director entries of a device on NIC",
8314 (void *)&cmd_flush_flow_director_flush,
8315 (void *)&cmd_flush_flow_director_port_id,
8320 /* *** deal with flow director mask on flexible payload *** */
8321 struct cmd_flow_director_flex_mask_result {
8322 cmdline_fixed_string_t flow_director_flexmask;
8324 cmdline_fixed_string_t flow;
8325 cmdline_fixed_string_t flow_type;
8326 cmdline_fixed_string_t mask;
8330 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8331 __attribute__((unused)) struct cmdline *cl,
8332 __attribute__((unused)) void *data)
8334 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8335 struct rte_eth_fdir_flex_mask flex_mask;
8336 struct rte_port *port;
8337 enum rte_eth_flow_type i;
8340 if (res->port_id > nb_ports) {
8341 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8345 port = &ports[res->port_id];
8346 /** Check if the port is not started **/
8347 if (port->port_status != RTE_PORT_STOPPED) {
8348 printf("Please stop port %d first\n", res->port_id);
8352 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8353 ret = parse_flexbytes(res->mask,
8355 RTE_ETH_FDIR_MAX_FLEXLEN);
8357 printf("error: Cannot parse mask input.\n");
8360 if (!strcmp(res->flow_type, "all")) {
8361 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8362 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8364 flex_mask.flow_type = i;
8365 fdir_set_flex_mask(res->port_id, &flex_mask);
8367 cmd_reconfig_device_queue(res->port_id, 1, 0);
8370 flex_mask.flow_type = str2flowtype(res->flow_type);
8371 fdir_set_flex_mask(res->port_id, &flex_mask);
8372 cmd_reconfig_device_queue(res->port_id, 1, 0);
8375 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8377 flow_director_flexmask,
8378 "flow_director_flex_mask");
8379 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8382 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8385 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8386 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8388 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8389 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8390 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8394 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8395 .f = cmd_flow_director_flex_mask_parsed,
8397 .help_str = "set flow director's flex mask on NIC",
8399 (void *)&cmd_flow_director_flexmask,
8400 (void *)&cmd_flow_director_flexmask_port_id,
8401 (void *)&cmd_flow_director_flexmask_flow,
8402 (void *)&cmd_flow_director_flexmask_flow_type,
8403 (void *)&cmd_flow_director_flexmask_mask,
8408 /* ******************************************************************************** */
8410 /* list of instructions */
8411 cmdline_parse_ctx_t main_ctx[] = {
8412 (cmdline_parse_inst_t *)&cmd_help_brief,
8413 (cmdline_parse_inst_t *)&cmd_help_long,
8414 (cmdline_parse_inst_t *)&cmd_quit,
8415 (cmdline_parse_inst_t *)&cmd_showport,
8416 (cmdline_parse_inst_t *)&cmd_showportall,
8417 (cmdline_parse_inst_t *)&cmd_showcfg,
8418 (cmdline_parse_inst_t *)&cmd_start,
8419 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8420 (cmdline_parse_inst_t *)&cmd_set_link_up,
8421 (cmdline_parse_inst_t *)&cmd_set_link_down,
8422 (cmdline_parse_inst_t *)&cmd_reset,
8423 (cmdline_parse_inst_t *)&cmd_set_numbers,
8424 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8425 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8426 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8427 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8428 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8429 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8430 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8431 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8432 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8433 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8434 (cmdline_parse_inst_t *)&cmd_set_link_check,
8435 #ifdef RTE_NIC_BYPASS
8436 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8437 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8438 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8439 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8441 #ifdef RTE_LIBRTE_PMD_BOND
8442 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8443 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8444 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8445 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8446 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8447 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8448 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8449 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8450 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8452 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8453 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8454 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8455 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8456 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8457 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8458 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8459 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8460 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8461 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8462 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8463 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8464 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8465 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8466 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8467 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8468 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8469 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8470 (cmdline_parse_inst_t *)&cmd_config_dcb,
8471 (cmdline_parse_inst_t *)&cmd_read_reg,
8472 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8473 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8474 (cmdline_parse_inst_t *)&cmd_write_reg,
8475 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8476 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8477 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8478 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8479 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8480 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8481 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8482 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8483 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8484 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8485 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8486 (cmdline_parse_inst_t *)&cmd_stop,
8487 (cmdline_parse_inst_t *)&cmd_mac_addr,
8488 (cmdline_parse_inst_t *)&cmd_set_qmap,
8489 (cmdline_parse_inst_t *)&cmd_operate_port,
8490 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8491 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8492 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8493 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8494 (cmdline_parse_inst_t *)&cmd_config_mtu,
8495 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8496 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8497 (cmdline_parse_inst_t *)&cmd_config_rss,
8498 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8499 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8500 (cmdline_parse_inst_t *)&cmd_showport_reta,
8501 (cmdline_parse_inst_t *)&cmd_config_burst,
8502 (cmdline_parse_inst_t *)&cmd_config_thresh,
8503 (cmdline_parse_inst_t *)&cmd_config_threshold,
8504 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8505 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8506 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8507 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8508 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8509 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8510 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8511 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8512 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8513 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8514 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8515 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8516 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8517 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8518 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8519 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8520 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8521 (cmdline_parse_inst_t *)&cmd_dump,
8522 (cmdline_parse_inst_t *)&cmd_dump_one,
8523 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8524 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8525 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8526 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8527 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8528 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8529 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8530 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8531 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8532 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8533 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8534 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8535 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8536 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8537 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8538 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8539 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8540 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8541 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8542 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8546 /* prompt function, called from main on MASTER lcore */
8552 /* initialize non-constant commands */
8553 cmd_set_fwd_mode_init();
8555 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8559 cmdline_interact(cl);
8560 cmdline_stdin_exit(cl);
8564 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8566 if (id < nb_ports) {
8567 /* check if need_reconfig has been set to 1 */
8568 if (ports[id].need_reconfig == 0)
8569 ports[id].need_reconfig = dev;
8570 /* check if need_reconfig_queues has been set to 1 */
8571 if (ports[id].need_reconfig_queues == 0)
8572 ports[id].need_reconfig_queues = queue;
8576 for (pid = 0; pid < nb_ports; pid++) {
8577 /* check if need_reconfig has been set to 1 */
8578 if (ports[pid].need_reconfig == 0)
8579 ports[pid].need_reconfig = dev;
8580 /* check if need_reconfig_queues has been set to 1 */
8581 if (ports[pid].need_reconfig_queues == 0)
8582 ports[pid].need_reconfig_queues = queue;
8587 #ifdef RTE_NIC_BYPASS
8589 bypass_is_supported(portid_t port_id)
8591 struct rte_port *port;
8592 struct rte_pci_id *pci_id;
8594 if (port_id >= nb_ports) {
8595 printf("\tPort id must be less than %d.\n", nb_ports);
8599 /* Get the device id. */
8600 port = &ports[port_id];
8601 pci_id = &port->dev_info.pci_dev->id;
8603 /* Check if NIC supports bypass. */
8604 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8608 printf("\tBypass not supported for port_id = %d.\n", port_id);