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"
730 cmdline_parse_token_string_t cmd_help_long_help =
731 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
733 cmdline_parse_token_string_t cmd_help_long_section =
734 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
735 "all#control#display#config#flowdir#"
736 "ports#registers#filters");
738 cmdline_parse_inst_t cmd_help_long = {
739 .f = cmd_help_long_parsed,
741 .help_str = "show help",
743 (void *)&cmd_help_long_help,
744 (void *)&cmd_help_long_section,
750 /* *** start/stop/close all ports *** */
751 struct cmd_operate_port_result {
752 cmdline_fixed_string_t keyword;
753 cmdline_fixed_string_t name;
754 cmdline_fixed_string_t value;
757 static void cmd_operate_port_parsed(void *parsed_result,
758 __attribute__((unused)) struct cmdline *cl,
759 __attribute__((unused)) void *data)
761 struct cmd_operate_port_result *res = parsed_result;
763 if (!strcmp(res->name, "start"))
764 start_port(RTE_PORT_ALL);
765 else if (!strcmp(res->name, "stop"))
766 stop_port(RTE_PORT_ALL);
767 else if (!strcmp(res->name, "close"))
768 close_port(RTE_PORT_ALL);
770 printf("Unknown parameter\n");
773 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
774 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
776 cmdline_parse_token_string_t cmd_operate_port_all_port =
777 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
779 cmdline_parse_token_string_t cmd_operate_port_all_all =
780 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
782 cmdline_parse_inst_t cmd_operate_port = {
783 .f = cmd_operate_port_parsed,
785 .help_str = "port start|stop|close all: start/stop/close all ports",
787 (void *)&cmd_operate_port_all_cmd,
788 (void *)&cmd_operate_port_all_port,
789 (void *)&cmd_operate_port_all_all,
794 /* *** start/stop/close specific port *** */
795 struct cmd_operate_specific_port_result {
796 cmdline_fixed_string_t keyword;
797 cmdline_fixed_string_t name;
801 static void cmd_operate_specific_port_parsed(void *parsed_result,
802 __attribute__((unused)) struct cmdline *cl,
803 __attribute__((unused)) void *data)
805 struct cmd_operate_specific_port_result *res = parsed_result;
807 if (!strcmp(res->name, "start"))
808 start_port(res->value);
809 else if (!strcmp(res->name, "stop"))
810 stop_port(res->value);
811 else if (!strcmp(res->name, "close"))
812 close_port(res->value);
814 printf("Unknown parameter\n");
817 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
818 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
820 cmdline_parse_token_string_t cmd_operate_specific_port_port =
821 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
822 name, "start#stop#close");
823 cmdline_parse_token_num_t cmd_operate_specific_port_id =
824 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
827 cmdline_parse_inst_t cmd_operate_specific_port = {
828 .f = cmd_operate_specific_port_parsed,
830 .help_str = "port start|stop|close X: start/stop/close port X",
832 (void *)&cmd_operate_specific_port_cmd,
833 (void *)&cmd_operate_specific_port_port,
834 (void *)&cmd_operate_specific_port_id,
839 /* *** configure speed for all ports *** */
840 struct cmd_config_speed_all {
841 cmdline_fixed_string_t port;
842 cmdline_fixed_string_t keyword;
843 cmdline_fixed_string_t all;
844 cmdline_fixed_string_t item1;
845 cmdline_fixed_string_t item2;
846 cmdline_fixed_string_t value1;
847 cmdline_fixed_string_t value2;
851 cmd_config_speed_all_parsed(void *parsed_result,
852 __attribute__((unused)) struct cmdline *cl,
853 __attribute__((unused)) void *data)
855 struct cmd_config_speed_all *res = parsed_result;
856 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
857 uint16_t link_duplex = 0;
860 if (!all_ports_stopped()) {
861 printf("Please stop all ports first\n");
865 if (!strcmp(res->value1, "10"))
866 link_speed = ETH_LINK_SPEED_10;
867 else if (!strcmp(res->value1, "100"))
868 link_speed = ETH_LINK_SPEED_100;
869 else if (!strcmp(res->value1, "1000"))
870 link_speed = ETH_LINK_SPEED_1000;
871 else if (!strcmp(res->value1, "10000"))
872 link_speed = ETH_LINK_SPEED_10G;
873 else if (!strcmp(res->value1, "40000"))
874 link_speed = ETH_LINK_SPEED_40G;
875 else if (!strcmp(res->value1, "auto"))
876 link_speed = ETH_LINK_SPEED_AUTONEG;
878 printf("Unknown parameter\n");
882 if (!strcmp(res->value2, "half"))
883 link_duplex = ETH_LINK_HALF_DUPLEX;
884 else if (!strcmp(res->value2, "full"))
885 link_duplex = ETH_LINK_FULL_DUPLEX;
886 else if (!strcmp(res->value2, "auto"))
887 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
889 printf("Unknown parameter\n");
893 for (pid = 0; pid < nb_ports; pid++) {
894 ports[pid].dev_conf.link_speed = link_speed;
895 ports[pid].dev_conf.link_duplex = link_duplex;
898 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
901 cmdline_parse_token_string_t cmd_config_speed_all_port =
902 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
903 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
904 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
906 cmdline_parse_token_string_t cmd_config_speed_all_all =
907 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
908 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
909 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
910 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
911 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
912 "10#100#1000#10000#40000#auto");
913 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
914 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
915 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
919 cmdline_parse_inst_t cmd_config_speed_all = {
920 .f = cmd_config_speed_all_parsed,
922 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
925 (void *)&cmd_config_speed_all_port,
926 (void *)&cmd_config_speed_all_keyword,
927 (void *)&cmd_config_speed_all_all,
928 (void *)&cmd_config_speed_all_item1,
929 (void *)&cmd_config_speed_all_value1,
930 (void *)&cmd_config_speed_all_item2,
931 (void *)&cmd_config_speed_all_value2,
936 /* *** configure speed for specific port *** */
937 struct cmd_config_speed_specific {
938 cmdline_fixed_string_t port;
939 cmdline_fixed_string_t keyword;
941 cmdline_fixed_string_t item1;
942 cmdline_fixed_string_t item2;
943 cmdline_fixed_string_t value1;
944 cmdline_fixed_string_t value2;
948 cmd_config_speed_specific_parsed(void *parsed_result,
949 __attribute__((unused)) struct cmdline *cl,
950 __attribute__((unused)) void *data)
952 struct cmd_config_speed_specific *res = parsed_result;
953 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
954 uint16_t link_duplex = 0;
956 if (!all_ports_stopped()) {
957 printf("Please stop all ports first\n");
961 if (res->id >= nb_ports) {
962 printf("Port id %d must be less than %d\n", res->id, nb_ports);
966 if (!strcmp(res->value1, "10"))
967 link_speed = ETH_LINK_SPEED_10;
968 else if (!strcmp(res->value1, "100"))
969 link_speed = ETH_LINK_SPEED_100;
970 else if (!strcmp(res->value1, "1000"))
971 link_speed = ETH_LINK_SPEED_1000;
972 else if (!strcmp(res->value1, "10000"))
973 link_speed = ETH_LINK_SPEED_10000;
974 else if (!strcmp(res->value1, "40000"))
975 link_speed = ETH_LINK_SPEED_40G;
976 else if (!strcmp(res->value1, "auto"))
977 link_speed = ETH_LINK_SPEED_AUTONEG;
979 printf("Unknown parameter\n");
983 if (!strcmp(res->value2, "half"))
984 link_duplex = ETH_LINK_HALF_DUPLEX;
985 else if (!strcmp(res->value2, "full"))
986 link_duplex = ETH_LINK_FULL_DUPLEX;
987 else if (!strcmp(res->value2, "auto"))
988 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
990 printf("Unknown parameter\n");
994 ports[res->id].dev_conf.link_speed = link_speed;
995 ports[res->id].dev_conf.link_duplex = link_duplex;
997 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1001 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1002 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1004 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1005 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1007 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1008 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1009 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1010 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1012 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1013 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1014 "10#100#1000#10000#40000#auto");
1015 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1016 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1018 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1019 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1022 cmdline_parse_inst_t cmd_config_speed_specific = {
1023 .f = cmd_config_speed_specific_parsed,
1025 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1028 (void *)&cmd_config_speed_specific_port,
1029 (void *)&cmd_config_speed_specific_keyword,
1030 (void *)&cmd_config_speed_specific_id,
1031 (void *)&cmd_config_speed_specific_item1,
1032 (void *)&cmd_config_speed_specific_value1,
1033 (void *)&cmd_config_speed_specific_item2,
1034 (void *)&cmd_config_speed_specific_value2,
1039 /* *** configure txq/rxq, txd/rxd *** */
1040 struct cmd_config_rx_tx {
1041 cmdline_fixed_string_t port;
1042 cmdline_fixed_string_t keyword;
1043 cmdline_fixed_string_t all;
1044 cmdline_fixed_string_t name;
1049 cmd_config_rx_tx_parsed(void *parsed_result,
1050 __attribute__((unused)) struct cmdline *cl,
1051 __attribute__((unused)) void *data)
1053 struct cmd_config_rx_tx *res = parsed_result;
1055 if (!all_ports_stopped()) {
1056 printf("Please stop all ports first\n");
1060 if (!strcmp(res->name, "rxq")) {
1061 if (res->value <= 0) {
1062 printf("rxq %d invalid - must be > 0\n", res->value);
1065 nb_rxq = res->value;
1067 else if (!strcmp(res->name, "txq")) {
1068 if (res->value <= 0) {
1069 printf("txq %d invalid - must be > 0\n", res->value);
1072 nb_txq = res->value;
1074 else if (!strcmp(res->name, "rxd")) {
1075 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1076 printf("rxd %d invalid - must be > 0 && <= %d\n",
1077 res->value, RTE_TEST_RX_DESC_MAX);
1080 nb_rxd = res->value;
1081 } else if (!strcmp(res->name, "txd")) {
1082 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1083 printf("txd %d invalid - must be > 0 && <= %d\n",
1084 res->value, RTE_TEST_TX_DESC_MAX);
1087 nb_txd = res->value;
1089 printf("Unknown parameter\n");
1095 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1098 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1099 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1100 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1101 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1102 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1103 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1104 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1105 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1107 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1108 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1110 cmdline_parse_inst_t cmd_config_rx_tx = {
1111 .f = cmd_config_rx_tx_parsed,
1113 .help_str = "port config all rxq|txq|rxd|txd value",
1115 (void *)&cmd_config_rx_tx_port,
1116 (void *)&cmd_config_rx_tx_keyword,
1117 (void *)&cmd_config_rx_tx_all,
1118 (void *)&cmd_config_rx_tx_name,
1119 (void *)&cmd_config_rx_tx_value,
1124 /* *** config max packet length *** */
1125 struct cmd_config_max_pkt_len_result {
1126 cmdline_fixed_string_t port;
1127 cmdline_fixed_string_t keyword;
1128 cmdline_fixed_string_t all;
1129 cmdline_fixed_string_t name;
1134 cmd_config_max_pkt_len_parsed(void *parsed_result,
1135 __attribute__((unused)) struct cmdline *cl,
1136 __attribute__((unused)) void *data)
1138 struct cmd_config_max_pkt_len_result *res = parsed_result;
1140 if (!all_ports_stopped()) {
1141 printf("Please stop all ports first\n");
1145 if (!strcmp(res->name, "max-pkt-len")) {
1146 if (res->value < ETHER_MIN_LEN) {
1147 printf("max-pkt-len can not be less than %d\n",
1151 if (res->value == rx_mode.max_rx_pkt_len)
1154 rx_mode.max_rx_pkt_len = res->value;
1155 if (res->value > ETHER_MAX_LEN)
1156 rx_mode.jumbo_frame = 1;
1158 rx_mode.jumbo_frame = 0;
1160 printf("Unknown parameter\n");
1166 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1169 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1170 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1172 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1175 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1176 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1178 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1179 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1181 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1182 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1185 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1186 .f = cmd_config_max_pkt_len_parsed,
1188 .help_str = "port config all max-pkt-len value",
1190 (void *)&cmd_config_max_pkt_len_port,
1191 (void *)&cmd_config_max_pkt_len_keyword,
1192 (void *)&cmd_config_max_pkt_len_all,
1193 (void *)&cmd_config_max_pkt_len_name,
1194 (void *)&cmd_config_max_pkt_len_value,
1199 /* *** configure port MTU *** */
1200 struct cmd_config_mtu_result {
1201 cmdline_fixed_string_t port;
1202 cmdline_fixed_string_t keyword;
1203 cmdline_fixed_string_t mtu;
1209 cmd_config_mtu_parsed(void *parsed_result,
1210 __attribute__((unused)) struct cmdline *cl,
1211 __attribute__((unused)) void *data)
1213 struct cmd_config_mtu_result *res = parsed_result;
1215 if (res->value < ETHER_MIN_LEN) {
1216 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1219 port_mtu_set(res->port_id, res->value);
1222 cmdline_parse_token_string_t cmd_config_mtu_port =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1225 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1228 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1229 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1231 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1232 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1233 cmdline_parse_token_num_t cmd_config_mtu_value =
1234 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1236 cmdline_parse_inst_t cmd_config_mtu = {
1237 .f = cmd_config_mtu_parsed,
1239 .help_str = "port config mtu value",
1241 (void *)&cmd_config_mtu_port,
1242 (void *)&cmd_config_mtu_keyword,
1243 (void *)&cmd_config_mtu_mtu,
1244 (void *)&cmd_config_mtu_port_id,
1245 (void *)&cmd_config_mtu_value,
1250 /* *** configure rx mode *** */
1251 struct cmd_config_rx_mode_flag {
1252 cmdline_fixed_string_t port;
1253 cmdline_fixed_string_t keyword;
1254 cmdline_fixed_string_t all;
1255 cmdline_fixed_string_t name;
1256 cmdline_fixed_string_t value;
1260 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1261 __attribute__((unused)) struct cmdline *cl,
1262 __attribute__((unused)) void *data)
1264 struct cmd_config_rx_mode_flag *res = parsed_result;
1266 if (!all_ports_stopped()) {
1267 printf("Please stop all ports first\n");
1271 if (!strcmp(res->name, "crc-strip")) {
1272 if (!strcmp(res->value, "on"))
1273 rx_mode.hw_strip_crc = 1;
1274 else if (!strcmp(res->value, "off"))
1275 rx_mode.hw_strip_crc = 0;
1277 printf("Unknown parameter\n");
1280 } else if (!strcmp(res->name, "rx-cksum")) {
1281 if (!strcmp(res->value, "on"))
1282 rx_mode.hw_ip_checksum = 1;
1283 else if (!strcmp(res->value, "off"))
1284 rx_mode.hw_ip_checksum = 0;
1286 printf("Unknown parameter\n");
1289 } else if (!strcmp(res->name, "hw-vlan")) {
1290 if (!strcmp(res->value, "on")) {
1291 rx_mode.hw_vlan_filter = 1;
1292 rx_mode.hw_vlan_strip = 1;
1294 else if (!strcmp(res->value, "off")) {
1295 rx_mode.hw_vlan_filter = 0;
1296 rx_mode.hw_vlan_strip = 0;
1299 printf("Unknown parameter\n");
1302 } else if (!strcmp(res->name, "drop-en")) {
1303 if (!strcmp(res->value, "on"))
1305 else if (!strcmp(res->value, "off"))
1308 printf("Unknown parameter\n");
1312 printf("Unknown parameter\n");
1318 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1321 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1323 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1326 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1328 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1329 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1330 "crc-strip#rx-cksum#hw-vlan");
1331 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1332 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1335 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1336 .f = cmd_config_rx_mode_flag_parsed,
1338 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1340 (void *)&cmd_config_rx_mode_flag_port,
1341 (void *)&cmd_config_rx_mode_flag_keyword,
1342 (void *)&cmd_config_rx_mode_flag_all,
1343 (void *)&cmd_config_rx_mode_flag_name,
1344 (void *)&cmd_config_rx_mode_flag_value,
1349 /* *** configure rss *** */
1350 struct cmd_config_rss {
1351 cmdline_fixed_string_t port;
1352 cmdline_fixed_string_t keyword;
1353 cmdline_fixed_string_t all;
1354 cmdline_fixed_string_t name;
1355 cmdline_fixed_string_t value;
1359 cmd_config_rss_parsed(void *parsed_result,
1360 __attribute__((unused)) struct cmdline *cl,
1361 __attribute__((unused)) void *data)
1363 struct cmd_config_rss *res = parsed_result;
1364 struct rte_eth_rss_conf rss_conf;
1367 if (!strcmp(res->value, "ip"))
1368 rss_conf.rss_hf = ETH_RSS_IP;
1369 else if (!strcmp(res->value, "udp"))
1370 rss_conf.rss_hf = ETH_RSS_UDP;
1371 else if (!strcmp(res->value, "none"))
1372 rss_conf.rss_hf = 0;
1374 printf("Unknown parameter\n");
1377 rss_conf.rss_key = NULL;
1378 for (i = 0; i < rte_eth_dev_count(); i++)
1379 rte_eth_dev_rss_hash_update(i, &rss_conf);
1382 cmdline_parse_token_string_t cmd_config_rss_port =
1383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1384 cmdline_parse_token_string_t cmd_config_rss_keyword =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1386 cmdline_parse_token_string_t cmd_config_rss_all =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1388 cmdline_parse_token_string_t cmd_config_rss_name =
1389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1390 cmdline_parse_token_string_t cmd_config_rss_value =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1393 cmdline_parse_inst_t cmd_config_rss = {
1394 .f = cmd_config_rss_parsed,
1396 .help_str = "port config all rss ip|udp|none",
1398 (void *)&cmd_config_rss_port,
1399 (void *)&cmd_config_rss_keyword,
1400 (void *)&cmd_config_rss_all,
1401 (void *)&cmd_config_rss_name,
1402 (void *)&cmd_config_rss_value,
1407 /* *** configure rss hash key *** */
1408 struct cmd_config_rss_hash_key {
1409 cmdline_fixed_string_t port;
1410 cmdline_fixed_string_t config;
1412 cmdline_fixed_string_t rss_hash_key;
1413 cmdline_fixed_string_t key;
1416 #define RSS_HASH_KEY_LENGTH 40
1418 hexa_digit_to_value(char hexa_digit)
1420 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1421 return (uint8_t) (hexa_digit - '0');
1422 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1423 return (uint8_t) ((hexa_digit - 'a') + 10);
1424 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1425 return (uint8_t) ((hexa_digit - 'A') + 10);
1426 /* Invalid hexa digit */
1431 parse_and_check_key_hexa_digit(char *key, int idx)
1435 hexa_v = hexa_digit_to_value(key[idx]);
1437 printf("invalid key: character %c at position %d is not a "
1438 "valid hexa digit\n", key[idx], idx);
1443 cmd_config_rss_hash_key_parsed(void *parsed_result,
1444 __attribute__((unused)) struct cmdline *cl,
1445 __attribute__((unused)) void *data)
1447 struct cmd_config_rss_hash_key *res = parsed_result;
1448 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1453 /* Check the length of the RSS hash key */
1454 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1455 printf("key length: %d invalid - key must be a string of %d"
1456 "hexa-decimal numbers\n", (int) strlen(res->key),
1457 RSS_HASH_KEY_LENGTH * 2);
1460 /* Translate RSS hash key into binary representation */
1461 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1462 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1465 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1468 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1470 port_rss_hash_key_update(res->port_id, hash_key);
1473 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1475 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1478 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1479 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1480 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1482 rss_hash_key, "rss-hash-key");
1483 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1486 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1487 .f = cmd_config_rss_hash_key_parsed,
1489 .help_str = "port config X rss-hash-key 80 hexa digits",
1491 (void *)&cmd_config_rss_hash_key_port,
1492 (void *)&cmd_config_rss_hash_key_config,
1493 (void *)&cmd_config_rss_hash_key_port_id,
1494 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1495 (void *)&cmd_config_rss_hash_key_value,
1500 /* *** configure port rxq/txq start/stop *** */
1501 struct cmd_config_rxtx_queue {
1502 cmdline_fixed_string_t port;
1504 cmdline_fixed_string_t rxtxq;
1506 cmdline_fixed_string_t opname;
1510 cmd_config_rxtx_queue_parsed(void *parsed_result,
1511 __attribute__((unused)) struct cmdline *cl,
1512 __attribute__((unused)) void *data)
1514 struct cmd_config_rxtx_queue *res = parsed_result;
1519 if (test_done == 0) {
1520 printf("Please stop forwarding first\n");
1524 if (port_id_is_invalid(res->portid))
1527 if (port_is_started(res->portid) != 1) {
1528 printf("Please start port %u first\n", res->portid);
1532 if (!strcmp(res->rxtxq, "rxq"))
1534 else if (!strcmp(res->rxtxq, "txq"))
1537 printf("Unknown parameter\n");
1541 if (isrx && rx_queue_id_is_invalid(res->qid))
1543 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1546 if (!strcmp(res->opname, "start"))
1548 else if (!strcmp(res->opname, "stop"))
1551 printf("Unknown parameter\n");
1555 if (isstart && isrx)
1556 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1557 else if (!isstart && isrx)
1558 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1559 else if (isstart && !isrx)
1560 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1562 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1564 if (ret == -ENOTSUP)
1565 printf("Function not supported in PMD driver\n");
1568 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1570 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1571 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1572 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1574 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1575 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1576 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1580 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1581 .f = cmd_config_rxtx_queue_parsed,
1583 .help_str = "port X rxq|txq ID start|stop",
1585 (void *)&cmd_config_speed_all_port,
1586 (void *)&cmd_config_rxtx_queue_portid,
1587 (void *)&cmd_config_rxtx_queue_rxtxq,
1588 (void *)&cmd_config_rxtx_queue_qid,
1589 (void *)&cmd_config_rxtx_queue_opname,
1594 /* *** Configure RSS RETA *** */
1595 struct cmd_config_rss_reta {
1596 cmdline_fixed_string_t port;
1597 cmdline_fixed_string_t keyword;
1599 cmdline_fixed_string_t name;
1600 cmdline_fixed_string_t list_name;
1601 cmdline_fixed_string_t list_of_items;
1605 parse_reta_config(const char *str,
1606 struct rte_eth_rss_reta_entry64 *reta_conf,
1607 uint16_t nb_entries)
1611 uint16_t hash_index, idx, shift;
1614 const char *p, *p0 = str;
1621 unsigned long int_fld[_NUM_FLD];
1622 char *str_fld[_NUM_FLD];
1624 while ((p = strchr(p0,'(')) != NULL) {
1626 if((p0 = strchr(p,')')) == NULL)
1630 if(size >= sizeof(s))
1633 snprintf(s, sizeof(s), "%.*s", size, p);
1634 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1636 for (i = 0; i < _NUM_FLD; i++) {
1638 int_fld[i] = strtoul(str_fld[i], &end, 0);
1639 if (errno != 0 || end == str_fld[i] ||
1644 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1645 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1647 if (hash_index >= nb_entries) {
1648 printf("Invalid RETA hash index=%d\n", hash_index);
1652 idx = hash_index / RTE_RETA_GROUP_SIZE;
1653 shift = hash_index % RTE_RETA_GROUP_SIZE;
1654 reta_conf[idx].mask |= (1ULL << shift);
1655 reta_conf[idx].reta[shift] = nb_queue;
1662 cmd_set_rss_reta_parsed(void *parsed_result,
1663 __attribute__((unused)) struct cmdline *cl,
1664 __attribute__((unused)) void *data)
1667 struct rte_eth_dev_info dev_info;
1668 struct rte_eth_rss_reta_entry64 reta_conf[8];
1669 struct cmd_config_rss_reta *res = parsed_result;
1671 memset(&dev_info, 0, sizeof(dev_info));
1672 rte_eth_dev_info_get(res->port_id, &dev_info);
1673 if (dev_info.reta_size == 0) {
1674 printf("Redirection table size is 0 which is "
1675 "invalid for RSS\n");
1678 printf("The reta size of port %d is %u\n",
1679 res->port_id, dev_info.reta_size);
1680 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1681 printf("Currently do not support more than %u entries of "
1682 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1686 memset(reta_conf, 0, sizeof(reta_conf));
1687 if (!strcmp(res->list_name, "reta")) {
1688 if (parse_reta_config(res->list_of_items, reta_conf,
1689 dev_info.reta_size)) {
1690 printf("Invalid RSS Redirection Table "
1691 "config entered\n");
1694 ret = rte_eth_dev_rss_reta_update(res->port_id,
1695 reta_conf, dev_info.reta_size);
1697 printf("Bad redirection table parameter, "
1698 "return code = %d \n", ret);
1702 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1704 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1705 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1706 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1707 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1708 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1710 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1712 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1715 cmdline_parse_inst_t cmd_config_rss_reta = {
1716 .f = cmd_set_rss_reta_parsed,
1718 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1720 (void *)&cmd_config_rss_reta_port,
1721 (void *)&cmd_config_rss_reta_keyword,
1722 (void *)&cmd_config_rss_reta_port_id,
1723 (void *)&cmd_config_rss_reta_name,
1724 (void *)&cmd_config_rss_reta_list_name,
1725 (void *)&cmd_config_rss_reta_list_of_items,
1730 /* *** SHOW PORT RETA INFO *** */
1731 struct cmd_showport_reta {
1732 cmdline_fixed_string_t show;
1733 cmdline_fixed_string_t port;
1735 cmdline_fixed_string_t rss;
1736 cmdline_fixed_string_t reta;
1738 cmdline_fixed_string_t list_of_items;
1742 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1743 uint16_t nb_entries,
1747 const char *p, *p0 = str;
1751 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1754 p = strchr(p0, '(');
1758 p0 = strchr(p, ')');
1762 if (size >= sizeof(s)) {
1763 printf("The string size exceeds the internal buffer size\n");
1766 snprintf(s, sizeof(s), "%.*s", size, p);
1767 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1768 if (ret <= 0 || ret != num) {
1769 printf("The bits of masks do not match the number of "
1770 "reta entries: %u\n", num);
1773 for (i = 0; i < ret; i++)
1774 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1780 cmd_showport_reta_parsed(void *parsed_result,
1781 __attribute__((unused)) struct cmdline *cl,
1782 __attribute__((unused)) void *data)
1784 struct cmd_showport_reta *res = parsed_result;
1785 struct rte_eth_rss_reta_entry64 reta_conf[8];
1786 struct rte_eth_dev_info dev_info;
1788 memset(&dev_info, 0, sizeof(dev_info));
1789 rte_eth_dev_info_get(res->port_id, &dev_info);
1790 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1791 res->size > ETH_RSS_RETA_SIZE_512) {
1792 printf("Invalid redirection table size: %u\n", res->size);
1796 memset(reta_conf, 0, sizeof(reta_conf));
1797 if (showport_parse_reta_config(reta_conf, res->size,
1798 res->list_of_items) < 0) {
1799 printf("Invalid string: %s for reta masks\n",
1800 res->list_of_items);
1803 port_rss_reta_info(res->port_id, reta_conf, res->size);
1806 cmdline_parse_token_string_t cmd_showport_reta_show =
1807 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1808 cmdline_parse_token_string_t cmd_showport_reta_port =
1809 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1810 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1811 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1812 cmdline_parse_token_string_t cmd_showport_reta_rss =
1813 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1814 cmdline_parse_token_string_t cmd_showport_reta_reta =
1815 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1816 cmdline_parse_token_num_t cmd_showport_reta_size =
1817 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1818 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1819 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1820 list_of_items, NULL);
1822 cmdline_parse_inst_t cmd_showport_reta = {
1823 .f = cmd_showport_reta_parsed,
1825 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1827 (void *)&cmd_showport_reta_show,
1828 (void *)&cmd_showport_reta_port,
1829 (void *)&cmd_showport_reta_port_id,
1830 (void *)&cmd_showport_reta_rss,
1831 (void *)&cmd_showport_reta_reta,
1832 (void *)&cmd_showport_reta_size,
1833 (void *)&cmd_showport_reta_list_of_items,
1838 /* *** Show RSS hash configuration *** */
1839 struct cmd_showport_rss_hash {
1840 cmdline_fixed_string_t show;
1841 cmdline_fixed_string_t port;
1843 cmdline_fixed_string_t rss_hash;
1844 cmdline_fixed_string_t key; /* optional argument */
1847 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1848 __attribute__((unused)) struct cmdline *cl,
1851 struct cmd_showport_rss_hash *res = parsed_result;
1853 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1856 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1857 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1858 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1859 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1860 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1861 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1862 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1863 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1865 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1866 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1868 cmdline_parse_inst_t cmd_showport_rss_hash = {
1869 .f = cmd_showport_rss_hash_parsed,
1871 .help_str = "show port X rss-hash (X = port number)\n",
1873 (void *)&cmd_showport_rss_hash_show,
1874 (void *)&cmd_showport_rss_hash_port,
1875 (void *)&cmd_showport_rss_hash_port_id,
1876 (void *)&cmd_showport_rss_hash_rss_hash,
1881 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1882 .f = cmd_showport_rss_hash_parsed,
1884 .help_str = "show port X rss-hash key (X = port number)\n",
1886 (void *)&cmd_showport_rss_hash_show,
1887 (void *)&cmd_showport_rss_hash_port,
1888 (void *)&cmd_showport_rss_hash_port_id,
1889 (void *)&cmd_showport_rss_hash_rss_hash,
1890 (void *)&cmd_showport_rss_hash_rss_key,
1895 /* *** Configure DCB *** */
1896 struct cmd_config_dcb {
1897 cmdline_fixed_string_t port;
1898 cmdline_fixed_string_t config;
1900 cmdline_fixed_string_t dcb;
1901 cmdline_fixed_string_t vt;
1902 cmdline_fixed_string_t vt_en;
1904 cmdline_fixed_string_t pfc;
1905 cmdline_fixed_string_t pfc_en;
1909 cmd_config_dcb_parsed(void *parsed_result,
1910 __attribute__((unused)) struct cmdline *cl,
1911 __attribute__((unused)) void *data)
1913 struct cmd_config_dcb *res = parsed_result;
1914 struct dcb_config dcb_conf;
1915 portid_t port_id = res->port_id;
1916 struct rte_port *port;
1918 port = &ports[port_id];
1919 /** Check if the port is not started **/
1920 if (port->port_status != RTE_PORT_STOPPED) {
1921 printf("Please stop port %d first\n",port_id);
1925 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1926 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1927 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1931 /* DCB in VT mode */
1932 if (!strncmp(res->vt_en, "on",2))
1933 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1935 dcb_conf.dcb_mode = DCB_ENABLED;
1937 if (!strncmp(res->pfc_en, "on",2)) {
1938 dcb_conf.pfc_en = 1;
1941 dcb_conf.pfc_en = 0;
1943 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1944 printf("Cannot initialize network ports\n");
1948 cmd_reconfig_device_queue(port_id, 1, 1);
1951 cmdline_parse_token_string_t cmd_config_dcb_port =
1952 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1953 cmdline_parse_token_string_t cmd_config_dcb_config =
1954 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1955 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1956 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1957 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1959 cmdline_parse_token_string_t cmd_config_dcb_vt =
1960 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1961 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1962 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1963 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1964 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1965 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1966 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1967 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1968 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1970 cmdline_parse_inst_t cmd_config_dcb = {
1971 .f = cmd_config_dcb_parsed,
1973 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1975 (void *)&cmd_config_dcb_port,
1976 (void *)&cmd_config_dcb_config,
1977 (void *)&cmd_config_dcb_port_id,
1978 (void *)&cmd_config_dcb_dcb,
1979 (void *)&cmd_config_dcb_vt,
1980 (void *)&cmd_config_dcb_vt_en,
1981 (void *)&cmd_config_dcb_num_tcs,
1982 (void *)&cmd_config_dcb_pfc,
1983 (void *)&cmd_config_dcb_pfc_en,
1988 /* *** configure number of packets per burst *** */
1989 struct cmd_config_burst {
1990 cmdline_fixed_string_t port;
1991 cmdline_fixed_string_t keyword;
1992 cmdline_fixed_string_t all;
1993 cmdline_fixed_string_t name;
1998 cmd_config_burst_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2002 struct cmd_config_burst *res = parsed_result;
2004 if (!all_ports_stopped()) {
2005 printf("Please stop all ports first\n");
2009 if (!strcmp(res->name, "burst")) {
2010 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2011 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2014 nb_pkt_per_burst = res->value;
2016 printf("Unknown parameter\n");
2022 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2025 cmdline_parse_token_string_t cmd_config_burst_port =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2027 cmdline_parse_token_string_t cmd_config_burst_keyword =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2029 cmdline_parse_token_string_t cmd_config_burst_all =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2031 cmdline_parse_token_string_t cmd_config_burst_name =
2032 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2033 cmdline_parse_token_num_t cmd_config_burst_value =
2034 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2036 cmdline_parse_inst_t cmd_config_burst = {
2037 .f = cmd_config_burst_parsed,
2039 .help_str = "port config all burst value",
2041 (void *)&cmd_config_burst_port,
2042 (void *)&cmd_config_burst_keyword,
2043 (void *)&cmd_config_burst_all,
2044 (void *)&cmd_config_burst_name,
2045 (void *)&cmd_config_burst_value,
2050 /* *** configure rx/tx queues *** */
2051 struct cmd_config_thresh {
2052 cmdline_fixed_string_t port;
2053 cmdline_fixed_string_t keyword;
2054 cmdline_fixed_string_t all;
2055 cmdline_fixed_string_t name;
2060 cmd_config_thresh_parsed(void *parsed_result,
2061 __attribute__((unused)) struct cmdline *cl,
2062 __attribute__((unused)) void *data)
2064 struct cmd_config_thresh *res = parsed_result;
2066 if (!all_ports_stopped()) {
2067 printf("Please stop all ports first\n");
2071 if (!strcmp(res->name, "txpt"))
2072 tx_thresh.pthresh = res->value;
2073 else if(!strcmp(res->name, "txht"))
2074 tx_thresh.hthresh = res->value;
2075 else if(!strcmp(res->name, "txwt"))
2076 tx_thresh.wthresh = res->value;
2077 else if(!strcmp(res->name, "rxpt"))
2078 rx_thresh.pthresh = res->value;
2079 else if(!strcmp(res->name, "rxht"))
2080 rx_thresh.hthresh = res->value;
2081 else if(!strcmp(res->name, "rxwt"))
2082 rx_thresh.wthresh = res->value;
2084 printf("Unknown parameter\n");
2090 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2093 cmdline_parse_token_string_t cmd_config_thresh_port =
2094 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2095 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2096 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2097 cmdline_parse_token_string_t cmd_config_thresh_all =
2098 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2099 cmdline_parse_token_string_t cmd_config_thresh_name =
2100 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2101 "txpt#txht#txwt#rxpt#rxht#rxwt");
2102 cmdline_parse_token_num_t cmd_config_thresh_value =
2103 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2105 cmdline_parse_inst_t cmd_config_thresh = {
2106 .f = cmd_config_thresh_parsed,
2108 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2110 (void *)&cmd_config_thresh_port,
2111 (void *)&cmd_config_thresh_keyword,
2112 (void *)&cmd_config_thresh_all,
2113 (void *)&cmd_config_thresh_name,
2114 (void *)&cmd_config_thresh_value,
2119 /* *** configure free/rs threshold *** */
2120 struct cmd_config_threshold {
2121 cmdline_fixed_string_t port;
2122 cmdline_fixed_string_t keyword;
2123 cmdline_fixed_string_t all;
2124 cmdline_fixed_string_t name;
2129 cmd_config_threshold_parsed(void *parsed_result,
2130 __attribute__((unused)) struct cmdline *cl,
2131 __attribute__((unused)) void *data)
2133 struct cmd_config_threshold *res = parsed_result;
2135 if (!all_ports_stopped()) {
2136 printf("Please stop all ports first\n");
2140 if (!strcmp(res->name, "txfreet"))
2141 tx_free_thresh = res->value;
2142 else if (!strcmp(res->name, "txrst"))
2143 tx_rs_thresh = res->value;
2144 else if (!strcmp(res->name, "rxfreet"))
2145 rx_free_thresh = res->value;
2147 printf("Unknown parameter\n");
2153 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2156 cmdline_parse_token_string_t cmd_config_threshold_port =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2158 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2161 cmdline_parse_token_string_t cmd_config_threshold_all =
2162 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2163 cmdline_parse_token_string_t cmd_config_threshold_name =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2165 "txfreet#txrst#rxfreet");
2166 cmdline_parse_token_num_t cmd_config_threshold_value =
2167 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2169 cmdline_parse_inst_t cmd_config_threshold = {
2170 .f = cmd_config_threshold_parsed,
2172 .help_str = "port config all txfreet|txrst|rxfreet value",
2174 (void *)&cmd_config_threshold_port,
2175 (void *)&cmd_config_threshold_keyword,
2176 (void *)&cmd_config_threshold_all,
2177 (void *)&cmd_config_threshold_name,
2178 (void *)&cmd_config_threshold_value,
2184 struct cmd_stop_result {
2185 cmdline_fixed_string_t stop;
2188 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2189 __attribute__((unused)) struct cmdline *cl,
2190 __attribute__((unused)) void *data)
2192 stop_packet_forwarding();
2195 cmdline_parse_token_string_t cmd_stop_stop =
2196 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2198 cmdline_parse_inst_t cmd_stop = {
2199 .f = cmd_stop_parsed,
2201 .help_str = "stop - stop packet forwarding",
2203 (void *)&cmd_stop_stop,
2208 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2211 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2212 unsigned int *parsed_items, int check_unique_values)
2214 unsigned int nb_item;
2222 * First parse all items in the list and store their value.
2227 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2229 if ((c >= '0') && (c <= '9')) {
2230 value = (unsigned int) (value * 10 + (c - '0'));
2235 printf("character %c is not a decimal digit\n", c);
2239 printf("No valid value before comma\n");
2242 if (nb_item < max_items) {
2243 parsed_items[nb_item] = value;
2249 if (nb_item >= max_items) {
2250 printf("Number of %s = %u > %u (maximum items)\n",
2251 item_name, nb_item + 1, max_items);
2254 parsed_items[nb_item++] = value;
2255 if (! check_unique_values)
2259 * Then, check that all values in the list are differents.
2260 * No optimization here...
2262 for (i = 0; i < nb_item; i++) {
2263 for (j = i + 1; j < nb_item; j++) {
2264 if (parsed_items[j] == parsed_items[i]) {
2265 printf("duplicated %s %u at index %u and %u\n",
2266 item_name, parsed_items[i], i, j);
2274 struct cmd_set_list_result {
2275 cmdline_fixed_string_t cmd_keyword;
2276 cmdline_fixed_string_t list_name;
2277 cmdline_fixed_string_t list_of_items;
2280 static void cmd_set_list_parsed(void *parsed_result,
2281 __attribute__((unused)) struct cmdline *cl,
2282 __attribute__((unused)) void *data)
2284 struct cmd_set_list_result *res;
2286 unsigned int lcorelist[RTE_MAX_LCORE];
2287 unsigned int portlist[RTE_MAX_ETHPORTS];
2289 unsigned int nb_item;
2291 res = parsed_result;
2292 if (!strcmp(res->list_name, "corelist")) {
2293 nb_item = parse_item_list(res->list_of_items, "core",
2295 parsed_items.lcorelist, 1);
2297 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2300 if (!strcmp(res->list_name, "portlist")) {
2301 nb_item = parse_item_list(res->list_of_items, "port",
2303 parsed_items.portlist, 1);
2305 set_fwd_ports_list(parsed_items.portlist, nb_item);
2309 cmdline_parse_token_string_t cmd_set_list_keyword =
2310 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2312 cmdline_parse_token_string_t cmd_set_list_name =
2313 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2314 "corelist#portlist");
2315 cmdline_parse_token_string_t cmd_set_list_of_items =
2316 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2319 cmdline_parse_inst_t cmd_set_fwd_list = {
2320 .f = cmd_set_list_parsed,
2322 .help_str = "set corelist|portlist x[,y]*",
2324 (void *)&cmd_set_list_keyword,
2325 (void *)&cmd_set_list_name,
2326 (void *)&cmd_set_list_of_items,
2331 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2333 struct cmd_setmask_result {
2334 cmdline_fixed_string_t set;
2335 cmdline_fixed_string_t mask;
2339 static void cmd_set_mask_parsed(void *parsed_result,
2340 __attribute__((unused)) struct cmdline *cl,
2341 __attribute__((unused)) void *data)
2343 struct cmd_setmask_result *res = parsed_result;
2345 if (!strcmp(res->mask, "coremask"))
2346 set_fwd_lcores_mask(res->hexavalue);
2347 else if (!strcmp(res->mask, "portmask"))
2348 set_fwd_ports_mask(res->hexavalue);
2351 cmdline_parse_token_string_t cmd_setmask_set =
2352 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2353 cmdline_parse_token_string_t cmd_setmask_mask =
2354 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2355 "coremask#portmask");
2356 cmdline_parse_token_num_t cmd_setmask_value =
2357 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2359 cmdline_parse_inst_t cmd_set_fwd_mask = {
2360 .f = cmd_set_mask_parsed,
2362 .help_str = "set coremask|portmask hexadecimal value",
2364 (void *)&cmd_setmask_set,
2365 (void *)&cmd_setmask_mask,
2366 (void *)&cmd_setmask_value,
2372 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2374 struct cmd_set_result {
2375 cmdline_fixed_string_t set;
2376 cmdline_fixed_string_t what;
2380 static void cmd_set_parsed(void *parsed_result,
2381 __attribute__((unused)) struct cmdline *cl,
2382 __attribute__((unused)) void *data)
2384 struct cmd_set_result *res = parsed_result;
2385 if (!strcmp(res->what, "nbport"))
2386 set_fwd_ports_number(res->value);
2387 else if (!strcmp(res->what, "nbcore"))
2388 set_fwd_lcores_number(res->value);
2389 else if (!strcmp(res->what, "burst"))
2390 set_nb_pkt_per_burst(res->value);
2391 else if (!strcmp(res->what, "verbose"))
2392 set_verbose_level(res->value);
2395 cmdline_parse_token_string_t cmd_set_set =
2396 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2397 cmdline_parse_token_string_t cmd_set_what =
2398 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2399 "nbport#nbcore#burst#verbose");
2400 cmdline_parse_token_num_t cmd_set_value =
2401 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2403 cmdline_parse_inst_t cmd_set_numbers = {
2404 .f = cmd_set_parsed,
2406 .help_str = "set nbport|nbcore|burst|verbose value",
2408 (void *)&cmd_set_set,
2409 (void *)&cmd_set_what,
2410 (void *)&cmd_set_value,
2415 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2417 struct cmd_set_txpkts_result {
2418 cmdline_fixed_string_t cmd_keyword;
2419 cmdline_fixed_string_t txpkts;
2420 cmdline_fixed_string_t seg_lengths;
2424 cmd_set_txpkts_parsed(void *parsed_result,
2425 __attribute__((unused)) struct cmdline *cl,
2426 __attribute__((unused)) void *data)
2428 struct cmd_set_txpkts_result *res;
2429 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2430 unsigned int nb_segs;
2432 res = parsed_result;
2433 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2434 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2436 set_tx_pkt_segments(seg_lengths, nb_segs);
2439 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2440 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2441 cmd_keyword, "set");
2442 cmdline_parse_token_string_t cmd_set_txpkts_name =
2443 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2445 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2446 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2449 cmdline_parse_inst_t cmd_set_txpkts = {
2450 .f = cmd_set_txpkts_parsed,
2452 .help_str = "set txpkts x[,y]*",
2454 (void *)&cmd_set_txpkts_keyword,
2455 (void *)&cmd_set_txpkts_name,
2456 (void *)&cmd_set_txpkts_lengths,
2461 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2462 struct cmd_rx_vlan_filter_all_result {
2463 cmdline_fixed_string_t rx_vlan;
2464 cmdline_fixed_string_t what;
2465 cmdline_fixed_string_t all;
2470 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2471 __attribute__((unused)) struct cmdline *cl,
2472 __attribute__((unused)) void *data)
2474 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2476 if (!strcmp(res->what, "add"))
2477 rx_vlan_all_filter_set(res->port_id, 1);
2479 rx_vlan_all_filter_set(res->port_id, 0);
2482 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2483 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2484 rx_vlan, "rx_vlan");
2485 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2486 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2488 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2489 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2491 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2492 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2495 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2496 .f = cmd_rx_vlan_filter_all_parsed,
2498 .help_str = "add/remove all identifiers to/from the set of VLAN "
2499 "Identifiers filtered by a port",
2501 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2502 (void *)&cmd_rx_vlan_filter_all_what,
2503 (void *)&cmd_rx_vlan_filter_all_all,
2504 (void *)&cmd_rx_vlan_filter_all_portid,
2509 /* *** VLAN OFFLOAD SET ON A PORT *** */
2510 struct cmd_vlan_offload_result {
2511 cmdline_fixed_string_t vlan;
2512 cmdline_fixed_string_t set;
2513 cmdline_fixed_string_t what;
2514 cmdline_fixed_string_t on;
2515 cmdline_fixed_string_t port_id;
2519 cmd_vlan_offload_parsed(void *parsed_result,
2520 __attribute__((unused)) struct cmdline *cl,
2521 __attribute__((unused)) void *data)
2524 struct cmd_vlan_offload_result *res = parsed_result;
2527 portid_t port_id = 0;
2531 len = strnlen(str, STR_TOKEN_SIZE);
2533 /* Get port_id first */
2541 tmp = strtoul(str, NULL, 0);
2542 /* If port_id greater that what portid_t can represent, return */
2543 if(tmp >= RTE_MAX_ETHPORTS)
2545 port_id = (portid_t)tmp;
2547 if (!strcmp(res->on, "on"))
2552 if (!strcmp(res->what, "strip"))
2553 rx_vlan_strip_set(port_id, on);
2554 else if(!strcmp(res->what, "stripq")){
2555 uint16_t queue_id = 0;
2557 /* No queue_id, return */
2559 printf("must specify (port,queue_id)\n");
2562 tmp = strtoul(str + i + 1, NULL, 0);
2563 /* If queue_id greater that what 16-bits can represent, return */
2567 queue_id = (uint16_t)tmp;
2568 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2570 else if (!strcmp(res->what, "filter"))
2571 rx_vlan_filter_set(port_id, on);
2573 vlan_extend_set(port_id, on);
2578 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2579 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2581 cmdline_parse_token_string_t cmd_vlan_offload_set =
2582 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2584 cmdline_parse_token_string_t cmd_vlan_offload_what =
2585 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2586 what, "strip#filter#qinq#stripq");
2587 cmdline_parse_token_string_t cmd_vlan_offload_on =
2588 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2590 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2591 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2594 cmdline_parse_inst_t cmd_vlan_offload = {
2595 .f = cmd_vlan_offload_parsed,
2597 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2598 " qinq(extended) for both rx/tx sides ",
2600 (void *)&cmd_vlan_offload_vlan,
2601 (void *)&cmd_vlan_offload_set,
2602 (void *)&cmd_vlan_offload_what,
2603 (void *)&cmd_vlan_offload_on,
2604 (void *)&cmd_vlan_offload_portid,
2609 /* *** VLAN TPID SET ON A PORT *** */
2610 struct cmd_vlan_tpid_result {
2611 cmdline_fixed_string_t vlan;
2612 cmdline_fixed_string_t set;
2613 cmdline_fixed_string_t what;
2619 cmd_vlan_tpid_parsed(void *parsed_result,
2620 __attribute__((unused)) struct cmdline *cl,
2621 __attribute__((unused)) void *data)
2623 struct cmd_vlan_tpid_result *res = parsed_result;
2624 vlan_tpid_set(res->port_id, res->tp_id);
2628 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2629 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2631 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2632 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2634 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2635 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2637 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2638 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2640 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2641 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2644 cmdline_parse_inst_t cmd_vlan_tpid = {
2645 .f = cmd_vlan_tpid_parsed,
2647 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2649 (void *)&cmd_vlan_tpid_vlan,
2650 (void *)&cmd_vlan_tpid_set,
2651 (void *)&cmd_vlan_tpid_what,
2652 (void *)&cmd_vlan_tpid_tpid,
2653 (void *)&cmd_vlan_tpid_portid,
2658 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2659 struct cmd_rx_vlan_filter_result {
2660 cmdline_fixed_string_t rx_vlan;
2661 cmdline_fixed_string_t what;
2667 cmd_rx_vlan_filter_parsed(void *parsed_result,
2668 __attribute__((unused)) struct cmdline *cl,
2669 __attribute__((unused)) void *data)
2671 struct cmd_rx_vlan_filter_result *res = parsed_result;
2673 if (!strcmp(res->what, "add"))
2674 rx_vft_set(res->port_id, res->vlan_id, 1);
2676 rx_vft_set(res->port_id, res->vlan_id, 0);
2679 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2680 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2681 rx_vlan, "rx_vlan");
2682 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2683 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2685 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2686 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2688 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2689 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2692 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2693 .f = cmd_rx_vlan_filter_parsed,
2695 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2696 "Identifiers filtered by a port",
2698 (void *)&cmd_rx_vlan_filter_rx_vlan,
2699 (void *)&cmd_rx_vlan_filter_what,
2700 (void *)&cmd_rx_vlan_filter_vlanid,
2701 (void *)&cmd_rx_vlan_filter_portid,
2706 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2707 struct cmd_tx_vlan_set_result {
2708 cmdline_fixed_string_t tx_vlan;
2709 cmdline_fixed_string_t set;
2715 cmd_tx_vlan_set_parsed(void *parsed_result,
2716 __attribute__((unused)) struct cmdline *cl,
2717 __attribute__((unused)) void *data)
2719 struct cmd_tx_vlan_set_result *res = parsed_result;
2720 tx_vlan_set(res->port_id, res->vlan_id);
2723 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2724 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2725 tx_vlan, "tx_vlan");
2726 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2727 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2729 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2730 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2732 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2733 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2736 cmdline_parse_inst_t cmd_tx_vlan_set = {
2737 .f = cmd_tx_vlan_set_parsed,
2739 .help_str = "enable hardware insertion of a VLAN header with a given "
2740 "TAG Identifier in packets sent on a port",
2742 (void *)&cmd_tx_vlan_set_tx_vlan,
2743 (void *)&cmd_tx_vlan_set_set,
2744 (void *)&cmd_tx_vlan_set_vlanid,
2745 (void *)&cmd_tx_vlan_set_portid,
2750 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2751 struct cmd_tx_vlan_set_pvid_result {
2752 cmdline_fixed_string_t tx_vlan;
2753 cmdline_fixed_string_t set;
2754 cmdline_fixed_string_t pvid;
2757 cmdline_fixed_string_t mode;
2761 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2762 __attribute__((unused)) struct cmdline *cl,
2763 __attribute__((unused)) void *data)
2765 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2767 if (strcmp(res->mode, "on") == 0)
2768 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2770 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2773 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2774 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2775 tx_vlan, "tx_vlan");
2776 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2777 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2779 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2780 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2782 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2783 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2785 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2786 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2788 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2789 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2792 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2793 .f = cmd_tx_vlan_set_pvid_parsed,
2795 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2797 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2798 (void *)&cmd_tx_vlan_set_pvid_set,
2799 (void *)&cmd_tx_vlan_set_pvid_pvid,
2800 (void *)&cmd_tx_vlan_set_pvid_port_id,
2801 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2802 (void *)&cmd_tx_vlan_set_pvid_mode,
2807 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2808 struct cmd_tx_vlan_reset_result {
2809 cmdline_fixed_string_t tx_vlan;
2810 cmdline_fixed_string_t reset;
2815 cmd_tx_vlan_reset_parsed(void *parsed_result,
2816 __attribute__((unused)) struct cmdline *cl,
2817 __attribute__((unused)) void *data)
2819 struct cmd_tx_vlan_reset_result *res = parsed_result;
2821 tx_vlan_reset(res->port_id);
2824 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2825 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2826 tx_vlan, "tx_vlan");
2827 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2828 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2830 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2831 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2834 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2835 .f = cmd_tx_vlan_reset_parsed,
2837 .help_str = "disable hardware insertion of a VLAN header in packets "
2840 (void *)&cmd_tx_vlan_reset_tx_vlan,
2841 (void *)&cmd_tx_vlan_reset_reset,
2842 (void *)&cmd_tx_vlan_reset_portid,
2848 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2849 struct cmd_tx_cksum_set_result {
2850 cmdline_fixed_string_t tx_cksum;
2851 cmdline_fixed_string_t set;
2857 cmd_tx_cksum_set_parsed(void *parsed_result,
2858 __attribute__((unused)) struct cmdline *cl,
2859 __attribute__((unused)) void *data)
2861 struct cmd_tx_cksum_set_result *res = parsed_result;
2863 tx_cksum_set(res->port_id, res->cksum_mask);
2866 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2867 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2868 tx_cksum, "tx_checksum");
2869 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2870 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2872 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2873 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2875 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2876 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2879 cmdline_parse_inst_t cmd_tx_cksum_set = {
2880 .f = cmd_tx_cksum_set_parsed,
2882 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2883 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2884 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2885 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2887 (void *)&cmd_tx_cksum_set_tx_cksum,
2888 (void *)&cmd_tx_cksum_set_set,
2889 (void *)&cmd_tx_cksum_set_cksum_mask,
2890 (void *)&cmd_tx_cksum_set_portid,
2895 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2896 struct cmd_set_flush_rx {
2897 cmdline_fixed_string_t set;
2898 cmdline_fixed_string_t flush_rx;
2899 cmdline_fixed_string_t mode;
2903 cmd_set_flush_rx_parsed(void *parsed_result,
2904 __attribute__((unused)) struct cmdline *cl,
2905 __attribute__((unused)) void *data)
2907 struct cmd_set_flush_rx *res = parsed_result;
2908 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2911 cmdline_parse_token_string_t cmd_setflushrx_set =
2912 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2914 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2915 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2916 flush_rx, "flush_rx");
2917 cmdline_parse_token_string_t cmd_setflushrx_mode =
2918 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2922 cmdline_parse_inst_t cmd_set_flush_rx = {
2923 .f = cmd_set_flush_rx_parsed,
2924 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2927 (void *)&cmd_setflushrx_set,
2928 (void *)&cmd_setflushrx_flush_rx,
2929 (void *)&cmd_setflushrx_mode,
2934 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2935 struct cmd_set_link_check {
2936 cmdline_fixed_string_t set;
2937 cmdline_fixed_string_t link_check;
2938 cmdline_fixed_string_t mode;
2942 cmd_set_link_check_parsed(void *parsed_result,
2943 __attribute__((unused)) struct cmdline *cl,
2944 __attribute__((unused)) void *data)
2946 struct cmd_set_link_check *res = parsed_result;
2947 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2950 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2951 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2953 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2954 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2955 link_check, "link_check");
2956 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2957 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2961 cmdline_parse_inst_t cmd_set_link_check = {
2962 .f = cmd_set_link_check_parsed,
2963 .help_str = "set link_check on|off: enable/disable link status check "
2964 "when starting/stopping a port",
2967 (void *)&cmd_setlinkcheck_set,
2968 (void *)&cmd_setlinkcheck_link_check,
2969 (void *)&cmd_setlinkcheck_mode,
2974 #ifdef RTE_NIC_BYPASS
2975 /* *** SET NIC BYPASS MODE *** */
2976 struct cmd_set_bypass_mode_result {
2977 cmdline_fixed_string_t set;
2978 cmdline_fixed_string_t bypass;
2979 cmdline_fixed_string_t mode;
2980 cmdline_fixed_string_t value;
2985 cmd_set_bypass_mode_parsed(void *parsed_result,
2986 __attribute__((unused)) struct cmdline *cl,
2987 __attribute__((unused)) void *data)
2989 struct cmd_set_bypass_mode_result *res = parsed_result;
2990 portid_t port_id = res->port_id;
2991 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2993 if (!bypass_is_supported(port_id))
2996 if (!strcmp(res->value, "bypass"))
2997 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2998 else if (!strcmp(res->value, "isolate"))
2999 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3001 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3003 /* Set the bypass mode for the relevant port. */
3004 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3005 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3009 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3010 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3012 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3013 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3015 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3016 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3018 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3020 value, "normal#bypass#isolate");
3021 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3022 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3025 cmdline_parse_inst_t cmd_set_bypass_mode = {
3026 .f = cmd_set_bypass_mode_parsed,
3027 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3028 "Set the NIC bypass mode for port_id",
3031 (void *)&cmd_setbypass_mode_set,
3032 (void *)&cmd_setbypass_mode_bypass,
3033 (void *)&cmd_setbypass_mode_mode,
3034 (void *)&cmd_setbypass_mode_value,
3035 (void *)&cmd_setbypass_mode_port,
3040 /* *** SET NIC BYPASS EVENT *** */
3041 struct cmd_set_bypass_event_result {
3042 cmdline_fixed_string_t set;
3043 cmdline_fixed_string_t bypass;
3044 cmdline_fixed_string_t event;
3045 cmdline_fixed_string_t event_value;
3046 cmdline_fixed_string_t mode;
3047 cmdline_fixed_string_t mode_value;
3052 cmd_set_bypass_event_parsed(void *parsed_result,
3053 __attribute__((unused)) struct cmdline *cl,
3054 __attribute__((unused)) void *data)
3057 struct cmd_set_bypass_event_result *res = parsed_result;
3058 portid_t port_id = res->port_id;
3059 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3060 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3062 if (!bypass_is_supported(port_id))
3065 if (!strcmp(res->event_value, "timeout"))
3066 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3067 else if (!strcmp(res->event_value, "os_on"))
3068 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3069 else if (!strcmp(res->event_value, "os_off"))
3070 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3071 else if (!strcmp(res->event_value, "power_on"))
3072 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3073 else if (!strcmp(res->event_value, "power_off"))
3074 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3076 bypass_event = RTE_BYPASS_EVENT_NONE;
3078 if (!strcmp(res->mode_value, "bypass"))
3079 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3080 else if (!strcmp(res->mode_value, "isolate"))
3081 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3083 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3085 /* Set the watchdog timeout. */
3086 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3089 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3090 (rc = rte_eth_dev_wd_timeout_store(port_id,
3091 bypass_timeout)) != 0) {
3092 printf("Failed to set timeout value %u "
3093 "for port %d, errto code: %d.\n",
3094 bypass_timeout, port_id, rc);
3098 /* Set the bypass event to transition to bypass mode. */
3099 if (0 != rte_eth_dev_bypass_event_store(port_id,
3100 bypass_event, bypass_mode)) {
3101 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3106 cmdline_parse_token_string_t cmd_setbypass_event_set =
3107 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3109 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3110 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3112 cmdline_parse_token_string_t cmd_setbypass_event_event =
3113 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3115 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3116 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3117 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3118 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3121 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3123 mode_value, "normal#bypass#isolate");
3124 cmdline_parse_token_num_t cmd_setbypass_event_port =
3125 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3128 cmdline_parse_inst_t cmd_set_bypass_event = {
3129 .f = cmd_set_bypass_event_parsed,
3130 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3131 "mode (normal|bypass|isolate) (port_id): "
3132 "Set the NIC bypass event mode for port_id",
3135 (void *)&cmd_setbypass_event_set,
3136 (void *)&cmd_setbypass_event_bypass,
3137 (void *)&cmd_setbypass_event_event,
3138 (void *)&cmd_setbypass_event_event_value,
3139 (void *)&cmd_setbypass_event_mode,
3140 (void *)&cmd_setbypass_event_mode_value,
3141 (void *)&cmd_setbypass_event_port,
3147 /* *** SET NIC BYPASS TIMEOUT *** */
3148 struct cmd_set_bypass_timeout_result {
3149 cmdline_fixed_string_t set;
3150 cmdline_fixed_string_t bypass;
3151 cmdline_fixed_string_t timeout;
3152 cmdline_fixed_string_t value;
3156 cmd_set_bypass_timeout_parsed(void *parsed_result,
3157 __attribute__((unused)) struct cmdline *cl,
3158 __attribute__((unused)) void *data)
3160 struct cmd_set_bypass_timeout_result *res = parsed_result;
3162 if (!strcmp(res->value, "1.5"))
3163 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3164 else if (!strcmp(res->value, "2"))
3165 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3166 else if (!strcmp(res->value, "3"))
3167 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3168 else if (!strcmp(res->value, "4"))
3169 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3170 else if (!strcmp(res->value, "8"))
3171 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3172 else if (!strcmp(res->value, "16"))
3173 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3174 else if (!strcmp(res->value, "32"))
3175 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3177 bypass_timeout = RTE_BYPASS_TMT_OFF;
3180 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3181 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3183 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3184 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3186 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3187 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3188 timeout, "timeout");
3189 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3190 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3191 value, "0#1.5#2#3#4#8#16#32");
3193 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3194 .f = cmd_set_bypass_timeout_parsed,
3195 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3196 "Set the NIC bypass watchdog timeout",
3199 (void *)&cmd_setbypass_timeout_set,
3200 (void *)&cmd_setbypass_timeout_bypass,
3201 (void *)&cmd_setbypass_timeout_timeout,
3202 (void *)&cmd_setbypass_timeout_value,
3207 /* *** SHOW NIC BYPASS MODE *** */
3208 struct cmd_show_bypass_config_result {
3209 cmdline_fixed_string_t show;
3210 cmdline_fixed_string_t bypass;
3211 cmdline_fixed_string_t config;
3216 cmd_show_bypass_config_parsed(void *parsed_result,
3217 __attribute__((unused)) struct cmdline *cl,
3218 __attribute__((unused)) void *data)
3220 struct cmd_show_bypass_config_result *res = parsed_result;
3221 uint32_t event_mode;
3222 uint32_t bypass_mode;
3223 portid_t port_id = res->port_id;
3224 uint32_t timeout = bypass_timeout;
3227 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3228 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3229 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3230 {"UNKNOWN", "normal", "bypass", "isolate"};
3231 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3238 int num_events = (sizeof events) / (sizeof events[0]);
3240 if (!bypass_is_supported(port_id))
3243 /* Display the bypass mode.*/
3244 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3245 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3249 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3250 bypass_mode = RTE_BYPASS_MODE_NONE;
3252 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3255 /* Display the bypass timeout.*/
3256 if (!RTE_BYPASS_TMT_VALID(timeout))
3257 timeout = RTE_BYPASS_TMT_OFF;
3259 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3261 /* Display the bypass events and associated modes. */
3262 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3264 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3265 printf("\tFailed to get bypass mode for event = %s\n",
3268 if (!RTE_BYPASS_MODE_VALID(event_mode))
3269 event_mode = RTE_BYPASS_MODE_NONE;
3271 printf("\tbypass event: %-16s = %s\n", events[i],
3277 cmdline_parse_token_string_t cmd_showbypass_config_show =
3278 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3280 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3281 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3283 cmdline_parse_token_string_t cmd_showbypass_config_config =
3284 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3286 cmdline_parse_token_num_t cmd_showbypass_config_port =
3287 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3290 cmdline_parse_inst_t cmd_show_bypass_config = {
3291 .f = cmd_show_bypass_config_parsed,
3292 .help_str = "show bypass config (port_id): "
3293 "Show the NIC bypass config for port_id",
3296 (void *)&cmd_showbypass_config_show,
3297 (void *)&cmd_showbypass_config_bypass,
3298 (void *)&cmd_showbypass_config_config,
3299 (void *)&cmd_showbypass_config_port,
3305 #ifdef RTE_LIBRTE_PMD_BOND
3306 /* *** SET BONDING MODE *** */
3307 struct cmd_set_bonding_mode_result {
3308 cmdline_fixed_string_t set;
3309 cmdline_fixed_string_t bonding;
3310 cmdline_fixed_string_t mode;
3315 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3316 __attribute__((unused)) struct cmdline *cl,
3317 __attribute__((unused)) void *data)
3319 struct cmd_set_bonding_mode_result *res = parsed_result;
3320 portid_t port_id = res->port_id;
3322 /* Set the bonding mode for the relevant port. */
3323 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3324 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3327 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3328 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3330 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3331 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3332 bonding, "bonding");
3333 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3334 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3336 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3337 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3339 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3340 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3343 cmdline_parse_inst_t cmd_set_bonding_mode = {
3344 .f = cmd_set_bonding_mode_parsed,
3345 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3348 (void *) &cmd_setbonding_mode_set,
3349 (void *) &cmd_setbonding_mode_bonding,
3350 (void *) &cmd_setbonding_mode_mode,
3351 (void *) &cmd_setbonding_mode_value,
3352 (void *) &cmd_setbonding_mode_port,
3357 /* *** SET BALANCE XMIT POLICY *** */
3358 struct cmd_set_bonding_balance_xmit_policy_result {
3359 cmdline_fixed_string_t set;
3360 cmdline_fixed_string_t bonding;
3361 cmdline_fixed_string_t balance_xmit_policy;
3363 cmdline_fixed_string_t policy;
3366 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3367 __attribute__((unused)) struct cmdline *cl,
3368 __attribute__((unused)) void *data)
3370 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3371 portid_t port_id = res->port_id;
3374 if (!strcmp(res->policy, "l2")) {
3375 policy = BALANCE_XMIT_POLICY_LAYER2;
3376 } else if (!strcmp(res->policy, "l23")) {
3377 policy = BALANCE_XMIT_POLICY_LAYER23;
3378 } else if (!strcmp(res->policy, "l34")) {
3379 policy = BALANCE_XMIT_POLICY_LAYER34;
3381 printf("\t Invalid xmit policy selection");
3385 /* Set the bonding mode for the relevant port. */
3386 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3387 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3392 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3393 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3395 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3396 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3397 bonding, "bonding");
3398 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3399 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3400 balance_xmit_policy, "balance_xmit_policy");
3401 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3402 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3404 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3405 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3406 policy, "l2#l23#l34");
3408 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3409 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3410 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3413 (void *)&cmd_setbonding_balance_xmit_policy_set,
3414 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3415 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3416 (void *)&cmd_setbonding_balance_xmit_policy_port,
3417 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3422 /* *** SHOW NIC BONDING CONFIGURATION *** */
3423 struct cmd_show_bonding_config_result {
3424 cmdline_fixed_string_t show;
3425 cmdline_fixed_string_t bonding;
3426 cmdline_fixed_string_t config;
3430 static void cmd_show_bonding_config_parsed(void *parsed_result,
3431 __attribute__((unused)) struct cmdline *cl,
3432 __attribute__((unused)) void *data)
3434 struct cmd_show_bonding_config_result *res = parsed_result;
3436 uint8_t slaves[RTE_MAX_ETHPORTS];
3437 int num_slaves, num_active_slaves;
3440 portid_t port_id = res->port_id;
3442 /* Display the bonding mode.*/
3443 bonding_mode = rte_eth_bond_mode_get(port_id);
3444 if (bonding_mode < 0) {
3445 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3448 printf("\tBonding mode: %d\n", bonding_mode);
3450 if (bonding_mode == BONDING_MODE_BALANCE) {
3451 int balance_xmit_policy;
3453 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3454 if (balance_xmit_policy < 0) {
3455 printf("\tFailed to get balance xmit policy for port = %d\n",
3459 printf("\tBalance Xmit Policy: ");
3461 switch (balance_xmit_policy) {
3462 case BALANCE_XMIT_POLICY_LAYER2:
3463 printf("BALANCE_XMIT_POLICY_LAYER2");
3465 case BALANCE_XMIT_POLICY_LAYER23:
3466 printf("BALANCE_XMIT_POLICY_LAYER23");
3468 case BALANCE_XMIT_POLICY_LAYER34:
3469 printf("BALANCE_XMIT_POLICY_LAYER34");
3476 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3478 if (num_slaves < 0) {
3479 printf("\tFailed to get slave list for port = %d\n", port_id);
3482 if (num_slaves > 0) {
3483 printf("\tSlaves (%d): [", num_slaves);
3484 for (i = 0; i < num_slaves - 1; i++)
3485 printf("%d ", slaves[i]);
3487 printf("%d]\n", slaves[num_slaves - 1]);
3489 printf("\tSlaves: []\n");
3493 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3496 if (num_active_slaves < 0) {
3497 printf("\tFailed to get active slave list for port = %d\n", port_id);
3500 if (num_active_slaves > 0) {
3501 printf("\tActive Slaves (%d): [", num_active_slaves);
3502 for (i = 0; i < num_active_slaves - 1; i++)
3503 printf("%d ", slaves[i]);
3505 printf("%d]\n", slaves[num_active_slaves - 1]);
3508 printf("\tActive Slaves: []\n");
3512 primary_id = rte_eth_bond_primary_get(port_id);
3513 if (primary_id < 0) {
3514 printf("\tFailed to get primary slave for port = %d\n", port_id);
3517 printf("\tPrimary: [%d]\n", primary_id);
3521 cmdline_parse_token_string_t cmd_showbonding_config_show =
3522 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3524 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3525 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3526 bonding, "bonding");
3527 cmdline_parse_token_string_t cmd_showbonding_config_config =
3528 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3530 cmdline_parse_token_num_t cmd_showbonding_config_port =
3531 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3534 cmdline_parse_inst_t cmd_show_bonding_config = {
3535 .f = cmd_show_bonding_config_parsed,
3536 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3539 (void *)&cmd_showbonding_config_show,
3540 (void *)&cmd_showbonding_config_bonding,
3541 (void *)&cmd_showbonding_config_config,
3542 (void *)&cmd_showbonding_config_port,
3547 /* *** SET BONDING PRIMARY *** */
3548 struct cmd_set_bonding_primary_result {
3549 cmdline_fixed_string_t set;
3550 cmdline_fixed_string_t bonding;
3551 cmdline_fixed_string_t primary;
3556 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3557 __attribute__((unused)) struct cmdline *cl,
3558 __attribute__((unused)) void *data)
3560 struct cmd_set_bonding_primary_result *res = parsed_result;
3561 portid_t master_port_id = res->port_id;
3562 portid_t slave_port_id = res->slave_id;
3564 /* Set the primary slave for a bonded device. */
3565 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3566 printf("\t Failed to set primary slave for port = %d.\n",
3573 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3576 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3577 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3578 bonding, "bonding");
3579 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3580 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3581 primary, "primary");
3582 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3583 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3585 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3586 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3589 cmdline_parse_inst_t cmd_set_bonding_primary = {
3590 .f = cmd_set_bonding_primary_parsed,
3591 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3594 (void *)&cmd_setbonding_primary_set,
3595 (void *)&cmd_setbonding_primary_bonding,
3596 (void *)&cmd_setbonding_primary_primary,
3597 (void *)&cmd_setbonding_primary_slave,
3598 (void *)&cmd_setbonding_primary_port,
3603 /* *** ADD SLAVE *** */
3604 struct cmd_add_bonding_slave_result {
3605 cmdline_fixed_string_t add;
3606 cmdline_fixed_string_t bonding;
3607 cmdline_fixed_string_t slave;
3612 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3613 __attribute__((unused)) struct cmdline *cl,
3614 __attribute__((unused)) void *data)
3616 struct cmd_add_bonding_slave_result *res = parsed_result;
3617 portid_t master_port_id = res->port_id;
3618 portid_t slave_port_id = res->slave_id;
3620 /* Set the primary slave for a bonded device. */
3621 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3622 printf("\t Failed to add slave %d to master port = %d.\n",
3623 slave_port_id, master_port_id);
3629 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3630 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3632 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3633 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3634 bonding, "bonding");
3635 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3636 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3638 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3639 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3641 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3642 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3645 cmdline_parse_inst_t cmd_add_bonding_slave = {
3646 .f = cmd_add_bonding_slave_parsed,
3647 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3650 (void *)&cmd_addbonding_slave_add,
3651 (void *)&cmd_addbonding_slave_bonding,
3652 (void *)&cmd_addbonding_slave_slave,
3653 (void *)&cmd_addbonding_slave_slaveid,
3654 (void *)&cmd_addbonding_slave_port,
3659 /* *** REMOVE SLAVE *** */
3660 struct cmd_remove_bonding_slave_result {
3661 cmdline_fixed_string_t remove;
3662 cmdline_fixed_string_t bonding;
3663 cmdline_fixed_string_t slave;
3668 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3669 __attribute__((unused)) struct cmdline *cl,
3670 __attribute__((unused)) void *data)
3672 struct cmd_remove_bonding_slave_result *res = parsed_result;
3673 portid_t master_port_id = res->port_id;
3674 portid_t slave_port_id = res->slave_id;
3676 /* Set the primary slave for a bonded device. */
3677 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3678 printf("\t Failed to remove slave %d from master port = %d.\n",
3679 slave_port_id, master_port_id);
3685 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3686 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3688 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3689 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3690 bonding, "bonding");
3691 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3692 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3694 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3695 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3697 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3698 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3701 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3702 .f = cmd_remove_bonding_slave_parsed,
3703 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3706 (void *)&cmd_removebonding_slave_remove,
3707 (void *)&cmd_removebonding_slave_bonding,
3708 (void *)&cmd_removebonding_slave_slave,
3709 (void *)&cmd_removebonding_slave_slaveid,
3710 (void *)&cmd_removebonding_slave_port,
3715 /* *** CREATE BONDED DEVICE *** */
3716 struct cmd_create_bonded_device_result {
3717 cmdline_fixed_string_t create;
3718 cmdline_fixed_string_t bonded;
3719 cmdline_fixed_string_t device;
3724 static int bond_dev_num = 0;
3726 static void cmd_create_bonded_device_parsed(void *parsed_result,
3727 __attribute__((unused)) struct cmdline *cl,
3728 __attribute__((unused)) void *data)
3730 struct cmd_create_bonded_device_result *res = parsed_result;
3731 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3734 if (test_done == 0) {
3735 printf("Please stop forwarding first\n");
3739 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3742 /* Create a new bonded device. */
3743 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3745 printf("\t Failed to create bonded device.\n");
3748 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3751 /* Update number of ports */
3752 nb_ports = rte_eth_dev_count();
3754 rte_eth_promiscuous_enable(port_id);
3759 cmdline_parse_token_string_t cmd_createbonded_device_create =
3760 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3762 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3763 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3765 cmdline_parse_token_string_t cmd_createbonded_device_device =
3766 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3768 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3769 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3771 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3772 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3775 cmdline_parse_inst_t cmd_create_bonded_device = {
3776 .f = cmd_create_bonded_device_parsed,
3777 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3780 (void *)&cmd_createbonded_device_create,
3781 (void *)&cmd_createbonded_device_bonded,
3782 (void *)&cmd_createbonded_device_device,
3783 (void *)&cmd_createbonded_device_mode,
3784 (void *)&cmd_createbonded_device_socket,
3789 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3790 struct cmd_set_bond_mac_addr_result {
3791 cmdline_fixed_string_t set;
3792 cmdline_fixed_string_t bonding;
3793 cmdline_fixed_string_t mac_addr;
3795 struct ether_addr address;
3798 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3799 __attribute__((unused)) struct cmdline *cl,
3800 __attribute__((unused)) void *data)
3802 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3805 if (res->port_num >= nb_ports) {
3806 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3810 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3812 /* check the return value and print it if is < 0 */
3814 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3817 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3818 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3819 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3820 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3822 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3823 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3825 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3826 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3827 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3828 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3830 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3831 .f = cmd_set_bond_mac_addr_parsed,
3833 .help_str = "set bonding mac_addr (port_id) (address): ",
3835 (void *)&cmd_set_bond_mac_addr_set,
3836 (void *)&cmd_set_bond_mac_addr_bonding,
3837 (void *)&cmd_set_bond_mac_addr_mac,
3838 (void *)&cmd_set_bond_mac_addr_portnum,
3839 (void *)&cmd_set_bond_mac_addr_addr,
3845 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3846 struct cmd_set_bond_mon_period_result {
3847 cmdline_fixed_string_t set;
3848 cmdline_fixed_string_t bonding;
3849 cmdline_fixed_string_t mon_period;
3854 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3855 __attribute__((unused)) struct cmdline *cl,
3856 __attribute__((unused)) void *data)
3858 struct cmd_set_bond_mon_period_result *res = parsed_result;
3861 if (res->port_num >= nb_ports) {
3862 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3866 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3868 /* check the return value and print it if is < 0 */
3870 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3873 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3876 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3878 bonding, "bonding");
3879 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3881 mon_period, "mon_period");
3882 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3883 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3885 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3886 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3889 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3890 .f = cmd_set_bond_mon_period_parsed,
3892 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3894 (void *)&cmd_set_bond_mon_period_set,
3895 (void *)&cmd_set_bond_mon_period_bonding,
3896 (void *)&cmd_set_bond_mon_period_mon_period,
3897 (void *)&cmd_set_bond_mon_period_portnum,
3898 (void *)&cmd_set_bond_mon_period_period_ms,
3903 #endif /* RTE_LIBRTE_PMD_BOND */
3905 /* *** SET FORWARDING MODE *** */
3906 struct cmd_set_fwd_mode_result {
3907 cmdline_fixed_string_t set;
3908 cmdline_fixed_string_t fwd;
3909 cmdline_fixed_string_t mode;
3912 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3913 __attribute__((unused)) struct cmdline *cl,
3914 __attribute__((unused)) void *data)
3916 struct cmd_set_fwd_mode_result *res = parsed_result;
3918 set_pkt_forwarding_mode(res->mode);
3921 cmdline_parse_token_string_t cmd_setfwd_set =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3923 cmdline_parse_token_string_t cmd_setfwd_fwd =
3924 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3925 cmdline_parse_token_string_t cmd_setfwd_mode =
3926 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3927 "" /* defined at init */);
3929 cmdline_parse_inst_t cmd_set_fwd_mode = {
3930 .f = cmd_set_fwd_mode_parsed,
3932 .help_str = NULL, /* defined at init */
3934 (void *)&cmd_setfwd_set,
3935 (void *)&cmd_setfwd_fwd,
3936 (void *)&cmd_setfwd_mode,
3941 static void cmd_set_fwd_mode_init(void)
3944 static char token[128];
3945 static char help[256];
3946 cmdline_parse_token_string_t *token_struct;
3948 modes = list_pkt_forwarding_modes();
3949 snprintf(help, sizeof help, "set fwd %s - "
3950 "set packet forwarding mode", modes);
3951 cmd_set_fwd_mode.help_str = help;
3953 /* string token separator is # */
3954 for (c = token; *modes != '\0'; modes++)
3959 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3960 token_struct->string_data.str = token;
3963 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3964 struct cmd_set_burst_tx_retry_result {
3965 cmdline_fixed_string_t set;
3966 cmdline_fixed_string_t burst;
3967 cmdline_fixed_string_t tx;
3968 cmdline_fixed_string_t delay;
3970 cmdline_fixed_string_t retry;
3974 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3975 __attribute__((unused)) struct cmdline *cl,
3976 __attribute__((unused)) void *data)
3978 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3980 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3981 && !strcmp(res->tx, "tx")) {
3982 if (!strcmp(res->delay, "delay"))
3983 burst_tx_delay_time = res->time;
3984 if (!strcmp(res->retry, "retry"))
3985 burst_tx_retry_num = res->retry_num;
3990 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3991 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3992 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3995 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3997 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3998 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3999 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4000 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4001 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4003 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4004 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4006 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4007 .f = cmd_set_burst_tx_retry_parsed,
4008 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4010 (void *)&cmd_set_burst_tx_retry_set,
4011 (void *)&cmd_set_burst_tx_retry_burst,
4012 (void *)&cmd_set_burst_tx_retry_tx,
4013 (void *)&cmd_set_burst_tx_retry_delay,
4014 (void *)&cmd_set_burst_tx_retry_time,
4015 (void *)&cmd_set_burst_tx_retry_retry,
4016 (void *)&cmd_set_burst_tx_retry_retry_num,
4021 /* *** SET PROMISC MODE *** */
4022 struct cmd_set_promisc_mode_result {
4023 cmdline_fixed_string_t set;
4024 cmdline_fixed_string_t promisc;
4025 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4026 uint8_t port_num; /* valid if "allports" argument == 0 */
4027 cmdline_fixed_string_t mode;
4030 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4031 __attribute__((unused)) struct cmdline *cl,
4034 struct cmd_set_promisc_mode_result *res = parsed_result;
4038 if (!strcmp(res->mode, "on"))
4045 for (i = 0; i < nb_ports; i++) {
4047 rte_eth_promiscuous_enable(i);
4049 rte_eth_promiscuous_disable(i);
4054 rte_eth_promiscuous_enable(res->port_num);
4056 rte_eth_promiscuous_disable(res->port_num);
4060 cmdline_parse_token_string_t cmd_setpromisc_set =
4061 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4062 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4065 cmdline_parse_token_string_t cmd_setpromisc_portall =
4066 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4068 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4069 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4071 cmdline_parse_token_string_t cmd_setpromisc_mode =
4072 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4075 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4076 .f = cmd_set_promisc_mode_parsed,
4078 .help_str = "set promisc all on|off: set promisc mode for all ports",
4080 (void *)&cmd_setpromisc_set,
4081 (void *)&cmd_setpromisc_promisc,
4082 (void *)&cmd_setpromisc_portall,
4083 (void *)&cmd_setpromisc_mode,
4088 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4089 .f = cmd_set_promisc_mode_parsed,
4091 .help_str = "set promisc X on|off: set promisc mode on port X",
4093 (void *)&cmd_setpromisc_set,
4094 (void *)&cmd_setpromisc_promisc,
4095 (void *)&cmd_setpromisc_portnum,
4096 (void *)&cmd_setpromisc_mode,
4101 /* *** SET ALLMULTI MODE *** */
4102 struct cmd_set_allmulti_mode_result {
4103 cmdline_fixed_string_t set;
4104 cmdline_fixed_string_t allmulti;
4105 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4106 uint8_t port_num; /* valid if "allports" argument == 0 */
4107 cmdline_fixed_string_t mode;
4110 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4111 __attribute__((unused)) struct cmdline *cl,
4114 struct cmd_set_allmulti_mode_result *res = parsed_result;
4118 if (!strcmp(res->mode, "on"))
4125 for (i = 0; i < nb_ports; i++) {
4127 rte_eth_allmulticast_enable(i);
4129 rte_eth_allmulticast_disable(i);
4134 rte_eth_allmulticast_enable(res->port_num);
4136 rte_eth_allmulticast_disable(res->port_num);
4140 cmdline_parse_token_string_t cmd_setallmulti_set =
4141 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4142 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4143 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4145 cmdline_parse_token_string_t cmd_setallmulti_portall =
4146 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4148 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4149 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4151 cmdline_parse_token_string_t cmd_setallmulti_mode =
4152 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4155 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4156 .f = cmd_set_allmulti_mode_parsed,
4158 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4160 (void *)&cmd_setallmulti_set,
4161 (void *)&cmd_setallmulti_allmulti,
4162 (void *)&cmd_setallmulti_portall,
4163 (void *)&cmd_setallmulti_mode,
4168 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4169 .f = cmd_set_allmulti_mode_parsed,
4171 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4173 (void *)&cmd_setallmulti_set,
4174 (void *)&cmd_setallmulti_allmulti,
4175 (void *)&cmd_setallmulti_portnum,
4176 (void *)&cmd_setallmulti_mode,
4181 /* *** ADD/REMOVE A PKT FILTER *** */
4182 struct cmd_pkt_filter_result {
4183 cmdline_fixed_string_t pkt_filter;
4185 cmdline_fixed_string_t protocol;
4186 cmdline_fixed_string_t src;
4187 cmdline_ipaddr_t ip_src;
4189 cmdline_fixed_string_t dst;
4190 cmdline_ipaddr_t ip_dst;
4192 cmdline_fixed_string_t flexbytes;
4193 uint16_t flexbytes_value;
4194 cmdline_fixed_string_t vlan;
4196 cmdline_fixed_string_t queue;
4198 cmdline_fixed_string_t soft;
4203 cmd_pkt_filter_parsed(void *parsed_result,
4204 __attribute__((unused)) struct cmdline *cl,
4205 __attribute__((unused)) void *data)
4207 struct rte_fdir_filter fdir_filter;
4208 struct cmd_pkt_filter_result *res = parsed_result;
4210 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4212 if (res->ip_src.family == AF_INET)
4213 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4215 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4216 &(res->ip_src.addr.ipv6),
4217 sizeof(struct in6_addr));
4219 if (res->ip_dst.family == AF_INET)
4220 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4222 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4223 &(res->ip_dst.addr.ipv6),
4224 sizeof(struct in6_addr));
4226 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4227 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4229 if (!strcmp(res->protocol, "udp"))
4230 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4231 else if (!strcmp(res->protocol, "tcp"))
4232 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4233 else if (!strcmp(res->protocol, "sctp"))
4234 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4235 else /* default only IP */
4236 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4238 if (res->ip_dst.family == AF_INET6)
4239 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4241 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4243 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4244 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4246 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4247 fdir_add_signature_filter(res->port_id, res->queue_id,
4249 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4250 fdir_update_signature_filter(res->port_id, res->queue_id,
4252 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4253 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4254 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4255 fdir_add_perfect_filter(res->port_id, res->soft_id,
4257 (uint8_t) (res->queue_id < 0),
4259 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4260 fdir_update_perfect_filter(res->port_id, res->soft_id,
4262 (uint8_t) (res->queue_id < 0),
4264 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4265 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4271 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4272 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4274 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4275 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4276 protocol, "ip#tcp#udp#sctp");
4277 cmdline_parse_token_string_t cmd_pkt_filter_src =
4278 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4280 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4281 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4283 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4284 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4286 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4287 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4289 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4290 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4292 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4293 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4295 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4296 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4297 flexbytes, "flexbytes");
4298 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4299 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4300 flexbytes_value, UINT16);
4301 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4302 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4304 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4305 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4307 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4308 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4310 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4311 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4313 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4314 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4316 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4317 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4321 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4322 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4323 pkt_filter, "add_signature_filter");
4324 cmdline_parse_inst_t cmd_add_signature_filter = {
4325 .f = cmd_pkt_filter_parsed,
4327 .help_str = "add a signature filter",
4329 (void *)&cmd_pkt_filter_add_signature_filter,
4330 (void *)&cmd_pkt_filter_port_id,
4331 (void *)&cmd_pkt_filter_protocol,
4332 (void *)&cmd_pkt_filter_src,
4333 (void *)&cmd_pkt_filter_ip_src,
4334 (void *)&cmd_pkt_filter_port_src,
4335 (void *)&cmd_pkt_filter_dst,
4336 (void *)&cmd_pkt_filter_ip_dst,
4337 (void *)&cmd_pkt_filter_port_dst,
4338 (void *)&cmd_pkt_filter_flexbytes,
4339 (void *)&cmd_pkt_filter_flexbytes_value,
4340 (void *)&cmd_pkt_filter_vlan,
4341 (void *)&cmd_pkt_filter_vlan_id,
4342 (void *)&cmd_pkt_filter_queue,
4343 (void *)&cmd_pkt_filter_queue_id,
4349 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4350 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4351 pkt_filter, "upd_signature_filter");
4352 cmdline_parse_inst_t cmd_upd_signature_filter = {
4353 .f = cmd_pkt_filter_parsed,
4355 .help_str = "update a signature filter",
4357 (void *)&cmd_pkt_filter_upd_signature_filter,
4358 (void *)&cmd_pkt_filter_port_id,
4359 (void *)&cmd_pkt_filter_protocol,
4360 (void *)&cmd_pkt_filter_src,
4361 (void *)&cmd_pkt_filter_ip_src,
4362 (void *)&cmd_pkt_filter_port_src,
4363 (void *)&cmd_pkt_filter_dst,
4364 (void *)&cmd_pkt_filter_ip_dst,
4365 (void *)&cmd_pkt_filter_port_dst,
4366 (void *)&cmd_pkt_filter_flexbytes,
4367 (void *)&cmd_pkt_filter_flexbytes_value,
4368 (void *)&cmd_pkt_filter_vlan,
4369 (void *)&cmd_pkt_filter_vlan_id,
4370 (void *)&cmd_pkt_filter_queue,
4371 (void *)&cmd_pkt_filter_queue_id,
4377 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4378 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4379 pkt_filter, "rm_signature_filter");
4380 cmdline_parse_inst_t cmd_rm_signature_filter = {
4381 .f = cmd_pkt_filter_parsed,
4383 .help_str = "remove a signature filter",
4385 (void *)&cmd_pkt_filter_rm_signature_filter,
4386 (void *)&cmd_pkt_filter_port_id,
4387 (void *)&cmd_pkt_filter_protocol,
4388 (void *)&cmd_pkt_filter_src,
4389 (void *)&cmd_pkt_filter_ip_src,
4390 (void *)&cmd_pkt_filter_port_src,
4391 (void *)&cmd_pkt_filter_dst,
4392 (void *)&cmd_pkt_filter_ip_dst,
4393 (void *)&cmd_pkt_filter_port_dst,
4394 (void *)&cmd_pkt_filter_flexbytes,
4395 (void *)&cmd_pkt_filter_flexbytes_value,
4396 (void *)&cmd_pkt_filter_vlan,
4397 (void *)&cmd_pkt_filter_vlan_id,
4403 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4404 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4405 pkt_filter, "add_perfect_filter");
4406 cmdline_parse_inst_t cmd_add_perfect_filter = {
4407 .f = cmd_pkt_filter_parsed,
4409 .help_str = "add a perfect filter",
4411 (void *)&cmd_pkt_filter_add_perfect_filter,
4412 (void *)&cmd_pkt_filter_port_id,
4413 (void *)&cmd_pkt_filter_protocol,
4414 (void *)&cmd_pkt_filter_src,
4415 (void *)&cmd_pkt_filter_ip_src,
4416 (void *)&cmd_pkt_filter_port_src,
4417 (void *)&cmd_pkt_filter_dst,
4418 (void *)&cmd_pkt_filter_ip_dst,
4419 (void *)&cmd_pkt_filter_port_dst,
4420 (void *)&cmd_pkt_filter_flexbytes,
4421 (void *)&cmd_pkt_filter_flexbytes_value,
4422 (void *)&cmd_pkt_filter_vlan,
4423 (void *)&cmd_pkt_filter_vlan_id,
4424 (void *)&cmd_pkt_filter_queue,
4425 (void *)&cmd_pkt_filter_queue_id,
4426 (void *)&cmd_pkt_filter_soft,
4427 (void *)&cmd_pkt_filter_soft_id,
4433 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4434 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4435 pkt_filter, "upd_perfect_filter");
4436 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4437 .f = cmd_pkt_filter_parsed,
4439 .help_str = "update a perfect filter",
4441 (void *)&cmd_pkt_filter_upd_perfect_filter,
4442 (void *)&cmd_pkt_filter_port_id,
4443 (void *)&cmd_pkt_filter_protocol,
4444 (void *)&cmd_pkt_filter_src,
4445 (void *)&cmd_pkt_filter_ip_src,
4446 (void *)&cmd_pkt_filter_port_src,
4447 (void *)&cmd_pkt_filter_dst,
4448 (void *)&cmd_pkt_filter_ip_dst,
4449 (void *)&cmd_pkt_filter_port_dst,
4450 (void *)&cmd_pkt_filter_flexbytes,
4451 (void *)&cmd_pkt_filter_flexbytes_value,
4452 (void *)&cmd_pkt_filter_vlan,
4453 (void *)&cmd_pkt_filter_vlan_id,
4454 (void *)&cmd_pkt_filter_queue,
4455 (void *)&cmd_pkt_filter_queue_id,
4456 (void *)&cmd_pkt_filter_soft,
4457 (void *)&cmd_pkt_filter_soft_id,
4463 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4464 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4465 pkt_filter, "rm_perfect_filter");
4466 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4467 .f = cmd_pkt_filter_parsed,
4469 .help_str = "remove a perfect filter",
4471 (void *)&cmd_pkt_filter_rm_perfect_filter,
4472 (void *)&cmd_pkt_filter_port_id,
4473 (void *)&cmd_pkt_filter_protocol,
4474 (void *)&cmd_pkt_filter_src,
4475 (void *)&cmd_pkt_filter_ip_src,
4476 (void *)&cmd_pkt_filter_port_src,
4477 (void *)&cmd_pkt_filter_dst,
4478 (void *)&cmd_pkt_filter_ip_dst,
4479 (void *)&cmd_pkt_filter_port_dst,
4480 (void *)&cmd_pkt_filter_flexbytes,
4481 (void *)&cmd_pkt_filter_flexbytes_value,
4482 (void *)&cmd_pkt_filter_vlan,
4483 (void *)&cmd_pkt_filter_vlan_id,
4484 (void *)&cmd_pkt_filter_soft,
4485 (void *)&cmd_pkt_filter_soft_id,
4490 /* *** SETUP MASKS FILTER *** */
4491 struct cmd_pkt_filter_masks_result {
4492 cmdline_fixed_string_t filter_mask;
4494 cmdline_fixed_string_t src_mask;
4495 uint32_t ip_src_mask;
4496 uint16_t ipv6_src_mask;
4497 uint16_t port_src_mask;
4498 cmdline_fixed_string_t dst_mask;
4499 uint32_t ip_dst_mask;
4500 uint16_t ipv6_dst_mask;
4501 uint16_t port_dst_mask;
4502 cmdline_fixed_string_t flexbytes;
4503 uint8_t flexbytes_value;
4504 cmdline_fixed_string_t vlan_id;
4505 uint8_t vlan_id_value;
4506 cmdline_fixed_string_t vlan_prio;
4507 uint8_t vlan_prio_value;
4508 cmdline_fixed_string_t only_ip_flow;
4509 uint8_t only_ip_flow_value;
4510 cmdline_fixed_string_t comp_ipv6_dst;
4511 uint8_t comp_ipv6_dst_value;
4515 cmd_pkt_filter_masks_parsed(void *parsed_result,
4516 __attribute__((unused)) struct cmdline *cl,
4517 __attribute__((unused)) void *data)
4519 struct rte_fdir_masks fdir_masks;
4520 struct cmd_pkt_filter_masks_result *res = parsed_result;
4522 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4524 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4525 fdir_masks.vlan_id = res->vlan_id_value;
4526 fdir_masks.vlan_prio = res->vlan_prio_value;
4527 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4528 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4529 fdir_masks.src_port_mask = res->port_src_mask;
4530 fdir_masks.dst_port_mask = res->port_dst_mask;
4531 fdir_masks.flexbytes = res->flexbytes_value;
4533 fdir_set_masks(res->port_id, &fdir_masks);
4536 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4537 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4538 filter_mask, "set_masks_filter");
4539 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4540 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4542 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4543 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4544 only_ip_flow, "only_ip_flow");
4545 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4546 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4547 only_ip_flow_value, UINT8);
4548 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4549 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4550 src_mask, "src_mask");
4551 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4552 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4553 ip_src_mask, UINT32);
4554 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4555 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4556 port_src_mask, UINT16);
4557 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4558 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4559 dst_mask, "dst_mask");
4560 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4561 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4562 ip_dst_mask, UINT32);
4563 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4564 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4565 port_dst_mask, UINT16);
4566 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4567 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4568 flexbytes, "flexbytes");
4569 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4570 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4571 flexbytes_value, UINT8);
4572 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4573 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4574 vlan_id, "vlan_id");
4575 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4576 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4577 vlan_id_value, UINT8);
4578 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4579 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4580 vlan_prio, "vlan_prio");
4581 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4582 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4583 vlan_prio_value, UINT8);
4585 cmdline_parse_inst_t cmd_set_masks_filter = {
4586 .f = cmd_pkt_filter_masks_parsed,
4588 .help_str = "setup masks filter",
4590 (void *)&cmd_pkt_filter_masks_filter_mask,
4591 (void *)&cmd_pkt_filter_masks_port_id,
4592 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4593 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4594 (void *)&cmd_pkt_filter_masks_src_mask,
4595 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4596 (void *)&cmd_pkt_filter_masks_port_src_mask,
4597 (void *)&cmd_pkt_filter_masks_dst_mask,
4598 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4599 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4600 (void *)&cmd_pkt_filter_masks_flexbytes,
4601 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4602 (void *)&cmd_pkt_filter_masks_vlan_id,
4603 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4604 (void *)&cmd_pkt_filter_masks_vlan_prio,
4605 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4611 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4612 __attribute__((unused)) struct cmdline *cl,
4613 __attribute__((unused)) void *data)
4615 struct rte_fdir_masks fdir_masks;
4616 struct cmd_pkt_filter_masks_result *res = parsed_result;
4618 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4620 fdir_masks.set_ipv6_mask = 1;
4621 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4622 fdir_masks.vlan_id = res->vlan_id_value;
4623 fdir_masks.vlan_prio = res->vlan_prio_value;
4624 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4625 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4626 fdir_masks.src_port_mask = res->port_src_mask;
4627 fdir_masks.dst_port_mask = res->port_dst_mask;
4628 fdir_masks.flexbytes = res->flexbytes_value;
4629 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4631 fdir_set_masks(res->port_id, &fdir_masks);
4634 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4635 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4636 filter_mask, "set_ipv6_masks_filter");
4637 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4638 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4639 ipv6_src_mask, UINT16);
4640 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4641 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4642 ipv6_dst_mask, UINT16);
4644 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4645 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4646 comp_ipv6_dst, "compare_dst");
4647 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4648 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4649 comp_ipv6_dst_value, UINT8);
4651 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4652 .f = cmd_pkt_filter_masks_ipv6_parsed,
4654 .help_str = "setup ipv6 masks filter",
4656 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4657 (void *)&cmd_pkt_filter_masks_port_id,
4658 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4659 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4660 (void *)&cmd_pkt_filter_masks_src_mask,
4661 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4662 (void *)&cmd_pkt_filter_masks_port_src_mask,
4663 (void *)&cmd_pkt_filter_masks_dst_mask,
4664 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4665 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4666 (void *)&cmd_pkt_filter_masks_flexbytes,
4667 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4668 (void *)&cmd_pkt_filter_masks_vlan_id,
4669 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4670 (void *)&cmd_pkt_filter_masks_vlan_prio,
4671 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4672 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4673 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4678 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4679 struct cmd_link_flow_ctrl_set_result {
4680 cmdline_fixed_string_t set;
4681 cmdline_fixed_string_t flow_ctrl;
4682 cmdline_fixed_string_t rx;
4683 cmdline_fixed_string_t rx_lfc_mode;
4684 cmdline_fixed_string_t tx;
4685 cmdline_fixed_string_t tx_lfc_mode;
4686 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4687 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4688 cmdline_fixed_string_t autoneg_str;
4689 cmdline_fixed_string_t autoneg;
4690 cmdline_fixed_string_t hw_str;
4691 uint32_t high_water;
4692 cmdline_fixed_string_t lw_str;
4694 cmdline_fixed_string_t pt_str;
4695 uint16_t pause_time;
4696 cmdline_fixed_string_t xon_str;
4701 cmdline_parse_token_string_t cmd_lfc_set_set =
4702 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4704 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4705 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4706 flow_ctrl, "flow_ctrl");
4707 cmdline_parse_token_string_t cmd_lfc_set_rx =
4708 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4710 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4711 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4712 rx_lfc_mode, "on#off");
4713 cmdline_parse_token_string_t cmd_lfc_set_tx =
4714 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4716 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4717 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4718 tx_lfc_mode, "on#off");
4719 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4720 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4721 hw_str, "high_water");
4722 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4723 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4724 high_water, UINT32);
4725 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4726 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4727 lw_str, "low_water");
4728 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4729 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4731 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4732 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4733 pt_str, "pause_time");
4734 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4735 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4736 pause_time, UINT16);
4737 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4738 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4739 xon_str, "send_xon");
4740 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4741 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4743 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4744 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4745 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4746 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4747 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4748 mac_ctrl_frame_fwd_mode, "on#off");
4749 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4750 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4751 autoneg_str, "autoneg");
4752 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4753 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4755 cmdline_parse_token_num_t cmd_lfc_set_portid =
4756 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4759 /* forward declaration */
4761 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4764 cmdline_parse_inst_t cmd_link_flow_control_set = {
4765 .f = cmd_link_flow_ctrl_set_parsed,
4767 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4768 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4769 autoneg on|off port_id",
4771 (void *)&cmd_lfc_set_set,
4772 (void *)&cmd_lfc_set_flow_ctrl,
4773 (void *)&cmd_lfc_set_rx,
4774 (void *)&cmd_lfc_set_rx_mode,
4775 (void *)&cmd_lfc_set_tx,
4776 (void *)&cmd_lfc_set_tx_mode,
4777 (void *)&cmd_lfc_set_high_water,
4778 (void *)&cmd_lfc_set_low_water,
4779 (void *)&cmd_lfc_set_pause_time,
4780 (void *)&cmd_lfc_set_send_xon,
4781 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4782 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4783 (void *)&cmd_lfc_set_autoneg_str,
4784 (void *)&cmd_lfc_set_autoneg,
4785 (void *)&cmd_lfc_set_portid,
4790 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4791 .f = cmd_link_flow_ctrl_set_parsed,
4792 .data = (void *)&cmd_link_flow_control_set_rx,
4793 .help_str = "Change rx flow control parameter: set flow_ctrl "
4794 "rx on|off port_id",
4796 (void *)&cmd_lfc_set_set,
4797 (void *)&cmd_lfc_set_flow_ctrl,
4798 (void *)&cmd_lfc_set_rx,
4799 (void *)&cmd_lfc_set_rx_mode,
4800 (void *)&cmd_lfc_set_portid,
4805 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4806 .f = cmd_link_flow_ctrl_set_parsed,
4807 .data = (void *)&cmd_link_flow_control_set_tx,
4808 .help_str = "Change tx flow control parameter: set flow_ctrl "
4809 "tx on|off port_id",
4811 (void *)&cmd_lfc_set_set,
4812 (void *)&cmd_lfc_set_flow_ctrl,
4813 (void *)&cmd_lfc_set_tx,
4814 (void *)&cmd_lfc_set_tx_mode,
4815 (void *)&cmd_lfc_set_portid,
4820 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4821 .f = cmd_link_flow_ctrl_set_parsed,
4822 .data = (void *)&cmd_link_flow_control_set_hw,
4823 .help_str = "Change high water flow control parameter: set flow_ctrl "
4824 "high_water value port_id",
4826 (void *)&cmd_lfc_set_set,
4827 (void *)&cmd_lfc_set_flow_ctrl,
4828 (void *)&cmd_lfc_set_high_water_str,
4829 (void *)&cmd_lfc_set_high_water,
4830 (void *)&cmd_lfc_set_portid,
4835 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4836 .f = cmd_link_flow_ctrl_set_parsed,
4837 .data = (void *)&cmd_link_flow_control_set_lw,
4838 .help_str = "Change low water flow control parameter: set flow_ctrl "
4839 "low_water value port_id",
4841 (void *)&cmd_lfc_set_set,
4842 (void *)&cmd_lfc_set_flow_ctrl,
4843 (void *)&cmd_lfc_set_low_water_str,
4844 (void *)&cmd_lfc_set_low_water,
4845 (void *)&cmd_lfc_set_portid,
4850 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4851 .f = cmd_link_flow_ctrl_set_parsed,
4852 .data = (void *)&cmd_link_flow_control_set_pt,
4853 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4854 "pause_time value port_id",
4856 (void *)&cmd_lfc_set_set,
4857 (void *)&cmd_lfc_set_flow_ctrl,
4858 (void *)&cmd_lfc_set_pause_time_str,
4859 (void *)&cmd_lfc_set_pause_time,
4860 (void *)&cmd_lfc_set_portid,
4865 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4866 .f = cmd_link_flow_ctrl_set_parsed,
4867 .data = (void *)&cmd_link_flow_control_set_xon,
4868 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4869 "send_xon value port_id",
4871 (void *)&cmd_lfc_set_set,
4872 (void *)&cmd_lfc_set_flow_ctrl,
4873 (void *)&cmd_lfc_set_send_xon_str,
4874 (void *)&cmd_lfc_set_send_xon,
4875 (void *)&cmd_lfc_set_portid,
4880 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4881 .f = cmd_link_flow_ctrl_set_parsed,
4882 .data = (void *)&cmd_link_flow_control_set_macfwd,
4883 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4884 "mac_ctrl_frame_fwd on|off port_id",
4886 (void *)&cmd_lfc_set_set,
4887 (void *)&cmd_lfc_set_flow_ctrl,
4888 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4889 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4890 (void *)&cmd_lfc_set_portid,
4895 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4896 .f = cmd_link_flow_ctrl_set_parsed,
4897 .data = (void *)&cmd_link_flow_control_set_autoneg,
4898 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4899 "autoneg on|off port_id",
4901 (void *)&cmd_lfc_set_set,
4902 (void *)&cmd_lfc_set_flow_ctrl,
4903 (void *)&cmd_lfc_set_autoneg_str,
4904 (void *)&cmd_lfc_set_autoneg,
4905 (void *)&cmd_lfc_set_portid,
4911 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4912 __attribute__((unused)) struct cmdline *cl,
4915 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4916 cmdline_parse_inst_t *cmd = data;
4917 struct rte_eth_fc_conf fc_conf;
4918 int rx_fc_en, tx_fc_en;
4922 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4923 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4924 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4925 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4927 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4928 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4931 /* Partial command line, retrieve current configuration */
4933 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4935 printf("cannot get current flow ctrl parameters, return"
4936 "code = %d\n", ret);
4940 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4941 (fc_conf.mode == RTE_FC_FULL))
4943 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4944 (fc_conf.mode == RTE_FC_FULL))
4948 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4949 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4951 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4952 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4954 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4956 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4957 fc_conf.high_water = res->high_water;
4959 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4960 fc_conf.low_water = res->low_water;
4962 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4963 fc_conf.pause_time = res->pause_time;
4965 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4966 fc_conf.send_xon = res->send_xon;
4968 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4969 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4970 fc_conf.mac_ctrl_frame_fwd = 1;
4972 fc_conf.mac_ctrl_frame_fwd = 0;
4975 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4976 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4978 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4980 printf("bad flow contrl parameter, return code = %d \n", ret);
4983 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4984 struct cmd_priority_flow_ctrl_set_result {
4985 cmdline_fixed_string_t set;
4986 cmdline_fixed_string_t pfc_ctrl;
4987 cmdline_fixed_string_t rx;
4988 cmdline_fixed_string_t rx_pfc_mode;
4989 cmdline_fixed_string_t tx;
4990 cmdline_fixed_string_t tx_pfc_mode;
4991 uint32_t high_water;
4993 uint16_t pause_time;
4999 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5000 __attribute__((unused)) struct cmdline *cl,
5001 __attribute__((unused)) void *data)
5003 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5004 struct rte_eth_pfc_conf pfc_conf;
5005 int rx_fc_enable, tx_fc_enable;
5009 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5010 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5011 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5012 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5014 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5015 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5018 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5019 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5020 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5021 pfc_conf.fc.high_water = res->high_water;
5022 pfc_conf.fc.low_water = res->low_water;
5023 pfc_conf.fc.pause_time = res->pause_time;
5024 pfc_conf.priority = res->priority;
5026 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5028 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5031 cmdline_parse_token_string_t cmd_pfc_set_set =
5032 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5034 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5035 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5036 pfc_ctrl, "pfc_ctrl");
5037 cmdline_parse_token_string_t cmd_pfc_set_rx =
5038 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5040 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5041 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5042 rx_pfc_mode, "on#off");
5043 cmdline_parse_token_string_t cmd_pfc_set_tx =
5044 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5046 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5047 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5048 tx_pfc_mode, "on#off");
5049 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5050 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5051 high_water, UINT32);
5052 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5053 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5055 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5056 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5057 pause_time, UINT16);
5058 cmdline_parse_token_num_t cmd_pfc_set_priority =
5059 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5061 cmdline_parse_token_num_t cmd_pfc_set_portid =
5062 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5065 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5066 .f = cmd_priority_flow_ctrl_set_parsed,
5068 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5069 tx on|off high_water low_water pause_time priority port_id",
5071 (void *)&cmd_pfc_set_set,
5072 (void *)&cmd_pfc_set_flow_ctrl,
5073 (void *)&cmd_pfc_set_rx,
5074 (void *)&cmd_pfc_set_rx_mode,
5075 (void *)&cmd_pfc_set_tx,
5076 (void *)&cmd_pfc_set_tx_mode,
5077 (void *)&cmd_pfc_set_high_water,
5078 (void *)&cmd_pfc_set_low_water,
5079 (void *)&cmd_pfc_set_pause_time,
5080 (void *)&cmd_pfc_set_priority,
5081 (void *)&cmd_pfc_set_portid,
5086 /* *** RESET CONFIGURATION *** */
5087 struct cmd_reset_result {
5088 cmdline_fixed_string_t reset;
5089 cmdline_fixed_string_t def;
5092 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5094 __attribute__((unused)) void *data)
5096 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5097 set_def_fwd_config();
5100 cmdline_parse_token_string_t cmd_reset_set =
5101 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5102 cmdline_parse_token_string_t cmd_reset_def =
5103 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5106 cmdline_parse_inst_t cmd_reset = {
5107 .f = cmd_reset_parsed,
5109 .help_str = "set default: reset default forwarding configuration",
5111 (void *)&cmd_reset_set,
5112 (void *)&cmd_reset_def,
5117 /* *** START FORWARDING *** */
5118 struct cmd_start_result {
5119 cmdline_fixed_string_t start;
5122 cmdline_parse_token_string_t cmd_start_start =
5123 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5125 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5126 __attribute__((unused)) struct cmdline *cl,
5127 __attribute__((unused)) void *data)
5129 start_packet_forwarding(0);
5132 cmdline_parse_inst_t cmd_start = {
5133 .f = cmd_start_parsed,
5135 .help_str = "start packet forwarding",
5137 (void *)&cmd_start_start,
5142 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5143 struct cmd_start_tx_first_result {
5144 cmdline_fixed_string_t start;
5145 cmdline_fixed_string_t tx_first;
5149 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5150 __attribute__((unused)) struct cmdline *cl,
5151 __attribute__((unused)) void *data)
5153 start_packet_forwarding(1);
5156 cmdline_parse_token_string_t cmd_start_tx_first_start =
5157 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5159 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5160 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5161 tx_first, "tx_first");
5163 cmdline_parse_inst_t cmd_start_tx_first = {
5164 .f = cmd_start_tx_first_parsed,
5166 .help_str = "start packet forwarding, after sending 1 burst of packets",
5168 (void *)&cmd_start_tx_first_start,
5169 (void *)&cmd_start_tx_first_tx_first,
5174 /* *** SET LINK UP *** */
5175 struct cmd_set_link_up_result {
5176 cmdline_fixed_string_t set;
5177 cmdline_fixed_string_t link_up;
5178 cmdline_fixed_string_t port;
5182 cmdline_parse_token_string_t cmd_set_link_up_set =
5183 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5184 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5187 cmdline_parse_token_string_t cmd_set_link_up_port =
5188 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5189 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5190 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5192 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5193 __attribute__((unused)) struct cmdline *cl,
5194 __attribute__((unused)) void *data)
5196 struct cmd_set_link_up_result *res = parsed_result;
5197 dev_set_link_up(res->port_id);
5200 cmdline_parse_inst_t cmd_set_link_up = {
5201 .f = cmd_set_link_up_parsed,
5203 .help_str = "set link-up port (port id)",
5205 (void *)&cmd_set_link_up_set,
5206 (void *)&cmd_set_link_up_link_up,
5207 (void *)&cmd_set_link_up_port,
5208 (void *)&cmd_set_link_up_port_id,
5213 /* *** SET LINK DOWN *** */
5214 struct cmd_set_link_down_result {
5215 cmdline_fixed_string_t set;
5216 cmdline_fixed_string_t link_down;
5217 cmdline_fixed_string_t port;
5221 cmdline_parse_token_string_t cmd_set_link_down_set =
5222 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5223 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5226 cmdline_parse_token_string_t cmd_set_link_down_port =
5227 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5228 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5229 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5231 static void cmd_set_link_down_parsed(
5232 __attribute__((unused)) void *parsed_result,
5233 __attribute__((unused)) struct cmdline *cl,
5234 __attribute__((unused)) void *data)
5236 struct cmd_set_link_down_result *res = parsed_result;
5237 dev_set_link_down(res->port_id);
5240 cmdline_parse_inst_t cmd_set_link_down = {
5241 .f = cmd_set_link_down_parsed,
5243 .help_str = "set link-down port (port id)",
5245 (void *)&cmd_set_link_down_set,
5246 (void *)&cmd_set_link_down_link_down,
5247 (void *)&cmd_set_link_down_port,
5248 (void *)&cmd_set_link_down_port_id,
5253 /* *** SHOW CFG *** */
5254 struct cmd_showcfg_result {
5255 cmdline_fixed_string_t show;
5256 cmdline_fixed_string_t cfg;
5257 cmdline_fixed_string_t what;
5260 static void cmd_showcfg_parsed(void *parsed_result,
5261 __attribute__((unused)) struct cmdline *cl,
5262 __attribute__((unused)) void *data)
5264 struct cmd_showcfg_result *res = parsed_result;
5265 if (!strcmp(res->what, "rxtx"))
5266 rxtx_config_display();
5267 else if (!strcmp(res->what, "cores"))
5268 fwd_lcores_config_display();
5269 else if (!strcmp(res->what, "fwd"))
5270 fwd_config_display();
5273 cmdline_parse_token_string_t cmd_showcfg_show =
5274 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5275 cmdline_parse_token_string_t cmd_showcfg_port =
5276 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5277 cmdline_parse_token_string_t cmd_showcfg_what =
5278 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5281 cmdline_parse_inst_t cmd_showcfg = {
5282 .f = cmd_showcfg_parsed,
5284 .help_str = "show config rxtx|cores|fwd",
5286 (void *)&cmd_showcfg_show,
5287 (void *)&cmd_showcfg_port,
5288 (void *)&cmd_showcfg_what,
5293 /* *** SHOW ALL PORT INFO *** */
5294 struct cmd_showportall_result {
5295 cmdline_fixed_string_t show;
5296 cmdline_fixed_string_t port;
5297 cmdline_fixed_string_t what;
5298 cmdline_fixed_string_t all;
5301 static void cmd_showportall_parsed(void *parsed_result,
5302 __attribute__((unused)) struct cmdline *cl,
5303 __attribute__((unused)) void *data)
5307 struct cmd_showportall_result *res = parsed_result;
5308 if (!strcmp(res->show, "clear")) {
5309 if (!strcmp(res->what, "stats"))
5310 for (i = 0; i < nb_ports; i++)
5312 else if (!strcmp(res->what, "xstats"))
5313 for (i = 0; i < nb_ports; i++)
5314 nic_xstats_clear(i);
5315 } else if (!strcmp(res->what, "info"))
5316 for (i = 0; i < nb_ports; i++)
5317 port_infos_display(i);
5318 else if (!strcmp(res->what, "stats"))
5319 for (i = 0; i < nb_ports; i++)
5320 nic_stats_display(i);
5321 else if (!strcmp(res->what, "xstats"))
5322 for (i = 0; i < nb_ports; i++)
5323 nic_xstats_display(i);
5324 else if (!strcmp(res->what, "fdir"))
5325 for (i = 0; i < nb_ports; i++)
5327 else if (!strcmp(res->what, "stat_qmap"))
5328 for (i = 0; i < nb_ports; i++)
5329 nic_stats_mapping_display(i);
5332 cmdline_parse_token_string_t cmd_showportall_show =
5333 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5335 cmdline_parse_token_string_t cmd_showportall_port =
5336 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5337 cmdline_parse_token_string_t cmd_showportall_what =
5338 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5339 "info#stats#xstats#fdir#stat_qmap");
5340 cmdline_parse_token_string_t cmd_showportall_all =
5341 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5342 cmdline_parse_inst_t cmd_showportall = {
5343 .f = cmd_showportall_parsed,
5345 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5347 (void *)&cmd_showportall_show,
5348 (void *)&cmd_showportall_port,
5349 (void *)&cmd_showportall_what,
5350 (void *)&cmd_showportall_all,
5355 /* *** SHOW PORT INFO *** */
5356 struct cmd_showport_result {
5357 cmdline_fixed_string_t show;
5358 cmdline_fixed_string_t port;
5359 cmdline_fixed_string_t what;
5363 static void cmd_showport_parsed(void *parsed_result,
5364 __attribute__((unused)) struct cmdline *cl,
5365 __attribute__((unused)) void *data)
5367 struct cmd_showport_result *res = parsed_result;
5368 if (!strcmp(res->show, "clear")) {
5369 if (!strcmp(res->what, "stats"))
5370 nic_stats_clear(res->portnum);
5371 else if (!strcmp(res->what, "xstats"))
5372 nic_xstats_clear(res->portnum);
5373 } else if (!strcmp(res->what, "info"))
5374 port_infos_display(res->portnum);
5375 else if (!strcmp(res->what, "stats"))
5376 nic_stats_display(res->portnum);
5377 else if (!strcmp(res->what, "xstats"))
5378 nic_xstats_display(res->portnum);
5379 else if (!strcmp(res->what, "fdir"))
5380 fdir_get_infos(res->portnum);
5381 else if (!strcmp(res->what, "stat_qmap"))
5382 nic_stats_mapping_display(res->portnum);
5385 cmdline_parse_token_string_t cmd_showport_show =
5386 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5388 cmdline_parse_token_string_t cmd_showport_port =
5389 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5390 cmdline_parse_token_string_t cmd_showport_what =
5391 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5392 "info#stats#xstats#fdir#stat_qmap");
5393 cmdline_parse_token_num_t cmd_showport_portnum =
5394 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5396 cmdline_parse_inst_t cmd_showport = {
5397 .f = cmd_showport_parsed,
5399 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5401 (void *)&cmd_showport_show,
5402 (void *)&cmd_showport_port,
5403 (void *)&cmd_showport_what,
5404 (void *)&cmd_showport_portnum,
5409 /* *** READ PORT REGISTER *** */
5410 struct cmd_read_reg_result {
5411 cmdline_fixed_string_t read;
5412 cmdline_fixed_string_t reg;
5418 cmd_read_reg_parsed(void *parsed_result,
5419 __attribute__((unused)) struct cmdline *cl,
5420 __attribute__((unused)) void *data)
5422 struct cmd_read_reg_result *res = parsed_result;
5423 port_reg_display(res->port_id, res->reg_off);
5426 cmdline_parse_token_string_t cmd_read_reg_read =
5427 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5428 cmdline_parse_token_string_t cmd_read_reg_reg =
5429 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5430 cmdline_parse_token_num_t cmd_read_reg_port_id =
5431 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5432 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5433 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5435 cmdline_parse_inst_t cmd_read_reg = {
5436 .f = cmd_read_reg_parsed,
5438 .help_str = "read reg port_id reg_off",
5440 (void *)&cmd_read_reg_read,
5441 (void *)&cmd_read_reg_reg,
5442 (void *)&cmd_read_reg_port_id,
5443 (void *)&cmd_read_reg_reg_off,
5448 /* *** READ PORT REGISTER BIT FIELD *** */
5449 struct cmd_read_reg_bit_field_result {
5450 cmdline_fixed_string_t read;
5451 cmdline_fixed_string_t regfield;
5459 cmd_read_reg_bit_field_parsed(void *parsed_result,
5460 __attribute__((unused)) struct cmdline *cl,
5461 __attribute__((unused)) void *data)
5463 struct cmd_read_reg_bit_field_result *res = parsed_result;
5464 port_reg_bit_field_display(res->port_id, res->reg_off,
5465 res->bit1_pos, res->bit2_pos);
5468 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5469 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5471 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5472 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5473 regfield, "regfield");
5474 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5475 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5477 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5478 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5480 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5481 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5483 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5484 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5487 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5488 .f = cmd_read_reg_bit_field_parsed,
5490 .help_str = "read regfield port_id reg_off bit_x bit_y "
5491 "(read register bit field between bit_x and bit_y included)",
5493 (void *)&cmd_read_reg_bit_field_read,
5494 (void *)&cmd_read_reg_bit_field_regfield,
5495 (void *)&cmd_read_reg_bit_field_port_id,
5496 (void *)&cmd_read_reg_bit_field_reg_off,
5497 (void *)&cmd_read_reg_bit_field_bit1_pos,
5498 (void *)&cmd_read_reg_bit_field_bit2_pos,
5503 /* *** READ PORT REGISTER BIT *** */
5504 struct cmd_read_reg_bit_result {
5505 cmdline_fixed_string_t read;
5506 cmdline_fixed_string_t regbit;
5513 cmd_read_reg_bit_parsed(void *parsed_result,
5514 __attribute__((unused)) struct cmdline *cl,
5515 __attribute__((unused)) void *data)
5517 struct cmd_read_reg_bit_result *res = parsed_result;
5518 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5521 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5522 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5523 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5524 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5526 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5527 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5528 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5529 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5530 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5531 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5533 cmdline_parse_inst_t cmd_read_reg_bit = {
5534 .f = cmd_read_reg_bit_parsed,
5536 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5538 (void *)&cmd_read_reg_bit_read,
5539 (void *)&cmd_read_reg_bit_regbit,
5540 (void *)&cmd_read_reg_bit_port_id,
5541 (void *)&cmd_read_reg_bit_reg_off,
5542 (void *)&cmd_read_reg_bit_bit_pos,
5547 /* *** WRITE PORT REGISTER *** */
5548 struct cmd_write_reg_result {
5549 cmdline_fixed_string_t write;
5550 cmdline_fixed_string_t reg;
5557 cmd_write_reg_parsed(void *parsed_result,
5558 __attribute__((unused)) struct cmdline *cl,
5559 __attribute__((unused)) void *data)
5561 struct cmd_write_reg_result *res = parsed_result;
5562 port_reg_set(res->port_id, res->reg_off, res->value);
5565 cmdline_parse_token_string_t cmd_write_reg_write =
5566 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5567 cmdline_parse_token_string_t cmd_write_reg_reg =
5568 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5569 cmdline_parse_token_num_t cmd_write_reg_port_id =
5570 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5571 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5572 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5573 cmdline_parse_token_num_t cmd_write_reg_value =
5574 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5576 cmdline_parse_inst_t cmd_write_reg = {
5577 .f = cmd_write_reg_parsed,
5579 .help_str = "write reg port_id reg_off reg_value",
5581 (void *)&cmd_write_reg_write,
5582 (void *)&cmd_write_reg_reg,
5583 (void *)&cmd_write_reg_port_id,
5584 (void *)&cmd_write_reg_reg_off,
5585 (void *)&cmd_write_reg_value,
5590 /* *** WRITE PORT REGISTER BIT FIELD *** */
5591 struct cmd_write_reg_bit_field_result {
5592 cmdline_fixed_string_t write;
5593 cmdline_fixed_string_t regfield;
5602 cmd_write_reg_bit_field_parsed(void *parsed_result,
5603 __attribute__((unused)) struct cmdline *cl,
5604 __attribute__((unused)) void *data)
5606 struct cmd_write_reg_bit_field_result *res = parsed_result;
5607 port_reg_bit_field_set(res->port_id, res->reg_off,
5608 res->bit1_pos, res->bit2_pos, res->value);
5611 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5612 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5614 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5615 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5616 regfield, "regfield");
5617 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5618 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5620 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5621 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5623 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5624 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5626 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5627 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5629 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5630 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5633 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5634 .f = cmd_write_reg_bit_field_parsed,
5636 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5637 "(set register bit field between bit_x and bit_y included)",
5639 (void *)&cmd_write_reg_bit_field_write,
5640 (void *)&cmd_write_reg_bit_field_regfield,
5641 (void *)&cmd_write_reg_bit_field_port_id,
5642 (void *)&cmd_write_reg_bit_field_reg_off,
5643 (void *)&cmd_write_reg_bit_field_bit1_pos,
5644 (void *)&cmd_write_reg_bit_field_bit2_pos,
5645 (void *)&cmd_write_reg_bit_field_value,
5650 /* *** WRITE PORT REGISTER BIT *** */
5651 struct cmd_write_reg_bit_result {
5652 cmdline_fixed_string_t write;
5653 cmdline_fixed_string_t regbit;
5661 cmd_write_reg_bit_parsed(void *parsed_result,
5662 __attribute__((unused)) struct cmdline *cl,
5663 __attribute__((unused)) void *data)
5665 struct cmd_write_reg_bit_result *res = parsed_result;
5666 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5669 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5670 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5672 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5673 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5675 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5676 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5677 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5678 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5679 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5680 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5681 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5682 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5684 cmdline_parse_inst_t cmd_write_reg_bit = {
5685 .f = cmd_write_reg_bit_parsed,
5687 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5689 (void *)&cmd_write_reg_bit_write,
5690 (void *)&cmd_write_reg_bit_regbit,
5691 (void *)&cmd_write_reg_bit_port_id,
5692 (void *)&cmd_write_reg_bit_reg_off,
5693 (void *)&cmd_write_reg_bit_bit_pos,
5694 (void *)&cmd_write_reg_bit_value,
5699 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5700 struct cmd_read_rxd_txd_result {
5701 cmdline_fixed_string_t read;
5702 cmdline_fixed_string_t rxd_txd;
5709 cmd_read_rxd_txd_parsed(void *parsed_result,
5710 __attribute__((unused)) struct cmdline *cl,
5711 __attribute__((unused)) void *data)
5713 struct cmd_read_rxd_txd_result *res = parsed_result;
5715 if (!strcmp(res->rxd_txd, "rxd"))
5716 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5717 else if (!strcmp(res->rxd_txd, "txd"))
5718 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5721 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5722 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5723 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5724 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5726 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5727 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5728 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5729 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5730 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5731 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5733 cmdline_parse_inst_t cmd_read_rxd_txd = {
5734 .f = cmd_read_rxd_txd_parsed,
5736 .help_str = "read rxd|txd port_id queue_id rxd_id",
5738 (void *)&cmd_read_rxd_txd_read,
5739 (void *)&cmd_read_rxd_txd_rxd_txd,
5740 (void *)&cmd_read_rxd_txd_port_id,
5741 (void *)&cmd_read_rxd_txd_queue_id,
5742 (void *)&cmd_read_rxd_txd_desc_id,
5748 struct cmd_quit_result {
5749 cmdline_fixed_string_t quit;
5752 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5754 __attribute__((unused)) void *data)
5760 cmdline_parse_token_string_t cmd_quit_quit =
5761 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5763 cmdline_parse_inst_t cmd_quit = {
5764 .f = cmd_quit_parsed,
5766 .help_str = "exit application",
5768 (void *)&cmd_quit_quit,
5773 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5774 struct cmd_mac_addr_result {
5775 cmdline_fixed_string_t mac_addr_cmd;
5776 cmdline_fixed_string_t what;
5778 struct ether_addr address;
5781 static void cmd_mac_addr_parsed(void *parsed_result,
5782 __attribute__((unused)) struct cmdline *cl,
5783 __attribute__((unused)) void *data)
5785 struct cmd_mac_addr_result *res = parsed_result;
5788 if (strcmp(res->what, "add") == 0)
5789 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5791 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5793 /* check the return value and print it if is < 0 */
5795 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5799 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5800 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5802 cmdline_parse_token_string_t cmd_mac_addr_what =
5803 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5805 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5806 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5807 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5808 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5810 cmdline_parse_inst_t cmd_mac_addr = {
5811 .f = cmd_mac_addr_parsed,
5813 .help_str = "mac_addr add|remove X <address>: "
5814 "add/remove MAC address on port X",
5816 (void *)&cmd_mac_addr_cmd,
5817 (void *)&cmd_mac_addr_what,
5818 (void *)&cmd_mac_addr_portnum,
5819 (void *)&cmd_mac_addr_addr,
5825 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5826 struct cmd_set_qmap_result {
5827 cmdline_fixed_string_t set;
5828 cmdline_fixed_string_t qmap;
5829 cmdline_fixed_string_t what;
5836 cmd_set_qmap_parsed(void *parsed_result,
5837 __attribute__((unused)) struct cmdline *cl,
5838 __attribute__((unused)) void *data)
5840 struct cmd_set_qmap_result *res = parsed_result;
5841 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5843 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5846 cmdline_parse_token_string_t cmd_setqmap_set =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5849 cmdline_parse_token_string_t cmd_setqmap_qmap =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5852 cmdline_parse_token_string_t cmd_setqmap_what =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5855 cmdline_parse_token_num_t cmd_setqmap_portid =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5858 cmdline_parse_token_num_t cmd_setqmap_queueid =
5859 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5861 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5862 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5865 cmdline_parse_inst_t cmd_set_qmap = {
5866 .f = cmd_set_qmap_parsed,
5868 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5870 (void *)&cmd_setqmap_set,
5871 (void *)&cmd_setqmap_qmap,
5872 (void *)&cmd_setqmap_what,
5873 (void *)&cmd_setqmap_portid,
5874 (void *)&cmd_setqmap_queueid,
5875 (void *)&cmd_setqmap_mapvalue,
5880 /* *** CONFIGURE UNICAST HASH TABLE *** */
5881 struct cmd_set_uc_hash_table {
5882 cmdline_fixed_string_t set;
5883 cmdline_fixed_string_t port;
5885 cmdline_fixed_string_t what;
5886 struct ether_addr address;
5887 cmdline_fixed_string_t mode;
5891 cmd_set_uc_hash_parsed(void *parsed_result,
5892 __attribute__((unused)) struct cmdline *cl,
5893 __attribute__((unused)) void *data)
5896 struct cmd_set_uc_hash_table *res = parsed_result;
5898 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5900 if (strcmp(res->what, "uta") == 0)
5901 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5902 &res->address,(uint8_t)is_on);
5904 printf("bad unicast hash table parameter, return code = %d \n", ret);
5908 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5911 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5914 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5917 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5920 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5921 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5923 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5927 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5928 .f = cmd_set_uc_hash_parsed,
5930 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5932 (void *)&cmd_set_uc_hash_set,
5933 (void *)&cmd_set_uc_hash_port,
5934 (void *)&cmd_set_uc_hash_portid,
5935 (void *)&cmd_set_uc_hash_what,
5936 (void *)&cmd_set_uc_hash_mac,
5937 (void *)&cmd_set_uc_hash_mode,
5942 struct cmd_set_uc_all_hash_table {
5943 cmdline_fixed_string_t set;
5944 cmdline_fixed_string_t port;
5946 cmdline_fixed_string_t what;
5947 cmdline_fixed_string_t value;
5948 cmdline_fixed_string_t mode;
5952 cmd_set_uc_all_hash_parsed(void *parsed_result,
5953 __attribute__((unused)) struct cmdline *cl,
5954 __attribute__((unused)) void *data)
5957 struct cmd_set_uc_all_hash_table *res = parsed_result;
5959 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5961 if ((strcmp(res->what, "uta") == 0) &&
5962 (strcmp(res->value, "all") == 0))
5963 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5965 printf("bad unicast hash table parameter,"
5966 "return code = %d \n", ret);
5969 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5970 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5972 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5973 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5975 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5976 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5978 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5979 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5981 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5982 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5984 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5985 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5988 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5989 .f = cmd_set_uc_all_hash_parsed,
5991 .help_str = "set port X uta all on|off (X = port number)",
5993 (void *)&cmd_set_uc_all_hash_set,
5994 (void *)&cmd_set_uc_all_hash_port,
5995 (void *)&cmd_set_uc_all_hash_portid,
5996 (void *)&cmd_set_uc_all_hash_what,
5997 (void *)&cmd_set_uc_all_hash_value,
5998 (void *)&cmd_set_uc_all_hash_mode,
6003 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6004 struct cmd_set_vf_macvlan_filter {
6005 cmdline_fixed_string_t set;
6006 cmdline_fixed_string_t port;
6008 cmdline_fixed_string_t vf;
6010 struct ether_addr address;
6011 cmdline_fixed_string_t filter_type;
6012 cmdline_fixed_string_t mode;
6016 cmd_set_vf_macvlan_parsed(void *parsed_result,
6017 __attribute__((unused)) struct cmdline *cl,
6018 __attribute__((unused)) void *data)
6021 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6022 struct rte_eth_mac_filter filter;
6024 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6026 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6028 /* set VF MAC filter */
6032 filter.dst_id = res->vf_id;
6034 if (!strcmp(res->filter_type, "exact-mac"))
6035 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6036 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6037 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6038 else if (!strcmp(res->filter_type, "hashmac"))
6039 filter.filter_type = RTE_MAC_HASH_MATCH;
6040 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6041 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6043 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6046 ret = rte_eth_dev_filter_ctrl(res->port_id,
6047 RTE_ETH_FILTER_MACVLAN,
6051 ret = rte_eth_dev_filter_ctrl(res->port_id,
6052 RTE_ETH_FILTER_MACVLAN,
6053 RTE_ETH_FILTER_DELETE,
6057 printf("bad set MAC hash parameter, return code = %d\n", ret);
6061 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6064 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6067 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6068 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6070 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6073 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6074 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6076 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6077 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6079 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6081 filter_type, "exact-mac#exact-mac-vlan"
6082 "#hashmac#hashmac-vlan");
6083 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6084 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6087 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6088 .f = cmd_set_vf_macvlan_parsed,
6090 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6091 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6093 "exact match rule:exact match of MAC or MAC and VLAN; "
6094 "hash match rule: hash match of MAC and exact match "
6097 (void *)&cmd_set_vf_macvlan_set,
6098 (void *)&cmd_set_vf_macvlan_port,
6099 (void *)&cmd_set_vf_macvlan_portid,
6100 (void *)&cmd_set_vf_macvlan_vf,
6101 (void *)&cmd_set_vf_macvlan_vf_id,
6102 (void *)&cmd_set_vf_macvlan_mac,
6103 (void *)&cmd_set_vf_macvlan_filter_type,
6104 (void *)&cmd_set_vf_macvlan_mode,
6109 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6110 struct cmd_set_vf_traffic {
6111 cmdline_fixed_string_t set;
6112 cmdline_fixed_string_t port;
6114 cmdline_fixed_string_t vf;
6116 cmdline_fixed_string_t what;
6117 cmdline_fixed_string_t mode;
6121 cmd_set_vf_traffic_parsed(void *parsed_result,
6122 __attribute__((unused)) struct cmdline *cl,
6123 __attribute__((unused)) void *data)
6125 struct cmd_set_vf_traffic *res = parsed_result;
6126 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6127 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6129 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6132 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6133 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6135 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6136 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6138 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6139 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6141 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6142 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6144 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6145 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6147 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6148 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6150 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6151 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6154 cmdline_parse_inst_t cmd_set_vf_traffic = {
6155 .f = cmd_set_vf_traffic_parsed,
6157 .help_str = "set port X vf Y rx|tx on|off"
6158 "(X = port number,Y = vf id)",
6160 (void *)&cmd_setvf_traffic_set,
6161 (void *)&cmd_setvf_traffic_port,
6162 (void *)&cmd_setvf_traffic_portid,
6163 (void *)&cmd_setvf_traffic_vf,
6164 (void *)&cmd_setvf_traffic_vfid,
6165 (void *)&cmd_setvf_traffic_what,
6166 (void *)&cmd_setvf_traffic_mode,
6171 /* *** CONFIGURE VF RECEIVE MODE *** */
6172 struct cmd_set_vf_rxmode {
6173 cmdline_fixed_string_t set;
6174 cmdline_fixed_string_t port;
6176 cmdline_fixed_string_t vf;
6178 cmdline_fixed_string_t what;
6179 cmdline_fixed_string_t mode;
6180 cmdline_fixed_string_t on;
6184 cmd_set_vf_rxmode_parsed(void *parsed_result,
6185 __attribute__((unused)) struct cmdline *cl,
6186 __attribute__((unused)) void *data)
6189 uint16_t rx_mode = 0;
6190 struct cmd_set_vf_rxmode *res = parsed_result;
6192 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6193 if (!strcmp(res->what,"rxmode")) {
6194 if (!strcmp(res->mode, "AUPE"))
6195 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6196 else if (!strcmp(res->mode, "ROPE"))
6197 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6198 else if (!strcmp(res->mode, "BAM"))
6199 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6200 else if (!strncmp(res->mode, "MPE",3))
6201 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6204 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6206 printf("bad VF receive mode parameter, return code = %d \n",
6210 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6211 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6213 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6214 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6216 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6217 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6219 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6220 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6222 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6223 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6225 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6228 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6230 mode, "AUPE#ROPE#BAM#MPE");
6231 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6235 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6236 .f = cmd_set_vf_rxmode_parsed,
6238 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6240 (void *)&cmd_set_vf_rxmode_set,
6241 (void *)&cmd_set_vf_rxmode_port,
6242 (void *)&cmd_set_vf_rxmode_portid,
6243 (void *)&cmd_set_vf_rxmode_vf,
6244 (void *)&cmd_set_vf_rxmode_vfid,
6245 (void *)&cmd_set_vf_rxmode_what,
6246 (void *)&cmd_set_vf_rxmode_mode,
6247 (void *)&cmd_set_vf_rxmode_on,
6252 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6253 struct cmd_vf_mac_addr_result {
6254 cmdline_fixed_string_t mac_addr_cmd;
6255 cmdline_fixed_string_t what;
6256 cmdline_fixed_string_t port;
6258 cmdline_fixed_string_t vf;
6260 struct ether_addr address;
6263 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6264 __attribute__((unused)) struct cmdline *cl,
6265 __attribute__((unused)) void *data)
6267 struct cmd_vf_mac_addr_result *res = parsed_result;
6270 if (strcmp(res->what, "add") == 0)
6271 ret = rte_eth_dev_mac_addr_add(res->port_num,
6272 &res->address, res->vf_num);
6274 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6278 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6279 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6280 mac_addr_cmd,"mac_addr");
6281 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6282 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6284 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6285 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6287 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6288 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6290 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6291 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6293 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6294 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6296 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6297 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6300 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6301 .f = cmd_vf_mac_addr_parsed,
6303 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6304 "Y = VF number)add MAC address filtering for a VF on port X",
6306 (void *)&cmd_vf_mac_addr_cmd,
6307 (void *)&cmd_vf_mac_addr_what,
6308 (void *)&cmd_vf_mac_addr_port,
6309 (void *)&cmd_vf_mac_addr_portnum,
6310 (void *)&cmd_vf_mac_addr_vf,
6311 (void *)&cmd_vf_mac_addr_vfnum,
6312 (void *)&cmd_vf_mac_addr_addr,
6317 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6318 struct cmd_vf_rx_vlan_filter {
6319 cmdline_fixed_string_t rx_vlan;
6320 cmdline_fixed_string_t what;
6322 cmdline_fixed_string_t port;
6324 cmdline_fixed_string_t vf;
6329 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6330 __attribute__((unused)) struct cmdline *cl,
6331 __attribute__((unused)) void *data)
6333 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6335 if (!strcmp(res->what, "add"))
6336 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6338 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6341 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6342 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6343 rx_vlan, "rx_vlan");
6344 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6345 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6347 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6348 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6350 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6351 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6353 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6354 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6356 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6357 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6359 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6360 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6363 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6364 .f = cmd_vf_rx_vlan_filter_parsed,
6366 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6367 "Y = port number,Z = hexadecimal VF mask)",
6369 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6370 (void *)&cmd_vf_rx_vlan_filter_what,
6371 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6372 (void *)&cmd_vf_rx_vlan_filter_port,
6373 (void *)&cmd_vf_rx_vlan_filter_portid,
6374 (void *)&cmd_vf_rx_vlan_filter_vf,
6375 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6380 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6381 struct cmd_queue_rate_limit_result {
6382 cmdline_fixed_string_t set;
6383 cmdline_fixed_string_t port;
6385 cmdline_fixed_string_t queue;
6387 cmdline_fixed_string_t rate;
6391 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6392 __attribute__((unused)) struct cmdline *cl,
6393 __attribute__((unused)) void *data)
6395 struct cmd_queue_rate_limit_result *res = parsed_result;
6398 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6399 && (strcmp(res->queue, "queue") == 0)
6400 && (strcmp(res->rate, "rate") == 0))
6401 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6404 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6408 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6409 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6411 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6412 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6414 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6415 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6417 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6418 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6420 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6421 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6423 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6424 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6426 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6427 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6430 cmdline_parse_inst_t cmd_queue_rate_limit = {
6431 .f = cmd_queue_rate_limit_parsed,
6433 .help_str = "set port X queue Y rate Z:(X = port number,"
6434 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6436 (void *)&cmd_queue_rate_limit_set,
6437 (void *)&cmd_queue_rate_limit_port,
6438 (void *)&cmd_queue_rate_limit_portnum,
6439 (void *)&cmd_queue_rate_limit_queue,
6440 (void *)&cmd_queue_rate_limit_queuenum,
6441 (void *)&cmd_queue_rate_limit_rate,
6442 (void *)&cmd_queue_rate_limit_ratenum,
6447 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6448 struct cmd_vf_rate_limit_result {
6449 cmdline_fixed_string_t set;
6450 cmdline_fixed_string_t port;
6452 cmdline_fixed_string_t vf;
6454 cmdline_fixed_string_t rate;
6456 cmdline_fixed_string_t q_msk;
6460 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6461 __attribute__((unused)) struct cmdline *cl,
6462 __attribute__((unused)) void *data)
6464 struct cmd_vf_rate_limit_result *res = parsed_result;
6467 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6468 && (strcmp(res->vf, "vf") == 0)
6469 && (strcmp(res->rate, "rate") == 0)
6470 && (strcmp(res->q_msk, "queue_mask") == 0))
6471 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6472 res->rate_num, res->q_msk_val);
6474 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6478 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6479 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6481 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6482 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6484 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6485 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6487 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6488 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6490 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6491 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6493 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6494 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6496 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6497 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6499 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6500 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6501 q_msk, "queue_mask");
6502 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6503 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6506 cmdline_parse_inst_t cmd_vf_rate_limit = {
6507 .f = cmd_vf_rate_limit_parsed,
6509 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6510 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6511 "for queues of VF on port X",
6513 (void *)&cmd_vf_rate_limit_set,
6514 (void *)&cmd_vf_rate_limit_port,
6515 (void *)&cmd_vf_rate_limit_portnum,
6516 (void *)&cmd_vf_rate_limit_vf,
6517 (void *)&cmd_vf_rate_limit_vfnum,
6518 (void *)&cmd_vf_rate_limit_rate,
6519 (void *)&cmd_vf_rate_limit_ratenum,
6520 (void *)&cmd_vf_rate_limit_q_msk,
6521 (void *)&cmd_vf_rate_limit_q_msk_val,
6526 /* *** ADD TUNNEL FILTER OF A PORT *** */
6527 struct cmd_tunnel_filter_result {
6528 cmdline_fixed_string_t cmd;
6529 cmdline_fixed_string_t what;
6531 struct ether_addr outer_mac;
6532 struct ether_addr inner_mac;
6533 cmdline_ipaddr_t ip_value;
6534 uint16_t inner_vlan;
6535 cmdline_fixed_string_t tunnel_type;
6536 cmdline_fixed_string_t filter_type;
6542 cmd_tunnel_filter_parsed(void *parsed_result,
6543 __attribute__((unused)) struct cmdline *cl,
6544 __attribute__((unused)) void *data)
6546 struct cmd_tunnel_filter_result *res = parsed_result;
6547 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6550 tunnel_filter_conf.outer_mac = &res->outer_mac;
6551 tunnel_filter_conf.inner_mac = &res->inner_mac;
6552 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6554 if (res->ip_value.family == AF_INET) {
6555 tunnel_filter_conf.ip_addr.ipv4_addr =
6556 res->ip_value.addr.ipv4.s_addr;
6557 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6559 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6560 &(res->ip_value.addr.ipv6),
6561 sizeof(struct in6_addr));
6562 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6565 if (!strcmp(res->filter_type, "imac-ivlan"))
6566 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6567 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6568 tunnel_filter_conf.filter_type =
6569 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6570 else if (!strcmp(res->filter_type, "imac-tenid"))
6571 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6572 else if (!strcmp(res->filter_type, "imac"))
6573 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6574 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6575 tunnel_filter_conf.filter_type =
6576 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6578 printf("The filter type is not supported");
6582 if (!strcmp(res->tunnel_type, "vxlan"))
6583 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6585 printf("Only VXLAN is supported now.\n");
6589 tunnel_filter_conf.tenant_id = res->tenant_id;
6590 tunnel_filter_conf.queue_id = res->queue_num;
6591 if (!strcmp(res->what, "add"))
6592 ret = rte_eth_dev_filter_ctrl(res->port_id,
6593 RTE_ETH_FILTER_TUNNEL,
6595 &tunnel_filter_conf);
6597 ret = rte_eth_dev_filter_ctrl(res->port_id,
6598 RTE_ETH_FILTER_TUNNEL,
6599 RTE_ETH_FILTER_DELETE,
6600 &tunnel_filter_conf);
6602 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6606 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6607 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6608 cmd, "tunnel_filter");
6609 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6610 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6612 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6613 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6615 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6616 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6618 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6619 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6621 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6622 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6623 inner_vlan, UINT16);
6624 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6625 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6627 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6628 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6629 tunnel_type, "vxlan");
6631 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6632 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6633 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6634 "imac#omac-imac-tenid");
6635 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6636 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6638 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6639 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6642 cmdline_parse_inst_t cmd_tunnel_filter = {
6643 .f = cmd_tunnel_filter_parsed,
6645 .help_str = "add/rm tunnel filter of a port: "
6646 "tunnel_filter add port_id outer_mac inner_mac ip "
6647 "inner_vlan tunnel_type(vxlan) filter_type "
6648 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6649 "imac|omac-imac-tenid) "
6650 "tenant_id queue_num",
6652 (void *)&cmd_tunnel_filter_cmd,
6653 (void *)&cmd_tunnel_filter_what,
6654 (void *)&cmd_tunnel_filter_port_id,
6655 (void *)&cmd_tunnel_filter_outer_mac,
6656 (void *)&cmd_tunnel_filter_inner_mac,
6657 (void *)&cmd_tunnel_filter_ip_value,
6658 (void *)&cmd_tunnel_filter_innner_vlan,
6659 (void *)&cmd_tunnel_filter_tunnel_type,
6660 (void *)&cmd_tunnel_filter_filter_type,
6661 (void *)&cmd_tunnel_filter_tenant_id,
6662 (void *)&cmd_tunnel_filter_queue_num,
6667 /* *** CONFIGURE TUNNEL UDP PORT *** */
6668 struct cmd_tunnel_udp_config {
6669 cmdline_fixed_string_t cmd;
6670 cmdline_fixed_string_t what;
6676 cmd_tunnel_udp_config_parsed(void *parsed_result,
6677 __attribute__((unused)) struct cmdline *cl,
6678 __attribute__((unused)) void *data)
6680 struct cmd_tunnel_udp_config *res = parsed_result;
6681 struct rte_eth_udp_tunnel tunnel_udp;
6684 tunnel_udp.udp_port = res->udp_port;
6686 if (!strcmp(res->cmd, "rx_vxlan_port"))
6687 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6689 if (!strcmp(res->what, "add"))
6690 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6692 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6695 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6698 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6699 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6700 cmd, "rx_vxlan_port");
6701 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6702 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6704 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6705 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6707 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6708 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6711 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6712 .f = cmd_tunnel_udp_config_parsed,
6714 .help_str = "add/rm an tunneling UDP port filter: "
6715 "rx_vxlan_port add udp_port port_id",
6717 (void *)&cmd_tunnel_udp_config_cmd,
6718 (void *)&cmd_tunnel_udp_config_what,
6719 (void *)&cmd_tunnel_udp_config_udp_port,
6720 (void *)&cmd_tunnel_udp_config_port_id,
6725 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6726 struct cmd_set_mirror_mask_result {
6727 cmdline_fixed_string_t set;
6728 cmdline_fixed_string_t port;
6730 cmdline_fixed_string_t mirror;
6732 cmdline_fixed_string_t what;
6733 cmdline_fixed_string_t value;
6734 cmdline_fixed_string_t dstpool;
6736 cmdline_fixed_string_t on;
6739 cmdline_parse_token_string_t cmd_mirror_mask_set =
6740 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6742 cmdline_parse_token_string_t cmd_mirror_mask_port =
6743 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6745 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6746 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6748 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6749 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6750 mirror, "mirror-rule");
6751 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6752 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6754 cmdline_parse_token_string_t cmd_mirror_mask_what =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6756 what, "pool-mirror#vlan-mirror");
6757 cmdline_parse_token_string_t cmd_mirror_mask_value =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6760 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6761 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6762 dstpool, "dst-pool");
6763 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6764 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6766 cmdline_parse_token_string_t cmd_mirror_mask_on =
6767 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6771 cmd_set_mirror_mask_parsed(void *parsed_result,
6772 __attribute__((unused)) struct cmdline *cl,
6773 __attribute__((unused)) void *data)
6776 struct cmd_set_mirror_mask_result *res = parsed_result;
6777 struct rte_eth_vmdq_mirror_conf mr_conf;
6779 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6781 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6783 mr_conf.dst_pool = res->dstpool_id;
6785 if (!strcmp(res->what, "pool-mirror")) {
6786 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6787 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6788 } else if(!strcmp(res->what, "vlan-mirror")) {
6789 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6790 nb_item = parse_item_list(res->value, "core",
6791 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6795 for(i=0; i < nb_item; i++) {
6796 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6797 printf("Invalid vlan_id: must be < 4096\n");
6801 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6802 mr_conf.vlan.vlan_mask |= 1ULL << i;
6806 if(!strcmp(res->on, "on"))
6807 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6810 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6813 printf("mirror rule add error: (%s)\n", strerror(-ret));
6816 cmdline_parse_inst_t cmd_set_mirror_mask = {
6817 .f = cmd_set_mirror_mask_parsed,
6819 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6820 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6822 (void *)&cmd_mirror_mask_set,
6823 (void *)&cmd_mirror_mask_port,
6824 (void *)&cmd_mirror_mask_portid,
6825 (void *)&cmd_mirror_mask_mirror,
6826 (void *)&cmd_mirror_mask_ruleid,
6827 (void *)&cmd_mirror_mask_what,
6828 (void *)&cmd_mirror_mask_value,
6829 (void *)&cmd_mirror_mask_dstpool,
6830 (void *)&cmd_mirror_mask_poolid,
6831 (void *)&cmd_mirror_mask_on,
6836 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6837 struct cmd_set_mirror_link_result {
6838 cmdline_fixed_string_t set;
6839 cmdline_fixed_string_t port;
6841 cmdline_fixed_string_t mirror;
6843 cmdline_fixed_string_t what;
6844 cmdline_fixed_string_t dstpool;
6846 cmdline_fixed_string_t on;
6849 cmdline_parse_token_string_t cmd_mirror_link_set =
6850 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6852 cmdline_parse_token_string_t cmd_mirror_link_port =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6855 cmdline_parse_token_num_t cmd_mirror_link_portid =
6856 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6858 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6860 mirror, "mirror-rule");
6861 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6862 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6864 cmdline_parse_token_string_t cmd_mirror_link_what =
6865 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6866 what, "uplink-mirror#downlink-mirror");
6867 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6868 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6869 dstpool, "dst-pool");
6870 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6871 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6873 cmdline_parse_token_string_t cmd_mirror_link_on =
6874 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6878 cmd_set_mirror_link_parsed(void *parsed_result,
6879 __attribute__((unused)) struct cmdline *cl,
6880 __attribute__((unused)) void *data)
6883 struct cmd_set_mirror_link_result *res = parsed_result;
6884 struct rte_eth_vmdq_mirror_conf mr_conf;
6886 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6887 if(!strcmp(res->what, "uplink-mirror")) {
6888 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6889 }else if(!strcmp(res->what, "downlink-mirror"))
6890 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6892 mr_conf.dst_pool = res->dstpool_id;
6894 if(!strcmp(res->on, "on"))
6895 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6898 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6901 /* check the return value and print it if is < 0 */
6903 printf("mirror rule add error: (%s)\n", strerror(-ret));
6907 cmdline_parse_inst_t cmd_set_mirror_link = {
6908 .f = cmd_set_mirror_link_parsed,
6910 .help_str = "set port X mirror-rule Y uplink-mirror|"
6911 "downlink-mirror dst-pool Z on|off",
6913 (void *)&cmd_mirror_link_set,
6914 (void *)&cmd_mirror_link_port,
6915 (void *)&cmd_mirror_link_portid,
6916 (void *)&cmd_mirror_link_mirror,
6917 (void *)&cmd_mirror_link_ruleid,
6918 (void *)&cmd_mirror_link_what,
6919 (void *)&cmd_mirror_link_dstpool,
6920 (void *)&cmd_mirror_link_poolid,
6921 (void *)&cmd_mirror_link_on,
6926 /* *** RESET VM MIRROR RULE *** */
6927 struct cmd_rm_mirror_rule_result {
6928 cmdline_fixed_string_t reset;
6929 cmdline_fixed_string_t port;
6931 cmdline_fixed_string_t mirror;
6935 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6936 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6938 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6939 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6941 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6942 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6944 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6945 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6946 mirror, "mirror-rule");
6947 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6948 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6952 cmd_reset_mirror_rule_parsed(void *parsed_result,
6953 __attribute__((unused)) struct cmdline *cl,
6954 __attribute__((unused)) void *data)
6957 struct cmd_set_mirror_link_result *res = parsed_result;
6959 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6961 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6964 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6965 .f = cmd_reset_mirror_rule_parsed,
6967 .help_str = "reset port X mirror-rule Y",
6969 (void *)&cmd_rm_mirror_rule_reset,
6970 (void *)&cmd_rm_mirror_rule_port,
6971 (void *)&cmd_rm_mirror_rule_portid,
6972 (void *)&cmd_rm_mirror_rule_mirror,
6973 (void *)&cmd_rm_mirror_rule_ruleid,
6978 /* ******************************************************************************** */
6980 struct cmd_dump_result {
6981 cmdline_fixed_string_t dump;
6985 dump_struct_sizes(void)
6987 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6988 DUMP_SIZE(struct rte_mbuf);
6989 DUMP_SIZE(struct rte_mempool);
6990 DUMP_SIZE(struct rte_ring);
6994 static void cmd_dump_parsed(void *parsed_result,
6995 __attribute__((unused)) struct cmdline *cl,
6996 __attribute__((unused)) void *data)
6998 struct cmd_dump_result *res = parsed_result;
7000 if (!strcmp(res->dump, "dump_physmem"))
7001 rte_dump_physmem_layout(stdout);
7002 else if (!strcmp(res->dump, "dump_memzone"))
7003 rte_memzone_dump(stdout);
7004 else if (!strcmp(res->dump, "dump_log_history"))
7005 rte_log_dump_history(stdout);
7006 else if (!strcmp(res->dump, "dump_struct_sizes"))
7007 dump_struct_sizes();
7008 else if (!strcmp(res->dump, "dump_ring"))
7009 rte_ring_list_dump(stdout);
7010 else if (!strcmp(res->dump, "dump_mempool"))
7011 rte_mempool_list_dump(stdout);
7012 else if (!strcmp(res->dump, "dump_devargs"))
7013 rte_eal_devargs_dump(stdout);
7016 cmdline_parse_token_string_t cmd_dump_dump =
7017 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7021 "dump_struct_sizes#"
7026 cmdline_parse_inst_t cmd_dump = {
7027 .f = cmd_dump_parsed, /* function to call */
7028 .data = NULL, /* 2nd arg of func */
7029 .help_str = "dump status",
7030 .tokens = { /* token list, NULL terminated */
7031 (void *)&cmd_dump_dump,
7036 /* ******************************************************************************** */
7038 struct cmd_dump_one_result {
7039 cmdline_fixed_string_t dump;
7040 cmdline_fixed_string_t name;
7043 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7044 __attribute__((unused)) void *data)
7046 struct cmd_dump_one_result *res = parsed_result;
7048 if (!strcmp(res->dump, "dump_ring")) {
7050 r = rte_ring_lookup(res->name);
7052 cmdline_printf(cl, "Cannot find ring\n");
7055 rte_ring_dump(stdout, r);
7056 } else if (!strcmp(res->dump, "dump_mempool")) {
7057 struct rte_mempool *mp;
7058 mp = rte_mempool_lookup(res->name);
7060 cmdline_printf(cl, "Cannot find mempool\n");
7063 rte_mempool_dump(stdout, mp);
7067 cmdline_parse_token_string_t cmd_dump_one_dump =
7068 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7069 "dump_ring#dump_mempool");
7071 cmdline_parse_token_string_t cmd_dump_one_name =
7072 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7074 cmdline_parse_inst_t cmd_dump_one = {
7075 .f = cmd_dump_one_parsed, /* function to call */
7076 .data = NULL, /* 2nd arg of func */
7077 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7078 .tokens = { /* token list, NULL terminated */
7079 (void *)&cmd_dump_one_dump,
7080 (void *)&cmd_dump_one_name,
7085 /* *** ADD/REMOVE an ethertype FILTER *** */
7086 struct cmd_ethertype_filter_result {
7087 cmdline_fixed_string_t filter;
7089 cmdline_fixed_string_t ethertype;
7090 uint16_t ethertype_value;
7091 cmdline_fixed_string_t priority;
7092 cmdline_fixed_string_t priority_en;
7093 uint8_t priority_value;
7094 cmdline_fixed_string_t queue;
7096 cmdline_fixed_string_t index;
7097 uint16_t index_value;
7101 cmd_ethertype_filter_parsed(void *parsed_result,
7102 __attribute__((unused)) struct cmdline *cl,
7103 __attribute__((unused)) void *data)
7106 struct cmd_ethertype_filter_result *res = parsed_result;
7107 struct rte_ethertype_filter filter;
7109 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7110 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7111 filter.priority = res->priority_value;
7113 if (!strcmp(res->priority_en, "enable"))
7114 filter.priority_en = 1;
7115 if (!strcmp(res->filter, "add_ethertype_filter"))
7116 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7118 &filter, res->queue_id);
7119 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7120 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7122 else if (!strcmp(res->filter, "get_ethertype_filter"))
7123 get_ethertype_filter(res->port_id, res->index_value);
7126 printf("ethertype filter setting error: (%s)\n",
7130 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7131 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7133 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7134 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7135 ethertype, "ethertype");
7136 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7137 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7138 ethertype_value, UINT16);
7139 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7140 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7141 priority, "priority");
7142 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7143 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7144 priority_en, "enable#disable");
7145 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7146 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7147 priority_value, UINT8);
7148 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7149 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7151 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7152 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7154 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7155 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7157 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7158 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7159 index_value, UINT16);
7160 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7161 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7162 filter, "add_ethertype_filter");
7163 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7164 .f = cmd_ethertype_filter_parsed,
7166 .help_str = "add an ethertype filter",
7168 (void *)&cmd_ethertype_filter_add_filter,
7169 (void *)&cmd_ethertype_filter_port_id,
7170 (void *)&cmd_ethertype_filter_ethertype,
7171 (void *)&cmd_ethertype_filter_ethertype_value,
7172 (void *)&cmd_ethertype_filter_priority,
7173 (void *)&cmd_ethertype_filter_priority_en,
7174 (void *)&cmd_ethertype_filter_priority_value,
7175 (void *)&cmd_ethertype_filter_queue,
7176 (void *)&cmd_ethertype_filter_queue_id,
7177 (void *)&cmd_ethertype_filter_index,
7178 (void *)&cmd_ethertype_filter_index_value,
7183 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7184 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7185 filter, "remove_ethertype_filter");
7186 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7187 .f = cmd_ethertype_filter_parsed,
7189 .help_str = "remove an ethertype filter",
7191 (void *)&cmd_ethertype_filter_remove_filter,
7192 (void *)&cmd_ethertype_filter_port_id,
7193 (void *)&cmd_ethertype_filter_index,
7194 (void *)&cmd_ethertype_filter_index_value,
7198 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7199 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7200 filter, "get_ethertype_filter");
7201 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7202 .f = cmd_ethertype_filter_parsed,
7204 .help_str = "get an ethertype filter",
7206 (void *)&cmd_ethertype_filter_get_filter,
7207 (void *)&cmd_ethertype_filter_port_id,
7208 (void *)&cmd_ethertype_filter_index,
7209 (void *)&cmd_ethertype_filter_index_value,
7214 /* *** set SYN filter *** */
7215 struct cmd_set_syn_filter_result {
7216 cmdline_fixed_string_t filter;
7218 cmdline_fixed_string_t priority;
7219 cmdline_fixed_string_t high;
7220 cmdline_fixed_string_t queue;
7225 cmd_set_syn_filter_parsed(void *parsed_result,
7226 __attribute__((unused)) struct cmdline *cl,
7227 __attribute__((unused)) void *data)
7230 struct cmd_set_syn_filter_result *res = parsed_result;
7231 struct rte_syn_filter filter;
7233 if (!strcmp(res->filter, "add_syn_filter")) {
7234 if (!strcmp(res->high, "high"))
7238 ret = rte_eth_dev_add_syn_filter(res->port_id,
7239 &filter, res->queue_id);
7240 } else if (!strcmp(res->filter, "remove_syn_filter"))
7241 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7242 else if (!strcmp(res->filter, "get_syn_filter"))
7243 get_syn_filter(res->port_id);
7245 printf("syn filter setting error: (%s)\n", strerror(-ret));
7248 cmdline_parse_token_num_t cmd_syn_filter_portid =
7249 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7251 cmdline_parse_token_string_t cmd_syn_filter_priority =
7252 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7253 priority, "priority");
7254 cmdline_parse_token_string_t cmd_syn_filter_high =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7257 cmdline_parse_token_string_t cmd_syn_filter_queue =
7258 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7260 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7261 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7263 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7264 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7265 filter, "add_syn_filter");
7266 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7267 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7268 filter, "remove_syn_filter");
7269 cmdline_parse_inst_t cmd_add_syn_filter = {
7270 .f = cmd_set_syn_filter_parsed,
7272 .help_str = "add syn filter",
7274 (void *)&cmd_syn_filter_add_filter,
7275 (void *)&cmd_syn_filter_portid,
7276 (void *)&cmd_syn_filter_priority,
7277 (void *)&cmd_syn_filter_high,
7278 (void *)&cmd_syn_filter_queue,
7279 (void *)&cmd_syn_filter_queue_id,
7283 cmdline_parse_inst_t cmd_remove_syn_filter = {
7284 .f = cmd_set_syn_filter_parsed,
7286 .help_str = "remove syn filter",
7288 (void *)&cmd_syn_filter_remove_filter,
7289 (void *)&cmd_syn_filter_portid,
7294 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7295 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7296 filter, "get_syn_filter");
7298 cmdline_parse_inst_t cmd_get_syn_filter = {
7299 .f = cmd_set_syn_filter_parsed,
7301 .help_str = "get syn filter",
7303 (void *)&cmd_syn_filter_get_filter,
7304 (void *)&cmd_syn_filter_portid,
7309 /* *** ADD/REMOVE A 2tuple FILTER *** */
7310 struct cmd_2tuple_filter_result {
7311 cmdline_fixed_string_t filter;
7313 cmdline_fixed_string_t protocol;
7314 uint8_t protocol_value;
7315 uint8_t protocol_mask;
7316 cmdline_fixed_string_t dst_port;
7317 uint16_t dst_port_value;
7318 uint16_t dst_port_mask;
7319 cmdline_fixed_string_t flags;
7320 uint8_t flags_value;
7321 cmdline_fixed_string_t priority;
7322 uint8_t priority_value;
7323 cmdline_fixed_string_t queue;
7325 cmdline_fixed_string_t index;
7326 uint16_t index_value;
7330 cmd_2tuple_filter_parsed(void *parsed_result,
7331 __attribute__((unused)) struct cmdline *cl,
7332 __attribute__((unused)) void *data)
7335 struct rte_2tuple_filter filter;
7336 struct cmd_2tuple_filter_result *res = parsed_result;
7338 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7340 if (!strcmp(res->filter, "add_2tuple_filter")) {
7341 /* need convert to big endian. */
7342 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7343 filter.protocol = res->protocol_value;
7344 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7345 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7346 filter.priority = res->priority_value;
7347 filter.tcp_flags = res->flags_value;
7348 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7349 res->index_value, &filter, res->queue_id);
7350 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7351 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7353 else if (!strcmp(res->filter, "get_2tuple_filter"))
7354 get_2tuple_filter(res->port_id, res->index_value);
7357 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7360 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7361 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7363 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7364 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7365 protocol, "protocol");
7366 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7367 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7368 protocol_value, UINT8);
7369 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7370 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7371 protocol_mask, UINT8);
7372 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7373 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7374 dst_port, "dst_port");
7375 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7376 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7377 dst_port_value, UINT16);
7378 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7379 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7380 dst_port_mask, UINT16);
7381 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7382 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7384 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7385 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7386 flags_value, UINT8);
7387 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7388 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7389 priority, "priority");
7390 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7391 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7392 priority_value, UINT8);
7393 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7394 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7396 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7397 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7399 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7400 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7402 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7403 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7404 index_value, UINT16);
7405 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7406 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7407 filter, "add_2tuple_filter");
7408 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7409 .f = cmd_2tuple_filter_parsed,
7411 .help_str = "add a 2tuple filter",
7413 (void *)&cmd_2tuple_filter_add_filter,
7414 (void *)&cmd_2tuple_filter_port_id,
7415 (void *)&cmd_2tuple_filter_protocol,
7416 (void *)&cmd_2tuple_filter_protocol_value,
7417 (void *)&cmd_2tuple_filter_protocol_mask,
7418 (void *)&cmd_2tuple_filter_dst_port,
7419 (void *)&cmd_2tuple_filter_dst_port_value,
7420 (void *)&cmd_2tuple_filter_dst_port_mask,
7421 (void *)&cmd_2tuple_filter_flags,
7422 (void *)&cmd_2tuple_filter_flags_value,
7423 (void *)&cmd_2tuple_filter_priority,
7424 (void *)&cmd_2tuple_filter_priority_value,
7425 (void *)&cmd_2tuple_filter_queue,
7426 (void *)&cmd_2tuple_filter_queue_id,
7427 (void *)&cmd_2tuple_filter_index,
7428 (void *)&cmd_2tuple_filter_index_value,
7433 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7434 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7435 filter, "remove_2tuple_filter");
7436 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7437 .f = cmd_2tuple_filter_parsed,
7439 .help_str = "remove a 2tuple filter",
7441 (void *)&cmd_2tuple_filter_remove_filter,
7442 (void *)&cmd_2tuple_filter_port_id,
7443 (void *)&cmd_2tuple_filter_index,
7444 (void *)&cmd_2tuple_filter_index_value,
7448 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7449 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7450 filter, "get_2tuple_filter");
7451 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7452 .f = cmd_2tuple_filter_parsed,
7454 .help_str = "get a 2tuple filter",
7456 (void *)&cmd_2tuple_filter_get_filter,
7457 (void *)&cmd_2tuple_filter_port_id,
7458 (void *)&cmd_2tuple_filter_index,
7459 (void *)&cmd_2tuple_filter_index_value,
7464 /* *** ADD/REMOVE A 5tuple FILTER *** */
7465 struct cmd_5tuple_filter_result {
7466 cmdline_fixed_string_t filter;
7468 cmdline_fixed_string_t dst_ip;
7469 cmdline_ipaddr_t dst_ip_value;
7470 cmdline_fixed_string_t src_ip;
7471 cmdline_ipaddr_t src_ip_value;
7472 cmdline_fixed_string_t dst_port;
7473 uint16_t dst_port_value;
7474 cmdline_fixed_string_t src_port;
7475 uint16_t src_port_value;
7476 cmdline_fixed_string_t protocol;
7477 uint8_t protocol_value;
7478 cmdline_fixed_string_t mask;
7480 cmdline_fixed_string_t flags;
7481 uint8_t flags_value;
7482 cmdline_fixed_string_t priority;
7483 uint8_t priority_value;
7484 cmdline_fixed_string_t queue;
7486 cmdline_fixed_string_t index;
7487 uint16_t index_value;
7491 cmd_5tuple_filter_parsed(void *parsed_result,
7492 __attribute__((unused)) struct cmdline *cl,
7493 __attribute__((unused)) void *data)
7496 struct rte_5tuple_filter filter;
7497 struct cmd_5tuple_filter_result *res = parsed_result;
7499 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7501 if (!strcmp(res->filter, "add_5tuple_filter")) {
7502 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7503 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7504 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7505 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7506 filter.protocol = res->protocol_value;
7507 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7508 filter.priority = res->priority_value;
7509 filter.tcp_flags = res->flags_value;
7511 if (res->dst_ip_value.family == AF_INET)
7512 /* no need to convert, already big endian. */
7513 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7515 if (filter.dst_ip_mask == 0) {
7516 printf("can not support ipv6 involved compare.\n");
7522 if (res->src_ip_value.family == AF_INET)
7523 /* no need to convert, already big endian. */
7524 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7526 if (filter.src_ip_mask == 0) {
7527 printf("can not support ipv6 involved compare.\n");
7532 /* need convert to big endian. */
7533 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7534 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7536 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7537 res->index_value, &filter, res->queue_id);
7538 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7539 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7541 else if (!strcmp(res->filter, "get_5tuple_filter"))
7542 get_5tuple_filter(res->port_id, res->index_value);
7544 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7548 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7549 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7551 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7552 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7554 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7555 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7557 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7558 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7560 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7561 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7563 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7564 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7565 dst_port, "dst_port");
7566 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7567 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7568 dst_port_value, UINT16);
7569 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7570 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7571 src_port, "src_port");
7572 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7573 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7574 src_port_value, UINT16);
7575 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7576 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7577 protocol, "protocol");
7578 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7579 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7580 protocol_value, UINT8);
7581 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7582 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7584 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7585 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7587 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7588 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7590 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7591 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7592 flags_value, UINT8);
7593 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7594 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7595 priority, "priority");
7596 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7597 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7598 priority_value, UINT8);
7599 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7600 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7602 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7603 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7605 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7606 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7608 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7609 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7610 index_value, UINT16);
7612 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7613 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7614 filter, "add_5tuple_filter");
7615 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7616 .f = cmd_5tuple_filter_parsed,
7618 .help_str = "add a 5tuple filter",
7620 (void *)&cmd_5tuple_filter_add_filter,
7621 (void *)&cmd_5tuple_filter_port_id,
7622 (void *)&cmd_5tuple_filter_dst_ip,
7623 (void *)&cmd_5tuple_filter_dst_ip_value,
7624 (void *)&cmd_5tuple_filter_src_ip,
7625 (void *)&cmd_5tuple_filter_src_ip_value,
7626 (void *)&cmd_5tuple_filter_dst_port,
7627 (void *)&cmd_5tuple_filter_dst_port_value,
7628 (void *)&cmd_5tuple_filter_src_port,
7629 (void *)&cmd_5tuple_filter_src_port_value,
7630 (void *)&cmd_5tuple_filter_protocol,
7631 (void *)&cmd_5tuple_filter_protocol_value,
7632 (void *)&cmd_5tuple_filter_mask,
7633 (void *)&cmd_5tuple_filter_mask_value,
7634 (void *)&cmd_5tuple_filter_flags,
7635 (void *)&cmd_5tuple_filter_flags_value,
7636 (void *)&cmd_5tuple_filter_priority,
7637 (void *)&cmd_5tuple_filter_priority_value,
7638 (void *)&cmd_5tuple_filter_queue,
7639 (void *)&cmd_5tuple_filter_queue_id,
7640 (void *)&cmd_5tuple_filter_index,
7641 (void *)&cmd_5tuple_filter_index_value,
7646 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7647 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7648 filter, "remove_5tuple_filter");
7649 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7650 .f = cmd_5tuple_filter_parsed,
7652 .help_str = "remove a 5tuple filter",
7654 (void *)&cmd_5tuple_filter_remove_filter,
7655 (void *)&cmd_5tuple_filter_port_id,
7656 (void *)&cmd_5tuple_filter_index,
7657 (void *)&cmd_5tuple_filter_index_value,
7662 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7663 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7664 filter, "get_5tuple_filter");
7665 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7666 .f = cmd_5tuple_filter_parsed,
7668 .help_str = "get a 5tuple filter",
7670 (void *)&cmd_5tuple_filter_get_filter,
7671 (void *)&cmd_5tuple_filter_port_id,
7672 (void *)&cmd_5tuple_filter_index,
7673 (void *)&cmd_5tuple_filter_index_value,
7678 /* *** ADD/REMOVE A flex FILTER *** */
7679 struct cmd_flex_filter_result {
7680 cmdline_fixed_string_t filter;
7682 cmdline_fixed_string_t len;
7684 cmdline_fixed_string_t bytes;
7685 cmdline_fixed_string_t bytes_value;
7686 cmdline_fixed_string_t mask;
7687 cmdline_fixed_string_t mask_value;
7688 cmdline_fixed_string_t priority;
7689 uint8_t priority_value;
7690 cmdline_fixed_string_t queue;
7692 cmdline_fixed_string_t index;
7693 uint16_t index_value;
7696 static int xdigit2val(unsigned char c)
7701 else if (isupper(c))
7709 cmd_flex_filter_parsed(void *parsed_result,
7710 __attribute__((unused)) struct cmdline *cl,
7711 __attribute__((unused)) void *data)
7714 struct rte_flex_filter filter;
7715 struct cmd_flex_filter_result *res = parsed_result;
7716 char *bytes_ptr, *mask_ptr;
7724 if (!strcmp(res->filter, "add_flex_filter")) {
7725 if (res->len_value > 128) {
7726 printf("the len exceed the max length 128\n");
7729 memset(&filter, 0, sizeof(struct rte_flex_filter));
7730 filter.len = res->len_value;
7731 filter.priority = res->priority_value;
7732 bytes_ptr = res->bytes_value;
7733 mask_ptr = res->mask_value;
7736 /* translate bytes string to uint_32 array. */
7737 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7738 (bytes_ptr[1] == 'X')))
7740 len = strnlen(bytes_ptr, res->len_value * 2);
7741 if (len == 0 || (len % 8 != 0)) {
7742 printf("please check len and bytes input\n");
7745 for (i = 0; i < len; i++) {
7747 if (isxdigit(c) == 0) {
7748 /* invalid characters. */
7749 printf("invalid input\n");
7752 val = xdigit2val(c);
7756 dword |= byte << (4 * mod - 4);
7761 filter.dwords[j] = dword;
7762 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7768 /* translate mask string to uint8_t array. */
7770 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7771 (mask_ptr[1] == 'X')))
7773 len = strnlen(mask_ptr, (res->len_value+3)/4);
7775 printf("invalid input\n");
7778 for (i = 0; i < len; i++) {
7780 if (isxdigit(c) == 0) {
7781 /* invalid characters. */
7782 printf("invalid input\n");
7785 val = xdigit2val(c);
7786 hex |= (uint8_t)(val & 0x8) >> 3;
7787 hex |= (uint8_t)(val & 0x4) >> 1;
7788 hex |= (uint8_t)(val & 0x2) << 1;
7789 hex |= (uint8_t)(val & 0x1) << 3;
7792 filter.mask[j] = byte;
7793 printf("mask[%d]:%02x ", j, filter.mask[j]);
7801 printf("call function rte_eth_dev_add_flex_filter: "
7802 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7803 res->index_value, res->queue_id,
7804 filter.len, filter.priority);
7805 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7806 &filter, res->queue_id);
7808 } else if (!strcmp(res->filter, "remove_flex_filter"))
7809 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7811 else if (!strcmp(res->filter, "get_flex_filter"))
7812 get_flex_filter(res->port_id, res->index_value);
7815 printf("flex filter setting error: (%s)\n", strerror(-ret));
7818 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7819 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7821 cmdline_parse_token_string_t cmd_flex_filter_len =
7822 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7824 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7825 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7827 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7828 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7830 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7831 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7833 cmdline_parse_token_string_t cmd_flex_filter_mask =
7834 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7836 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7837 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7839 cmdline_parse_token_string_t cmd_flex_filter_priority =
7840 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7841 priority, "priority");
7842 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7843 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7844 priority_value, UINT8);
7845 cmdline_parse_token_string_t cmd_flex_filter_queue =
7846 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7848 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7849 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7851 cmdline_parse_token_string_t cmd_flex_filter_index =
7852 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7854 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7855 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7856 index_value, UINT16);
7857 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7858 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7859 filter, "add_flex_filter");
7860 cmdline_parse_inst_t cmd_add_flex_filter = {
7861 .f = cmd_flex_filter_parsed,
7863 .help_str = "add a flex filter",
7865 (void *)&cmd_flex_filter_add_filter,
7866 (void *)&cmd_flex_filter_port_id,
7867 (void *)&cmd_flex_filter_len,
7868 (void *)&cmd_flex_filter_len_value,
7869 (void *)&cmd_flex_filter_bytes,
7870 (void *)&cmd_flex_filter_bytes_value,
7871 (void *)&cmd_flex_filter_mask,
7872 (void *)&cmd_flex_filter_mask_value,
7873 (void *)&cmd_flex_filter_priority,
7874 (void *)&cmd_flex_filter_priority_value,
7875 (void *)&cmd_flex_filter_queue,
7876 (void *)&cmd_flex_filter_queue_id,
7877 (void *)&cmd_flex_filter_index,
7878 (void *)&cmd_flex_filter_index_value,
7883 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7884 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7885 filter, "remove_flex_filter");
7886 cmdline_parse_inst_t cmd_remove_flex_filter = {
7887 .f = cmd_flex_filter_parsed,
7889 .help_str = "remove a flex filter",
7891 (void *)&cmd_flex_filter_remove_filter,
7892 (void *)&cmd_flex_filter_port_id,
7893 (void *)&cmd_flex_filter_index,
7894 (void *)&cmd_flex_filter_index_value,
7899 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7900 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7901 filter, "get_flex_filter");
7902 cmdline_parse_inst_t cmd_get_flex_filter = {
7903 .f = cmd_flex_filter_parsed,
7905 .help_str = "get a flex filter",
7907 (void *)&cmd_flex_filter_get_filter,
7908 (void *)&cmd_flex_filter_port_id,
7909 (void *)&cmd_flex_filter_index,
7910 (void *)&cmd_flex_filter_index_value,
7915 /* *** Filters Control *** */
7917 /* *** deal with flow director filter *** */
7918 struct cmd_flow_director_result {
7919 cmdline_fixed_string_t flow_director_filter;
7921 cmdline_fixed_string_t ops;
7922 cmdline_fixed_string_t flow;
7923 cmdline_fixed_string_t flow_type;
7924 cmdline_fixed_string_t src;
7925 cmdline_ipaddr_t ip_src;
7927 cmdline_fixed_string_t dst;
7928 cmdline_ipaddr_t ip_dst;
7930 cmdline_fixed_string_t verify_tag;
7931 uint32_t verify_tag_value;
7932 cmdline_fixed_string_t flexbytes;
7933 cmdline_fixed_string_t flexbytes_value;
7934 cmdline_fixed_string_t drop;
7935 cmdline_fixed_string_t queue;
7937 cmdline_fixed_string_t fd_id;
7938 uint32_t fd_id_value;
7942 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7945 const char *p, *p0 = q_arg;
7947 unsigned long int_fld;
7948 char *str_fld[max_num];
7953 p = strchr(p0, '(');
7957 p0 = strchr(p, ')');
7962 if (size >= sizeof(s))
7965 snprintf(s, sizeof(s), "%.*s", size, p);
7966 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7967 if (ret < 0 || ret > max_num)
7969 for (i = 0; i < ret; i++) {
7971 int_fld = strtoul(str_fld[i], &end, 0);
7972 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7974 flexbytes[i] = (uint8_t)int_fld;
7979 static enum rte_eth_flow_type
7980 str2flowtype(char *string)
7983 static const struct {
7985 enum rte_eth_flow_type type;
7986 } flowtype_str[] = {
7987 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7988 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7989 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7990 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7991 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7992 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7993 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7994 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
7995 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
7996 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
7999 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8000 if (!strcmp(flowtype_str[i].str, string))
8001 return flowtype_str[i].type;
8003 return RTE_ETH_FLOW_TYPE_NONE;
8006 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8008 if ((ip_addr).family == AF_INET) \
8009 (ip) = (ip_addr).addr.ipv4.s_addr; \
8011 printf("invalid parameter.\n"); \
8016 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8018 if ((ip_addr).family == AF_INET6) \
8019 (void)rte_memcpy(&(ip), \
8020 &((ip_addr).addr.ipv6), \
8021 sizeof(struct in6_addr)); \
8023 printf("invalid parameter.\n"); \
8029 cmd_flow_director_filter_parsed(void *parsed_result,
8030 __attribute__((unused)) struct cmdline *cl,
8031 __attribute__((unused)) void *data)
8033 struct cmd_flow_director_result *res = parsed_result;
8034 struct rte_eth_fdir_filter entry;
8035 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8038 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8040 printf("flow director is not supported on port %u.\n",
8044 memset(flexbytes, 0, sizeof(flexbytes));
8045 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8046 ret = parse_flexbytes(res->flexbytes_value,
8048 RTE_ETH_FDIR_MAX_FLEXLEN);
8050 printf("error: Cannot parse flexbytes input.\n");
8054 entry.input.flow_type = str2flowtype(res->flow_type);
8055 switch (entry.input.flow_type) {
8056 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8057 case RTE_ETH_FLOW_TYPE_UDPV4:
8058 case RTE_ETH_FLOW_TYPE_TCPV4:
8059 IPV4_ADDR_TO_UINT(res->ip_dst,
8060 entry.input.flow.ip4_flow.dst_ip);
8061 IPV4_ADDR_TO_UINT(res->ip_src,
8062 entry.input.flow.ip4_flow.src_ip);
8063 /* need convert to big endian. */
8064 entry.input.flow.udp4_flow.dst_port =
8065 rte_cpu_to_be_16(res->port_dst);
8066 entry.input.flow.udp4_flow.src_port =
8067 rte_cpu_to_be_16(res->port_src);
8069 case RTE_ETH_FLOW_TYPE_SCTPV4:
8070 IPV4_ADDR_TO_UINT(res->ip_dst,
8071 entry.input.flow.sctp4_flow.ip.dst_ip);
8072 IPV4_ADDR_TO_UINT(res->ip_src,
8073 entry.input.flow.sctp4_flow.ip.src_ip);
8074 /* need convert to big endian. */
8075 entry.input.flow.sctp4_flow.verify_tag =
8076 rte_cpu_to_be_32(res->verify_tag_value);
8078 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8079 case RTE_ETH_FLOW_TYPE_UDPV6:
8080 case RTE_ETH_FLOW_TYPE_TCPV6:
8081 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8082 entry.input.flow.ip6_flow.dst_ip);
8083 IPV6_ADDR_TO_ARRAY(res->ip_src,
8084 entry.input.flow.ip6_flow.src_ip);
8085 /* need convert to big endian. */
8086 entry.input.flow.udp6_flow.dst_port =
8087 rte_cpu_to_be_16(res->port_dst);
8088 entry.input.flow.udp6_flow.src_port =
8089 rte_cpu_to_be_16(res->port_src);
8091 case RTE_ETH_FLOW_TYPE_SCTPV6:
8092 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8093 entry.input.flow.sctp6_flow.ip.dst_ip);
8094 IPV6_ADDR_TO_ARRAY(res->ip_src,
8095 entry.input.flow.sctp6_flow.ip.src_ip);
8096 /* need convert to big endian. */
8097 entry.input.flow.sctp6_flow.verify_tag =
8098 rte_cpu_to_be_32(res->verify_tag_value);
8101 printf("invalid parameter.\n");
8104 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8106 RTE_ETH_FDIR_MAX_FLEXLEN);
8108 entry.action.flex_off = 0; /*use 0 by default */
8109 if (!strcmp(res->drop, "drop"))
8110 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8112 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8113 /* set to report FD ID by default */
8114 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8115 entry.action.rx_queue = res->queue_id;
8116 entry.soft_id = res->fd_id_value;
8117 if (!strcmp(res->ops, "add"))
8118 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8119 RTE_ETH_FILTER_ADD, &entry);
8121 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8122 RTE_ETH_FILTER_DELETE, &entry);
8124 printf("flow director programming error: (%s)\n",
8128 cmdline_parse_token_string_t cmd_flow_director_filter =
8129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8130 flow_director_filter, "flow_director_filter");
8131 cmdline_parse_token_num_t cmd_flow_director_port_id =
8132 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8134 cmdline_parse_token_string_t cmd_flow_director_ops =
8135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8137 cmdline_parse_token_string_t cmd_flow_director_flow =
8138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8140 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8143 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8144 "ip6#ip6-frag#tcp6#udp6#sctp6");
8145 cmdline_parse_token_string_t cmd_flow_director_src =
8146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8148 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8149 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8151 cmdline_parse_token_num_t cmd_flow_director_port_src =
8152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8154 cmdline_parse_token_string_t cmd_flow_director_dst =
8155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8157 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8158 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8160 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8161 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8163 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8165 verify_tag, "verify_tag");
8166 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8167 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8168 verify_tag_value, UINT32);
8169 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8171 flexbytes, "flexbytes");
8172 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8174 flexbytes_value, NULL);
8175 cmdline_parse_token_string_t cmd_flow_director_drop =
8176 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8178 cmdline_parse_token_string_t cmd_flow_director_queue =
8179 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8181 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8182 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8184 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8185 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8187 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8188 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8189 fd_id_value, UINT32);
8191 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8192 .f = cmd_flow_director_filter_parsed,
8194 .help_str = "add or delete an ip flow director entry on NIC",
8196 (void *)&cmd_flow_director_filter,
8197 (void *)&cmd_flow_director_port_id,
8198 (void *)&cmd_flow_director_ops,
8199 (void *)&cmd_flow_director_flow,
8200 (void *)&cmd_flow_director_flow_type,
8201 (void *)&cmd_flow_director_src,
8202 (void *)&cmd_flow_director_ip_src,
8203 (void *)&cmd_flow_director_dst,
8204 (void *)&cmd_flow_director_ip_dst,
8205 (void *)&cmd_flow_director_flexbytes,
8206 (void *)&cmd_flow_director_flexbytes_value,
8207 (void *)&cmd_flow_director_drop,
8208 (void *)&cmd_flow_director_queue,
8209 (void *)&cmd_flow_director_queue_id,
8210 (void *)&cmd_flow_director_fd_id,
8211 (void *)&cmd_flow_director_fd_id_value,
8216 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8217 .f = cmd_flow_director_filter_parsed,
8219 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8221 (void *)&cmd_flow_director_filter,
8222 (void *)&cmd_flow_director_port_id,
8223 (void *)&cmd_flow_director_ops,
8224 (void *)&cmd_flow_director_flow,
8225 (void *)&cmd_flow_director_flow_type,
8226 (void *)&cmd_flow_director_src,
8227 (void *)&cmd_flow_director_ip_src,
8228 (void *)&cmd_flow_director_port_src,
8229 (void *)&cmd_flow_director_dst,
8230 (void *)&cmd_flow_director_ip_dst,
8231 (void *)&cmd_flow_director_port_dst,
8232 (void *)&cmd_flow_director_flexbytes,
8233 (void *)&cmd_flow_director_flexbytes_value,
8234 (void *)&cmd_flow_director_drop,
8235 (void *)&cmd_flow_director_queue,
8236 (void *)&cmd_flow_director_queue_id,
8237 (void *)&cmd_flow_director_fd_id,
8238 (void *)&cmd_flow_director_fd_id_value,
8243 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8244 .f = cmd_flow_director_filter_parsed,
8246 .help_str = "add or delete a sctp flow director entry on NIC",
8248 (void *)&cmd_flow_director_filter,
8249 (void *)&cmd_flow_director_port_id,
8250 (void *)&cmd_flow_director_ops,
8251 (void *)&cmd_flow_director_flow,
8252 (void *)&cmd_flow_director_flow_type,
8253 (void *)&cmd_flow_director_src,
8254 (void *)&cmd_flow_director_ip_src,
8255 (void *)&cmd_flow_director_dst,
8256 (void *)&cmd_flow_director_ip_dst,
8257 (void *)&cmd_flow_director_verify_tag,
8258 (void *)&cmd_flow_director_verify_tag_value,
8259 (void *)&cmd_flow_director_flexbytes,
8260 (void *)&cmd_flow_director_flexbytes_value,
8261 (void *)&cmd_flow_director_drop,
8262 (void *)&cmd_flow_director_queue,
8263 (void *)&cmd_flow_director_queue_id,
8264 (void *)&cmd_flow_director_fd_id,
8265 (void *)&cmd_flow_director_fd_id_value,
8270 struct cmd_flush_flow_director_result {
8271 cmdline_fixed_string_t flush_flow_director;
8275 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8276 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8277 flush_flow_director, "flush_flow_director");
8278 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8279 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8283 cmd_flush_flow_director_parsed(void *parsed_result,
8284 __attribute__((unused)) struct cmdline *cl,
8285 __attribute__((unused)) void *data)
8287 struct cmd_flow_director_result *res = parsed_result;
8290 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8292 printf("flow director is not supported on port %u.\n",
8297 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8298 RTE_ETH_FILTER_FLUSH, NULL);
8300 printf("flow director table flushing error: (%s)\n",
8304 cmdline_parse_inst_t cmd_flush_flow_director = {
8305 .f = cmd_flush_flow_director_parsed,
8307 .help_str = "flush all flow director entries of a device on NIC",
8309 (void *)&cmd_flush_flow_director_flush,
8310 (void *)&cmd_flush_flow_director_port_id,
8315 /* ******************************************************************************** */
8317 /* list of instructions */
8318 cmdline_parse_ctx_t main_ctx[] = {
8319 (cmdline_parse_inst_t *)&cmd_help_brief,
8320 (cmdline_parse_inst_t *)&cmd_help_long,
8321 (cmdline_parse_inst_t *)&cmd_quit,
8322 (cmdline_parse_inst_t *)&cmd_showport,
8323 (cmdline_parse_inst_t *)&cmd_showportall,
8324 (cmdline_parse_inst_t *)&cmd_showcfg,
8325 (cmdline_parse_inst_t *)&cmd_start,
8326 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8327 (cmdline_parse_inst_t *)&cmd_set_link_up,
8328 (cmdline_parse_inst_t *)&cmd_set_link_down,
8329 (cmdline_parse_inst_t *)&cmd_reset,
8330 (cmdline_parse_inst_t *)&cmd_set_numbers,
8331 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8332 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8333 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8334 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8335 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8336 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8337 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8338 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8339 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8340 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8341 (cmdline_parse_inst_t *)&cmd_set_link_check,
8342 #ifdef RTE_NIC_BYPASS
8343 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8344 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8345 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8346 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8348 #ifdef RTE_LIBRTE_PMD_BOND
8349 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8350 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8351 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8352 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8353 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8354 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8355 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8356 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8357 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8359 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8360 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8361 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8362 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8363 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8364 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8365 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8366 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8367 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8368 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8369 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8370 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8371 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8372 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8373 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8374 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8375 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8376 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8377 (cmdline_parse_inst_t *)&cmd_config_dcb,
8378 (cmdline_parse_inst_t *)&cmd_read_reg,
8379 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8380 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8381 (cmdline_parse_inst_t *)&cmd_write_reg,
8382 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8383 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8384 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8385 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8386 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8387 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8388 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8389 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8390 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8391 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8392 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8393 (cmdline_parse_inst_t *)&cmd_stop,
8394 (cmdline_parse_inst_t *)&cmd_mac_addr,
8395 (cmdline_parse_inst_t *)&cmd_set_qmap,
8396 (cmdline_parse_inst_t *)&cmd_operate_port,
8397 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8398 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8399 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8400 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8401 (cmdline_parse_inst_t *)&cmd_config_mtu,
8402 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8403 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8404 (cmdline_parse_inst_t *)&cmd_config_rss,
8405 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8406 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8407 (cmdline_parse_inst_t *)&cmd_showport_reta,
8408 (cmdline_parse_inst_t *)&cmd_config_burst,
8409 (cmdline_parse_inst_t *)&cmd_config_thresh,
8410 (cmdline_parse_inst_t *)&cmd_config_threshold,
8411 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8412 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8413 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8414 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8415 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8416 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8417 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8418 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8419 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8420 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8421 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8422 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8423 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8424 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8425 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8426 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8427 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8428 (cmdline_parse_inst_t *)&cmd_dump,
8429 (cmdline_parse_inst_t *)&cmd_dump_one,
8430 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8431 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8432 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8433 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8434 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8435 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8436 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8437 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8438 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8439 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8440 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8441 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8442 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8443 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8444 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8445 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8446 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8447 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8448 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8452 /* prompt function, called from main on MASTER lcore */
8458 /* initialize non-constant commands */
8459 cmd_set_fwd_mode_init();
8461 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8465 cmdline_interact(cl);
8466 cmdline_stdin_exit(cl);
8470 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8472 if (id < nb_ports) {
8473 /* check if need_reconfig has been set to 1 */
8474 if (ports[id].need_reconfig == 0)
8475 ports[id].need_reconfig = dev;
8476 /* check if need_reconfig_queues has been set to 1 */
8477 if (ports[id].need_reconfig_queues == 0)
8478 ports[id].need_reconfig_queues = queue;
8482 for (pid = 0; pid < nb_ports; pid++) {
8483 /* check if need_reconfig has been set to 1 */
8484 if (ports[pid].need_reconfig == 0)
8485 ports[pid].need_reconfig = dev;
8486 /* check if need_reconfig_queues has been set to 1 */
8487 if (ports[pid].need_reconfig_queues == 0)
8488 ports[pid].need_reconfig_queues = queue;
8493 #ifdef RTE_NIC_BYPASS
8495 bypass_is_supported(portid_t port_id)
8497 struct rte_port *port;
8498 struct rte_pci_id *pci_id;
8500 if (port_id >= nb_ports) {
8501 printf("\tPort id must be less than %d.\n", nb_ports);
8505 /* Get the device id. */
8506 port = &ports[port_id];
8507 pci_id = &port->dev_info.pci_dev->id;
8509 /* Check if NIC supports bypass. */
8510 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8514 printf("\tBypass not supported for port_id = %d.\n", port_id);