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"
727 cmdline_parse_token_string_t cmd_help_long_help =
728 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
730 cmdline_parse_token_string_t cmd_help_long_section =
731 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
732 "all#control#display#config#flowdir#"
733 "ports#registers#filters");
735 cmdline_parse_inst_t cmd_help_long = {
736 .f = cmd_help_long_parsed,
738 .help_str = "show help",
740 (void *)&cmd_help_long_help,
741 (void *)&cmd_help_long_section,
747 /* *** start/stop/close all ports *** */
748 struct cmd_operate_port_result {
749 cmdline_fixed_string_t keyword;
750 cmdline_fixed_string_t name;
751 cmdline_fixed_string_t value;
754 static void cmd_operate_port_parsed(void *parsed_result,
755 __attribute__((unused)) struct cmdline *cl,
756 __attribute__((unused)) void *data)
758 struct cmd_operate_port_result *res = parsed_result;
760 if (!strcmp(res->name, "start"))
761 start_port(RTE_PORT_ALL);
762 else if (!strcmp(res->name, "stop"))
763 stop_port(RTE_PORT_ALL);
764 else if (!strcmp(res->name, "close"))
765 close_port(RTE_PORT_ALL);
767 printf("Unknown parameter\n");
770 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
771 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
773 cmdline_parse_token_string_t cmd_operate_port_all_port =
774 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
776 cmdline_parse_token_string_t cmd_operate_port_all_all =
777 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
779 cmdline_parse_inst_t cmd_operate_port = {
780 .f = cmd_operate_port_parsed,
782 .help_str = "port start|stop|close all: start/stop/close all ports",
784 (void *)&cmd_operate_port_all_cmd,
785 (void *)&cmd_operate_port_all_port,
786 (void *)&cmd_operate_port_all_all,
791 /* *** start/stop/close specific port *** */
792 struct cmd_operate_specific_port_result {
793 cmdline_fixed_string_t keyword;
794 cmdline_fixed_string_t name;
798 static void cmd_operate_specific_port_parsed(void *parsed_result,
799 __attribute__((unused)) struct cmdline *cl,
800 __attribute__((unused)) void *data)
802 struct cmd_operate_specific_port_result *res = parsed_result;
804 if (!strcmp(res->name, "start"))
805 start_port(res->value);
806 else if (!strcmp(res->name, "stop"))
807 stop_port(res->value);
808 else if (!strcmp(res->name, "close"))
809 close_port(res->value);
811 printf("Unknown parameter\n");
814 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
815 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
817 cmdline_parse_token_string_t cmd_operate_specific_port_port =
818 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
819 name, "start#stop#close");
820 cmdline_parse_token_num_t cmd_operate_specific_port_id =
821 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
824 cmdline_parse_inst_t cmd_operate_specific_port = {
825 .f = cmd_operate_specific_port_parsed,
827 .help_str = "port start|stop|close X: start/stop/close port X",
829 (void *)&cmd_operate_specific_port_cmd,
830 (void *)&cmd_operate_specific_port_port,
831 (void *)&cmd_operate_specific_port_id,
836 /* *** configure speed for all ports *** */
837 struct cmd_config_speed_all {
838 cmdline_fixed_string_t port;
839 cmdline_fixed_string_t keyword;
840 cmdline_fixed_string_t all;
841 cmdline_fixed_string_t item1;
842 cmdline_fixed_string_t item2;
843 cmdline_fixed_string_t value1;
844 cmdline_fixed_string_t value2;
848 cmd_config_speed_all_parsed(void *parsed_result,
849 __attribute__((unused)) struct cmdline *cl,
850 __attribute__((unused)) void *data)
852 struct cmd_config_speed_all *res = parsed_result;
853 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
854 uint16_t link_duplex = 0;
857 if (!all_ports_stopped()) {
858 printf("Please stop all ports first\n");
862 if (!strcmp(res->value1, "10"))
863 link_speed = ETH_LINK_SPEED_10;
864 else if (!strcmp(res->value1, "100"))
865 link_speed = ETH_LINK_SPEED_100;
866 else if (!strcmp(res->value1, "1000"))
867 link_speed = ETH_LINK_SPEED_1000;
868 else if (!strcmp(res->value1, "10000"))
869 link_speed = ETH_LINK_SPEED_10G;
870 else if (!strcmp(res->value1, "40000"))
871 link_speed = ETH_LINK_SPEED_40G;
872 else if (!strcmp(res->value1, "auto"))
873 link_speed = ETH_LINK_SPEED_AUTONEG;
875 printf("Unknown parameter\n");
879 if (!strcmp(res->value2, "half"))
880 link_duplex = ETH_LINK_HALF_DUPLEX;
881 else if (!strcmp(res->value2, "full"))
882 link_duplex = ETH_LINK_FULL_DUPLEX;
883 else if (!strcmp(res->value2, "auto"))
884 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
886 printf("Unknown parameter\n");
890 for (pid = 0; pid < nb_ports; pid++) {
891 ports[pid].dev_conf.link_speed = link_speed;
892 ports[pid].dev_conf.link_duplex = link_duplex;
895 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
898 cmdline_parse_token_string_t cmd_config_speed_all_port =
899 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
900 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
901 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
903 cmdline_parse_token_string_t cmd_config_speed_all_all =
904 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
905 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
906 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
907 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
908 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
909 "10#100#1000#10000#40000#auto");
910 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
911 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
912 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
913 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
916 cmdline_parse_inst_t cmd_config_speed_all = {
917 .f = cmd_config_speed_all_parsed,
919 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
922 (void *)&cmd_config_speed_all_port,
923 (void *)&cmd_config_speed_all_keyword,
924 (void *)&cmd_config_speed_all_all,
925 (void *)&cmd_config_speed_all_item1,
926 (void *)&cmd_config_speed_all_value1,
927 (void *)&cmd_config_speed_all_item2,
928 (void *)&cmd_config_speed_all_value2,
933 /* *** configure speed for specific port *** */
934 struct cmd_config_speed_specific {
935 cmdline_fixed_string_t port;
936 cmdline_fixed_string_t keyword;
938 cmdline_fixed_string_t item1;
939 cmdline_fixed_string_t item2;
940 cmdline_fixed_string_t value1;
941 cmdline_fixed_string_t value2;
945 cmd_config_speed_specific_parsed(void *parsed_result,
946 __attribute__((unused)) struct cmdline *cl,
947 __attribute__((unused)) void *data)
949 struct cmd_config_speed_specific *res = parsed_result;
950 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
951 uint16_t link_duplex = 0;
953 if (!all_ports_stopped()) {
954 printf("Please stop all ports first\n");
958 if (res->id >= nb_ports) {
959 printf("Port id %d must be less than %d\n", res->id, nb_ports);
963 if (!strcmp(res->value1, "10"))
964 link_speed = ETH_LINK_SPEED_10;
965 else if (!strcmp(res->value1, "100"))
966 link_speed = ETH_LINK_SPEED_100;
967 else if (!strcmp(res->value1, "1000"))
968 link_speed = ETH_LINK_SPEED_1000;
969 else if (!strcmp(res->value1, "10000"))
970 link_speed = ETH_LINK_SPEED_10000;
971 else if (!strcmp(res->value1, "40000"))
972 link_speed = ETH_LINK_SPEED_40G;
973 else if (!strcmp(res->value1, "auto"))
974 link_speed = ETH_LINK_SPEED_AUTONEG;
976 printf("Unknown parameter\n");
980 if (!strcmp(res->value2, "half"))
981 link_duplex = ETH_LINK_HALF_DUPLEX;
982 else if (!strcmp(res->value2, "full"))
983 link_duplex = ETH_LINK_FULL_DUPLEX;
984 else if (!strcmp(res->value2, "auto"))
985 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
987 printf("Unknown parameter\n");
991 ports[res->id].dev_conf.link_speed = link_speed;
992 ports[res->id].dev_conf.link_duplex = link_duplex;
994 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
998 cmdline_parse_token_string_t cmd_config_speed_specific_port =
999 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1001 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1002 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1004 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1005 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1006 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1007 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1009 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1010 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1011 "10#100#1000#10000#40000#auto");
1012 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1013 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1015 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1016 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1019 cmdline_parse_inst_t cmd_config_speed_specific = {
1020 .f = cmd_config_speed_specific_parsed,
1022 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1025 (void *)&cmd_config_speed_specific_port,
1026 (void *)&cmd_config_speed_specific_keyword,
1027 (void *)&cmd_config_speed_specific_id,
1028 (void *)&cmd_config_speed_specific_item1,
1029 (void *)&cmd_config_speed_specific_value1,
1030 (void *)&cmd_config_speed_specific_item2,
1031 (void *)&cmd_config_speed_specific_value2,
1036 /* *** configure txq/rxq, txd/rxd *** */
1037 struct cmd_config_rx_tx {
1038 cmdline_fixed_string_t port;
1039 cmdline_fixed_string_t keyword;
1040 cmdline_fixed_string_t all;
1041 cmdline_fixed_string_t name;
1046 cmd_config_rx_tx_parsed(void *parsed_result,
1047 __attribute__((unused)) struct cmdline *cl,
1048 __attribute__((unused)) void *data)
1050 struct cmd_config_rx_tx *res = parsed_result;
1052 if (!all_ports_stopped()) {
1053 printf("Please stop all ports first\n");
1057 if (!strcmp(res->name, "rxq")) {
1058 if (res->value <= 0) {
1059 printf("rxq %d invalid - must be > 0\n", res->value);
1062 nb_rxq = res->value;
1064 else if (!strcmp(res->name, "txq")) {
1065 if (res->value <= 0) {
1066 printf("txq %d invalid - must be > 0\n", res->value);
1069 nb_txq = res->value;
1071 else if (!strcmp(res->name, "rxd")) {
1072 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1073 printf("rxd %d invalid - must be > 0 && <= %d\n",
1074 res->value, RTE_TEST_RX_DESC_MAX);
1077 nb_rxd = res->value;
1078 } else if (!strcmp(res->name, "txd")) {
1079 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1080 printf("txd %d invalid - must be > 0 && <= %d\n",
1081 res->value, RTE_TEST_TX_DESC_MAX);
1084 nb_txd = res->value;
1086 printf("Unknown parameter\n");
1092 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1095 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1096 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1097 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1098 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1099 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1100 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1101 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1102 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1104 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1105 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1107 cmdline_parse_inst_t cmd_config_rx_tx = {
1108 .f = cmd_config_rx_tx_parsed,
1110 .help_str = "port config all rxq|txq|rxd|txd value",
1112 (void *)&cmd_config_rx_tx_port,
1113 (void *)&cmd_config_rx_tx_keyword,
1114 (void *)&cmd_config_rx_tx_all,
1115 (void *)&cmd_config_rx_tx_name,
1116 (void *)&cmd_config_rx_tx_value,
1121 /* *** config max packet length *** */
1122 struct cmd_config_max_pkt_len_result {
1123 cmdline_fixed_string_t port;
1124 cmdline_fixed_string_t keyword;
1125 cmdline_fixed_string_t all;
1126 cmdline_fixed_string_t name;
1131 cmd_config_max_pkt_len_parsed(void *parsed_result,
1132 __attribute__((unused)) struct cmdline *cl,
1133 __attribute__((unused)) void *data)
1135 struct cmd_config_max_pkt_len_result *res = parsed_result;
1137 if (!all_ports_stopped()) {
1138 printf("Please stop all ports first\n");
1142 if (!strcmp(res->name, "max-pkt-len")) {
1143 if (res->value < ETHER_MIN_LEN) {
1144 printf("max-pkt-len can not be less than %d\n",
1148 if (res->value == rx_mode.max_rx_pkt_len)
1151 rx_mode.max_rx_pkt_len = res->value;
1152 if (res->value > ETHER_MAX_LEN)
1153 rx_mode.jumbo_frame = 1;
1155 rx_mode.jumbo_frame = 0;
1157 printf("Unknown parameter\n");
1163 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1166 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1167 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1169 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1170 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1172 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1175 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1176 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1178 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1179 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1182 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1183 .f = cmd_config_max_pkt_len_parsed,
1185 .help_str = "port config all max-pkt-len value",
1187 (void *)&cmd_config_max_pkt_len_port,
1188 (void *)&cmd_config_max_pkt_len_keyword,
1189 (void *)&cmd_config_max_pkt_len_all,
1190 (void *)&cmd_config_max_pkt_len_name,
1191 (void *)&cmd_config_max_pkt_len_value,
1196 /* *** configure port MTU *** */
1197 struct cmd_config_mtu_result {
1198 cmdline_fixed_string_t port;
1199 cmdline_fixed_string_t keyword;
1200 cmdline_fixed_string_t mtu;
1206 cmd_config_mtu_parsed(void *parsed_result,
1207 __attribute__((unused)) struct cmdline *cl,
1208 __attribute__((unused)) void *data)
1210 struct cmd_config_mtu_result *res = parsed_result;
1212 if (res->value < ETHER_MIN_LEN) {
1213 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1216 port_mtu_set(res->port_id, res->value);
1219 cmdline_parse_token_string_t cmd_config_mtu_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1222 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1225 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1226 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1228 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1229 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1230 cmdline_parse_token_num_t cmd_config_mtu_value =
1231 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1233 cmdline_parse_inst_t cmd_config_mtu = {
1234 .f = cmd_config_mtu_parsed,
1236 .help_str = "port config mtu value",
1238 (void *)&cmd_config_mtu_port,
1239 (void *)&cmd_config_mtu_keyword,
1240 (void *)&cmd_config_mtu_mtu,
1241 (void *)&cmd_config_mtu_port_id,
1242 (void *)&cmd_config_mtu_value,
1247 /* *** configure rx mode *** */
1248 struct cmd_config_rx_mode_flag {
1249 cmdline_fixed_string_t port;
1250 cmdline_fixed_string_t keyword;
1251 cmdline_fixed_string_t all;
1252 cmdline_fixed_string_t name;
1253 cmdline_fixed_string_t value;
1257 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1258 __attribute__((unused)) struct cmdline *cl,
1259 __attribute__((unused)) void *data)
1261 struct cmd_config_rx_mode_flag *res = parsed_result;
1263 if (!all_ports_stopped()) {
1264 printf("Please stop all ports first\n");
1268 if (!strcmp(res->name, "crc-strip")) {
1269 if (!strcmp(res->value, "on"))
1270 rx_mode.hw_strip_crc = 1;
1271 else if (!strcmp(res->value, "off"))
1272 rx_mode.hw_strip_crc = 0;
1274 printf("Unknown parameter\n");
1277 } else if (!strcmp(res->name, "rx-cksum")) {
1278 if (!strcmp(res->value, "on"))
1279 rx_mode.hw_ip_checksum = 1;
1280 else if (!strcmp(res->value, "off"))
1281 rx_mode.hw_ip_checksum = 0;
1283 printf("Unknown parameter\n");
1286 } else if (!strcmp(res->name, "hw-vlan")) {
1287 if (!strcmp(res->value, "on")) {
1288 rx_mode.hw_vlan_filter = 1;
1289 rx_mode.hw_vlan_strip = 1;
1291 else if (!strcmp(res->value, "off")) {
1292 rx_mode.hw_vlan_filter = 0;
1293 rx_mode.hw_vlan_strip = 0;
1296 printf("Unknown parameter\n");
1299 } else if (!strcmp(res->name, "drop-en")) {
1300 if (!strcmp(res->value, "on"))
1302 else if (!strcmp(res->value, "off"))
1305 printf("Unknown parameter\n");
1309 printf("Unknown parameter\n");
1315 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1318 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1320 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1321 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1323 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1325 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1327 "crc-strip#rx-cksum#hw-vlan");
1328 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1329 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1332 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1333 .f = cmd_config_rx_mode_flag_parsed,
1335 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1337 (void *)&cmd_config_rx_mode_flag_port,
1338 (void *)&cmd_config_rx_mode_flag_keyword,
1339 (void *)&cmd_config_rx_mode_flag_all,
1340 (void *)&cmd_config_rx_mode_flag_name,
1341 (void *)&cmd_config_rx_mode_flag_value,
1346 /* *** configure rss *** */
1347 struct cmd_config_rss {
1348 cmdline_fixed_string_t port;
1349 cmdline_fixed_string_t keyword;
1350 cmdline_fixed_string_t all;
1351 cmdline_fixed_string_t name;
1352 cmdline_fixed_string_t value;
1356 cmd_config_rss_parsed(void *parsed_result,
1357 __attribute__((unused)) struct cmdline *cl,
1358 __attribute__((unused)) void *data)
1360 struct cmd_config_rss *res = parsed_result;
1361 struct rte_eth_rss_conf rss_conf;
1364 if (!strcmp(res->value, "ip"))
1365 rss_conf.rss_hf = ETH_RSS_IP;
1366 else if (!strcmp(res->value, "udp"))
1367 rss_conf.rss_hf = ETH_RSS_UDP;
1368 else if (!strcmp(res->value, "none"))
1369 rss_conf.rss_hf = 0;
1371 printf("Unknown parameter\n");
1374 rss_conf.rss_key = NULL;
1375 for (i = 0; i < rte_eth_dev_count(); i++)
1376 rte_eth_dev_rss_hash_update(i, &rss_conf);
1379 cmdline_parse_token_string_t cmd_config_rss_port =
1380 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1381 cmdline_parse_token_string_t cmd_config_rss_keyword =
1382 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1383 cmdline_parse_token_string_t cmd_config_rss_all =
1384 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1385 cmdline_parse_token_string_t cmd_config_rss_name =
1386 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1387 cmdline_parse_token_string_t cmd_config_rss_value =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1390 cmdline_parse_inst_t cmd_config_rss = {
1391 .f = cmd_config_rss_parsed,
1393 .help_str = "port config all rss ip|udp|none",
1395 (void *)&cmd_config_rss_port,
1396 (void *)&cmd_config_rss_keyword,
1397 (void *)&cmd_config_rss_all,
1398 (void *)&cmd_config_rss_name,
1399 (void *)&cmd_config_rss_value,
1404 /* *** configure rss hash key *** */
1405 struct cmd_config_rss_hash_key {
1406 cmdline_fixed_string_t port;
1407 cmdline_fixed_string_t config;
1409 cmdline_fixed_string_t rss_hash_key;
1410 cmdline_fixed_string_t key;
1413 #define RSS_HASH_KEY_LENGTH 40
1415 hexa_digit_to_value(char hexa_digit)
1417 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1418 return (uint8_t) (hexa_digit - '0');
1419 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1420 return (uint8_t) ((hexa_digit - 'a') + 10);
1421 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1422 return (uint8_t) ((hexa_digit - 'A') + 10);
1423 /* Invalid hexa digit */
1428 parse_and_check_key_hexa_digit(char *key, int idx)
1432 hexa_v = hexa_digit_to_value(key[idx]);
1434 printf("invalid key: character %c at position %d is not a "
1435 "valid hexa digit\n", key[idx], idx);
1440 cmd_config_rss_hash_key_parsed(void *parsed_result,
1441 __attribute__((unused)) struct cmdline *cl,
1442 __attribute__((unused)) void *data)
1444 struct cmd_config_rss_hash_key *res = parsed_result;
1445 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1450 /* Check the length of the RSS hash key */
1451 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1452 printf("key length: %d invalid - key must be a string of %d"
1453 "hexa-decimal numbers\n", (int) strlen(res->key),
1454 RSS_HASH_KEY_LENGTH * 2);
1457 /* Translate RSS hash key into binary representation */
1458 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1459 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1462 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1465 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1467 port_rss_hash_key_update(res->port_id, hash_key);
1470 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1471 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1472 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1473 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1475 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1476 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1477 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1479 rss_hash_key, "rss-hash-key");
1480 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1483 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1484 .f = cmd_config_rss_hash_key_parsed,
1486 .help_str = "port config X rss-hash-key 80 hexa digits",
1488 (void *)&cmd_config_rss_hash_key_port,
1489 (void *)&cmd_config_rss_hash_key_config,
1490 (void *)&cmd_config_rss_hash_key_port_id,
1491 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1492 (void *)&cmd_config_rss_hash_key_value,
1497 /* *** configure port rxq/txq start/stop *** */
1498 struct cmd_config_rxtx_queue {
1499 cmdline_fixed_string_t port;
1501 cmdline_fixed_string_t rxtxq;
1503 cmdline_fixed_string_t opname;
1507 cmd_config_rxtx_queue_parsed(void *parsed_result,
1508 __attribute__((unused)) struct cmdline *cl,
1509 __attribute__((unused)) void *data)
1511 struct cmd_config_rxtx_queue *res = parsed_result;
1516 if (test_done == 0) {
1517 printf("Please stop forwarding first\n");
1521 if (port_id_is_invalid(res->portid))
1524 if (port_is_started(res->portid) != 1) {
1525 printf("Please start port %u first\n", res->portid);
1529 if (!strcmp(res->rxtxq, "rxq"))
1531 else if (!strcmp(res->rxtxq, "txq"))
1534 printf("Unknown parameter\n");
1538 if (isrx && rx_queue_id_is_invalid(res->qid))
1540 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1543 if (!strcmp(res->opname, "start"))
1545 else if (!strcmp(res->opname, "stop"))
1548 printf("Unknown parameter\n");
1552 if (isstart && isrx)
1553 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1554 else if (!isstart && isrx)
1555 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1556 else if (isstart && !isrx)
1557 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1559 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1561 if (ret == -ENOTSUP)
1562 printf("Function not supported in PMD driver\n");
1565 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1567 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1568 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1569 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1571 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1572 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1573 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1577 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1578 .f = cmd_config_rxtx_queue_parsed,
1580 .help_str = "port X rxq|txq ID start|stop",
1582 (void *)&cmd_config_speed_all_port,
1583 (void *)&cmd_config_rxtx_queue_portid,
1584 (void *)&cmd_config_rxtx_queue_rxtxq,
1585 (void *)&cmd_config_rxtx_queue_qid,
1586 (void *)&cmd_config_rxtx_queue_opname,
1591 /* *** Configure RSS RETA *** */
1592 struct cmd_config_rss_reta {
1593 cmdline_fixed_string_t port;
1594 cmdline_fixed_string_t keyword;
1596 cmdline_fixed_string_t name;
1597 cmdline_fixed_string_t list_name;
1598 cmdline_fixed_string_t list_of_items;
1602 parse_reta_config(const char *str,
1603 struct rte_eth_rss_reta_entry64 *reta_conf,
1604 uint16_t nb_entries)
1608 uint16_t hash_index, idx, shift;
1611 const char *p, *p0 = str;
1618 unsigned long int_fld[_NUM_FLD];
1619 char *str_fld[_NUM_FLD];
1621 while ((p = strchr(p0,'(')) != NULL) {
1623 if((p0 = strchr(p,')')) == NULL)
1627 if(size >= sizeof(s))
1630 snprintf(s, sizeof(s), "%.*s", size, p);
1631 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1633 for (i = 0; i < _NUM_FLD; i++) {
1635 int_fld[i] = strtoul(str_fld[i], &end, 0);
1636 if (errno != 0 || end == str_fld[i] ||
1641 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1642 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1644 if (hash_index >= nb_entries) {
1645 printf("Invalid RETA hash index=%d\n", hash_index);
1649 idx = hash_index / RTE_RETA_GROUP_SIZE;
1650 shift = hash_index % RTE_RETA_GROUP_SIZE;
1651 reta_conf[idx].mask |= (1ULL << shift);
1652 reta_conf[idx].reta[shift] = nb_queue;
1659 cmd_set_rss_reta_parsed(void *parsed_result,
1660 __attribute__((unused)) struct cmdline *cl,
1661 __attribute__((unused)) void *data)
1664 struct rte_eth_dev_info dev_info;
1665 struct rte_eth_rss_reta_entry64 reta_conf[8];
1666 struct cmd_config_rss_reta *res = parsed_result;
1668 memset(&dev_info, 0, sizeof(dev_info));
1669 rte_eth_dev_info_get(res->port_id, &dev_info);
1670 if (dev_info.reta_size == 0) {
1671 printf("Redirection table size is 0 which is "
1672 "invalid for RSS\n");
1675 printf("The reta size of port %d is %u\n",
1676 res->port_id, dev_info.reta_size);
1677 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1678 printf("Currently do not support more than %u entries of "
1679 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1683 memset(reta_conf, 0, sizeof(reta_conf));
1684 if (!strcmp(res->list_name, "reta")) {
1685 if (parse_reta_config(res->list_of_items, reta_conf,
1686 dev_info.reta_size)) {
1687 printf("Invalid RSS Redirection Table "
1688 "config entered\n");
1691 ret = rte_eth_dev_rss_reta_update(res->port_id,
1692 reta_conf, dev_info.reta_size);
1694 printf("Bad redirection table parameter, "
1695 "return code = %d \n", ret);
1699 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1701 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1703 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1704 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1705 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1707 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1709 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1712 cmdline_parse_inst_t cmd_config_rss_reta = {
1713 .f = cmd_set_rss_reta_parsed,
1715 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1717 (void *)&cmd_config_rss_reta_port,
1718 (void *)&cmd_config_rss_reta_keyword,
1719 (void *)&cmd_config_rss_reta_port_id,
1720 (void *)&cmd_config_rss_reta_name,
1721 (void *)&cmd_config_rss_reta_list_name,
1722 (void *)&cmd_config_rss_reta_list_of_items,
1727 /* *** SHOW PORT RETA INFO *** */
1728 struct cmd_showport_reta {
1729 cmdline_fixed_string_t show;
1730 cmdline_fixed_string_t port;
1732 cmdline_fixed_string_t rss;
1733 cmdline_fixed_string_t reta;
1735 cmdline_fixed_string_t list_of_items;
1739 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1740 uint16_t nb_entries,
1744 const char *p, *p0 = str;
1748 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1751 p = strchr(p0, '(');
1755 p0 = strchr(p, ')');
1759 if (size >= sizeof(s)) {
1760 printf("The string size exceeds the internal buffer size\n");
1763 snprintf(s, sizeof(s), "%.*s", size, p);
1764 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1765 if (ret <= 0 || ret != num) {
1766 printf("The bits of masks do not match the number of "
1767 "reta entries: %u\n", num);
1770 for (i = 0; i < ret; i++)
1771 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1777 cmd_showport_reta_parsed(void *parsed_result,
1778 __attribute__((unused)) struct cmdline *cl,
1779 __attribute__((unused)) void *data)
1781 struct cmd_showport_reta *res = parsed_result;
1782 struct rte_eth_rss_reta_entry64 reta_conf[8];
1783 struct rte_eth_dev_info dev_info;
1785 memset(&dev_info, 0, sizeof(dev_info));
1786 rte_eth_dev_info_get(res->port_id, &dev_info);
1787 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1788 res->size > ETH_RSS_RETA_SIZE_512) {
1789 printf("Invalid redirection table size: %u\n", res->size);
1793 memset(reta_conf, 0, sizeof(reta_conf));
1794 if (showport_parse_reta_config(reta_conf, res->size,
1795 res->list_of_items) < 0) {
1796 printf("Invalid string: %s for reta masks\n",
1797 res->list_of_items);
1800 port_rss_reta_info(res->port_id, reta_conf, res->size);
1803 cmdline_parse_token_string_t cmd_showport_reta_show =
1804 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1805 cmdline_parse_token_string_t cmd_showport_reta_port =
1806 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1807 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1808 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1809 cmdline_parse_token_string_t cmd_showport_reta_rss =
1810 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1811 cmdline_parse_token_string_t cmd_showport_reta_reta =
1812 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1813 cmdline_parse_token_num_t cmd_showport_reta_size =
1814 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1815 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1816 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1817 list_of_items, NULL);
1819 cmdline_parse_inst_t cmd_showport_reta = {
1820 .f = cmd_showport_reta_parsed,
1822 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1824 (void *)&cmd_showport_reta_show,
1825 (void *)&cmd_showport_reta_port,
1826 (void *)&cmd_showport_reta_port_id,
1827 (void *)&cmd_showport_reta_rss,
1828 (void *)&cmd_showport_reta_reta,
1829 (void *)&cmd_showport_reta_size,
1830 (void *)&cmd_showport_reta_list_of_items,
1835 /* *** Show RSS hash configuration *** */
1836 struct cmd_showport_rss_hash {
1837 cmdline_fixed_string_t show;
1838 cmdline_fixed_string_t port;
1840 cmdline_fixed_string_t rss_hash;
1841 cmdline_fixed_string_t key; /* optional argument */
1844 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1845 __attribute__((unused)) struct cmdline *cl,
1848 struct cmd_showport_rss_hash *res = parsed_result;
1850 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1853 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1854 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1855 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1857 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1858 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1859 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1860 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1862 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1863 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1865 cmdline_parse_inst_t cmd_showport_rss_hash = {
1866 .f = cmd_showport_rss_hash_parsed,
1868 .help_str = "show port X rss-hash (X = port number)\n",
1870 (void *)&cmd_showport_rss_hash_show,
1871 (void *)&cmd_showport_rss_hash_port,
1872 (void *)&cmd_showport_rss_hash_port_id,
1873 (void *)&cmd_showport_rss_hash_rss_hash,
1878 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1879 .f = cmd_showport_rss_hash_parsed,
1881 .help_str = "show port X rss-hash key (X = port number)\n",
1883 (void *)&cmd_showport_rss_hash_show,
1884 (void *)&cmd_showport_rss_hash_port,
1885 (void *)&cmd_showport_rss_hash_port_id,
1886 (void *)&cmd_showport_rss_hash_rss_hash,
1887 (void *)&cmd_showport_rss_hash_rss_key,
1892 /* *** Configure DCB *** */
1893 struct cmd_config_dcb {
1894 cmdline_fixed_string_t port;
1895 cmdline_fixed_string_t config;
1897 cmdline_fixed_string_t dcb;
1898 cmdline_fixed_string_t vt;
1899 cmdline_fixed_string_t vt_en;
1901 cmdline_fixed_string_t pfc;
1902 cmdline_fixed_string_t pfc_en;
1906 cmd_config_dcb_parsed(void *parsed_result,
1907 __attribute__((unused)) struct cmdline *cl,
1908 __attribute__((unused)) void *data)
1910 struct cmd_config_dcb *res = parsed_result;
1911 struct dcb_config dcb_conf;
1912 portid_t port_id = res->port_id;
1913 struct rte_port *port;
1915 port = &ports[port_id];
1916 /** Check if the port is not started **/
1917 if (port->port_status != RTE_PORT_STOPPED) {
1918 printf("Please stop port %d first\n",port_id);
1922 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1923 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1924 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1928 /* DCB in VT mode */
1929 if (!strncmp(res->vt_en, "on",2))
1930 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1932 dcb_conf.dcb_mode = DCB_ENABLED;
1934 if (!strncmp(res->pfc_en, "on",2)) {
1935 dcb_conf.pfc_en = 1;
1938 dcb_conf.pfc_en = 0;
1940 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1941 printf("Cannot initialize network ports\n");
1945 cmd_reconfig_device_queue(port_id, 1, 1);
1948 cmdline_parse_token_string_t cmd_config_dcb_port =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1950 cmdline_parse_token_string_t cmd_config_dcb_config =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1952 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1953 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1954 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1956 cmdline_parse_token_string_t cmd_config_dcb_vt =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1958 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1959 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1960 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1961 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1962 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1964 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1965 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1967 cmdline_parse_inst_t cmd_config_dcb = {
1968 .f = cmd_config_dcb_parsed,
1970 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1972 (void *)&cmd_config_dcb_port,
1973 (void *)&cmd_config_dcb_config,
1974 (void *)&cmd_config_dcb_port_id,
1975 (void *)&cmd_config_dcb_dcb,
1976 (void *)&cmd_config_dcb_vt,
1977 (void *)&cmd_config_dcb_vt_en,
1978 (void *)&cmd_config_dcb_num_tcs,
1979 (void *)&cmd_config_dcb_pfc,
1980 (void *)&cmd_config_dcb_pfc_en,
1985 /* *** configure number of packets per burst *** */
1986 struct cmd_config_burst {
1987 cmdline_fixed_string_t port;
1988 cmdline_fixed_string_t keyword;
1989 cmdline_fixed_string_t all;
1990 cmdline_fixed_string_t name;
1995 cmd_config_burst_parsed(void *parsed_result,
1996 __attribute__((unused)) struct cmdline *cl,
1997 __attribute__((unused)) void *data)
1999 struct cmd_config_burst *res = parsed_result;
2001 if (!all_ports_stopped()) {
2002 printf("Please stop all ports first\n");
2006 if (!strcmp(res->name, "burst")) {
2007 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2008 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2011 nb_pkt_per_burst = res->value;
2013 printf("Unknown parameter\n");
2019 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2022 cmdline_parse_token_string_t cmd_config_burst_port =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2024 cmdline_parse_token_string_t cmd_config_burst_keyword =
2025 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2026 cmdline_parse_token_string_t cmd_config_burst_all =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2028 cmdline_parse_token_string_t cmd_config_burst_name =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2030 cmdline_parse_token_num_t cmd_config_burst_value =
2031 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2033 cmdline_parse_inst_t cmd_config_burst = {
2034 .f = cmd_config_burst_parsed,
2036 .help_str = "port config all burst value",
2038 (void *)&cmd_config_burst_port,
2039 (void *)&cmd_config_burst_keyword,
2040 (void *)&cmd_config_burst_all,
2041 (void *)&cmd_config_burst_name,
2042 (void *)&cmd_config_burst_value,
2047 /* *** configure rx/tx queues *** */
2048 struct cmd_config_thresh {
2049 cmdline_fixed_string_t port;
2050 cmdline_fixed_string_t keyword;
2051 cmdline_fixed_string_t all;
2052 cmdline_fixed_string_t name;
2057 cmd_config_thresh_parsed(void *parsed_result,
2058 __attribute__((unused)) struct cmdline *cl,
2059 __attribute__((unused)) void *data)
2061 struct cmd_config_thresh *res = parsed_result;
2063 if (!all_ports_stopped()) {
2064 printf("Please stop all ports first\n");
2068 if (!strcmp(res->name, "txpt"))
2069 tx_thresh.pthresh = res->value;
2070 else if(!strcmp(res->name, "txht"))
2071 tx_thresh.hthresh = res->value;
2072 else if(!strcmp(res->name, "txwt"))
2073 tx_thresh.wthresh = res->value;
2074 else if(!strcmp(res->name, "rxpt"))
2075 rx_thresh.pthresh = res->value;
2076 else if(!strcmp(res->name, "rxht"))
2077 rx_thresh.hthresh = res->value;
2078 else if(!strcmp(res->name, "rxwt"))
2079 rx_thresh.wthresh = res->value;
2081 printf("Unknown parameter\n");
2087 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2090 cmdline_parse_token_string_t cmd_config_thresh_port =
2091 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2092 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2093 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2094 cmdline_parse_token_string_t cmd_config_thresh_all =
2095 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2096 cmdline_parse_token_string_t cmd_config_thresh_name =
2097 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2098 "txpt#txht#txwt#rxpt#rxht#rxwt");
2099 cmdline_parse_token_num_t cmd_config_thresh_value =
2100 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2102 cmdline_parse_inst_t cmd_config_thresh = {
2103 .f = cmd_config_thresh_parsed,
2105 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2107 (void *)&cmd_config_thresh_port,
2108 (void *)&cmd_config_thresh_keyword,
2109 (void *)&cmd_config_thresh_all,
2110 (void *)&cmd_config_thresh_name,
2111 (void *)&cmd_config_thresh_value,
2116 /* *** configure free/rs threshold *** */
2117 struct cmd_config_threshold {
2118 cmdline_fixed_string_t port;
2119 cmdline_fixed_string_t keyword;
2120 cmdline_fixed_string_t all;
2121 cmdline_fixed_string_t name;
2126 cmd_config_threshold_parsed(void *parsed_result,
2127 __attribute__((unused)) struct cmdline *cl,
2128 __attribute__((unused)) void *data)
2130 struct cmd_config_threshold *res = parsed_result;
2132 if (!all_ports_stopped()) {
2133 printf("Please stop all ports first\n");
2137 if (!strcmp(res->name, "txfreet"))
2138 tx_free_thresh = res->value;
2139 else if (!strcmp(res->name, "txrst"))
2140 tx_rs_thresh = res->value;
2141 else if (!strcmp(res->name, "rxfreet"))
2142 rx_free_thresh = res->value;
2144 printf("Unknown parameter\n");
2150 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2153 cmdline_parse_token_string_t cmd_config_threshold_port =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2155 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2158 cmdline_parse_token_string_t cmd_config_threshold_all =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2160 cmdline_parse_token_string_t cmd_config_threshold_name =
2161 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2162 "txfreet#txrst#rxfreet");
2163 cmdline_parse_token_num_t cmd_config_threshold_value =
2164 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2166 cmdline_parse_inst_t cmd_config_threshold = {
2167 .f = cmd_config_threshold_parsed,
2169 .help_str = "port config all txfreet|txrst|rxfreet value",
2171 (void *)&cmd_config_threshold_port,
2172 (void *)&cmd_config_threshold_keyword,
2173 (void *)&cmd_config_threshold_all,
2174 (void *)&cmd_config_threshold_name,
2175 (void *)&cmd_config_threshold_value,
2181 struct cmd_stop_result {
2182 cmdline_fixed_string_t stop;
2185 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2186 __attribute__((unused)) struct cmdline *cl,
2187 __attribute__((unused)) void *data)
2189 stop_packet_forwarding();
2192 cmdline_parse_token_string_t cmd_stop_stop =
2193 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2195 cmdline_parse_inst_t cmd_stop = {
2196 .f = cmd_stop_parsed,
2198 .help_str = "stop - stop packet forwarding",
2200 (void *)&cmd_stop_stop,
2205 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2208 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2209 unsigned int *parsed_items, int check_unique_values)
2211 unsigned int nb_item;
2219 * First parse all items in the list and store their value.
2224 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2226 if ((c >= '0') && (c <= '9')) {
2227 value = (unsigned int) (value * 10 + (c - '0'));
2232 printf("character %c is not a decimal digit\n", c);
2236 printf("No valid value before comma\n");
2239 if (nb_item < max_items) {
2240 parsed_items[nb_item] = value;
2246 if (nb_item >= max_items) {
2247 printf("Number of %s = %u > %u (maximum items)\n",
2248 item_name, nb_item + 1, max_items);
2251 parsed_items[nb_item++] = value;
2252 if (! check_unique_values)
2256 * Then, check that all values in the list are differents.
2257 * No optimization here...
2259 for (i = 0; i < nb_item; i++) {
2260 for (j = i + 1; j < nb_item; j++) {
2261 if (parsed_items[j] == parsed_items[i]) {
2262 printf("duplicated %s %u at index %u and %u\n",
2263 item_name, parsed_items[i], i, j);
2271 struct cmd_set_list_result {
2272 cmdline_fixed_string_t cmd_keyword;
2273 cmdline_fixed_string_t list_name;
2274 cmdline_fixed_string_t list_of_items;
2277 static void cmd_set_list_parsed(void *parsed_result,
2278 __attribute__((unused)) struct cmdline *cl,
2279 __attribute__((unused)) void *data)
2281 struct cmd_set_list_result *res;
2283 unsigned int lcorelist[RTE_MAX_LCORE];
2284 unsigned int portlist[RTE_MAX_ETHPORTS];
2286 unsigned int nb_item;
2288 res = parsed_result;
2289 if (!strcmp(res->list_name, "corelist")) {
2290 nb_item = parse_item_list(res->list_of_items, "core",
2292 parsed_items.lcorelist, 1);
2294 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2297 if (!strcmp(res->list_name, "portlist")) {
2298 nb_item = parse_item_list(res->list_of_items, "port",
2300 parsed_items.portlist, 1);
2302 set_fwd_ports_list(parsed_items.portlist, nb_item);
2306 cmdline_parse_token_string_t cmd_set_list_keyword =
2307 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2309 cmdline_parse_token_string_t cmd_set_list_name =
2310 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2311 "corelist#portlist");
2312 cmdline_parse_token_string_t cmd_set_list_of_items =
2313 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2316 cmdline_parse_inst_t cmd_set_fwd_list = {
2317 .f = cmd_set_list_parsed,
2319 .help_str = "set corelist|portlist x[,y]*",
2321 (void *)&cmd_set_list_keyword,
2322 (void *)&cmd_set_list_name,
2323 (void *)&cmd_set_list_of_items,
2328 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2330 struct cmd_setmask_result {
2331 cmdline_fixed_string_t set;
2332 cmdline_fixed_string_t mask;
2336 static void cmd_set_mask_parsed(void *parsed_result,
2337 __attribute__((unused)) struct cmdline *cl,
2338 __attribute__((unused)) void *data)
2340 struct cmd_setmask_result *res = parsed_result;
2342 if (!strcmp(res->mask, "coremask"))
2343 set_fwd_lcores_mask(res->hexavalue);
2344 else if (!strcmp(res->mask, "portmask"))
2345 set_fwd_ports_mask(res->hexavalue);
2348 cmdline_parse_token_string_t cmd_setmask_set =
2349 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2350 cmdline_parse_token_string_t cmd_setmask_mask =
2351 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2352 "coremask#portmask");
2353 cmdline_parse_token_num_t cmd_setmask_value =
2354 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2356 cmdline_parse_inst_t cmd_set_fwd_mask = {
2357 .f = cmd_set_mask_parsed,
2359 .help_str = "set coremask|portmask hexadecimal value",
2361 (void *)&cmd_setmask_set,
2362 (void *)&cmd_setmask_mask,
2363 (void *)&cmd_setmask_value,
2369 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2371 struct cmd_set_result {
2372 cmdline_fixed_string_t set;
2373 cmdline_fixed_string_t what;
2377 static void cmd_set_parsed(void *parsed_result,
2378 __attribute__((unused)) struct cmdline *cl,
2379 __attribute__((unused)) void *data)
2381 struct cmd_set_result *res = parsed_result;
2382 if (!strcmp(res->what, "nbport"))
2383 set_fwd_ports_number(res->value);
2384 else if (!strcmp(res->what, "nbcore"))
2385 set_fwd_lcores_number(res->value);
2386 else if (!strcmp(res->what, "burst"))
2387 set_nb_pkt_per_burst(res->value);
2388 else if (!strcmp(res->what, "verbose"))
2389 set_verbose_level(res->value);
2392 cmdline_parse_token_string_t cmd_set_set =
2393 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2394 cmdline_parse_token_string_t cmd_set_what =
2395 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2396 "nbport#nbcore#burst#verbose");
2397 cmdline_parse_token_num_t cmd_set_value =
2398 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2400 cmdline_parse_inst_t cmd_set_numbers = {
2401 .f = cmd_set_parsed,
2403 .help_str = "set nbport|nbcore|burst|verbose value",
2405 (void *)&cmd_set_set,
2406 (void *)&cmd_set_what,
2407 (void *)&cmd_set_value,
2412 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2414 struct cmd_set_txpkts_result {
2415 cmdline_fixed_string_t cmd_keyword;
2416 cmdline_fixed_string_t txpkts;
2417 cmdline_fixed_string_t seg_lengths;
2421 cmd_set_txpkts_parsed(void *parsed_result,
2422 __attribute__((unused)) struct cmdline *cl,
2423 __attribute__((unused)) void *data)
2425 struct cmd_set_txpkts_result *res;
2426 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2427 unsigned int nb_segs;
2429 res = parsed_result;
2430 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2431 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2433 set_tx_pkt_segments(seg_lengths, nb_segs);
2436 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2437 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2438 cmd_keyword, "set");
2439 cmdline_parse_token_string_t cmd_set_txpkts_name =
2440 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2442 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2443 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2446 cmdline_parse_inst_t cmd_set_txpkts = {
2447 .f = cmd_set_txpkts_parsed,
2449 .help_str = "set txpkts x[,y]*",
2451 (void *)&cmd_set_txpkts_keyword,
2452 (void *)&cmd_set_txpkts_name,
2453 (void *)&cmd_set_txpkts_lengths,
2458 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2459 struct cmd_rx_vlan_filter_all_result {
2460 cmdline_fixed_string_t rx_vlan;
2461 cmdline_fixed_string_t what;
2462 cmdline_fixed_string_t all;
2467 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2468 __attribute__((unused)) struct cmdline *cl,
2469 __attribute__((unused)) void *data)
2471 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2473 if (!strcmp(res->what, "add"))
2474 rx_vlan_all_filter_set(res->port_id, 1);
2476 rx_vlan_all_filter_set(res->port_id, 0);
2479 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2480 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2481 rx_vlan, "rx_vlan");
2482 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2483 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2485 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2486 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2488 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2489 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2492 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2493 .f = cmd_rx_vlan_filter_all_parsed,
2495 .help_str = "add/remove all identifiers to/from the set of VLAN "
2496 "Identifiers filtered by a port",
2498 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2499 (void *)&cmd_rx_vlan_filter_all_what,
2500 (void *)&cmd_rx_vlan_filter_all_all,
2501 (void *)&cmd_rx_vlan_filter_all_portid,
2506 /* *** VLAN OFFLOAD SET ON A PORT *** */
2507 struct cmd_vlan_offload_result {
2508 cmdline_fixed_string_t vlan;
2509 cmdline_fixed_string_t set;
2510 cmdline_fixed_string_t what;
2511 cmdline_fixed_string_t on;
2512 cmdline_fixed_string_t port_id;
2516 cmd_vlan_offload_parsed(void *parsed_result,
2517 __attribute__((unused)) struct cmdline *cl,
2518 __attribute__((unused)) void *data)
2521 struct cmd_vlan_offload_result *res = parsed_result;
2524 portid_t port_id = 0;
2528 len = strnlen(str, STR_TOKEN_SIZE);
2530 /* Get port_id first */
2538 tmp = strtoul(str, NULL, 0);
2539 /* If port_id greater that what portid_t can represent, return */
2540 if(tmp >= RTE_MAX_ETHPORTS)
2542 port_id = (portid_t)tmp;
2544 if (!strcmp(res->on, "on"))
2549 if (!strcmp(res->what, "strip"))
2550 rx_vlan_strip_set(port_id, on);
2551 else if(!strcmp(res->what, "stripq")){
2552 uint16_t queue_id = 0;
2554 /* No queue_id, return */
2556 printf("must specify (port,queue_id)\n");
2559 tmp = strtoul(str + i + 1, NULL, 0);
2560 /* If queue_id greater that what 16-bits can represent, return */
2564 queue_id = (uint16_t)tmp;
2565 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2567 else if (!strcmp(res->what, "filter"))
2568 rx_vlan_filter_set(port_id, on);
2570 vlan_extend_set(port_id, on);
2575 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2576 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2578 cmdline_parse_token_string_t cmd_vlan_offload_set =
2579 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2581 cmdline_parse_token_string_t cmd_vlan_offload_what =
2582 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2583 what, "strip#filter#qinq#stripq");
2584 cmdline_parse_token_string_t cmd_vlan_offload_on =
2585 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2587 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2588 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2591 cmdline_parse_inst_t cmd_vlan_offload = {
2592 .f = cmd_vlan_offload_parsed,
2594 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2595 " qinq(extended) for both rx/tx sides ",
2597 (void *)&cmd_vlan_offload_vlan,
2598 (void *)&cmd_vlan_offload_set,
2599 (void *)&cmd_vlan_offload_what,
2600 (void *)&cmd_vlan_offload_on,
2601 (void *)&cmd_vlan_offload_portid,
2606 /* *** VLAN TPID SET ON A PORT *** */
2607 struct cmd_vlan_tpid_result {
2608 cmdline_fixed_string_t vlan;
2609 cmdline_fixed_string_t set;
2610 cmdline_fixed_string_t what;
2616 cmd_vlan_tpid_parsed(void *parsed_result,
2617 __attribute__((unused)) struct cmdline *cl,
2618 __attribute__((unused)) void *data)
2620 struct cmd_vlan_tpid_result *res = parsed_result;
2621 vlan_tpid_set(res->port_id, res->tp_id);
2625 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2626 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2628 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2629 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2631 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2632 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2634 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2635 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2637 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2638 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2641 cmdline_parse_inst_t cmd_vlan_tpid = {
2642 .f = cmd_vlan_tpid_parsed,
2644 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2646 (void *)&cmd_vlan_tpid_vlan,
2647 (void *)&cmd_vlan_tpid_set,
2648 (void *)&cmd_vlan_tpid_what,
2649 (void *)&cmd_vlan_tpid_tpid,
2650 (void *)&cmd_vlan_tpid_portid,
2655 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2656 struct cmd_rx_vlan_filter_result {
2657 cmdline_fixed_string_t rx_vlan;
2658 cmdline_fixed_string_t what;
2664 cmd_rx_vlan_filter_parsed(void *parsed_result,
2665 __attribute__((unused)) struct cmdline *cl,
2666 __attribute__((unused)) void *data)
2668 struct cmd_rx_vlan_filter_result *res = parsed_result;
2670 if (!strcmp(res->what, "add"))
2671 rx_vft_set(res->port_id, res->vlan_id, 1);
2673 rx_vft_set(res->port_id, res->vlan_id, 0);
2676 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2677 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2678 rx_vlan, "rx_vlan");
2679 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2680 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2682 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2683 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2685 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2686 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2689 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2690 .f = cmd_rx_vlan_filter_parsed,
2692 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2693 "Identifiers filtered by a port",
2695 (void *)&cmd_rx_vlan_filter_rx_vlan,
2696 (void *)&cmd_rx_vlan_filter_what,
2697 (void *)&cmd_rx_vlan_filter_vlanid,
2698 (void *)&cmd_rx_vlan_filter_portid,
2703 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2704 struct cmd_tx_vlan_set_result {
2705 cmdline_fixed_string_t tx_vlan;
2706 cmdline_fixed_string_t set;
2712 cmd_tx_vlan_set_parsed(void *parsed_result,
2713 __attribute__((unused)) struct cmdline *cl,
2714 __attribute__((unused)) void *data)
2716 struct cmd_tx_vlan_set_result *res = parsed_result;
2717 tx_vlan_set(res->port_id, res->vlan_id);
2720 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2721 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2722 tx_vlan, "tx_vlan");
2723 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2724 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2726 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2727 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2729 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2730 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2733 cmdline_parse_inst_t cmd_tx_vlan_set = {
2734 .f = cmd_tx_vlan_set_parsed,
2736 .help_str = "enable hardware insertion of a VLAN header with a given "
2737 "TAG Identifier in packets sent on a port",
2739 (void *)&cmd_tx_vlan_set_tx_vlan,
2740 (void *)&cmd_tx_vlan_set_set,
2741 (void *)&cmd_tx_vlan_set_vlanid,
2742 (void *)&cmd_tx_vlan_set_portid,
2747 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2748 struct cmd_tx_vlan_set_pvid_result {
2749 cmdline_fixed_string_t tx_vlan;
2750 cmdline_fixed_string_t set;
2751 cmdline_fixed_string_t pvid;
2754 cmdline_fixed_string_t mode;
2758 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2759 __attribute__((unused)) struct cmdline *cl,
2760 __attribute__((unused)) void *data)
2762 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2764 if (strcmp(res->mode, "on") == 0)
2765 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2767 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2770 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2771 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2772 tx_vlan, "tx_vlan");
2773 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2774 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2776 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2777 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2779 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2780 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2782 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2783 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2785 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2786 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2789 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2790 .f = cmd_tx_vlan_set_pvid_parsed,
2792 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2794 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2795 (void *)&cmd_tx_vlan_set_pvid_set,
2796 (void *)&cmd_tx_vlan_set_pvid_pvid,
2797 (void *)&cmd_tx_vlan_set_pvid_port_id,
2798 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2799 (void *)&cmd_tx_vlan_set_pvid_mode,
2804 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2805 struct cmd_tx_vlan_reset_result {
2806 cmdline_fixed_string_t tx_vlan;
2807 cmdline_fixed_string_t reset;
2812 cmd_tx_vlan_reset_parsed(void *parsed_result,
2813 __attribute__((unused)) struct cmdline *cl,
2814 __attribute__((unused)) void *data)
2816 struct cmd_tx_vlan_reset_result *res = parsed_result;
2818 tx_vlan_reset(res->port_id);
2821 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2822 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2823 tx_vlan, "tx_vlan");
2824 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2825 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2827 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2828 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2831 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2832 .f = cmd_tx_vlan_reset_parsed,
2834 .help_str = "disable hardware insertion of a VLAN header in packets "
2837 (void *)&cmd_tx_vlan_reset_tx_vlan,
2838 (void *)&cmd_tx_vlan_reset_reset,
2839 (void *)&cmd_tx_vlan_reset_portid,
2845 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2846 struct cmd_tx_cksum_set_result {
2847 cmdline_fixed_string_t tx_cksum;
2848 cmdline_fixed_string_t set;
2854 cmd_tx_cksum_set_parsed(void *parsed_result,
2855 __attribute__((unused)) struct cmdline *cl,
2856 __attribute__((unused)) void *data)
2858 struct cmd_tx_cksum_set_result *res = parsed_result;
2860 tx_cksum_set(res->port_id, res->cksum_mask);
2863 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2864 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2865 tx_cksum, "tx_checksum");
2866 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2867 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2869 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2870 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2872 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2873 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2876 cmdline_parse_inst_t cmd_tx_cksum_set = {
2877 .f = cmd_tx_cksum_set_parsed,
2879 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2880 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2881 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2882 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2884 (void *)&cmd_tx_cksum_set_tx_cksum,
2885 (void *)&cmd_tx_cksum_set_set,
2886 (void *)&cmd_tx_cksum_set_cksum_mask,
2887 (void *)&cmd_tx_cksum_set_portid,
2892 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2893 struct cmd_set_flush_rx {
2894 cmdline_fixed_string_t set;
2895 cmdline_fixed_string_t flush_rx;
2896 cmdline_fixed_string_t mode;
2900 cmd_set_flush_rx_parsed(void *parsed_result,
2901 __attribute__((unused)) struct cmdline *cl,
2902 __attribute__((unused)) void *data)
2904 struct cmd_set_flush_rx *res = parsed_result;
2905 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2908 cmdline_parse_token_string_t cmd_setflushrx_set =
2909 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2911 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2912 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2913 flush_rx, "flush_rx");
2914 cmdline_parse_token_string_t cmd_setflushrx_mode =
2915 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2919 cmdline_parse_inst_t cmd_set_flush_rx = {
2920 .f = cmd_set_flush_rx_parsed,
2921 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2924 (void *)&cmd_setflushrx_set,
2925 (void *)&cmd_setflushrx_flush_rx,
2926 (void *)&cmd_setflushrx_mode,
2931 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2932 struct cmd_set_link_check {
2933 cmdline_fixed_string_t set;
2934 cmdline_fixed_string_t link_check;
2935 cmdline_fixed_string_t mode;
2939 cmd_set_link_check_parsed(void *parsed_result,
2940 __attribute__((unused)) struct cmdline *cl,
2941 __attribute__((unused)) void *data)
2943 struct cmd_set_link_check *res = parsed_result;
2944 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2947 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2948 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2950 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2951 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2952 link_check, "link_check");
2953 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2954 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2958 cmdline_parse_inst_t cmd_set_link_check = {
2959 .f = cmd_set_link_check_parsed,
2960 .help_str = "set link_check on|off: enable/disable link status check "
2961 "when starting/stopping a port",
2964 (void *)&cmd_setlinkcheck_set,
2965 (void *)&cmd_setlinkcheck_link_check,
2966 (void *)&cmd_setlinkcheck_mode,
2971 #ifdef RTE_NIC_BYPASS
2972 /* *** SET NIC BYPASS MODE *** */
2973 struct cmd_set_bypass_mode_result {
2974 cmdline_fixed_string_t set;
2975 cmdline_fixed_string_t bypass;
2976 cmdline_fixed_string_t mode;
2977 cmdline_fixed_string_t value;
2982 cmd_set_bypass_mode_parsed(void *parsed_result,
2983 __attribute__((unused)) struct cmdline *cl,
2984 __attribute__((unused)) void *data)
2986 struct cmd_set_bypass_mode_result *res = parsed_result;
2987 portid_t port_id = res->port_id;
2988 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2990 if (!bypass_is_supported(port_id))
2993 if (!strcmp(res->value, "bypass"))
2994 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2995 else if (!strcmp(res->value, "isolate"))
2996 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2998 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3000 /* Set the bypass mode for the relevant port. */
3001 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3002 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3006 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3007 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3009 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3010 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3012 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3013 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3015 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3016 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3017 value, "normal#bypass#isolate");
3018 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3019 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3022 cmdline_parse_inst_t cmd_set_bypass_mode = {
3023 .f = cmd_set_bypass_mode_parsed,
3024 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3025 "Set the NIC bypass mode for port_id",
3028 (void *)&cmd_setbypass_mode_set,
3029 (void *)&cmd_setbypass_mode_bypass,
3030 (void *)&cmd_setbypass_mode_mode,
3031 (void *)&cmd_setbypass_mode_value,
3032 (void *)&cmd_setbypass_mode_port,
3037 /* *** SET NIC BYPASS EVENT *** */
3038 struct cmd_set_bypass_event_result {
3039 cmdline_fixed_string_t set;
3040 cmdline_fixed_string_t bypass;
3041 cmdline_fixed_string_t event;
3042 cmdline_fixed_string_t event_value;
3043 cmdline_fixed_string_t mode;
3044 cmdline_fixed_string_t mode_value;
3049 cmd_set_bypass_event_parsed(void *parsed_result,
3050 __attribute__((unused)) struct cmdline *cl,
3051 __attribute__((unused)) void *data)
3054 struct cmd_set_bypass_event_result *res = parsed_result;
3055 portid_t port_id = res->port_id;
3056 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3057 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3059 if (!bypass_is_supported(port_id))
3062 if (!strcmp(res->event_value, "timeout"))
3063 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3064 else if (!strcmp(res->event_value, "os_on"))
3065 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3066 else if (!strcmp(res->event_value, "os_off"))
3067 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3068 else if (!strcmp(res->event_value, "power_on"))
3069 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3070 else if (!strcmp(res->event_value, "power_off"))
3071 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3073 bypass_event = RTE_BYPASS_EVENT_NONE;
3075 if (!strcmp(res->mode_value, "bypass"))
3076 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3077 else if (!strcmp(res->mode_value, "isolate"))
3078 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3080 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3082 /* Set the watchdog timeout. */
3083 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3086 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3087 (rc = rte_eth_dev_wd_timeout_store(port_id,
3088 bypass_timeout)) != 0) {
3089 printf("Failed to set timeout value %u "
3090 "for port %d, errto code: %d.\n",
3091 bypass_timeout, port_id, rc);
3095 /* Set the bypass event to transition to bypass mode. */
3096 if (0 != rte_eth_dev_bypass_event_store(port_id,
3097 bypass_event, bypass_mode)) {
3098 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3103 cmdline_parse_token_string_t cmd_setbypass_event_set =
3104 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3106 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3107 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3109 cmdline_parse_token_string_t cmd_setbypass_event_event =
3110 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3112 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3113 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3114 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3115 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3116 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3118 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3120 mode_value, "normal#bypass#isolate");
3121 cmdline_parse_token_num_t cmd_setbypass_event_port =
3122 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3125 cmdline_parse_inst_t cmd_set_bypass_event = {
3126 .f = cmd_set_bypass_event_parsed,
3127 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3128 "mode (normal|bypass|isolate) (port_id): "
3129 "Set the NIC bypass event mode for port_id",
3132 (void *)&cmd_setbypass_event_set,
3133 (void *)&cmd_setbypass_event_bypass,
3134 (void *)&cmd_setbypass_event_event,
3135 (void *)&cmd_setbypass_event_event_value,
3136 (void *)&cmd_setbypass_event_mode,
3137 (void *)&cmd_setbypass_event_mode_value,
3138 (void *)&cmd_setbypass_event_port,
3144 /* *** SET NIC BYPASS TIMEOUT *** */
3145 struct cmd_set_bypass_timeout_result {
3146 cmdline_fixed_string_t set;
3147 cmdline_fixed_string_t bypass;
3148 cmdline_fixed_string_t timeout;
3149 cmdline_fixed_string_t value;
3153 cmd_set_bypass_timeout_parsed(void *parsed_result,
3154 __attribute__((unused)) struct cmdline *cl,
3155 __attribute__((unused)) void *data)
3157 struct cmd_set_bypass_timeout_result *res = parsed_result;
3159 if (!strcmp(res->value, "1.5"))
3160 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3161 else if (!strcmp(res->value, "2"))
3162 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3163 else if (!strcmp(res->value, "3"))
3164 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3165 else if (!strcmp(res->value, "4"))
3166 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3167 else if (!strcmp(res->value, "8"))
3168 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3169 else if (!strcmp(res->value, "16"))
3170 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3171 else if (!strcmp(res->value, "32"))
3172 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3174 bypass_timeout = RTE_BYPASS_TMT_OFF;
3177 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3178 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3180 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3181 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3183 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3184 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3185 timeout, "timeout");
3186 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3187 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3188 value, "0#1.5#2#3#4#8#16#32");
3190 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3191 .f = cmd_set_bypass_timeout_parsed,
3192 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3193 "Set the NIC bypass watchdog timeout",
3196 (void *)&cmd_setbypass_timeout_set,
3197 (void *)&cmd_setbypass_timeout_bypass,
3198 (void *)&cmd_setbypass_timeout_timeout,
3199 (void *)&cmd_setbypass_timeout_value,
3204 /* *** SHOW NIC BYPASS MODE *** */
3205 struct cmd_show_bypass_config_result {
3206 cmdline_fixed_string_t show;
3207 cmdline_fixed_string_t bypass;
3208 cmdline_fixed_string_t config;
3213 cmd_show_bypass_config_parsed(void *parsed_result,
3214 __attribute__((unused)) struct cmdline *cl,
3215 __attribute__((unused)) void *data)
3217 struct cmd_show_bypass_config_result *res = parsed_result;
3218 uint32_t event_mode;
3219 uint32_t bypass_mode;
3220 portid_t port_id = res->port_id;
3221 uint32_t timeout = bypass_timeout;
3224 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3225 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3226 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3227 {"UNKNOWN", "normal", "bypass", "isolate"};
3228 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3235 int num_events = (sizeof events) / (sizeof events[0]);
3237 if (!bypass_is_supported(port_id))
3240 /* Display the bypass mode.*/
3241 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3242 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3246 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3247 bypass_mode = RTE_BYPASS_MODE_NONE;
3249 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3252 /* Display the bypass timeout.*/
3253 if (!RTE_BYPASS_TMT_VALID(timeout))
3254 timeout = RTE_BYPASS_TMT_OFF;
3256 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3258 /* Display the bypass events and associated modes. */
3259 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3261 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3262 printf("\tFailed to get bypass mode for event = %s\n",
3265 if (!RTE_BYPASS_MODE_VALID(event_mode))
3266 event_mode = RTE_BYPASS_MODE_NONE;
3268 printf("\tbypass event: %-16s = %s\n", events[i],
3274 cmdline_parse_token_string_t cmd_showbypass_config_show =
3275 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3277 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3278 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3280 cmdline_parse_token_string_t cmd_showbypass_config_config =
3281 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3283 cmdline_parse_token_num_t cmd_showbypass_config_port =
3284 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3287 cmdline_parse_inst_t cmd_show_bypass_config = {
3288 .f = cmd_show_bypass_config_parsed,
3289 .help_str = "show bypass config (port_id): "
3290 "Show the NIC bypass config for port_id",
3293 (void *)&cmd_showbypass_config_show,
3294 (void *)&cmd_showbypass_config_bypass,
3295 (void *)&cmd_showbypass_config_config,
3296 (void *)&cmd_showbypass_config_port,
3302 #ifdef RTE_LIBRTE_PMD_BOND
3303 /* *** SET BONDING MODE *** */
3304 struct cmd_set_bonding_mode_result {
3305 cmdline_fixed_string_t set;
3306 cmdline_fixed_string_t bonding;
3307 cmdline_fixed_string_t mode;
3312 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3313 __attribute__((unused)) struct cmdline *cl,
3314 __attribute__((unused)) void *data)
3316 struct cmd_set_bonding_mode_result *res = parsed_result;
3317 portid_t port_id = res->port_id;
3319 /* Set the bonding mode for the relevant port. */
3320 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3321 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3324 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3325 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3327 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3328 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3329 bonding, "bonding");
3330 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3331 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3333 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3334 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3336 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3337 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3340 cmdline_parse_inst_t cmd_set_bonding_mode = {
3341 .f = cmd_set_bonding_mode_parsed,
3342 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3345 (void *) &cmd_setbonding_mode_set,
3346 (void *) &cmd_setbonding_mode_bonding,
3347 (void *) &cmd_setbonding_mode_mode,
3348 (void *) &cmd_setbonding_mode_value,
3349 (void *) &cmd_setbonding_mode_port,
3354 /* *** SET BALANCE XMIT POLICY *** */
3355 struct cmd_set_bonding_balance_xmit_policy_result {
3356 cmdline_fixed_string_t set;
3357 cmdline_fixed_string_t bonding;
3358 cmdline_fixed_string_t balance_xmit_policy;
3360 cmdline_fixed_string_t policy;
3363 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3367 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3368 portid_t port_id = res->port_id;
3371 if (!strcmp(res->policy, "l2")) {
3372 policy = BALANCE_XMIT_POLICY_LAYER2;
3373 } else if (!strcmp(res->policy, "l23")) {
3374 policy = BALANCE_XMIT_POLICY_LAYER23;
3375 } else if (!strcmp(res->policy, "l34")) {
3376 policy = BALANCE_XMIT_POLICY_LAYER34;
3378 printf("\t Invalid xmit policy selection");
3382 /* Set the bonding mode for the relevant port. */
3383 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3384 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3389 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3390 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3392 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3393 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3394 bonding, "bonding");
3395 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3396 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3397 balance_xmit_policy, "balance_xmit_policy");
3398 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3399 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3401 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3402 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3403 policy, "l2#l23#l34");
3405 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3406 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3407 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3410 (void *)&cmd_setbonding_balance_xmit_policy_set,
3411 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3412 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3413 (void *)&cmd_setbonding_balance_xmit_policy_port,
3414 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3419 /* *** SHOW NIC BONDING CONFIGURATION *** */
3420 struct cmd_show_bonding_config_result {
3421 cmdline_fixed_string_t show;
3422 cmdline_fixed_string_t bonding;
3423 cmdline_fixed_string_t config;
3427 static void cmd_show_bonding_config_parsed(void *parsed_result,
3428 __attribute__((unused)) struct cmdline *cl,
3429 __attribute__((unused)) void *data)
3431 struct cmd_show_bonding_config_result *res = parsed_result;
3433 uint8_t slaves[RTE_MAX_ETHPORTS];
3434 int num_slaves, num_active_slaves;
3437 portid_t port_id = res->port_id;
3439 /* Display the bonding mode.*/
3440 bonding_mode = rte_eth_bond_mode_get(port_id);
3441 if (bonding_mode < 0) {
3442 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3445 printf("\tBonding mode: %d\n", bonding_mode);
3447 if (bonding_mode == BONDING_MODE_BALANCE) {
3448 int balance_xmit_policy;
3450 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3451 if (balance_xmit_policy < 0) {
3452 printf("\tFailed to get balance xmit policy for port = %d\n",
3456 printf("\tBalance Xmit Policy: ");
3458 switch (balance_xmit_policy) {
3459 case BALANCE_XMIT_POLICY_LAYER2:
3460 printf("BALANCE_XMIT_POLICY_LAYER2");
3462 case BALANCE_XMIT_POLICY_LAYER23:
3463 printf("BALANCE_XMIT_POLICY_LAYER23");
3465 case BALANCE_XMIT_POLICY_LAYER34:
3466 printf("BALANCE_XMIT_POLICY_LAYER34");
3473 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3475 if (num_slaves < 0) {
3476 printf("\tFailed to get slave list for port = %d\n", port_id);
3479 if (num_slaves > 0) {
3480 printf("\tSlaves (%d): [", num_slaves);
3481 for (i = 0; i < num_slaves - 1; i++)
3482 printf("%d ", slaves[i]);
3484 printf("%d]\n", slaves[num_slaves - 1]);
3486 printf("\tSlaves: []\n");
3490 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3493 if (num_active_slaves < 0) {
3494 printf("\tFailed to get active slave list for port = %d\n", port_id);
3497 if (num_active_slaves > 0) {
3498 printf("\tActive Slaves (%d): [", num_active_slaves);
3499 for (i = 0; i < num_active_slaves - 1; i++)
3500 printf("%d ", slaves[i]);
3502 printf("%d]\n", slaves[num_active_slaves - 1]);
3505 printf("\tActive Slaves: []\n");
3509 primary_id = rte_eth_bond_primary_get(port_id);
3510 if (primary_id < 0) {
3511 printf("\tFailed to get primary slave for port = %d\n", port_id);
3514 printf("\tPrimary: [%d]\n", primary_id);
3518 cmdline_parse_token_string_t cmd_showbonding_config_show =
3519 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3521 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3522 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3523 bonding, "bonding");
3524 cmdline_parse_token_string_t cmd_showbonding_config_config =
3525 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3527 cmdline_parse_token_num_t cmd_showbonding_config_port =
3528 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3531 cmdline_parse_inst_t cmd_show_bonding_config = {
3532 .f = cmd_show_bonding_config_parsed,
3533 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3536 (void *)&cmd_showbonding_config_show,
3537 (void *)&cmd_showbonding_config_bonding,
3538 (void *)&cmd_showbonding_config_config,
3539 (void *)&cmd_showbonding_config_port,
3544 /* *** SET BONDING PRIMARY *** */
3545 struct cmd_set_bonding_primary_result {
3546 cmdline_fixed_string_t set;
3547 cmdline_fixed_string_t bonding;
3548 cmdline_fixed_string_t primary;
3553 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3554 __attribute__((unused)) struct cmdline *cl,
3555 __attribute__((unused)) void *data)
3557 struct cmd_set_bonding_primary_result *res = parsed_result;
3558 portid_t master_port_id = res->port_id;
3559 portid_t slave_port_id = res->slave_id;
3561 /* Set the primary slave for a bonded device. */
3562 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3563 printf("\t Failed to set primary slave for port = %d.\n",
3570 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3571 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3573 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3575 bonding, "bonding");
3576 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3577 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3578 primary, "primary");
3579 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3580 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3582 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3583 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3586 cmdline_parse_inst_t cmd_set_bonding_primary = {
3587 .f = cmd_set_bonding_primary_parsed,
3588 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3591 (void *)&cmd_setbonding_primary_set,
3592 (void *)&cmd_setbonding_primary_bonding,
3593 (void *)&cmd_setbonding_primary_primary,
3594 (void *)&cmd_setbonding_primary_slave,
3595 (void *)&cmd_setbonding_primary_port,
3600 /* *** ADD SLAVE *** */
3601 struct cmd_add_bonding_slave_result {
3602 cmdline_fixed_string_t add;
3603 cmdline_fixed_string_t bonding;
3604 cmdline_fixed_string_t slave;
3609 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3610 __attribute__((unused)) struct cmdline *cl,
3611 __attribute__((unused)) void *data)
3613 struct cmd_add_bonding_slave_result *res = parsed_result;
3614 portid_t master_port_id = res->port_id;
3615 portid_t slave_port_id = res->slave_id;
3617 /* Set the primary slave for a bonded device. */
3618 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3619 printf("\t Failed to add slave %d to master port = %d.\n",
3620 slave_port_id, master_port_id);
3626 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3627 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3629 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3630 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3631 bonding, "bonding");
3632 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3633 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3635 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3636 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3638 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3639 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3642 cmdline_parse_inst_t cmd_add_bonding_slave = {
3643 .f = cmd_add_bonding_slave_parsed,
3644 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3647 (void *)&cmd_addbonding_slave_add,
3648 (void *)&cmd_addbonding_slave_bonding,
3649 (void *)&cmd_addbonding_slave_slave,
3650 (void *)&cmd_addbonding_slave_slaveid,
3651 (void *)&cmd_addbonding_slave_port,
3656 /* *** REMOVE SLAVE *** */
3657 struct cmd_remove_bonding_slave_result {
3658 cmdline_fixed_string_t remove;
3659 cmdline_fixed_string_t bonding;
3660 cmdline_fixed_string_t slave;
3665 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3666 __attribute__((unused)) struct cmdline *cl,
3667 __attribute__((unused)) void *data)
3669 struct cmd_remove_bonding_slave_result *res = parsed_result;
3670 portid_t master_port_id = res->port_id;
3671 portid_t slave_port_id = res->slave_id;
3673 /* Set the primary slave for a bonded device. */
3674 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3675 printf("\t Failed to remove slave %d from master port = %d.\n",
3676 slave_port_id, master_port_id);
3682 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3683 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3685 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3686 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3687 bonding, "bonding");
3688 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3689 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3691 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3692 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3694 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3695 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3698 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3699 .f = cmd_remove_bonding_slave_parsed,
3700 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3703 (void *)&cmd_removebonding_slave_remove,
3704 (void *)&cmd_removebonding_slave_bonding,
3705 (void *)&cmd_removebonding_slave_slave,
3706 (void *)&cmd_removebonding_slave_slaveid,
3707 (void *)&cmd_removebonding_slave_port,
3712 /* *** CREATE BONDED DEVICE *** */
3713 struct cmd_create_bonded_device_result {
3714 cmdline_fixed_string_t create;
3715 cmdline_fixed_string_t bonded;
3716 cmdline_fixed_string_t device;
3721 static int bond_dev_num = 0;
3723 static void cmd_create_bonded_device_parsed(void *parsed_result,
3724 __attribute__((unused)) struct cmdline *cl,
3725 __attribute__((unused)) void *data)
3727 struct cmd_create_bonded_device_result *res = parsed_result;
3728 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3731 if (test_done == 0) {
3732 printf("Please stop forwarding first\n");
3736 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3739 /* Create a new bonded device. */
3740 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3742 printf("\t Failed to create bonded device.\n");
3745 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3748 /* Update number of ports */
3749 nb_ports = rte_eth_dev_count();
3751 rte_eth_promiscuous_enable(port_id);
3756 cmdline_parse_token_string_t cmd_createbonded_device_create =
3757 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3759 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3760 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3762 cmdline_parse_token_string_t cmd_createbonded_device_device =
3763 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3765 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3766 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3768 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3769 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3772 cmdline_parse_inst_t cmd_create_bonded_device = {
3773 .f = cmd_create_bonded_device_parsed,
3774 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3777 (void *)&cmd_createbonded_device_create,
3778 (void *)&cmd_createbonded_device_bonded,
3779 (void *)&cmd_createbonded_device_device,
3780 (void *)&cmd_createbonded_device_mode,
3781 (void *)&cmd_createbonded_device_socket,
3786 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3787 struct cmd_set_bond_mac_addr_result {
3788 cmdline_fixed_string_t set;
3789 cmdline_fixed_string_t bonding;
3790 cmdline_fixed_string_t mac_addr;
3792 struct ether_addr address;
3795 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3796 __attribute__((unused)) struct cmdline *cl,
3797 __attribute__((unused)) void *data)
3799 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3802 if (res->port_num >= nb_ports) {
3803 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3807 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3809 /* check the return value and print it if is < 0 */
3811 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3814 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3815 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3816 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3819 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3820 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3822 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3823 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3824 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3825 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3827 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3828 .f = cmd_set_bond_mac_addr_parsed,
3830 .help_str = "set bonding mac_addr (port_id) (address): ",
3832 (void *)&cmd_set_bond_mac_addr_set,
3833 (void *)&cmd_set_bond_mac_addr_bonding,
3834 (void *)&cmd_set_bond_mac_addr_mac,
3835 (void *)&cmd_set_bond_mac_addr_portnum,
3836 (void *)&cmd_set_bond_mac_addr_addr,
3842 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3843 struct cmd_set_bond_mon_period_result {
3844 cmdline_fixed_string_t set;
3845 cmdline_fixed_string_t bonding;
3846 cmdline_fixed_string_t mon_period;
3851 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3852 __attribute__((unused)) struct cmdline *cl,
3853 __attribute__((unused)) void *data)
3855 struct cmd_set_bond_mon_period_result *res = parsed_result;
3858 if (res->port_num >= nb_ports) {
3859 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3863 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3865 /* check the return value and print it if is < 0 */
3867 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3870 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3873 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3875 bonding, "bonding");
3876 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3878 mon_period, "mon_period");
3879 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3880 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3882 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3883 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3886 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3887 .f = cmd_set_bond_mon_period_parsed,
3889 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3891 (void *)&cmd_set_bond_mon_period_set,
3892 (void *)&cmd_set_bond_mon_period_bonding,
3893 (void *)&cmd_set_bond_mon_period_mon_period,
3894 (void *)&cmd_set_bond_mon_period_portnum,
3895 (void *)&cmd_set_bond_mon_period_period_ms,
3900 #endif /* RTE_LIBRTE_PMD_BOND */
3902 /* *** SET FORWARDING MODE *** */
3903 struct cmd_set_fwd_mode_result {
3904 cmdline_fixed_string_t set;
3905 cmdline_fixed_string_t fwd;
3906 cmdline_fixed_string_t mode;
3909 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3910 __attribute__((unused)) struct cmdline *cl,
3911 __attribute__((unused)) void *data)
3913 struct cmd_set_fwd_mode_result *res = parsed_result;
3915 set_pkt_forwarding_mode(res->mode);
3918 cmdline_parse_token_string_t cmd_setfwd_set =
3919 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3920 cmdline_parse_token_string_t cmd_setfwd_fwd =
3921 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3922 cmdline_parse_token_string_t cmd_setfwd_mode =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3924 "" /* defined at init */);
3926 cmdline_parse_inst_t cmd_set_fwd_mode = {
3927 .f = cmd_set_fwd_mode_parsed,
3929 .help_str = NULL, /* defined at init */
3931 (void *)&cmd_setfwd_set,
3932 (void *)&cmd_setfwd_fwd,
3933 (void *)&cmd_setfwd_mode,
3938 static void cmd_set_fwd_mode_init(void)
3941 static char token[128];
3942 static char help[256];
3943 cmdline_parse_token_string_t *token_struct;
3945 modes = list_pkt_forwarding_modes();
3946 snprintf(help, sizeof help, "set fwd %s - "
3947 "set packet forwarding mode", modes);
3948 cmd_set_fwd_mode.help_str = help;
3950 /* string token separator is # */
3951 for (c = token; *modes != '\0'; modes++)
3956 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3957 token_struct->string_data.str = token;
3960 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3961 struct cmd_set_burst_tx_retry_result {
3962 cmdline_fixed_string_t set;
3963 cmdline_fixed_string_t burst;
3964 cmdline_fixed_string_t tx;
3965 cmdline_fixed_string_t delay;
3967 cmdline_fixed_string_t retry;
3971 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3972 __attribute__((unused)) struct cmdline *cl,
3973 __attribute__((unused)) void *data)
3975 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3977 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3978 && !strcmp(res->tx, "tx")) {
3979 if (!strcmp(res->delay, "delay"))
3980 burst_tx_delay_time = res->time;
3981 if (!strcmp(res->retry, "retry"))
3982 burst_tx_retry_num = res->retry_num;
3987 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3988 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3989 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3992 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3994 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3995 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3996 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3997 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3998 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4000 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4001 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4003 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4004 .f = cmd_set_burst_tx_retry_parsed,
4005 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4007 (void *)&cmd_set_burst_tx_retry_set,
4008 (void *)&cmd_set_burst_tx_retry_burst,
4009 (void *)&cmd_set_burst_tx_retry_tx,
4010 (void *)&cmd_set_burst_tx_retry_delay,
4011 (void *)&cmd_set_burst_tx_retry_time,
4012 (void *)&cmd_set_burst_tx_retry_retry,
4013 (void *)&cmd_set_burst_tx_retry_retry_num,
4018 /* *** SET PROMISC MODE *** */
4019 struct cmd_set_promisc_mode_result {
4020 cmdline_fixed_string_t set;
4021 cmdline_fixed_string_t promisc;
4022 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4023 uint8_t port_num; /* valid if "allports" argument == 0 */
4024 cmdline_fixed_string_t mode;
4027 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4028 __attribute__((unused)) struct cmdline *cl,
4031 struct cmd_set_promisc_mode_result *res = parsed_result;
4035 if (!strcmp(res->mode, "on"))
4042 for (i = 0; i < nb_ports; i++) {
4044 rte_eth_promiscuous_enable(i);
4046 rte_eth_promiscuous_disable(i);
4051 rte_eth_promiscuous_enable(res->port_num);
4053 rte_eth_promiscuous_disable(res->port_num);
4057 cmdline_parse_token_string_t cmd_setpromisc_set =
4058 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4059 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4060 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4062 cmdline_parse_token_string_t cmd_setpromisc_portall =
4063 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4065 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4066 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4068 cmdline_parse_token_string_t cmd_setpromisc_mode =
4069 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4072 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4073 .f = cmd_set_promisc_mode_parsed,
4075 .help_str = "set promisc all on|off: set promisc mode for all ports",
4077 (void *)&cmd_setpromisc_set,
4078 (void *)&cmd_setpromisc_promisc,
4079 (void *)&cmd_setpromisc_portall,
4080 (void *)&cmd_setpromisc_mode,
4085 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4086 .f = cmd_set_promisc_mode_parsed,
4088 .help_str = "set promisc X on|off: set promisc mode on port X",
4090 (void *)&cmd_setpromisc_set,
4091 (void *)&cmd_setpromisc_promisc,
4092 (void *)&cmd_setpromisc_portnum,
4093 (void *)&cmd_setpromisc_mode,
4098 /* *** SET ALLMULTI MODE *** */
4099 struct cmd_set_allmulti_mode_result {
4100 cmdline_fixed_string_t set;
4101 cmdline_fixed_string_t allmulti;
4102 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4103 uint8_t port_num; /* valid if "allports" argument == 0 */
4104 cmdline_fixed_string_t mode;
4107 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4108 __attribute__((unused)) struct cmdline *cl,
4111 struct cmd_set_allmulti_mode_result *res = parsed_result;
4115 if (!strcmp(res->mode, "on"))
4122 for (i = 0; i < nb_ports; i++) {
4124 rte_eth_allmulticast_enable(i);
4126 rte_eth_allmulticast_disable(i);
4131 rte_eth_allmulticast_enable(res->port_num);
4133 rte_eth_allmulticast_disable(res->port_num);
4137 cmdline_parse_token_string_t cmd_setallmulti_set =
4138 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4139 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4140 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4142 cmdline_parse_token_string_t cmd_setallmulti_portall =
4143 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4145 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4146 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4148 cmdline_parse_token_string_t cmd_setallmulti_mode =
4149 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4152 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4153 .f = cmd_set_allmulti_mode_parsed,
4155 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4157 (void *)&cmd_setallmulti_set,
4158 (void *)&cmd_setallmulti_allmulti,
4159 (void *)&cmd_setallmulti_portall,
4160 (void *)&cmd_setallmulti_mode,
4165 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4166 .f = cmd_set_allmulti_mode_parsed,
4168 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4170 (void *)&cmd_setallmulti_set,
4171 (void *)&cmd_setallmulti_allmulti,
4172 (void *)&cmd_setallmulti_portnum,
4173 (void *)&cmd_setallmulti_mode,
4178 /* *** ADD/REMOVE A PKT FILTER *** */
4179 struct cmd_pkt_filter_result {
4180 cmdline_fixed_string_t pkt_filter;
4182 cmdline_fixed_string_t protocol;
4183 cmdline_fixed_string_t src;
4184 cmdline_ipaddr_t ip_src;
4186 cmdline_fixed_string_t dst;
4187 cmdline_ipaddr_t ip_dst;
4189 cmdline_fixed_string_t flexbytes;
4190 uint16_t flexbytes_value;
4191 cmdline_fixed_string_t vlan;
4193 cmdline_fixed_string_t queue;
4195 cmdline_fixed_string_t soft;
4200 cmd_pkt_filter_parsed(void *parsed_result,
4201 __attribute__((unused)) struct cmdline *cl,
4202 __attribute__((unused)) void *data)
4204 struct rte_fdir_filter fdir_filter;
4205 struct cmd_pkt_filter_result *res = parsed_result;
4207 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4209 if (res->ip_src.family == AF_INET)
4210 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4212 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4213 &(res->ip_src.addr.ipv6),
4214 sizeof(struct in6_addr));
4216 if (res->ip_dst.family == AF_INET)
4217 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4219 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4220 &(res->ip_dst.addr.ipv6),
4221 sizeof(struct in6_addr));
4223 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4224 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4226 if (!strcmp(res->protocol, "udp"))
4227 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4228 else if (!strcmp(res->protocol, "tcp"))
4229 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4230 else if (!strcmp(res->protocol, "sctp"))
4231 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4232 else /* default only IP */
4233 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4235 if (res->ip_dst.family == AF_INET6)
4236 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4238 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4240 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4241 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4243 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4244 fdir_add_signature_filter(res->port_id, res->queue_id,
4246 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4247 fdir_update_signature_filter(res->port_id, res->queue_id,
4249 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4250 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4251 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4252 fdir_add_perfect_filter(res->port_id, res->soft_id,
4254 (uint8_t) (res->queue_id < 0),
4256 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4257 fdir_update_perfect_filter(res->port_id, res->soft_id,
4259 (uint8_t) (res->queue_id < 0),
4261 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4262 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4268 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4269 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4271 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4272 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4273 protocol, "ip#tcp#udp#sctp");
4274 cmdline_parse_token_string_t cmd_pkt_filter_src =
4275 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4277 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4278 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4280 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4281 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4283 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4284 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4286 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4287 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4289 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4290 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4292 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4293 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4294 flexbytes, "flexbytes");
4295 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4296 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4297 flexbytes_value, UINT16);
4298 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4299 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4301 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4302 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4304 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4305 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4307 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4308 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4310 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4311 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4313 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4314 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4318 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4319 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4320 pkt_filter, "add_signature_filter");
4321 cmdline_parse_inst_t cmd_add_signature_filter = {
4322 .f = cmd_pkt_filter_parsed,
4324 .help_str = "add a signature filter",
4326 (void *)&cmd_pkt_filter_add_signature_filter,
4327 (void *)&cmd_pkt_filter_port_id,
4328 (void *)&cmd_pkt_filter_protocol,
4329 (void *)&cmd_pkt_filter_src,
4330 (void *)&cmd_pkt_filter_ip_src,
4331 (void *)&cmd_pkt_filter_port_src,
4332 (void *)&cmd_pkt_filter_dst,
4333 (void *)&cmd_pkt_filter_ip_dst,
4334 (void *)&cmd_pkt_filter_port_dst,
4335 (void *)&cmd_pkt_filter_flexbytes,
4336 (void *)&cmd_pkt_filter_flexbytes_value,
4337 (void *)&cmd_pkt_filter_vlan,
4338 (void *)&cmd_pkt_filter_vlan_id,
4339 (void *)&cmd_pkt_filter_queue,
4340 (void *)&cmd_pkt_filter_queue_id,
4346 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4347 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4348 pkt_filter, "upd_signature_filter");
4349 cmdline_parse_inst_t cmd_upd_signature_filter = {
4350 .f = cmd_pkt_filter_parsed,
4352 .help_str = "update a signature filter",
4354 (void *)&cmd_pkt_filter_upd_signature_filter,
4355 (void *)&cmd_pkt_filter_port_id,
4356 (void *)&cmd_pkt_filter_protocol,
4357 (void *)&cmd_pkt_filter_src,
4358 (void *)&cmd_pkt_filter_ip_src,
4359 (void *)&cmd_pkt_filter_port_src,
4360 (void *)&cmd_pkt_filter_dst,
4361 (void *)&cmd_pkt_filter_ip_dst,
4362 (void *)&cmd_pkt_filter_port_dst,
4363 (void *)&cmd_pkt_filter_flexbytes,
4364 (void *)&cmd_pkt_filter_flexbytes_value,
4365 (void *)&cmd_pkt_filter_vlan,
4366 (void *)&cmd_pkt_filter_vlan_id,
4367 (void *)&cmd_pkt_filter_queue,
4368 (void *)&cmd_pkt_filter_queue_id,
4374 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4375 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4376 pkt_filter, "rm_signature_filter");
4377 cmdline_parse_inst_t cmd_rm_signature_filter = {
4378 .f = cmd_pkt_filter_parsed,
4380 .help_str = "remove a signature filter",
4382 (void *)&cmd_pkt_filter_rm_signature_filter,
4383 (void *)&cmd_pkt_filter_port_id,
4384 (void *)&cmd_pkt_filter_protocol,
4385 (void *)&cmd_pkt_filter_src,
4386 (void *)&cmd_pkt_filter_ip_src,
4387 (void *)&cmd_pkt_filter_port_src,
4388 (void *)&cmd_pkt_filter_dst,
4389 (void *)&cmd_pkt_filter_ip_dst,
4390 (void *)&cmd_pkt_filter_port_dst,
4391 (void *)&cmd_pkt_filter_flexbytes,
4392 (void *)&cmd_pkt_filter_flexbytes_value,
4393 (void *)&cmd_pkt_filter_vlan,
4394 (void *)&cmd_pkt_filter_vlan_id,
4400 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4401 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4402 pkt_filter, "add_perfect_filter");
4403 cmdline_parse_inst_t cmd_add_perfect_filter = {
4404 .f = cmd_pkt_filter_parsed,
4406 .help_str = "add a perfect filter",
4408 (void *)&cmd_pkt_filter_add_perfect_filter,
4409 (void *)&cmd_pkt_filter_port_id,
4410 (void *)&cmd_pkt_filter_protocol,
4411 (void *)&cmd_pkt_filter_src,
4412 (void *)&cmd_pkt_filter_ip_src,
4413 (void *)&cmd_pkt_filter_port_src,
4414 (void *)&cmd_pkt_filter_dst,
4415 (void *)&cmd_pkt_filter_ip_dst,
4416 (void *)&cmd_pkt_filter_port_dst,
4417 (void *)&cmd_pkt_filter_flexbytes,
4418 (void *)&cmd_pkt_filter_flexbytes_value,
4419 (void *)&cmd_pkt_filter_vlan,
4420 (void *)&cmd_pkt_filter_vlan_id,
4421 (void *)&cmd_pkt_filter_queue,
4422 (void *)&cmd_pkt_filter_queue_id,
4423 (void *)&cmd_pkt_filter_soft,
4424 (void *)&cmd_pkt_filter_soft_id,
4430 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4431 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4432 pkt_filter, "upd_perfect_filter");
4433 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4434 .f = cmd_pkt_filter_parsed,
4436 .help_str = "update a perfect filter",
4438 (void *)&cmd_pkt_filter_upd_perfect_filter,
4439 (void *)&cmd_pkt_filter_port_id,
4440 (void *)&cmd_pkt_filter_protocol,
4441 (void *)&cmd_pkt_filter_src,
4442 (void *)&cmd_pkt_filter_ip_src,
4443 (void *)&cmd_pkt_filter_port_src,
4444 (void *)&cmd_pkt_filter_dst,
4445 (void *)&cmd_pkt_filter_ip_dst,
4446 (void *)&cmd_pkt_filter_port_dst,
4447 (void *)&cmd_pkt_filter_flexbytes,
4448 (void *)&cmd_pkt_filter_flexbytes_value,
4449 (void *)&cmd_pkt_filter_vlan,
4450 (void *)&cmd_pkt_filter_vlan_id,
4451 (void *)&cmd_pkt_filter_queue,
4452 (void *)&cmd_pkt_filter_queue_id,
4453 (void *)&cmd_pkt_filter_soft,
4454 (void *)&cmd_pkt_filter_soft_id,
4460 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4461 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4462 pkt_filter, "rm_perfect_filter");
4463 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4464 .f = cmd_pkt_filter_parsed,
4466 .help_str = "remove a perfect filter",
4468 (void *)&cmd_pkt_filter_rm_perfect_filter,
4469 (void *)&cmd_pkt_filter_port_id,
4470 (void *)&cmd_pkt_filter_protocol,
4471 (void *)&cmd_pkt_filter_src,
4472 (void *)&cmd_pkt_filter_ip_src,
4473 (void *)&cmd_pkt_filter_port_src,
4474 (void *)&cmd_pkt_filter_dst,
4475 (void *)&cmd_pkt_filter_ip_dst,
4476 (void *)&cmd_pkt_filter_port_dst,
4477 (void *)&cmd_pkt_filter_flexbytes,
4478 (void *)&cmd_pkt_filter_flexbytes_value,
4479 (void *)&cmd_pkt_filter_vlan,
4480 (void *)&cmd_pkt_filter_vlan_id,
4481 (void *)&cmd_pkt_filter_soft,
4482 (void *)&cmd_pkt_filter_soft_id,
4487 /* *** SETUP MASKS FILTER *** */
4488 struct cmd_pkt_filter_masks_result {
4489 cmdline_fixed_string_t filter_mask;
4491 cmdline_fixed_string_t src_mask;
4492 uint32_t ip_src_mask;
4493 uint16_t ipv6_src_mask;
4494 uint16_t port_src_mask;
4495 cmdline_fixed_string_t dst_mask;
4496 uint32_t ip_dst_mask;
4497 uint16_t ipv6_dst_mask;
4498 uint16_t port_dst_mask;
4499 cmdline_fixed_string_t flexbytes;
4500 uint8_t flexbytes_value;
4501 cmdline_fixed_string_t vlan_id;
4502 uint8_t vlan_id_value;
4503 cmdline_fixed_string_t vlan_prio;
4504 uint8_t vlan_prio_value;
4505 cmdline_fixed_string_t only_ip_flow;
4506 uint8_t only_ip_flow_value;
4507 cmdline_fixed_string_t comp_ipv6_dst;
4508 uint8_t comp_ipv6_dst_value;
4512 cmd_pkt_filter_masks_parsed(void *parsed_result,
4513 __attribute__((unused)) struct cmdline *cl,
4514 __attribute__((unused)) void *data)
4516 struct rte_fdir_masks fdir_masks;
4517 struct cmd_pkt_filter_masks_result *res = parsed_result;
4519 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4521 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4522 fdir_masks.vlan_id = res->vlan_id_value;
4523 fdir_masks.vlan_prio = res->vlan_prio_value;
4524 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4525 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4526 fdir_masks.src_port_mask = res->port_src_mask;
4527 fdir_masks.dst_port_mask = res->port_dst_mask;
4528 fdir_masks.flexbytes = res->flexbytes_value;
4530 fdir_set_masks(res->port_id, &fdir_masks);
4533 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4534 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4535 filter_mask, "set_masks_filter");
4536 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4537 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4539 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4540 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4541 only_ip_flow, "only_ip_flow");
4542 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4543 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4544 only_ip_flow_value, UINT8);
4545 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4546 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4547 src_mask, "src_mask");
4548 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4549 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4550 ip_src_mask, UINT32);
4551 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4552 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4553 port_src_mask, UINT16);
4554 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4555 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4556 dst_mask, "dst_mask");
4557 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4558 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4559 ip_dst_mask, UINT32);
4560 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4561 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4562 port_dst_mask, UINT16);
4563 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4564 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4565 flexbytes, "flexbytes");
4566 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4567 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4568 flexbytes_value, UINT8);
4569 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4570 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4571 vlan_id, "vlan_id");
4572 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4573 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4574 vlan_id_value, UINT8);
4575 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4576 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4577 vlan_prio, "vlan_prio");
4578 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4579 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4580 vlan_prio_value, UINT8);
4582 cmdline_parse_inst_t cmd_set_masks_filter = {
4583 .f = cmd_pkt_filter_masks_parsed,
4585 .help_str = "setup masks filter",
4587 (void *)&cmd_pkt_filter_masks_filter_mask,
4588 (void *)&cmd_pkt_filter_masks_port_id,
4589 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4590 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4591 (void *)&cmd_pkt_filter_masks_src_mask,
4592 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4593 (void *)&cmd_pkt_filter_masks_port_src_mask,
4594 (void *)&cmd_pkt_filter_masks_dst_mask,
4595 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4596 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4597 (void *)&cmd_pkt_filter_masks_flexbytes,
4598 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4599 (void *)&cmd_pkt_filter_masks_vlan_id,
4600 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4601 (void *)&cmd_pkt_filter_masks_vlan_prio,
4602 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4608 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4609 __attribute__((unused)) struct cmdline *cl,
4610 __attribute__((unused)) void *data)
4612 struct rte_fdir_masks fdir_masks;
4613 struct cmd_pkt_filter_masks_result *res = parsed_result;
4615 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4617 fdir_masks.set_ipv6_mask = 1;
4618 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4619 fdir_masks.vlan_id = res->vlan_id_value;
4620 fdir_masks.vlan_prio = res->vlan_prio_value;
4621 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4622 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4623 fdir_masks.src_port_mask = res->port_src_mask;
4624 fdir_masks.dst_port_mask = res->port_dst_mask;
4625 fdir_masks.flexbytes = res->flexbytes_value;
4626 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4628 fdir_set_masks(res->port_id, &fdir_masks);
4631 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4632 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4633 filter_mask, "set_ipv6_masks_filter");
4634 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4635 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4636 ipv6_src_mask, UINT16);
4637 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4638 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4639 ipv6_dst_mask, UINT16);
4641 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4642 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4643 comp_ipv6_dst, "compare_dst");
4644 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4645 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4646 comp_ipv6_dst_value, UINT8);
4648 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4649 .f = cmd_pkt_filter_masks_ipv6_parsed,
4651 .help_str = "setup ipv6 masks filter",
4653 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4654 (void *)&cmd_pkt_filter_masks_port_id,
4655 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4656 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4657 (void *)&cmd_pkt_filter_masks_src_mask,
4658 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4659 (void *)&cmd_pkt_filter_masks_port_src_mask,
4660 (void *)&cmd_pkt_filter_masks_dst_mask,
4661 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4662 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4663 (void *)&cmd_pkt_filter_masks_flexbytes,
4664 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4665 (void *)&cmd_pkt_filter_masks_vlan_id,
4666 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4667 (void *)&cmd_pkt_filter_masks_vlan_prio,
4668 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4669 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4670 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4675 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4676 struct cmd_link_flow_ctrl_set_result {
4677 cmdline_fixed_string_t set;
4678 cmdline_fixed_string_t flow_ctrl;
4679 cmdline_fixed_string_t rx;
4680 cmdline_fixed_string_t rx_lfc_mode;
4681 cmdline_fixed_string_t tx;
4682 cmdline_fixed_string_t tx_lfc_mode;
4683 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4684 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4685 cmdline_fixed_string_t autoneg_str;
4686 cmdline_fixed_string_t autoneg;
4687 cmdline_fixed_string_t hw_str;
4688 uint32_t high_water;
4689 cmdline_fixed_string_t lw_str;
4691 cmdline_fixed_string_t pt_str;
4692 uint16_t pause_time;
4693 cmdline_fixed_string_t xon_str;
4698 cmdline_parse_token_string_t cmd_lfc_set_set =
4699 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4701 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4702 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4703 flow_ctrl, "flow_ctrl");
4704 cmdline_parse_token_string_t cmd_lfc_set_rx =
4705 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4707 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4708 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4709 rx_lfc_mode, "on#off");
4710 cmdline_parse_token_string_t cmd_lfc_set_tx =
4711 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4713 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4714 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4715 tx_lfc_mode, "on#off");
4716 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4717 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4718 hw_str, "high_water");
4719 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4720 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4721 high_water, UINT32);
4722 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4723 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4724 lw_str, "low_water");
4725 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4726 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4728 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4729 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4730 pt_str, "pause_time");
4731 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4732 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4733 pause_time, UINT16);
4734 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4735 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4736 xon_str, "send_xon");
4737 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4738 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4740 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4741 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4742 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4743 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4744 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4745 mac_ctrl_frame_fwd_mode, "on#off");
4746 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4747 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4748 autoneg_str, "autoneg");
4749 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4750 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4752 cmdline_parse_token_num_t cmd_lfc_set_portid =
4753 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4756 /* forward declaration */
4758 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4761 cmdline_parse_inst_t cmd_link_flow_control_set = {
4762 .f = cmd_link_flow_ctrl_set_parsed,
4764 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4765 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4766 autoneg on|off port_id",
4768 (void *)&cmd_lfc_set_set,
4769 (void *)&cmd_lfc_set_flow_ctrl,
4770 (void *)&cmd_lfc_set_rx,
4771 (void *)&cmd_lfc_set_rx_mode,
4772 (void *)&cmd_lfc_set_tx,
4773 (void *)&cmd_lfc_set_tx_mode,
4774 (void *)&cmd_lfc_set_high_water,
4775 (void *)&cmd_lfc_set_low_water,
4776 (void *)&cmd_lfc_set_pause_time,
4777 (void *)&cmd_lfc_set_send_xon,
4778 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4779 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4780 (void *)&cmd_lfc_set_autoneg_str,
4781 (void *)&cmd_lfc_set_autoneg,
4782 (void *)&cmd_lfc_set_portid,
4787 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4788 .f = cmd_link_flow_ctrl_set_parsed,
4789 .data = (void *)&cmd_link_flow_control_set_rx,
4790 .help_str = "Change rx flow control parameter: set flow_ctrl "
4791 "rx on|off port_id",
4793 (void *)&cmd_lfc_set_set,
4794 (void *)&cmd_lfc_set_flow_ctrl,
4795 (void *)&cmd_lfc_set_rx,
4796 (void *)&cmd_lfc_set_rx_mode,
4797 (void *)&cmd_lfc_set_portid,
4802 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4803 .f = cmd_link_flow_ctrl_set_parsed,
4804 .data = (void *)&cmd_link_flow_control_set_tx,
4805 .help_str = "Change tx flow control parameter: set flow_ctrl "
4806 "tx on|off port_id",
4808 (void *)&cmd_lfc_set_set,
4809 (void *)&cmd_lfc_set_flow_ctrl,
4810 (void *)&cmd_lfc_set_tx,
4811 (void *)&cmd_lfc_set_tx_mode,
4812 (void *)&cmd_lfc_set_portid,
4817 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4818 .f = cmd_link_flow_ctrl_set_parsed,
4819 .data = (void *)&cmd_link_flow_control_set_hw,
4820 .help_str = "Change high water flow control parameter: set flow_ctrl "
4821 "high_water value port_id",
4823 (void *)&cmd_lfc_set_set,
4824 (void *)&cmd_lfc_set_flow_ctrl,
4825 (void *)&cmd_lfc_set_high_water_str,
4826 (void *)&cmd_lfc_set_high_water,
4827 (void *)&cmd_lfc_set_portid,
4832 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4833 .f = cmd_link_flow_ctrl_set_parsed,
4834 .data = (void *)&cmd_link_flow_control_set_lw,
4835 .help_str = "Change low water flow control parameter: set flow_ctrl "
4836 "low_water value port_id",
4838 (void *)&cmd_lfc_set_set,
4839 (void *)&cmd_lfc_set_flow_ctrl,
4840 (void *)&cmd_lfc_set_low_water_str,
4841 (void *)&cmd_lfc_set_low_water,
4842 (void *)&cmd_lfc_set_portid,
4847 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4848 .f = cmd_link_flow_ctrl_set_parsed,
4849 .data = (void *)&cmd_link_flow_control_set_pt,
4850 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4851 "pause_time value port_id",
4853 (void *)&cmd_lfc_set_set,
4854 (void *)&cmd_lfc_set_flow_ctrl,
4855 (void *)&cmd_lfc_set_pause_time_str,
4856 (void *)&cmd_lfc_set_pause_time,
4857 (void *)&cmd_lfc_set_portid,
4862 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4863 .f = cmd_link_flow_ctrl_set_parsed,
4864 .data = (void *)&cmd_link_flow_control_set_xon,
4865 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4866 "send_xon value port_id",
4868 (void *)&cmd_lfc_set_set,
4869 (void *)&cmd_lfc_set_flow_ctrl,
4870 (void *)&cmd_lfc_set_send_xon_str,
4871 (void *)&cmd_lfc_set_send_xon,
4872 (void *)&cmd_lfc_set_portid,
4877 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4878 .f = cmd_link_flow_ctrl_set_parsed,
4879 .data = (void *)&cmd_link_flow_control_set_macfwd,
4880 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4881 "mac_ctrl_frame_fwd on|off port_id",
4883 (void *)&cmd_lfc_set_set,
4884 (void *)&cmd_lfc_set_flow_ctrl,
4885 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4886 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4887 (void *)&cmd_lfc_set_portid,
4892 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4893 .f = cmd_link_flow_ctrl_set_parsed,
4894 .data = (void *)&cmd_link_flow_control_set_autoneg,
4895 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4896 "autoneg on|off port_id",
4898 (void *)&cmd_lfc_set_set,
4899 (void *)&cmd_lfc_set_flow_ctrl,
4900 (void *)&cmd_lfc_set_autoneg_str,
4901 (void *)&cmd_lfc_set_autoneg,
4902 (void *)&cmd_lfc_set_portid,
4908 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4909 __attribute__((unused)) struct cmdline *cl,
4912 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4913 cmdline_parse_inst_t *cmd = data;
4914 struct rte_eth_fc_conf fc_conf;
4915 int rx_fc_en, tx_fc_en;
4919 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4920 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4921 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4922 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4924 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4925 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4928 /* Partial command line, retrieve current configuration */
4930 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4932 printf("cannot get current flow ctrl parameters, return"
4933 "code = %d\n", ret);
4937 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4938 (fc_conf.mode == RTE_FC_FULL))
4940 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4941 (fc_conf.mode == RTE_FC_FULL))
4945 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4946 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4948 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4949 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4951 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4953 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4954 fc_conf.high_water = res->high_water;
4956 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4957 fc_conf.low_water = res->low_water;
4959 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4960 fc_conf.pause_time = res->pause_time;
4962 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4963 fc_conf.send_xon = res->send_xon;
4965 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4966 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4967 fc_conf.mac_ctrl_frame_fwd = 1;
4969 fc_conf.mac_ctrl_frame_fwd = 0;
4972 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4973 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4975 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4977 printf("bad flow contrl parameter, return code = %d \n", ret);
4980 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4981 struct cmd_priority_flow_ctrl_set_result {
4982 cmdline_fixed_string_t set;
4983 cmdline_fixed_string_t pfc_ctrl;
4984 cmdline_fixed_string_t rx;
4985 cmdline_fixed_string_t rx_pfc_mode;
4986 cmdline_fixed_string_t tx;
4987 cmdline_fixed_string_t tx_pfc_mode;
4988 uint32_t high_water;
4990 uint16_t pause_time;
4996 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
4997 __attribute__((unused)) struct cmdline *cl,
4998 __attribute__((unused)) void *data)
5000 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5001 struct rte_eth_pfc_conf pfc_conf;
5002 int rx_fc_enable, tx_fc_enable;
5006 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5007 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5008 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5009 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5011 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5012 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5015 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5016 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5017 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5018 pfc_conf.fc.high_water = res->high_water;
5019 pfc_conf.fc.low_water = res->low_water;
5020 pfc_conf.fc.pause_time = res->pause_time;
5021 pfc_conf.priority = res->priority;
5023 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5025 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5028 cmdline_parse_token_string_t cmd_pfc_set_set =
5029 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5031 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5032 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5033 pfc_ctrl, "pfc_ctrl");
5034 cmdline_parse_token_string_t cmd_pfc_set_rx =
5035 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5037 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5038 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5039 rx_pfc_mode, "on#off");
5040 cmdline_parse_token_string_t cmd_pfc_set_tx =
5041 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5043 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5044 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5045 tx_pfc_mode, "on#off");
5046 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5047 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5048 high_water, UINT32);
5049 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5050 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5052 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5053 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5054 pause_time, UINT16);
5055 cmdline_parse_token_num_t cmd_pfc_set_priority =
5056 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5058 cmdline_parse_token_num_t cmd_pfc_set_portid =
5059 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5062 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5063 .f = cmd_priority_flow_ctrl_set_parsed,
5065 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5066 tx on|off high_water low_water pause_time priority port_id",
5068 (void *)&cmd_pfc_set_set,
5069 (void *)&cmd_pfc_set_flow_ctrl,
5070 (void *)&cmd_pfc_set_rx,
5071 (void *)&cmd_pfc_set_rx_mode,
5072 (void *)&cmd_pfc_set_tx,
5073 (void *)&cmd_pfc_set_tx_mode,
5074 (void *)&cmd_pfc_set_high_water,
5075 (void *)&cmd_pfc_set_low_water,
5076 (void *)&cmd_pfc_set_pause_time,
5077 (void *)&cmd_pfc_set_priority,
5078 (void *)&cmd_pfc_set_portid,
5083 /* *** RESET CONFIGURATION *** */
5084 struct cmd_reset_result {
5085 cmdline_fixed_string_t reset;
5086 cmdline_fixed_string_t def;
5089 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5091 __attribute__((unused)) void *data)
5093 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5094 set_def_fwd_config();
5097 cmdline_parse_token_string_t cmd_reset_set =
5098 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5099 cmdline_parse_token_string_t cmd_reset_def =
5100 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5103 cmdline_parse_inst_t cmd_reset = {
5104 .f = cmd_reset_parsed,
5106 .help_str = "set default: reset default forwarding configuration",
5108 (void *)&cmd_reset_set,
5109 (void *)&cmd_reset_def,
5114 /* *** START FORWARDING *** */
5115 struct cmd_start_result {
5116 cmdline_fixed_string_t start;
5119 cmdline_parse_token_string_t cmd_start_start =
5120 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5122 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5123 __attribute__((unused)) struct cmdline *cl,
5124 __attribute__((unused)) void *data)
5126 start_packet_forwarding(0);
5129 cmdline_parse_inst_t cmd_start = {
5130 .f = cmd_start_parsed,
5132 .help_str = "start packet forwarding",
5134 (void *)&cmd_start_start,
5139 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5140 struct cmd_start_tx_first_result {
5141 cmdline_fixed_string_t start;
5142 cmdline_fixed_string_t tx_first;
5146 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5147 __attribute__((unused)) struct cmdline *cl,
5148 __attribute__((unused)) void *data)
5150 start_packet_forwarding(1);
5153 cmdline_parse_token_string_t cmd_start_tx_first_start =
5154 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5156 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5157 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5158 tx_first, "tx_first");
5160 cmdline_parse_inst_t cmd_start_tx_first = {
5161 .f = cmd_start_tx_first_parsed,
5163 .help_str = "start packet forwarding, after sending 1 burst of packets",
5165 (void *)&cmd_start_tx_first_start,
5166 (void *)&cmd_start_tx_first_tx_first,
5171 /* *** SET LINK UP *** */
5172 struct cmd_set_link_up_result {
5173 cmdline_fixed_string_t set;
5174 cmdline_fixed_string_t link_up;
5175 cmdline_fixed_string_t port;
5179 cmdline_parse_token_string_t cmd_set_link_up_set =
5180 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5181 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5182 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5184 cmdline_parse_token_string_t cmd_set_link_up_port =
5185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5186 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5187 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5189 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5190 __attribute__((unused)) struct cmdline *cl,
5191 __attribute__((unused)) void *data)
5193 struct cmd_set_link_up_result *res = parsed_result;
5194 dev_set_link_up(res->port_id);
5197 cmdline_parse_inst_t cmd_set_link_up = {
5198 .f = cmd_set_link_up_parsed,
5200 .help_str = "set link-up port (port id)",
5202 (void *)&cmd_set_link_up_set,
5203 (void *)&cmd_set_link_up_link_up,
5204 (void *)&cmd_set_link_up_port,
5205 (void *)&cmd_set_link_up_port_id,
5210 /* *** SET LINK DOWN *** */
5211 struct cmd_set_link_down_result {
5212 cmdline_fixed_string_t set;
5213 cmdline_fixed_string_t link_down;
5214 cmdline_fixed_string_t port;
5218 cmdline_parse_token_string_t cmd_set_link_down_set =
5219 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5220 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5221 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5223 cmdline_parse_token_string_t cmd_set_link_down_port =
5224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5225 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5226 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5228 static void cmd_set_link_down_parsed(
5229 __attribute__((unused)) void *parsed_result,
5230 __attribute__((unused)) struct cmdline *cl,
5231 __attribute__((unused)) void *data)
5233 struct cmd_set_link_down_result *res = parsed_result;
5234 dev_set_link_down(res->port_id);
5237 cmdline_parse_inst_t cmd_set_link_down = {
5238 .f = cmd_set_link_down_parsed,
5240 .help_str = "set link-down port (port id)",
5242 (void *)&cmd_set_link_down_set,
5243 (void *)&cmd_set_link_down_link_down,
5244 (void *)&cmd_set_link_down_port,
5245 (void *)&cmd_set_link_down_port_id,
5250 /* *** SHOW CFG *** */
5251 struct cmd_showcfg_result {
5252 cmdline_fixed_string_t show;
5253 cmdline_fixed_string_t cfg;
5254 cmdline_fixed_string_t what;
5257 static void cmd_showcfg_parsed(void *parsed_result,
5258 __attribute__((unused)) struct cmdline *cl,
5259 __attribute__((unused)) void *data)
5261 struct cmd_showcfg_result *res = parsed_result;
5262 if (!strcmp(res->what, "rxtx"))
5263 rxtx_config_display();
5264 else if (!strcmp(res->what, "cores"))
5265 fwd_lcores_config_display();
5266 else if (!strcmp(res->what, "fwd"))
5267 fwd_config_display();
5270 cmdline_parse_token_string_t cmd_showcfg_show =
5271 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5272 cmdline_parse_token_string_t cmd_showcfg_port =
5273 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5274 cmdline_parse_token_string_t cmd_showcfg_what =
5275 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5278 cmdline_parse_inst_t cmd_showcfg = {
5279 .f = cmd_showcfg_parsed,
5281 .help_str = "show config rxtx|cores|fwd",
5283 (void *)&cmd_showcfg_show,
5284 (void *)&cmd_showcfg_port,
5285 (void *)&cmd_showcfg_what,
5290 /* *** SHOW ALL PORT INFO *** */
5291 struct cmd_showportall_result {
5292 cmdline_fixed_string_t show;
5293 cmdline_fixed_string_t port;
5294 cmdline_fixed_string_t what;
5295 cmdline_fixed_string_t all;
5298 static void cmd_showportall_parsed(void *parsed_result,
5299 __attribute__((unused)) struct cmdline *cl,
5300 __attribute__((unused)) void *data)
5304 struct cmd_showportall_result *res = parsed_result;
5305 if (!strcmp(res->show, "clear")) {
5306 if (!strcmp(res->what, "stats"))
5307 for (i = 0; i < nb_ports; i++)
5309 else if (!strcmp(res->what, "xstats"))
5310 for (i = 0; i < nb_ports; i++)
5311 nic_xstats_clear(i);
5312 } else if (!strcmp(res->what, "info"))
5313 for (i = 0; i < nb_ports; i++)
5314 port_infos_display(i);
5315 else if (!strcmp(res->what, "stats"))
5316 for (i = 0; i < nb_ports; i++)
5317 nic_stats_display(i);
5318 else if (!strcmp(res->what, "xstats"))
5319 for (i = 0; i < nb_ports; i++)
5320 nic_xstats_display(i);
5321 else if (!strcmp(res->what, "fdir"))
5322 for (i = 0; i < nb_ports; i++)
5324 else if (!strcmp(res->what, "stat_qmap"))
5325 for (i = 0; i < nb_ports; i++)
5326 nic_stats_mapping_display(i);
5329 cmdline_parse_token_string_t cmd_showportall_show =
5330 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5332 cmdline_parse_token_string_t cmd_showportall_port =
5333 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5334 cmdline_parse_token_string_t cmd_showportall_what =
5335 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5336 "info#stats#xstats#fdir#stat_qmap");
5337 cmdline_parse_token_string_t cmd_showportall_all =
5338 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5339 cmdline_parse_inst_t cmd_showportall = {
5340 .f = cmd_showportall_parsed,
5342 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5344 (void *)&cmd_showportall_show,
5345 (void *)&cmd_showportall_port,
5346 (void *)&cmd_showportall_what,
5347 (void *)&cmd_showportall_all,
5352 /* *** SHOW PORT INFO *** */
5353 struct cmd_showport_result {
5354 cmdline_fixed_string_t show;
5355 cmdline_fixed_string_t port;
5356 cmdline_fixed_string_t what;
5360 static void cmd_showport_parsed(void *parsed_result,
5361 __attribute__((unused)) struct cmdline *cl,
5362 __attribute__((unused)) void *data)
5364 struct cmd_showport_result *res = parsed_result;
5365 if (!strcmp(res->show, "clear")) {
5366 if (!strcmp(res->what, "stats"))
5367 nic_stats_clear(res->portnum);
5368 else if (!strcmp(res->what, "xstats"))
5369 nic_xstats_clear(res->portnum);
5370 } else if (!strcmp(res->what, "info"))
5371 port_infos_display(res->portnum);
5372 else if (!strcmp(res->what, "stats"))
5373 nic_stats_display(res->portnum);
5374 else if (!strcmp(res->what, "xstats"))
5375 nic_xstats_display(res->portnum);
5376 else if (!strcmp(res->what, "fdir"))
5377 fdir_get_infos(res->portnum);
5378 else if (!strcmp(res->what, "stat_qmap"))
5379 nic_stats_mapping_display(res->portnum);
5382 cmdline_parse_token_string_t cmd_showport_show =
5383 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5385 cmdline_parse_token_string_t cmd_showport_port =
5386 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5387 cmdline_parse_token_string_t cmd_showport_what =
5388 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5389 "info#stats#xstats#fdir#stat_qmap");
5390 cmdline_parse_token_num_t cmd_showport_portnum =
5391 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5393 cmdline_parse_inst_t cmd_showport = {
5394 .f = cmd_showport_parsed,
5396 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5398 (void *)&cmd_showport_show,
5399 (void *)&cmd_showport_port,
5400 (void *)&cmd_showport_what,
5401 (void *)&cmd_showport_portnum,
5406 /* *** READ PORT REGISTER *** */
5407 struct cmd_read_reg_result {
5408 cmdline_fixed_string_t read;
5409 cmdline_fixed_string_t reg;
5415 cmd_read_reg_parsed(void *parsed_result,
5416 __attribute__((unused)) struct cmdline *cl,
5417 __attribute__((unused)) void *data)
5419 struct cmd_read_reg_result *res = parsed_result;
5420 port_reg_display(res->port_id, res->reg_off);
5423 cmdline_parse_token_string_t cmd_read_reg_read =
5424 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5425 cmdline_parse_token_string_t cmd_read_reg_reg =
5426 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5427 cmdline_parse_token_num_t cmd_read_reg_port_id =
5428 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5429 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5430 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5432 cmdline_parse_inst_t cmd_read_reg = {
5433 .f = cmd_read_reg_parsed,
5435 .help_str = "read reg port_id reg_off",
5437 (void *)&cmd_read_reg_read,
5438 (void *)&cmd_read_reg_reg,
5439 (void *)&cmd_read_reg_port_id,
5440 (void *)&cmd_read_reg_reg_off,
5445 /* *** READ PORT REGISTER BIT FIELD *** */
5446 struct cmd_read_reg_bit_field_result {
5447 cmdline_fixed_string_t read;
5448 cmdline_fixed_string_t regfield;
5456 cmd_read_reg_bit_field_parsed(void *parsed_result,
5457 __attribute__((unused)) struct cmdline *cl,
5458 __attribute__((unused)) void *data)
5460 struct cmd_read_reg_bit_field_result *res = parsed_result;
5461 port_reg_bit_field_display(res->port_id, res->reg_off,
5462 res->bit1_pos, res->bit2_pos);
5465 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5466 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5468 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5469 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5470 regfield, "regfield");
5471 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5472 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5474 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5475 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5477 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5478 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5480 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5481 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5484 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5485 .f = cmd_read_reg_bit_field_parsed,
5487 .help_str = "read regfield port_id reg_off bit_x bit_y "
5488 "(read register bit field between bit_x and bit_y included)",
5490 (void *)&cmd_read_reg_bit_field_read,
5491 (void *)&cmd_read_reg_bit_field_regfield,
5492 (void *)&cmd_read_reg_bit_field_port_id,
5493 (void *)&cmd_read_reg_bit_field_reg_off,
5494 (void *)&cmd_read_reg_bit_field_bit1_pos,
5495 (void *)&cmd_read_reg_bit_field_bit2_pos,
5500 /* *** READ PORT REGISTER BIT *** */
5501 struct cmd_read_reg_bit_result {
5502 cmdline_fixed_string_t read;
5503 cmdline_fixed_string_t regbit;
5510 cmd_read_reg_bit_parsed(void *parsed_result,
5511 __attribute__((unused)) struct cmdline *cl,
5512 __attribute__((unused)) void *data)
5514 struct cmd_read_reg_bit_result *res = parsed_result;
5515 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5518 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5519 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5520 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5521 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5523 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5524 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5525 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5526 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5527 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5528 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5530 cmdline_parse_inst_t cmd_read_reg_bit = {
5531 .f = cmd_read_reg_bit_parsed,
5533 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5535 (void *)&cmd_read_reg_bit_read,
5536 (void *)&cmd_read_reg_bit_regbit,
5537 (void *)&cmd_read_reg_bit_port_id,
5538 (void *)&cmd_read_reg_bit_reg_off,
5539 (void *)&cmd_read_reg_bit_bit_pos,
5544 /* *** WRITE PORT REGISTER *** */
5545 struct cmd_write_reg_result {
5546 cmdline_fixed_string_t write;
5547 cmdline_fixed_string_t reg;
5554 cmd_write_reg_parsed(void *parsed_result,
5555 __attribute__((unused)) struct cmdline *cl,
5556 __attribute__((unused)) void *data)
5558 struct cmd_write_reg_result *res = parsed_result;
5559 port_reg_set(res->port_id, res->reg_off, res->value);
5562 cmdline_parse_token_string_t cmd_write_reg_write =
5563 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5564 cmdline_parse_token_string_t cmd_write_reg_reg =
5565 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5566 cmdline_parse_token_num_t cmd_write_reg_port_id =
5567 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5568 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5569 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5570 cmdline_parse_token_num_t cmd_write_reg_value =
5571 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5573 cmdline_parse_inst_t cmd_write_reg = {
5574 .f = cmd_write_reg_parsed,
5576 .help_str = "write reg port_id reg_off reg_value",
5578 (void *)&cmd_write_reg_write,
5579 (void *)&cmd_write_reg_reg,
5580 (void *)&cmd_write_reg_port_id,
5581 (void *)&cmd_write_reg_reg_off,
5582 (void *)&cmd_write_reg_value,
5587 /* *** WRITE PORT REGISTER BIT FIELD *** */
5588 struct cmd_write_reg_bit_field_result {
5589 cmdline_fixed_string_t write;
5590 cmdline_fixed_string_t regfield;
5599 cmd_write_reg_bit_field_parsed(void *parsed_result,
5600 __attribute__((unused)) struct cmdline *cl,
5601 __attribute__((unused)) void *data)
5603 struct cmd_write_reg_bit_field_result *res = parsed_result;
5604 port_reg_bit_field_set(res->port_id, res->reg_off,
5605 res->bit1_pos, res->bit2_pos, res->value);
5608 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5609 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5611 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5612 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5613 regfield, "regfield");
5614 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5615 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5617 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5618 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5620 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5621 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5623 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5624 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5626 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5627 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5630 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5631 .f = cmd_write_reg_bit_field_parsed,
5633 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5634 "(set register bit field between bit_x and bit_y included)",
5636 (void *)&cmd_write_reg_bit_field_write,
5637 (void *)&cmd_write_reg_bit_field_regfield,
5638 (void *)&cmd_write_reg_bit_field_port_id,
5639 (void *)&cmd_write_reg_bit_field_reg_off,
5640 (void *)&cmd_write_reg_bit_field_bit1_pos,
5641 (void *)&cmd_write_reg_bit_field_bit2_pos,
5642 (void *)&cmd_write_reg_bit_field_value,
5647 /* *** WRITE PORT REGISTER BIT *** */
5648 struct cmd_write_reg_bit_result {
5649 cmdline_fixed_string_t write;
5650 cmdline_fixed_string_t regbit;
5658 cmd_write_reg_bit_parsed(void *parsed_result,
5659 __attribute__((unused)) struct cmdline *cl,
5660 __attribute__((unused)) void *data)
5662 struct cmd_write_reg_bit_result *res = parsed_result;
5663 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5666 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5667 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5669 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5670 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5672 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5673 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5674 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5675 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5676 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5677 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5678 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5679 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5681 cmdline_parse_inst_t cmd_write_reg_bit = {
5682 .f = cmd_write_reg_bit_parsed,
5684 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5686 (void *)&cmd_write_reg_bit_write,
5687 (void *)&cmd_write_reg_bit_regbit,
5688 (void *)&cmd_write_reg_bit_port_id,
5689 (void *)&cmd_write_reg_bit_reg_off,
5690 (void *)&cmd_write_reg_bit_bit_pos,
5691 (void *)&cmd_write_reg_bit_value,
5696 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5697 struct cmd_read_rxd_txd_result {
5698 cmdline_fixed_string_t read;
5699 cmdline_fixed_string_t rxd_txd;
5706 cmd_read_rxd_txd_parsed(void *parsed_result,
5707 __attribute__((unused)) struct cmdline *cl,
5708 __attribute__((unused)) void *data)
5710 struct cmd_read_rxd_txd_result *res = parsed_result;
5712 if (!strcmp(res->rxd_txd, "rxd"))
5713 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5714 else if (!strcmp(res->rxd_txd, "txd"))
5715 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5718 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5719 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5720 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5721 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5723 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5724 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5725 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5726 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5727 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5728 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5730 cmdline_parse_inst_t cmd_read_rxd_txd = {
5731 .f = cmd_read_rxd_txd_parsed,
5733 .help_str = "read rxd|txd port_id queue_id rxd_id",
5735 (void *)&cmd_read_rxd_txd_read,
5736 (void *)&cmd_read_rxd_txd_rxd_txd,
5737 (void *)&cmd_read_rxd_txd_port_id,
5738 (void *)&cmd_read_rxd_txd_queue_id,
5739 (void *)&cmd_read_rxd_txd_desc_id,
5745 struct cmd_quit_result {
5746 cmdline_fixed_string_t quit;
5749 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5751 __attribute__((unused)) void *data)
5757 cmdline_parse_token_string_t cmd_quit_quit =
5758 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5760 cmdline_parse_inst_t cmd_quit = {
5761 .f = cmd_quit_parsed,
5763 .help_str = "exit application",
5765 (void *)&cmd_quit_quit,
5770 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5771 struct cmd_mac_addr_result {
5772 cmdline_fixed_string_t mac_addr_cmd;
5773 cmdline_fixed_string_t what;
5775 struct ether_addr address;
5778 static void cmd_mac_addr_parsed(void *parsed_result,
5779 __attribute__((unused)) struct cmdline *cl,
5780 __attribute__((unused)) void *data)
5782 struct cmd_mac_addr_result *res = parsed_result;
5785 if (strcmp(res->what, "add") == 0)
5786 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5788 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5790 /* check the return value and print it if is < 0 */
5792 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5796 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5797 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5799 cmdline_parse_token_string_t cmd_mac_addr_what =
5800 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5802 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5803 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5804 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5805 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5807 cmdline_parse_inst_t cmd_mac_addr = {
5808 .f = cmd_mac_addr_parsed,
5810 .help_str = "mac_addr add|remove X <address>: "
5811 "add/remove MAC address on port X",
5813 (void *)&cmd_mac_addr_cmd,
5814 (void *)&cmd_mac_addr_what,
5815 (void *)&cmd_mac_addr_portnum,
5816 (void *)&cmd_mac_addr_addr,
5822 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5823 struct cmd_set_qmap_result {
5824 cmdline_fixed_string_t set;
5825 cmdline_fixed_string_t qmap;
5826 cmdline_fixed_string_t what;
5833 cmd_set_qmap_parsed(void *parsed_result,
5834 __attribute__((unused)) struct cmdline *cl,
5835 __attribute__((unused)) void *data)
5837 struct cmd_set_qmap_result *res = parsed_result;
5838 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5840 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5843 cmdline_parse_token_string_t cmd_setqmap_set =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5846 cmdline_parse_token_string_t cmd_setqmap_qmap =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5849 cmdline_parse_token_string_t cmd_setqmap_what =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5852 cmdline_parse_token_num_t cmd_setqmap_portid =
5853 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5855 cmdline_parse_token_num_t cmd_setqmap_queueid =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5858 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5859 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5862 cmdline_parse_inst_t cmd_set_qmap = {
5863 .f = cmd_set_qmap_parsed,
5865 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5867 (void *)&cmd_setqmap_set,
5868 (void *)&cmd_setqmap_qmap,
5869 (void *)&cmd_setqmap_what,
5870 (void *)&cmd_setqmap_portid,
5871 (void *)&cmd_setqmap_queueid,
5872 (void *)&cmd_setqmap_mapvalue,
5877 /* *** CONFIGURE UNICAST HASH TABLE *** */
5878 struct cmd_set_uc_hash_table {
5879 cmdline_fixed_string_t set;
5880 cmdline_fixed_string_t port;
5882 cmdline_fixed_string_t what;
5883 struct ether_addr address;
5884 cmdline_fixed_string_t mode;
5888 cmd_set_uc_hash_parsed(void *parsed_result,
5889 __attribute__((unused)) struct cmdline *cl,
5890 __attribute__((unused)) void *data)
5893 struct cmd_set_uc_hash_table *res = parsed_result;
5895 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5897 if (strcmp(res->what, "uta") == 0)
5898 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5899 &res->address,(uint8_t)is_on);
5901 printf("bad unicast hash table parameter, return code = %d \n", ret);
5905 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5908 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5911 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5912 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5914 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5917 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5918 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5920 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5924 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5925 .f = cmd_set_uc_hash_parsed,
5927 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5929 (void *)&cmd_set_uc_hash_set,
5930 (void *)&cmd_set_uc_hash_port,
5931 (void *)&cmd_set_uc_hash_portid,
5932 (void *)&cmd_set_uc_hash_what,
5933 (void *)&cmd_set_uc_hash_mac,
5934 (void *)&cmd_set_uc_hash_mode,
5939 struct cmd_set_uc_all_hash_table {
5940 cmdline_fixed_string_t set;
5941 cmdline_fixed_string_t port;
5943 cmdline_fixed_string_t what;
5944 cmdline_fixed_string_t value;
5945 cmdline_fixed_string_t mode;
5949 cmd_set_uc_all_hash_parsed(void *parsed_result,
5950 __attribute__((unused)) struct cmdline *cl,
5951 __attribute__((unused)) void *data)
5954 struct cmd_set_uc_all_hash_table *res = parsed_result;
5956 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5958 if ((strcmp(res->what, "uta") == 0) &&
5959 (strcmp(res->value, "all") == 0))
5960 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5962 printf("bad unicast hash table parameter,"
5963 "return code = %d \n", ret);
5966 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5967 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5969 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5970 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5972 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5973 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5975 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5976 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5978 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5979 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5981 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5982 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5985 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5986 .f = cmd_set_uc_all_hash_parsed,
5988 .help_str = "set port X uta all on|off (X = port number)",
5990 (void *)&cmd_set_uc_all_hash_set,
5991 (void *)&cmd_set_uc_all_hash_port,
5992 (void *)&cmd_set_uc_all_hash_portid,
5993 (void *)&cmd_set_uc_all_hash_what,
5994 (void *)&cmd_set_uc_all_hash_value,
5995 (void *)&cmd_set_uc_all_hash_mode,
6000 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6001 struct cmd_set_vf_macvlan_filter {
6002 cmdline_fixed_string_t set;
6003 cmdline_fixed_string_t port;
6005 cmdline_fixed_string_t vf;
6007 struct ether_addr address;
6008 cmdline_fixed_string_t filter_type;
6009 cmdline_fixed_string_t mode;
6013 cmd_set_vf_macvlan_parsed(void *parsed_result,
6014 __attribute__((unused)) struct cmdline *cl,
6015 __attribute__((unused)) void *data)
6018 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6019 struct rte_eth_mac_filter filter;
6021 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6023 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6025 /* set VF MAC filter */
6029 filter.dst_id = res->vf_id;
6031 if (!strcmp(res->filter_type, "exact-mac"))
6032 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6033 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6034 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6035 else if (!strcmp(res->filter_type, "hashmac"))
6036 filter.filter_type = RTE_MAC_HASH_MATCH;
6037 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6038 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6040 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6043 ret = rte_eth_dev_filter_ctrl(res->port_id,
6044 RTE_ETH_FILTER_MACVLAN,
6048 ret = rte_eth_dev_filter_ctrl(res->port_id,
6049 RTE_ETH_FILTER_MACVLAN,
6050 RTE_ETH_FILTER_DELETE,
6054 printf("bad set MAC hash parameter, return code = %d\n", ret);
6058 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6061 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6064 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6065 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6067 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6068 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6070 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6071 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6073 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6074 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6076 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6077 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6078 filter_type, "exact-mac#exact-mac-vlan"
6079 "#hashmac#hashmac-vlan");
6080 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6081 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6084 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6085 .f = cmd_set_vf_macvlan_parsed,
6087 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6088 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6090 "exact match rule:exact match of MAC or MAC and VLAN; "
6091 "hash match rule: hash match of MAC and exact match "
6094 (void *)&cmd_set_vf_macvlan_set,
6095 (void *)&cmd_set_vf_macvlan_port,
6096 (void *)&cmd_set_vf_macvlan_portid,
6097 (void *)&cmd_set_vf_macvlan_vf,
6098 (void *)&cmd_set_vf_macvlan_vf_id,
6099 (void *)&cmd_set_vf_macvlan_mac,
6100 (void *)&cmd_set_vf_macvlan_filter_type,
6101 (void *)&cmd_set_vf_macvlan_mode,
6106 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6107 struct cmd_set_vf_traffic {
6108 cmdline_fixed_string_t set;
6109 cmdline_fixed_string_t port;
6111 cmdline_fixed_string_t vf;
6113 cmdline_fixed_string_t what;
6114 cmdline_fixed_string_t mode;
6118 cmd_set_vf_traffic_parsed(void *parsed_result,
6119 __attribute__((unused)) struct cmdline *cl,
6120 __attribute__((unused)) void *data)
6122 struct cmd_set_vf_traffic *res = parsed_result;
6123 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6124 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6126 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6129 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6132 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6133 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6135 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6136 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6138 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6139 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6141 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6142 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6144 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6145 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6147 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6148 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6151 cmdline_parse_inst_t cmd_set_vf_traffic = {
6152 .f = cmd_set_vf_traffic_parsed,
6154 .help_str = "set port X vf Y rx|tx on|off"
6155 "(X = port number,Y = vf id)",
6157 (void *)&cmd_setvf_traffic_set,
6158 (void *)&cmd_setvf_traffic_port,
6159 (void *)&cmd_setvf_traffic_portid,
6160 (void *)&cmd_setvf_traffic_vf,
6161 (void *)&cmd_setvf_traffic_vfid,
6162 (void *)&cmd_setvf_traffic_what,
6163 (void *)&cmd_setvf_traffic_mode,
6168 /* *** CONFIGURE VF RECEIVE MODE *** */
6169 struct cmd_set_vf_rxmode {
6170 cmdline_fixed_string_t set;
6171 cmdline_fixed_string_t port;
6173 cmdline_fixed_string_t vf;
6175 cmdline_fixed_string_t what;
6176 cmdline_fixed_string_t mode;
6177 cmdline_fixed_string_t on;
6181 cmd_set_vf_rxmode_parsed(void *parsed_result,
6182 __attribute__((unused)) struct cmdline *cl,
6183 __attribute__((unused)) void *data)
6186 uint16_t rx_mode = 0;
6187 struct cmd_set_vf_rxmode *res = parsed_result;
6189 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6190 if (!strcmp(res->what,"rxmode")) {
6191 if (!strcmp(res->mode, "AUPE"))
6192 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6193 else if (!strcmp(res->mode, "ROPE"))
6194 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6195 else if (!strcmp(res->mode, "BAM"))
6196 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6197 else if (!strncmp(res->mode, "MPE",3))
6198 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6201 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6203 printf("bad VF receive mode parameter, return code = %d \n",
6207 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6210 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6211 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6213 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6214 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6216 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6217 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6219 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6220 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6222 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6223 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6225 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6227 mode, "AUPE#ROPE#BAM#MPE");
6228 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6232 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6233 .f = cmd_set_vf_rxmode_parsed,
6235 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6237 (void *)&cmd_set_vf_rxmode_set,
6238 (void *)&cmd_set_vf_rxmode_port,
6239 (void *)&cmd_set_vf_rxmode_portid,
6240 (void *)&cmd_set_vf_rxmode_vf,
6241 (void *)&cmd_set_vf_rxmode_vfid,
6242 (void *)&cmd_set_vf_rxmode_what,
6243 (void *)&cmd_set_vf_rxmode_mode,
6244 (void *)&cmd_set_vf_rxmode_on,
6249 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6250 struct cmd_vf_mac_addr_result {
6251 cmdline_fixed_string_t mac_addr_cmd;
6252 cmdline_fixed_string_t what;
6253 cmdline_fixed_string_t port;
6255 cmdline_fixed_string_t vf;
6257 struct ether_addr address;
6260 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6261 __attribute__((unused)) struct cmdline *cl,
6262 __attribute__((unused)) void *data)
6264 struct cmd_vf_mac_addr_result *res = parsed_result;
6267 if (strcmp(res->what, "add") == 0)
6268 ret = rte_eth_dev_mac_addr_add(res->port_num,
6269 &res->address, res->vf_num);
6271 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6275 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6276 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6277 mac_addr_cmd,"mac_addr");
6278 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6279 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6281 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6282 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6284 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6285 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6287 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6288 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6290 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6291 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6293 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6294 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6297 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6298 .f = cmd_vf_mac_addr_parsed,
6300 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6301 "Y = VF number)add MAC address filtering for a VF on port X",
6303 (void *)&cmd_vf_mac_addr_cmd,
6304 (void *)&cmd_vf_mac_addr_what,
6305 (void *)&cmd_vf_mac_addr_port,
6306 (void *)&cmd_vf_mac_addr_portnum,
6307 (void *)&cmd_vf_mac_addr_vf,
6308 (void *)&cmd_vf_mac_addr_vfnum,
6309 (void *)&cmd_vf_mac_addr_addr,
6314 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6315 struct cmd_vf_rx_vlan_filter {
6316 cmdline_fixed_string_t rx_vlan;
6317 cmdline_fixed_string_t what;
6319 cmdline_fixed_string_t port;
6321 cmdline_fixed_string_t vf;
6326 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6327 __attribute__((unused)) struct cmdline *cl,
6328 __attribute__((unused)) void *data)
6330 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6332 if (!strcmp(res->what, "add"))
6333 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6335 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6338 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6339 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6340 rx_vlan, "rx_vlan");
6341 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6342 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6344 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6345 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6347 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6348 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6350 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6351 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6353 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6354 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6356 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6357 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6360 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6361 .f = cmd_vf_rx_vlan_filter_parsed,
6363 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6364 "Y = port number,Z = hexadecimal VF mask)",
6366 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6367 (void *)&cmd_vf_rx_vlan_filter_what,
6368 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6369 (void *)&cmd_vf_rx_vlan_filter_port,
6370 (void *)&cmd_vf_rx_vlan_filter_portid,
6371 (void *)&cmd_vf_rx_vlan_filter_vf,
6372 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6377 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6378 struct cmd_queue_rate_limit_result {
6379 cmdline_fixed_string_t set;
6380 cmdline_fixed_string_t port;
6382 cmdline_fixed_string_t queue;
6384 cmdline_fixed_string_t rate;
6388 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6389 __attribute__((unused)) struct cmdline *cl,
6390 __attribute__((unused)) void *data)
6392 struct cmd_queue_rate_limit_result *res = parsed_result;
6395 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6396 && (strcmp(res->queue, "queue") == 0)
6397 && (strcmp(res->rate, "rate") == 0))
6398 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6401 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6405 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6406 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6408 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6409 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6411 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6412 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6414 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6415 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6417 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6418 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6420 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6421 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6423 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6424 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6427 cmdline_parse_inst_t cmd_queue_rate_limit = {
6428 .f = cmd_queue_rate_limit_parsed,
6430 .help_str = "set port X queue Y rate Z:(X = port number,"
6431 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6433 (void *)&cmd_queue_rate_limit_set,
6434 (void *)&cmd_queue_rate_limit_port,
6435 (void *)&cmd_queue_rate_limit_portnum,
6436 (void *)&cmd_queue_rate_limit_queue,
6437 (void *)&cmd_queue_rate_limit_queuenum,
6438 (void *)&cmd_queue_rate_limit_rate,
6439 (void *)&cmd_queue_rate_limit_ratenum,
6444 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6445 struct cmd_vf_rate_limit_result {
6446 cmdline_fixed_string_t set;
6447 cmdline_fixed_string_t port;
6449 cmdline_fixed_string_t vf;
6451 cmdline_fixed_string_t rate;
6453 cmdline_fixed_string_t q_msk;
6457 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6458 __attribute__((unused)) struct cmdline *cl,
6459 __attribute__((unused)) void *data)
6461 struct cmd_vf_rate_limit_result *res = parsed_result;
6464 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6465 && (strcmp(res->vf, "vf") == 0)
6466 && (strcmp(res->rate, "rate") == 0)
6467 && (strcmp(res->q_msk, "queue_mask") == 0))
6468 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6469 res->rate_num, res->q_msk_val);
6471 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6475 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6476 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6478 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6479 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6481 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6482 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6484 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6485 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6487 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6488 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6490 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6491 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6493 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6494 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6496 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6497 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6498 q_msk, "queue_mask");
6499 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6500 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6503 cmdline_parse_inst_t cmd_vf_rate_limit = {
6504 .f = cmd_vf_rate_limit_parsed,
6506 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6507 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6508 "for queues of VF on port X",
6510 (void *)&cmd_vf_rate_limit_set,
6511 (void *)&cmd_vf_rate_limit_port,
6512 (void *)&cmd_vf_rate_limit_portnum,
6513 (void *)&cmd_vf_rate_limit_vf,
6514 (void *)&cmd_vf_rate_limit_vfnum,
6515 (void *)&cmd_vf_rate_limit_rate,
6516 (void *)&cmd_vf_rate_limit_ratenum,
6517 (void *)&cmd_vf_rate_limit_q_msk,
6518 (void *)&cmd_vf_rate_limit_q_msk_val,
6523 /* *** ADD TUNNEL FILTER OF A PORT *** */
6524 struct cmd_tunnel_filter_result {
6525 cmdline_fixed_string_t cmd;
6526 cmdline_fixed_string_t what;
6528 struct ether_addr outer_mac;
6529 struct ether_addr inner_mac;
6530 cmdline_ipaddr_t ip_value;
6531 uint16_t inner_vlan;
6532 cmdline_fixed_string_t tunnel_type;
6533 cmdline_fixed_string_t filter_type;
6539 cmd_tunnel_filter_parsed(void *parsed_result,
6540 __attribute__((unused)) struct cmdline *cl,
6541 __attribute__((unused)) void *data)
6543 struct cmd_tunnel_filter_result *res = parsed_result;
6544 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6547 tunnel_filter_conf.outer_mac = &res->outer_mac;
6548 tunnel_filter_conf.inner_mac = &res->inner_mac;
6549 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6551 if (res->ip_value.family == AF_INET) {
6552 tunnel_filter_conf.ip_addr.ipv4_addr =
6553 res->ip_value.addr.ipv4.s_addr;
6554 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6556 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6557 &(res->ip_value.addr.ipv6),
6558 sizeof(struct in6_addr));
6559 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6562 if (!strcmp(res->filter_type, "imac-ivlan"))
6563 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6564 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6565 tunnel_filter_conf.filter_type =
6566 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6567 else if (!strcmp(res->filter_type, "imac-tenid"))
6568 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6569 else if (!strcmp(res->filter_type, "imac"))
6570 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6571 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6572 tunnel_filter_conf.filter_type =
6573 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6575 printf("The filter type is not supported");
6579 if (!strcmp(res->tunnel_type, "vxlan"))
6580 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6582 printf("Only VXLAN is supported now.\n");
6586 tunnel_filter_conf.tenant_id = res->tenant_id;
6587 tunnel_filter_conf.queue_id = res->queue_num;
6588 if (!strcmp(res->what, "add"))
6589 ret = rte_eth_dev_filter_ctrl(res->port_id,
6590 RTE_ETH_FILTER_TUNNEL,
6592 &tunnel_filter_conf);
6594 ret = rte_eth_dev_filter_ctrl(res->port_id,
6595 RTE_ETH_FILTER_TUNNEL,
6596 RTE_ETH_FILTER_DELETE,
6597 &tunnel_filter_conf);
6599 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6603 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6604 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6605 cmd, "tunnel_filter");
6606 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6607 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6609 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6610 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6612 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6613 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6615 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6616 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6618 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6619 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6620 inner_vlan, UINT16);
6621 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6622 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6624 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6625 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6626 tunnel_type, "vxlan");
6628 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6629 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6630 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6631 "imac#omac-imac-tenid");
6632 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6633 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6635 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6636 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6639 cmdline_parse_inst_t cmd_tunnel_filter = {
6640 .f = cmd_tunnel_filter_parsed,
6642 .help_str = "add/rm tunnel filter of a port: "
6643 "tunnel_filter add port_id outer_mac inner_mac ip "
6644 "inner_vlan tunnel_type(vxlan) filter_type "
6645 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6646 "imac|omac-imac-tenid) "
6647 "tenant_id queue_num",
6649 (void *)&cmd_tunnel_filter_cmd,
6650 (void *)&cmd_tunnel_filter_what,
6651 (void *)&cmd_tunnel_filter_port_id,
6652 (void *)&cmd_tunnel_filter_outer_mac,
6653 (void *)&cmd_tunnel_filter_inner_mac,
6654 (void *)&cmd_tunnel_filter_ip_value,
6655 (void *)&cmd_tunnel_filter_innner_vlan,
6656 (void *)&cmd_tunnel_filter_tunnel_type,
6657 (void *)&cmd_tunnel_filter_filter_type,
6658 (void *)&cmd_tunnel_filter_tenant_id,
6659 (void *)&cmd_tunnel_filter_queue_num,
6664 /* *** CONFIGURE TUNNEL UDP PORT *** */
6665 struct cmd_tunnel_udp_config {
6666 cmdline_fixed_string_t cmd;
6667 cmdline_fixed_string_t what;
6673 cmd_tunnel_udp_config_parsed(void *parsed_result,
6674 __attribute__((unused)) struct cmdline *cl,
6675 __attribute__((unused)) void *data)
6677 struct cmd_tunnel_udp_config *res = parsed_result;
6678 struct rte_eth_udp_tunnel tunnel_udp;
6681 tunnel_udp.udp_port = res->udp_port;
6683 if (!strcmp(res->cmd, "rx_vxlan_port"))
6684 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6686 if (!strcmp(res->what, "add"))
6687 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6689 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6692 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6695 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6696 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6697 cmd, "rx_vxlan_port");
6698 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6699 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6701 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6702 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6704 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6705 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6708 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6709 .f = cmd_tunnel_udp_config_parsed,
6711 .help_str = "add/rm an tunneling UDP port filter: "
6712 "rx_vxlan_port add udp_port port_id",
6714 (void *)&cmd_tunnel_udp_config_cmd,
6715 (void *)&cmd_tunnel_udp_config_what,
6716 (void *)&cmd_tunnel_udp_config_udp_port,
6717 (void *)&cmd_tunnel_udp_config_port_id,
6722 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6723 struct cmd_set_mirror_mask_result {
6724 cmdline_fixed_string_t set;
6725 cmdline_fixed_string_t port;
6727 cmdline_fixed_string_t mirror;
6729 cmdline_fixed_string_t what;
6730 cmdline_fixed_string_t value;
6731 cmdline_fixed_string_t dstpool;
6733 cmdline_fixed_string_t on;
6736 cmdline_parse_token_string_t cmd_mirror_mask_set =
6737 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6739 cmdline_parse_token_string_t cmd_mirror_mask_port =
6740 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6742 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6743 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6745 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6747 mirror, "mirror-rule");
6748 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6749 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6751 cmdline_parse_token_string_t cmd_mirror_mask_what =
6752 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6753 what, "pool-mirror#vlan-mirror");
6754 cmdline_parse_token_string_t cmd_mirror_mask_value =
6755 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6757 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6759 dstpool, "dst-pool");
6760 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6761 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6763 cmdline_parse_token_string_t cmd_mirror_mask_on =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6768 cmd_set_mirror_mask_parsed(void *parsed_result,
6769 __attribute__((unused)) struct cmdline *cl,
6770 __attribute__((unused)) void *data)
6773 struct cmd_set_mirror_mask_result *res = parsed_result;
6774 struct rte_eth_vmdq_mirror_conf mr_conf;
6776 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6778 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6780 mr_conf.dst_pool = res->dstpool_id;
6782 if (!strcmp(res->what, "pool-mirror")) {
6783 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6784 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6785 } else if(!strcmp(res->what, "vlan-mirror")) {
6786 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6787 nb_item = parse_item_list(res->value, "core",
6788 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6792 for(i=0; i < nb_item; i++) {
6793 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6794 printf("Invalid vlan_id: must be < 4096\n");
6798 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6799 mr_conf.vlan.vlan_mask |= 1ULL << i;
6803 if(!strcmp(res->on, "on"))
6804 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6807 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6810 printf("mirror rule add error: (%s)\n", strerror(-ret));
6813 cmdline_parse_inst_t cmd_set_mirror_mask = {
6814 .f = cmd_set_mirror_mask_parsed,
6816 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6817 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6819 (void *)&cmd_mirror_mask_set,
6820 (void *)&cmd_mirror_mask_port,
6821 (void *)&cmd_mirror_mask_portid,
6822 (void *)&cmd_mirror_mask_mirror,
6823 (void *)&cmd_mirror_mask_ruleid,
6824 (void *)&cmd_mirror_mask_what,
6825 (void *)&cmd_mirror_mask_value,
6826 (void *)&cmd_mirror_mask_dstpool,
6827 (void *)&cmd_mirror_mask_poolid,
6828 (void *)&cmd_mirror_mask_on,
6833 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6834 struct cmd_set_mirror_link_result {
6835 cmdline_fixed_string_t set;
6836 cmdline_fixed_string_t port;
6838 cmdline_fixed_string_t mirror;
6840 cmdline_fixed_string_t what;
6841 cmdline_fixed_string_t dstpool;
6843 cmdline_fixed_string_t on;
6846 cmdline_parse_token_string_t cmd_mirror_link_set =
6847 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6849 cmdline_parse_token_string_t cmd_mirror_link_port =
6850 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6852 cmdline_parse_token_num_t cmd_mirror_link_portid =
6853 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6855 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6856 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6857 mirror, "mirror-rule");
6858 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6859 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6861 cmdline_parse_token_string_t cmd_mirror_link_what =
6862 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6863 what, "uplink-mirror#downlink-mirror");
6864 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6865 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6866 dstpool, "dst-pool");
6867 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6868 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6870 cmdline_parse_token_string_t cmd_mirror_link_on =
6871 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6875 cmd_set_mirror_link_parsed(void *parsed_result,
6876 __attribute__((unused)) struct cmdline *cl,
6877 __attribute__((unused)) void *data)
6880 struct cmd_set_mirror_link_result *res = parsed_result;
6881 struct rte_eth_vmdq_mirror_conf mr_conf;
6883 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6884 if(!strcmp(res->what, "uplink-mirror")) {
6885 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6886 }else if(!strcmp(res->what, "downlink-mirror"))
6887 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6889 mr_conf.dst_pool = res->dstpool_id;
6891 if(!strcmp(res->on, "on"))
6892 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6895 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6898 /* check the return value and print it if is < 0 */
6900 printf("mirror rule add error: (%s)\n", strerror(-ret));
6904 cmdline_parse_inst_t cmd_set_mirror_link = {
6905 .f = cmd_set_mirror_link_parsed,
6907 .help_str = "set port X mirror-rule Y uplink-mirror|"
6908 "downlink-mirror dst-pool Z on|off",
6910 (void *)&cmd_mirror_link_set,
6911 (void *)&cmd_mirror_link_port,
6912 (void *)&cmd_mirror_link_portid,
6913 (void *)&cmd_mirror_link_mirror,
6914 (void *)&cmd_mirror_link_ruleid,
6915 (void *)&cmd_mirror_link_what,
6916 (void *)&cmd_mirror_link_dstpool,
6917 (void *)&cmd_mirror_link_poolid,
6918 (void *)&cmd_mirror_link_on,
6923 /* *** RESET VM MIRROR RULE *** */
6924 struct cmd_rm_mirror_rule_result {
6925 cmdline_fixed_string_t reset;
6926 cmdline_fixed_string_t port;
6928 cmdline_fixed_string_t mirror;
6932 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6933 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6935 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6936 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6938 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6939 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6941 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6942 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6943 mirror, "mirror-rule");
6944 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6945 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6949 cmd_reset_mirror_rule_parsed(void *parsed_result,
6950 __attribute__((unused)) struct cmdline *cl,
6951 __attribute__((unused)) void *data)
6954 struct cmd_set_mirror_link_result *res = parsed_result;
6956 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6958 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6961 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6962 .f = cmd_reset_mirror_rule_parsed,
6964 .help_str = "reset port X mirror-rule Y",
6966 (void *)&cmd_rm_mirror_rule_reset,
6967 (void *)&cmd_rm_mirror_rule_port,
6968 (void *)&cmd_rm_mirror_rule_portid,
6969 (void *)&cmd_rm_mirror_rule_mirror,
6970 (void *)&cmd_rm_mirror_rule_ruleid,
6975 /* ******************************************************************************** */
6977 struct cmd_dump_result {
6978 cmdline_fixed_string_t dump;
6982 dump_struct_sizes(void)
6984 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6985 DUMP_SIZE(struct rte_mbuf);
6986 DUMP_SIZE(struct rte_mempool);
6987 DUMP_SIZE(struct rte_ring);
6991 static void cmd_dump_parsed(void *parsed_result,
6992 __attribute__((unused)) struct cmdline *cl,
6993 __attribute__((unused)) void *data)
6995 struct cmd_dump_result *res = parsed_result;
6997 if (!strcmp(res->dump, "dump_physmem"))
6998 rte_dump_physmem_layout(stdout);
6999 else if (!strcmp(res->dump, "dump_memzone"))
7000 rte_memzone_dump(stdout);
7001 else if (!strcmp(res->dump, "dump_log_history"))
7002 rte_log_dump_history(stdout);
7003 else if (!strcmp(res->dump, "dump_struct_sizes"))
7004 dump_struct_sizes();
7005 else if (!strcmp(res->dump, "dump_ring"))
7006 rte_ring_list_dump(stdout);
7007 else if (!strcmp(res->dump, "dump_mempool"))
7008 rte_mempool_list_dump(stdout);
7009 else if (!strcmp(res->dump, "dump_devargs"))
7010 rte_eal_devargs_dump(stdout);
7013 cmdline_parse_token_string_t cmd_dump_dump =
7014 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7018 "dump_struct_sizes#"
7023 cmdline_parse_inst_t cmd_dump = {
7024 .f = cmd_dump_parsed, /* function to call */
7025 .data = NULL, /* 2nd arg of func */
7026 .help_str = "dump status",
7027 .tokens = { /* token list, NULL terminated */
7028 (void *)&cmd_dump_dump,
7033 /* ******************************************************************************** */
7035 struct cmd_dump_one_result {
7036 cmdline_fixed_string_t dump;
7037 cmdline_fixed_string_t name;
7040 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7041 __attribute__((unused)) void *data)
7043 struct cmd_dump_one_result *res = parsed_result;
7045 if (!strcmp(res->dump, "dump_ring")) {
7047 r = rte_ring_lookup(res->name);
7049 cmdline_printf(cl, "Cannot find ring\n");
7052 rte_ring_dump(stdout, r);
7053 } else if (!strcmp(res->dump, "dump_mempool")) {
7054 struct rte_mempool *mp;
7055 mp = rte_mempool_lookup(res->name);
7057 cmdline_printf(cl, "Cannot find mempool\n");
7060 rte_mempool_dump(stdout, mp);
7064 cmdline_parse_token_string_t cmd_dump_one_dump =
7065 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7066 "dump_ring#dump_mempool");
7068 cmdline_parse_token_string_t cmd_dump_one_name =
7069 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7071 cmdline_parse_inst_t cmd_dump_one = {
7072 .f = cmd_dump_one_parsed, /* function to call */
7073 .data = NULL, /* 2nd arg of func */
7074 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7075 .tokens = { /* token list, NULL terminated */
7076 (void *)&cmd_dump_one_dump,
7077 (void *)&cmd_dump_one_name,
7082 /* *** ADD/REMOVE an ethertype FILTER *** */
7083 struct cmd_ethertype_filter_result {
7084 cmdline_fixed_string_t filter;
7086 cmdline_fixed_string_t ethertype;
7087 uint16_t ethertype_value;
7088 cmdline_fixed_string_t priority;
7089 cmdline_fixed_string_t priority_en;
7090 uint8_t priority_value;
7091 cmdline_fixed_string_t queue;
7093 cmdline_fixed_string_t index;
7094 uint16_t index_value;
7098 cmd_ethertype_filter_parsed(void *parsed_result,
7099 __attribute__((unused)) struct cmdline *cl,
7100 __attribute__((unused)) void *data)
7103 struct cmd_ethertype_filter_result *res = parsed_result;
7104 struct rte_ethertype_filter filter;
7106 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7107 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7108 filter.priority = res->priority_value;
7110 if (!strcmp(res->priority_en, "enable"))
7111 filter.priority_en = 1;
7112 if (!strcmp(res->filter, "add_ethertype_filter"))
7113 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7115 &filter, res->queue_id);
7116 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7117 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7119 else if (!strcmp(res->filter, "get_ethertype_filter"))
7120 get_ethertype_filter(res->port_id, res->index_value);
7123 printf("ethertype filter setting error: (%s)\n",
7127 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7128 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7130 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7131 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7132 ethertype, "ethertype");
7133 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7134 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7135 ethertype_value, UINT16);
7136 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7137 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7138 priority, "priority");
7139 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7140 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7141 priority_en, "enable#disable");
7142 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7143 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7144 priority_value, UINT8);
7145 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7146 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7148 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7149 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7151 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7152 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7154 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7155 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7156 index_value, UINT16);
7157 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7158 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7159 filter, "add_ethertype_filter");
7160 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7161 .f = cmd_ethertype_filter_parsed,
7163 .help_str = "add an ethertype filter",
7165 (void *)&cmd_ethertype_filter_add_filter,
7166 (void *)&cmd_ethertype_filter_port_id,
7167 (void *)&cmd_ethertype_filter_ethertype,
7168 (void *)&cmd_ethertype_filter_ethertype_value,
7169 (void *)&cmd_ethertype_filter_priority,
7170 (void *)&cmd_ethertype_filter_priority_en,
7171 (void *)&cmd_ethertype_filter_priority_value,
7172 (void *)&cmd_ethertype_filter_queue,
7173 (void *)&cmd_ethertype_filter_queue_id,
7174 (void *)&cmd_ethertype_filter_index,
7175 (void *)&cmd_ethertype_filter_index_value,
7180 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7181 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7182 filter, "remove_ethertype_filter");
7183 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7184 .f = cmd_ethertype_filter_parsed,
7186 .help_str = "remove an ethertype filter",
7188 (void *)&cmd_ethertype_filter_remove_filter,
7189 (void *)&cmd_ethertype_filter_port_id,
7190 (void *)&cmd_ethertype_filter_index,
7191 (void *)&cmd_ethertype_filter_index_value,
7195 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7196 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7197 filter, "get_ethertype_filter");
7198 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7199 .f = cmd_ethertype_filter_parsed,
7201 .help_str = "get an ethertype filter",
7203 (void *)&cmd_ethertype_filter_get_filter,
7204 (void *)&cmd_ethertype_filter_port_id,
7205 (void *)&cmd_ethertype_filter_index,
7206 (void *)&cmd_ethertype_filter_index_value,
7211 /* *** set SYN filter *** */
7212 struct cmd_set_syn_filter_result {
7213 cmdline_fixed_string_t filter;
7215 cmdline_fixed_string_t priority;
7216 cmdline_fixed_string_t high;
7217 cmdline_fixed_string_t queue;
7222 cmd_set_syn_filter_parsed(void *parsed_result,
7223 __attribute__((unused)) struct cmdline *cl,
7224 __attribute__((unused)) void *data)
7227 struct cmd_set_syn_filter_result *res = parsed_result;
7228 struct rte_syn_filter filter;
7230 if (!strcmp(res->filter, "add_syn_filter")) {
7231 if (!strcmp(res->high, "high"))
7235 ret = rte_eth_dev_add_syn_filter(res->port_id,
7236 &filter, res->queue_id);
7237 } else if (!strcmp(res->filter, "remove_syn_filter"))
7238 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7239 else if (!strcmp(res->filter, "get_syn_filter"))
7240 get_syn_filter(res->port_id);
7242 printf("syn filter setting error: (%s)\n", strerror(-ret));
7245 cmdline_parse_token_num_t cmd_syn_filter_portid =
7246 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7248 cmdline_parse_token_string_t cmd_syn_filter_priority =
7249 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7250 priority, "priority");
7251 cmdline_parse_token_string_t cmd_syn_filter_high =
7252 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7254 cmdline_parse_token_string_t cmd_syn_filter_queue =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7257 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7258 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7260 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7261 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7262 filter, "add_syn_filter");
7263 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7264 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7265 filter, "remove_syn_filter");
7266 cmdline_parse_inst_t cmd_add_syn_filter = {
7267 .f = cmd_set_syn_filter_parsed,
7269 .help_str = "add syn filter",
7271 (void *)&cmd_syn_filter_add_filter,
7272 (void *)&cmd_syn_filter_portid,
7273 (void *)&cmd_syn_filter_priority,
7274 (void *)&cmd_syn_filter_high,
7275 (void *)&cmd_syn_filter_queue,
7276 (void *)&cmd_syn_filter_queue_id,
7280 cmdline_parse_inst_t cmd_remove_syn_filter = {
7281 .f = cmd_set_syn_filter_parsed,
7283 .help_str = "remove syn filter",
7285 (void *)&cmd_syn_filter_remove_filter,
7286 (void *)&cmd_syn_filter_portid,
7291 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7292 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7293 filter, "get_syn_filter");
7295 cmdline_parse_inst_t cmd_get_syn_filter = {
7296 .f = cmd_set_syn_filter_parsed,
7298 .help_str = "get syn filter",
7300 (void *)&cmd_syn_filter_get_filter,
7301 (void *)&cmd_syn_filter_portid,
7306 /* *** ADD/REMOVE A 2tuple FILTER *** */
7307 struct cmd_2tuple_filter_result {
7308 cmdline_fixed_string_t filter;
7310 cmdline_fixed_string_t protocol;
7311 uint8_t protocol_value;
7312 uint8_t protocol_mask;
7313 cmdline_fixed_string_t dst_port;
7314 uint16_t dst_port_value;
7315 uint16_t dst_port_mask;
7316 cmdline_fixed_string_t flags;
7317 uint8_t flags_value;
7318 cmdline_fixed_string_t priority;
7319 uint8_t priority_value;
7320 cmdline_fixed_string_t queue;
7322 cmdline_fixed_string_t index;
7323 uint16_t index_value;
7327 cmd_2tuple_filter_parsed(void *parsed_result,
7328 __attribute__((unused)) struct cmdline *cl,
7329 __attribute__((unused)) void *data)
7332 struct rte_2tuple_filter filter;
7333 struct cmd_2tuple_filter_result *res = parsed_result;
7335 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7337 if (!strcmp(res->filter, "add_2tuple_filter")) {
7338 /* need convert to big endian. */
7339 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7340 filter.protocol = res->protocol_value;
7341 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7342 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7343 filter.priority = res->priority_value;
7344 filter.tcp_flags = res->flags_value;
7345 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7346 res->index_value, &filter, res->queue_id);
7347 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7348 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7350 else if (!strcmp(res->filter, "get_2tuple_filter"))
7351 get_2tuple_filter(res->port_id, res->index_value);
7354 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7357 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7358 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7360 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7361 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7362 protocol, "protocol");
7363 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7364 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7365 protocol_value, UINT8);
7366 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7367 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7368 protocol_mask, UINT8);
7369 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7370 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7371 dst_port, "dst_port");
7372 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7373 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7374 dst_port_value, UINT16);
7375 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7376 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7377 dst_port_mask, UINT16);
7378 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7379 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7381 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7382 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7383 flags_value, UINT8);
7384 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7385 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7386 priority, "priority");
7387 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7388 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7389 priority_value, UINT8);
7390 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7391 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7393 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7394 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7396 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7397 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7399 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7400 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7401 index_value, UINT16);
7402 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7403 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7404 filter, "add_2tuple_filter");
7405 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7406 .f = cmd_2tuple_filter_parsed,
7408 .help_str = "add a 2tuple filter",
7410 (void *)&cmd_2tuple_filter_add_filter,
7411 (void *)&cmd_2tuple_filter_port_id,
7412 (void *)&cmd_2tuple_filter_protocol,
7413 (void *)&cmd_2tuple_filter_protocol_value,
7414 (void *)&cmd_2tuple_filter_protocol_mask,
7415 (void *)&cmd_2tuple_filter_dst_port,
7416 (void *)&cmd_2tuple_filter_dst_port_value,
7417 (void *)&cmd_2tuple_filter_dst_port_mask,
7418 (void *)&cmd_2tuple_filter_flags,
7419 (void *)&cmd_2tuple_filter_flags_value,
7420 (void *)&cmd_2tuple_filter_priority,
7421 (void *)&cmd_2tuple_filter_priority_value,
7422 (void *)&cmd_2tuple_filter_queue,
7423 (void *)&cmd_2tuple_filter_queue_id,
7424 (void *)&cmd_2tuple_filter_index,
7425 (void *)&cmd_2tuple_filter_index_value,
7430 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7431 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7432 filter, "remove_2tuple_filter");
7433 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7434 .f = cmd_2tuple_filter_parsed,
7436 .help_str = "remove a 2tuple filter",
7438 (void *)&cmd_2tuple_filter_remove_filter,
7439 (void *)&cmd_2tuple_filter_port_id,
7440 (void *)&cmd_2tuple_filter_index,
7441 (void *)&cmd_2tuple_filter_index_value,
7445 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7446 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7447 filter, "get_2tuple_filter");
7448 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7449 .f = cmd_2tuple_filter_parsed,
7451 .help_str = "get a 2tuple filter",
7453 (void *)&cmd_2tuple_filter_get_filter,
7454 (void *)&cmd_2tuple_filter_port_id,
7455 (void *)&cmd_2tuple_filter_index,
7456 (void *)&cmd_2tuple_filter_index_value,
7461 /* *** ADD/REMOVE A 5tuple FILTER *** */
7462 struct cmd_5tuple_filter_result {
7463 cmdline_fixed_string_t filter;
7465 cmdline_fixed_string_t dst_ip;
7466 cmdline_ipaddr_t dst_ip_value;
7467 cmdline_fixed_string_t src_ip;
7468 cmdline_ipaddr_t src_ip_value;
7469 cmdline_fixed_string_t dst_port;
7470 uint16_t dst_port_value;
7471 cmdline_fixed_string_t src_port;
7472 uint16_t src_port_value;
7473 cmdline_fixed_string_t protocol;
7474 uint8_t protocol_value;
7475 cmdline_fixed_string_t mask;
7477 cmdline_fixed_string_t flags;
7478 uint8_t flags_value;
7479 cmdline_fixed_string_t priority;
7480 uint8_t priority_value;
7481 cmdline_fixed_string_t queue;
7483 cmdline_fixed_string_t index;
7484 uint16_t index_value;
7488 cmd_5tuple_filter_parsed(void *parsed_result,
7489 __attribute__((unused)) struct cmdline *cl,
7490 __attribute__((unused)) void *data)
7493 struct rte_5tuple_filter filter;
7494 struct cmd_5tuple_filter_result *res = parsed_result;
7496 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7498 if (!strcmp(res->filter, "add_5tuple_filter")) {
7499 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7500 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7501 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7502 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7503 filter.protocol = res->protocol_value;
7504 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7505 filter.priority = res->priority_value;
7506 filter.tcp_flags = res->flags_value;
7508 if (res->dst_ip_value.family == AF_INET)
7509 /* no need to convert, already big endian. */
7510 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7512 if (filter.dst_ip_mask == 0) {
7513 printf("can not support ipv6 involved compare.\n");
7519 if (res->src_ip_value.family == AF_INET)
7520 /* no need to convert, already big endian. */
7521 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7523 if (filter.src_ip_mask == 0) {
7524 printf("can not support ipv6 involved compare.\n");
7529 /* need convert to big endian. */
7530 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7531 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7533 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7534 res->index_value, &filter, res->queue_id);
7535 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7536 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7538 else if (!strcmp(res->filter, "get_5tuple_filter"))
7539 get_5tuple_filter(res->port_id, res->index_value);
7541 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7545 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7546 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7548 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7549 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7551 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7552 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7554 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7555 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7557 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7558 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7560 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7561 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7562 dst_port, "dst_port");
7563 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7564 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7565 dst_port_value, UINT16);
7566 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7567 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7568 src_port, "src_port");
7569 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7570 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7571 src_port_value, UINT16);
7572 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7573 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7574 protocol, "protocol");
7575 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7576 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7577 protocol_value, UINT8);
7578 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7579 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7581 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7582 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7584 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7585 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7587 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7588 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7589 flags_value, UINT8);
7590 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7591 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7592 priority, "priority");
7593 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7594 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7595 priority_value, UINT8);
7596 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7597 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7599 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7600 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7602 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7603 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7605 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7606 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7607 index_value, UINT16);
7609 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7610 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7611 filter, "add_5tuple_filter");
7612 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7613 .f = cmd_5tuple_filter_parsed,
7615 .help_str = "add a 5tuple filter",
7617 (void *)&cmd_5tuple_filter_add_filter,
7618 (void *)&cmd_5tuple_filter_port_id,
7619 (void *)&cmd_5tuple_filter_dst_ip,
7620 (void *)&cmd_5tuple_filter_dst_ip_value,
7621 (void *)&cmd_5tuple_filter_src_ip,
7622 (void *)&cmd_5tuple_filter_src_ip_value,
7623 (void *)&cmd_5tuple_filter_dst_port,
7624 (void *)&cmd_5tuple_filter_dst_port_value,
7625 (void *)&cmd_5tuple_filter_src_port,
7626 (void *)&cmd_5tuple_filter_src_port_value,
7627 (void *)&cmd_5tuple_filter_protocol,
7628 (void *)&cmd_5tuple_filter_protocol_value,
7629 (void *)&cmd_5tuple_filter_mask,
7630 (void *)&cmd_5tuple_filter_mask_value,
7631 (void *)&cmd_5tuple_filter_flags,
7632 (void *)&cmd_5tuple_filter_flags_value,
7633 (void *)&cmd_5tuple_filter_priority,
7634 (void *)&cmd_5tuple_filter_priority_value,
7635 (void *)&cmd_5tuple_filter_queue,
7636 (void *)&cmd_5tuple_filter_queue_id,
7637 (void *)&cmd_5tuple_filter_index,
7638 (void *)&cmd_5tuple_filter_index_value,
7643 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7644 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7645 filter, "remove_5tuple_filter");
7646 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7647 .f = cmd_5tuple_filter_parsed,
7649 .help_str = "remove a 5tuple filter",
7651 (void *)&cmd_5tuple_filter_remove_filter,
7652 (void *)&cmd_5tuple_filter_port_id,
7653 (void *)&cmd_5tuple_filter_index,
7654 (void *)&cmd_5tuple_filter_index_value,
7659 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7660 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7661 filter, "get_5tuple_filter");
7662 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7663 .f = cmd_5tuple_filter_parsed,
7665 .help_str = "get a 5tuple filter",
7667 (void *)&cmd_5tuple_filter_get_filter,
7668 (void *)&cmd_5tuple_filter_port_id,
7669 (void *)&cmd_5tuple_filter_index,
7670 (void *)&cmd_5tuple_filter_index_value,
7675 /* *** ADD/REMOVE A flex FILTER *** */
7676 struct cmd_flex_filter_result {
7677 cmdline_fixed_string_t filter;
7679 cmdline_fixed_string_t len;
7681 cmdline_fixed_string_t bytes;
7682 cmdline_fixed_string_t bytes_value;
7683 cmdline_fixed_string_t mask;
7684 cmdline_fixed_string_t mask_value;
7685 cmdline_fixed_string_t priority;
7686 uint8_t priority_value;
7687 cmdline_fixed_string_t queue;
7689 cmdline_fixed_string_t index;
7690 uint16_t index_value;
7693 static int xdigit2val(unsigned char c)
7698 else if (isupper(c))
7706 cmd_flex_filter_parsed(void *parsed_result,
7707 __attribute__((unused)) struct cmdline *cl,
7708 __attribute__((unused)) void *data)
7711 struct rte_flex_filter filter;
7712 struct cmd_flex_filter_result *res = parsed_result;
7713 char *bytes_ptr, *mask_ptr;
7721 if (!strcmp(res->filter, "add_flex_filter")) {
7722 if (res->len_value > 128) {
7723 printf("the len exceed the max length 128\n");
7726 memset(&filter, 0, sizeof(struct rte_flex_filter));
7727 filter.len = res->len_value;
7728 filter.priority = res->priority_value;
7729 bytes_ptr = res->bytes_value;
7730 mask_ptr = res->mask_value;
7733 /* translate bytes string to uint_32 array. */
7734 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7735 (bytes_ptr[1] == 'X')))
7737 len = strnlen(bytes_ptr, res->len_value * 2);
7738 if (len == 0 || (len % 8 != 0)) {
7739 printf("please check len and bytes input\n");
7742 for (i = 0; i < len; i++) {
7744 if (isxdigit(c) == 0) {
7745 /* invalid characters. */
7746 printf("invalid input\n");
7749 val = xdigit2val(c);
7753 dword |= byte << (4 * mod - 4);
7758 filter.dwords[j] = dword;
7759 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7765 /* translate mask string to uint8_t array. */
7767 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7768 (mask_ptr[1] == 'X')))
7770 len = strnlen(mask_ptr, (res->len_value+3)/4);
7772 printf("invalid input\n");
7775 for (i = 0; i < len; i++) {
7777 if (isxdigit(c) == 0) {
7778 /* invalid characters. */
7779 printf("invalid input\n");
7782 val = xdigit2val(c);
7783 hex |= (uint8_t)(val & 0x8) >> 3;
7784 hex |= (uint8_t)(val & 0x4) >> 1;
7785 hex |= (uint8_t)(val & 0x2) << 1;
7786 hex |= (uint8_t)(val & 0x1) << 3;
7789 filter.mask[j] = byte;
7790 printf("mask[%d]:%02x ", j, filter.mask[j]);
7798 printf("call function rte_eth_dev_add_flex_filter: "
7799 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7800 res->index_value, res->queue_id,
7801 filter.len, filter.priority);
7802 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7803 &filter, res->queue_id);
7805 } else if (!strcmp(res->filter, "remove_flex_filter"))
7806 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7808 else if (!strcmp(res->filter, "get_flex_filter"))
7809 get_flex_filter(res->port_id, res->index_value);
7812 printf("flex filter setting error: (%s)\n", strerror(-ret));
7815 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7816 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7818 cmdline_parse_token_string_t cmd_flex_filter_len =
7819 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7821 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7822 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7824 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7825 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7827 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7828 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7830 cmdline_parse_token_string_t cmd_flex_filter_mask =
7831 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7833 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7834 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7836 cmdline_parse_token_string_t cmd_flex_filter_priority =
7837 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7838 priority, "priority");
7839 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7840 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7841 priority_value, UINT8);
7842 cmdline_parse_token_string_t cmd_flex_filter_queue =
7843 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7845 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7846 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7848 cmdline_parse_token_string_t cmd_flex_filter_index =
7849 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7851 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7852 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7853 index_value, UINT16);
7854 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7855 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7856 filter, "add_flex_filter");
7857 cmdline_parse_inst_t cmd_add_flex_filter = {
7858 .f = cmd_flex_filter_parsed,
7860 .help_str = "add a flex filter",
7862 (void *)&cmd_flex_filter_add_filter,
7863 (void *)&cmd_flex_filter_port_id,
7864 (void *)&cmd_flex_filter_len,
7865 (void *)&cmd_flex_filter_len_value,
7866 (void *)&cmd_flex_filter_bytes,
7867 (void *)&cmd_flex_filter_bytes_value,
7868 (void *)&cmd_flex_filter_mask,
7869 (void *)&cmd_flex_filter_mask_value,
7870 (void *)&cmd_flex_filter_priority,
7871 (void *)&cmd_flex_filter_priority_value,
7872 (void *)&cmd_flex_filter_queue,
7873 (void *)&cmd_flex_filter_queue_id,
7874 (void *)&cmd_flex_filter_index,
7875 (void *)&cmd_flex_filter_index_value,
7880 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7881 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7882 filter, "remove_flex_filter");
7883 cmdline_parse_inst_t cmd_remove_flex_filter = {
7884 .f = cmd_flex_filter_parsed,
7886 .help_str = "remove a flex filter",
7888 (void *)&cmd_flex_filter_remove_filter,
7889 (void *)&cmd_flex_filter_port_id,
7890 (void *)&cmd_flex_filter_index,
7891 (void *)&cmd_flex_filter_index_value,
7896 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7897 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7898 filter, "get_flex_filter");
7899 cmdline_parse_inst_t cmd_get_flex_filter = {
7900 .f = cmd_flex_filter_parsed,
7902 .help_str = "get a flex filter",
7904 (void *)&cmd_flex_filter_get_filter,
7905 (void *)&cmd_flex_filter_port_id,
7906 (void *)&cmd_flex_filter_index,
7907 (void *)&cmd_flex_filter_index_value,
7912 /* *** Filters Control *** */
7914 /* *** deal with flow director filter *** */
7915 struct cmd_flow_director_result {
7916 cmdline_fixed_string_t flow_director_filter;
7918 cmdline_fixed_string_t ops;
7919 cmdline_fixed_string_t flow;
7920 cmdline_fixed_string_t flow_type;
7921 cmdline_fixed_string_t src;
7922 cmdline_ipaddr_t ip_src;
7924 cmdline_fixed_string_t dst;
7925 cmdline_ipaddr_t ip_dst;
7927 cmdline_fixed_string_t verify_tag;
7928 uint32_t verify_tag_value;
7929 cmdline_fixed_string_t flexbytes;
7930 cmdline_fixed_string_t flexbytes_value;
7931 cmdline_fixed_string_t drop;
7932 cmdline_fixed_string_t queue;
7934 cmdline_fixed_string_t fd_id;
7935 uint32_t fd_id_value;
7939 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7942 const char *p, *p0 = q_arg;
7944 unsigned long int_fld;
7945 char *str_fld[max_num];
7950 p = strchr(p0, '(');
7954 p0 = strchr(p, ')');
7959 if (size >= sizeof(s))
7962 snprintf(s, sizeof(s), "%.*s", size, p);
7963 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7964 if (ret < 0 || ret > max_num)
7966 for (i = 0; i < ret; i++) {
7968 int_fld = strtoul(str_fld[i], &end, 0);
7969 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7971 flexbytes[i] = (uint8_t)int_fld;
7976 static enum rte_eth_flow_type
7977 str2flowtype(char *string)
7980 static const struct {
7982 enum rte_eth_flow_type type;
7983 } flowtype_str[] = {
7984 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7985 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7986 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7987 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
7988 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
7989 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
7990 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
7991 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
7992 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
7993 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
7996 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
7997 if (!strcmp(flowtype_str[i].str, string))
7998 return flowtype_str[i].type;
8000 return RTE_ETH_FLOW_TYPE_NONE;
8003 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8005 if ((ip_addr).family == AF_INET) \
8006 (ip) = (ip_addr).addr.ipv4.s_addr; \
8008 printf("invalid parameter.\n"); \
8013 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8015 if ((ip_addr).family == AF_INET6) \
8016 (void)rte_memcpy(&(ip), \
8017 &((ip_addr).addr.ipv6), \
8018 sizeof(struct in6_addr)); \
8020 printf("invalid parameter.\n"); \
8026 cmd_flow_director_filter_parsed(void *parsed_result,
8027 __attribute__((unused)) struct cmdline *cl,
8028 __attribute__((unused)) void *data)
8030 struct cmd_flow_director_result *res = parsed_result;
8031 struct rte_eth_fdir_filter entry;
8032 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8035 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8037 printf("flow director is not supported on port %u.\n",
8041 memset(flexbytes, 0, sizeof(flexbytes));
8042 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8043 ret = parse_flexbytes(res->flexbytes_value,
8045 RTE_ETH_FDIR_MAX_FLEXLEN);
8047 printf("error: Cannot parse flexbytes input.\n");
8051 entry.input.flow_type = str2flowtype(res->flow_type);
8052 switch (entry.input.flow_type) {
8053 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8054 case RTE_ETH_FLOW_TYPE_UDPV4:
8055 case RTE_ETH_FLOW_TYPE_TCPV4:
8056 IPV4_ADDR_TO_UINT(res->ip_dst,
8057 entry.input.flow.ip4_flow.dst_ip);
8058 IPV4_ADDR_TO_UINT(res->ip_src,
8059 entry.input.flow.ip4_flow.src_ip);
8060 /* need convert to big endian. */
8061 entry.input.flow.udp4_flow.dst_port =
8062 rte_cpu_to_be_16(res->port_dst);
8063 entry.input.flow.udp4_flow.src_port =
8064 rte_cpu_to_be_16(res->port_src);
8066 case RTE_ETH_FLOW_TYPE_SCTPV4:
8067 IPV4_ADDR_TO_UINT(res->ip_dst,
8068 entry.input.flow.sctp4_flow.ip.dst_ip);
8069 IPV4_ADDR_TO_UINT(res->ip_src,
8070 entry.input.flow.sctp4_flow.ip.src_ip);
8071 /* need convert to big endian. */
8072 entry.input.flow.sctp4_flow.verify_tag =
8073 rte_cpu_to_be_32(res->verify_tag_value);
8075 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8076 case RTE_ETH_FLOW_TYPE_UDPV6:
8077 case RTE_ETH_FLOW_TYPE_TCPV6:
8078 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8079 entry.input.flow.ip6_flow.dst_ip);
8080 IPV6_ADDR_TO_ARRAY(res->ip_src,
8081 entry.input.flow.ip6_flow.src_ip);
8082 /* need convert to big endian. */
8083 entry.input.flow.udp6_flow.dst_port =
8084 rte_cpu_to_be_16(res->port_dst);
8085 entry.input.flow.udp6_flow.src_port =
8086 rte_cpu_to_be_16(res->port_src);
8088 case RTE_ETH_FLOW_TYPE_SCTPV6:
8089 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8090 entry.input.flow.sctp6_flow.ip.dst_ip);
8091 IPV6_ADDR_TO_ARRAY(res->ip_src,
8092 entry.input.flow.sctp6_flow.ip.src_ip);
8093 /* need convert to big endian. */
8094 entry.input.flow.sctp6_flow.verify_tag =
8095 rte_cpu_to_be_32(res->verify_tag_value);
8098 printf("invalid parameter.\n");
8101 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8103 RTE_ETH_FDIR_MAX_FLEXLEN);
8105 entry.action.flex_off = 0; /*use 0 by default */
8106 if (!strcmp(res->drop, "drop"))
8107 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8109 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8110 /* set to report FD ID by default */
8111 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8112 entry.action.rx_queue = res->queue_id;
8113 entry.soft_id = res->fd_id_value;
8114 if (!strcmp(res->ops, "add"))
8115 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8116 RTE_ETH_FILTER_ADD, &entry);
8118 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8119 RTE_ETH_FILTER_DELETE, &entry);
8121 printf("flow director programming error: (%s)\n",
8125 cmdline_parse_token_string_t cmd_flow_director_filter =
8126 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8127 flow_director_filter, "flow_director_filter");
8128 cmdline_parse_token_num_t cmd_flow_director_port_id =
8129 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8131 cmdline_parse_token_string_t cmd_flow_director_ops =
8132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8134 cmdline_parse_token_string_t cmd_flow_director_flow =
8135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8137 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8140 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8141 "ip6#ip6-frag#tcp6#udp6#sctp6");
8142 cmdline_parse_token_string_t cmd_flow_director_src =
8143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8145 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8146 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8148 cmdline_parse_token_num_t cmd_flow_director_port_src =
8149 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8151 cmdline_parse_token_string_t cmd_flow_director_dst =
8152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8154 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8155 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8157 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8158 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8160 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8162 verify_tag, "verify_tag");
8163 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8164 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8165 verify_tag_value, UINT32);
8166 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8167 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8168 flexbytes, "flexbytes");
8169 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8171 flexbytes_value, NULL);
8172 cmdline_parse_token_string_t cmd_flow_director_drop =
8173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8175 cmdline_parse_token_string_t cmd_flow_director_queue =
8176 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8178 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8179 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8181 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8182 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8184 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8185 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8186 fd_id_value, UINT32);
8188 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8189 .f = cmd_flow_director_filter_parsed,
8191 .help_str = "add or delete an ip flow director entry on NIC",
8193 (void *)&cmd_flow_director_filter,
8194 (void *)&cmd_flow_director_port_id,
8195 (void *)&cmd_flow_director_ops,
8196 (void *)&cmd_flow_director_flow,
8197 (void *)&cmd_flow_director_flow_type,
8198 (void *)&cmd_flow_director_src,
8199 (void *)&cmd_flow_director_ip_src,
8200 (void *)&cmd_flow_director_dst,
8201 (void *)&cmd_flow_director_ip_dst,
8202 (void *)&cmd_flow_director_flexbytes,
8203 (void *)&cmd_flow_director_flexbytes_value,
8204 (void *)&cmd_flow_director_drop,
8205 (void *)&cmd_flow_director_queue,
8206 (void *)&cmd_flow_director_queue_id,
8207 (void *)&cmd_flow_director_fd_id,
8208 (void *)&cmd_flow_director_fd_id_value,
8213 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8214 .f = cmd_flow_director_filter_parsed,
8216 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8218 (void *)&cmd_flow_director_filter,
8219 (void *)&cmd_flow_director_port_id,
8220 (void *)&cmd_flow_director_ops,
8221 (void *)&cmd_flow_director_flow,
8222 (void *)&cmd_flow_director_flow_type,
8223 (void *)&cmd_flow_director_src,
8224 (void *)&cmd_flow_director_ip_src,
8225 (void *)&cmd_flow_director_port_src,
8226 (void *)&cmd_flow_director_dst,
8227 (void *)&cmd_flow_director_ip_dst,
8228 (void *)&cmd_flow_director_port_dst,
8229 (void *)&cmd_flow_director_flexbytes,
8230 (void *)&cmd_flow_director_flexbytes_value,
8231 (void *)&cmd_flow_director_drop,
8232 (void *)&cmd_flow_director_queue,
8233 (void *)&cmd_flow_director_queue_id,
8234 (void *)&cmd_flow_director_fd_id,
8235 (void *)&cmd_flow_director_fd_id_value,
8240 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8241 .f = cmd_flow_director_filter_parsed,
8243 .help_str = "add or delete a sctp flow director entry on NIC",
8245 (void *)&cmd_flow_director_filter,
8246 (void *)&cmd_flow_director_port_id,
8247 (void *)&cmd_flow_director_ops,
8248 (void *)&cmd_flow_director_flow,
8249 (void *)&cmd_flow_director_flow_type,
8250 (void *)&cmd_flow_director_src,
8251 (void *)&cmd_flow_director_ip_src,
8252 (void *)&cmd_flow_director_dst,
8253 (void *)&cmd_flow_director_ip_dst,
8254 (void *)&cmd_flow_director_verify_tag,
8255 (void *)&cmd_flow_director_verify_tag_value,
8256 (void *)&cmd_flow_director_flexbytes,
8257 (void *)&cmd_flow_director_flexbytes_value,
8258 (void *)&cmd_flow_director_drop,
8259 (void *)&cmd_flow_director_queue,
8260 (void *)&cmd_flow_director_queue_id,
8261 (void *)&cmd_flow_director_fd_id,
8262 (void *)&cmd_flow_director_fd_id_value,
8267 /* ******************************************************************************** */
8269 /* list of instructions */
8270 cmdline_parse_ctx_t main_ctx[] = {
8271 (cmdline_parse_inst_t *)&cmd_help_brief,
8272 (cmdline_parse_inst_t *)&cmd_help_long,
8273 (cmdline_parse_inst_t *)&cmd_quit,
8274 (cmdline_parse_inst_t *)&cmd_showport,
8275 (cmdline_parse_inst_t *)&cmd_showportall,
8276 (cmdline_parse_inst_t *)&cmd_showcfg,
8277 (cmdline_parse_inst_t *)&cmd_start,
8278 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8279 (cmdline_parse_inst_t *)&cmd_set_link_up,
8280 (cmdline_parse_inst_t *)&cmd_set_link_down,
8281 (cmdline_parse_inst_t *)&cmd_reset,
8282 (cmdline_parse_inst_t *)&cmd_set_numbers,
8283 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8284 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8285 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8286 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8287 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8288 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8289 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8290 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8291 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8292 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8293 (cmdline_parse_inst_t *)&cmd_set_link_check,
8294 #ifdef RTE_NIC_BYPASS
8295 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8296 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8297 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8298 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8300 #ifdef RTE_LIBRTE_PMD_BOND
8301 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8302 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8303 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8304 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8305 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8306 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8307 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8308 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8309 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8311 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8312 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8313 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8314 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8315 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8316 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8317 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8318 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8319 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8320 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8321 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8322 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8323 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8324 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8325 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8326 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8327 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8328 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8329 (cmdline_parse_inst_t *)&cmd_config_dcb,
8330 (cmdline_parse_inst_t *)&cmd_read_reg,
8331 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8332 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8333 (cmdline_parse_inst_t *)&cmd_write_reg,
8334 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8335 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8336 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8337 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8338 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8339 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8340 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8341 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8342 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8343 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8344 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8345 (cmdline_parse_inst_t *)&cmd_stop,
8346 (cmdline_parse_inst_t *)&cmd_mac_addr,
8347 (cmdline_parse_inst_t *)&cmd_set_qmap,
8348 (cmdline_parse_inst_t *)&cmd_operate_port,
8349 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8350 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8351 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8352 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8353 (cmdline_parse_inst_t *)&cmd_config_mtu,
8354 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8355 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8356 (cmdline_parse_inst_t *)&cmd_config_rss,
8357 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8358 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8359 (cmdline_parse_inst_t *)&cmd_showport_reta,
8360 (cmdline_parse_inst_t *)&cmd_config_burst,
8361 (cmdline_parse_inst_t *)&cmd_config_thresh,
8362 (cmdline_parse_inst_t *)&cmd_config_threshold,
8363 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8364 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8365 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8366 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8367 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8368 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8369 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8370 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8371 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8372 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8373 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8374 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8375 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8376 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8377 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8378 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8379 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8380 (cmdline_parse_inst_t *)&cmd_dump,
8381 (cmdline_parse_inst_t *)&cmd_dump_one,
8382 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8383 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8384 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8385 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8386 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8387 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8388 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8389 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8390 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8391 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8392 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8393 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8394 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8395 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8396 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8397 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8398 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8399 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8403 /* prompt function, called from main on MASTER lcore */
8409 /* initialize non-constant commands */
8410 cmd_set_fwd_mode_init();
8412 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8416 cmdline_interact(cl);
8417 cmdline_stdin_exit(cl);
8421 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8423 if (id < nb_ports) {
8424 /* check if need_reconfig has been set to 1 */
8425 if (ports[id].need_reconfig == 0)
8426 ports[id].need_reconfig = dev;
8427 /* check if need_reconfig_queues has been set to 1 */
8428 if (ports[id].need_reconfig_queues == 0)
8429 ports[id].need_reconfig_queues = queue;
8433 for (pid = 0; pid < nb_ports; pid++) {
8434 /* check if need_reconfig has been set to 1 */
8435 if (ports[pid].need_reconfig == 0)
8436 ports[pid].need_reconfig = dev;
8437 /* check if need_reconfig_queues has been set to 1 */
8438 if (ports[pid].need_reconfig_queues == 0)
8439 ports[pid].need_reconfig_queues = queue;
8444 #ifdef RTE_NIC_BYPASS
8446 bypass_is_supported(portid_t port_id)
8448 struct rte_port *port;
8449 struct rte_pci_id *pci_id;
8451 if (port_id >= nb_ports) {
8452 printf("\tPort id must be less than %d.\n", nb_ports);
8456 /* Get the device id. */
8457 port = &ports[port_id];
8458 pci_id = &port->dev_info.pci_dev->id;
8460 /* Check if NIC supports bypass. */
8461 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8465 printf("\tBypass not supported for port_id = %d.\n", port_id);