4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_malloc.h>
63 #include <rte_launch.h>
64 #include <rte_tailq.h>
66 #include <rte_per_lcore.h>
67 #include <rte_lcore.h>
68 #include <rte_atomic.h>
69 #include <rte_branch_prediction.h>
71 #include <rte_mempool.h>
72 #include <rte_interrupts.h>
74 #include <rte_ether.h>
75 #include <rte_ethdev.h>
76 #include <rte_string_fns.h>
77 #include <rte_devargs.h>
79 #include <cmdline_rdline.h>
80 #include <cmdline_parse.h>
81 #include <cmdline_parse_num.h>
82 #include <cmdline_parse_string.h>
83 #include <cmdline_parse_ipaddr.h>
84 #include <cmdline_parse_etheraddr.h>
85 #include <cmdline_socket.h>
87 #include <rte_pci_dev_ids.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
94 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
97 uint8_t bypass_is_supported(portid_t port_id);
100 /* *** Help command with introduction. *** */
101 struct cmd_help_brief_result {
102 cmdline_fixed_string_t help;
105 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
107 __attribute__((unused)) void *data)
112 "Help is available for the following sections:\n\n"
113 " help control : Start and stop forwarding.\n"
114 " help display : Displaying port, stats and config "
116 " help config : Configuration information.\n"
117 " help ports : Configuring ports.\n"
118 " help flowdir : Flow Director filter help.\n"
119 " help registers : Reading and setting port registers.\n"
120 " help filters : Filters configuration help.\n"
121 " help all : All of the above sections.\n\n"
126 cmdline_parse_token_string_t cmd_help_brief_help =
127 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
129 cmdline_parse_inst_t cmd_help_brief = {
130 .f = cmd_help_brief_parsed,
132 .help_str = "show help",
134 (void *)&cmd_help_brief_help,
139 /* *** Help command with help sections. *** */
140 struct cmd_help_long_result {
141 cmdline_fixed_string_t help;
142 cmdline_fixed_string_t section;
145 static void cmd_help_long_parsed(void *parsed_result,
147 __attribute__((unused)) void *data)
150 struct cmd_help_long_result *res = parsed_result;
152 if (!strcmp(res->section, "all"))
155 if (show_all || !strcmp(res->section, "control")) {
160 "Control forwarding:\n"
161 "-------------------\n\n"
164 " Start packet forwarding with current configuration.\n\n"
167 " Start packet forwarding with current config"
168 " after sending one burst of packets.\n\n"
171 " Stop packet forwarding, and display accumulated"
175 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
179 if (show_all || !strcmp(res->section, "display")) {
187 "show port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
188 " Display information for port_id, or all.\n\n"
190 "show port X rss reta (size) (mask0,mask1,...)\n"
191 " Display the rss redirection table entry indicated"
192 " by masks on port X. size is used to indicate the"
193 " hardware supported reta size\n\n"
195 "show port rss-hash [key]\n"
196 " Display the RSS hash functions and RSS hash key"
199 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
200 " Clear information for port_id, or all.\n\n"
202 "show config (rxtx|cores|fwd)\n"
203 " Display the given configuration.\n\n"
205 "read rxd (port_id) (queue_id) (rxd_id)\n"
206 " Display an RX descriptor of a port RX queue.\n\n"
208 "read txd (port_id) (queue_id) (txd_id)\n"
209 " Display a TX descriptor of a port TX queue.\n\n"
213 if (show_all || !strcmp(res->section, "config")) {
219 "Configuration changes only become active when"
220 " forwarding is started/restarted.\n\n"
223 " Reset forwarding to the default configuration.\n\n"
225 "set verbose (level)\n"
226 " Set the debug verbosity level X.\n\n"
229 " Set number of ports.\n\n"
232 " Set number of cores.\n\n"
234 "set coremask (mask)\n"
235 " Set the forwarding cores hexadecimal mask.\n\n"
237 "set portmask (mask)\n"
238 " Set the forwarding ports hexadecimal mask.\n\n"
241 " Set number of packets per burst.\n\n"
243 "set burst tx delay (microseconds) retry (num)\n"
244 " Set the transmit delay time and number of retries"
245 " in mac_retry forwarding mode.\n\n"
247 "set txpkts (x[,y]*)\n"
248 " Set the length of each segment of TXONLY"
251 "set corelist (x[,y]*)\n"
252 " Set the list of forwarding cores.\n\n"
254 "set portlist (x[,y]*)\n"
255 " Set the list of forwarding ports.\n\n"
257 "vlan set strip (on|off) (port_id)\n"
258 " Set the VLAN strip on a port.\n\n"
260 "vlan set stripq (on|off) (port_id,queue_id)\n"
261 " Set the VLAN strip for a queue on a port.\n\n"
263 "vlan set filter (on|off) (port_id)\n"
264 " Set the VLAN filter on a port.\n\n"
266 "vlan set qinq (on|off) (port_id)\n"
267 " Set the VLAN QinQ (extended queue in queue)"
270 "vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "rx_vlan add (vlan_id|all) (port_id)\n"
275 " Add a vlan_id, or all identifiers, to the set"
276 " of VLAN identifiers filtered by port_id.\n\n"
278 "rx_vlan rm (vlan_id|all) (port_id)\n"
279 " Remove a vlan_id, or all identifiers, from the set"
280 " of VLAN identifiers filtered by port_id.\n\n"
282 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
283 " Add a vlan_id, to the set of VLAN identifiers"
284 "filtered for VF(s) from port_id.\n\n"
286 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
287 " Remove a vlan_id, to the set of VLAN identifiers"
288 "filtered for VF(s) from port_id.\n\n"
290 "rx_vlan set tpid (value) (port_id)\n"
291 " Set the outer VLAN TPID for Packet Filtering on"
294 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
295 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
296 " add a tunnel filter of a port.\n\n"
298 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
299 "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n"
300 " remove a tunnel filter of a port.\n\n"
302 "rx_vxlan_port add (udp_port) (port_id)\n"
303 " Add an UDP port for VXLAN packet filter on a port\n\n"
305 "rx_vxlan_port rm (udp_port) (port_id)\n"
306 " Remove an UDP port for VXLAN packet filter on a port\n\n"
308 "tx_vlan set vlan_id (port_id)\n"
309 " Set hardware insertion of VLAN ID in packets sent"
312 "tx_vlan set pvid port_id vlan_id (on|off)\n"
313 " Set port based TX VLAN insertion.\n\n"
315 "tx_vlan reset (port_id)\n"
316 " Disable hardware insertion of a VLAN header in"
317 " packets sent on a port.\n\n"
319 "tx_checksum set (mask) (port_id)\n"
320 " Enable hardware insertion of checksum offload with"
321 " the 8-bit mask, 0~0xff, in packets sent on a port.\n"
322 " bit 0 - insert ip checksum offload if set\n"
323 " bit 1 - insert udp checksum offload if set\n"
324 " bit 2 - insert tcp checksum offload if set\n"
325 " bit 3 - insert sctp checksum offload if set\n"
326 " bit 4 - insert inner ip checksum offload if set\n"
327 " bit 5 - insert inner udp checksum offload if set\n"
328 " bit 6 - insert inner tcp checksum offload if set\n"
329 " bit 7 - insert inner sctp checksum offload if set\n"
330 " Please check the NIC datasheet for HW limits.\n\n"
333 " Set packet forwarding mode.\n\n"
335 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
336 " Add a MAC address on port_id.\n\n"
338 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
339 " Remove a MAC address from port_id.\n\n"
341 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
342 " Add a MAC address for a VF on the port.\n\n"
344 "set port (port_id) uta (mac_address|all) (on|off)\n"
345 " Add/Remove a or all unicast hash filter(s)"
348 "set promisc (port_id|all) (on|off)\n"
349 " Set the promiscuous mode on port_id, or all.\n\n"
351 "set allmulti (port_id|all) (on|off)\n"
352 " Set the allmulti mode on port_id, or all.\n\n"
354 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
355 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
356 " (on|off) autoneg (on|off) (port_id)\n"
357 "set flow_ctrl rx (on|off) (portid)\n"
358 "set flow_ctrl tx (on|off) (portid)\n"
359 "set flow_ctrl high_water (high_water) (portid)\n"
360 "set flow_ctrl low_water (low_water) (portid)\n"
361 "set flow_ctrl pause_time (pause_time) (portid)\n"
362 "set flow_ctrl send_xon (send_xon) (portid)\n"
363 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
364 "set flow_ctrl autoneg (on|off) (port_id)\n"
365 " Set the link flow control parameter on a port.\n\n"
367 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
368 " (low_water) (pause_time) (priority) (port_id)\n"
369 " Set the priority flow control parameter on a"
372 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
373 " Set statistics mapping (qmapping 0..15) for RX/TX"
375 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
376 " on port 0 to mapping 5.\n\n"
378 "set port (port_id) vf (vf_id) rx|tx on|off\n"
379 " Enable/Disable a VF receive/tranmit from a port\n\n"
381 "set port (port_id) vf (vf_id) (mac_addr)"
382 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
383 " Add/Remove unicast or multicast MAC addr filter"
386 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
388 " AUPE:accepts untagged VLAN;"
389 "ROPE:accept unicast hash\n\n"
390 " BAM:accepts broadcast packets;"
391 "MPE:accepts all multicast packets\n\n"
392 " Enable/Disable a VF receive mode of a port\n\n"
394 "set port (port_id) queue (queue_id) rate (rate_num)\n"
395 " Set rate limit for a queue of a port\n\n"
397 "set port (port_id) vf (vf_id) rate (rate_num) "
398 "queue_mask (queue_mask_value)\n"
399 " Set rate limit for queues in VF of a port\n\n"
401 "set port (port_id) mirror-rule (rule_id)"
402 "(pool-mirror|vlan-mirror)\n"
403 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
404 " Set pool or vlan type mirror rule on a port.\n"
405 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
406 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
409 "set port (port_id) mirror-rule (rule_id)"
410 " (uplink-mirror|downlink-mirror) dst-pool"
411 " (pool_id) (on|off)\n"
412 " Set uplink or downlink type mirror rule on a port.\n"
413 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
414 " 0 on' enable mirror income traffic to pool 0.\n\n"
416 "reset port (port_id) mirror-rule (rule_id)\n"
417 " Reset a mirror rule.\n\n"
419 "set flush_rx (on|off)\n"
420 " Flush (default) or don't flush RX streams before"
421 " forwarding. Mainly used with PCAP drivers.\n\n"
423 #ifdef RTE_NIC_BYPASS
424 "set bypass mode (normal|bypass|isolate) (port_id)\n"
425 " Set the bypass mode for the lowest port on bypass enabled"
428 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
429 "mode (normal|bypass|isolate) (port_id)\n"
430 " Set the event required to initiate specified bypass mode for"
431 " the lowest port on a bypass enabled NIC where:\n"
432 " timeout = enable bypass after watchdog timeout.\n"
433 " os_on = enable bypass when OS/board is powered on.\n"
434 " os_off = enable bypass when OS/board is powered off.\n"
435 " power_on = enable bypass when power supply is turned on.\n"
436 " power_off = enable bypass when power supply is turned off."
439 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
440 " Set the bypass watchdog timeout to 'n' seconds"
441 " where 0 = instant.\n\n"
443 "show bypass config (port_id)\n"
444 " Show the bypass configuration for a bypass enabled NIC"
445 " using the lowest port on the NIC.\n\n"
447 #ifdef RTE_LIBRTE_PMD_BOND
448 "create bonded device (mode) (socket)\n"
449 " Create a new bonded device with specific bonding mode and socket.\n\n"
451 "add bonding slave (slave_id) (port_id)\n"
452 " Add a slave device to a bonded device.\n\n"
454 "remove bonding slave (slave_id) (port_id)\n"
455 " Remove a slave device from a bonded device.\n\n"
457 "set bonding mode (value) (port_id)\n"
458 " Set the bonding mode on a bonded device.\n\n"
460 "set bonding primary (slave_id) (port_id)\n"
461 " Set the primary slave for a bonded device.\n\n"
463 "show bonding config (port_id)\n"
464 " Show the bonding config for port_id.\n\n"
466 "set bonding mac_addr (port_id) (address)\n"
467 " Set the MAC address of a bonded device.\n\n"
469 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
470 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
472 "set bonding mon_period (port_id) (value)\n"
473 " Set the bonding link status monitoring polling period in ms.\n\n"
475 "set link-up port (port_id)\n"
476 " Set link up for a port.\n\n"
478 "set link-down port (port_id)\n"
479 " Set link down for a port.\n\n"
481 , list_pkt_forwarding_modes()
486 if (show_all || !strcmp(res->section, "flowdir")) {
491 "Flow director mode:\n"
492 "-------------------\n\n"
494 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
495 " src (src_ip_address) (src_port)"
496 " dst (dst_ip_address) (dst_port)"
497 " flexbytes (flexbytes_values) vlan (vlan_id)"
498 " queue (queue_id)\n"
499 " Add a signature filter.\n\n"
501 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
502 " src (src_ip_address) (src_port)"
503 " dst (dst_ip_address) (dst_port)"
504 " flexbytes (flexbytes_values) vlan (vlan_id)"
505 " queue (queue_id)\n"
506 " Update a signature filter.\n\n"
508 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
509 " src (src_ip_address) (src_port)"
510 " dst (dst_ip_address) (dst_port)"
511 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
512 " Remove a signature filter.\n\n"
514 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
515 " src (src_ip_address) (src_port)"
516 " dst (dst_ip_address) (dst_port)"
517 " flexbytes (flexbytes_values) vlan (vlan_id)"
518 " queue (queue_id) soft (soft_id)\n"
519 " Add a perfect filter.\n\n"
521 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
522 " src (src_ip_address) (src_port)"
523 " dst (dst_ip_address) (dst_port)"
524 " flexbytes (flexbytes_values) vlan (vlan_id)"
525 " queue (queue_id)\n"
526 " Update a perfect filter.\n\n"
528 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
529 " src (src_ip_address) (src_port)"
530 " dst (dst_ip_address) (dst_port)"
531 " flexbytes (flexbytes_values) vlan (vlan_id)"
533 " Remove a perfect filter.\n\n"
535 "set_masks_filter (port_id) only_ip_flow (0|1)"
536 " src_mask (ip_src_mask) (src_port_mask)"
537 " dst_mask (ip_dst_mask) (dst_port_mask)"
538 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
539 " Set IPv4 filter masks.\n\n"
541 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
542 " src_mask (ip_src_mask) (src_port_mask)"
543 " dst_mask (ip_dst_mask) (dst_port_mask)"
544 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
545 " compare_dst (0|1)\n"
546 " Set IPv6 filter masks.\n\n"
550 if (show_all || !strcmp(res->section, "ports")) {
556 "----------------\n\n"
558 "port start (port_id|all)\n"
559 " Start all ports or port_id.\n\n"
561 "port stop (port_id|all)\n"
562 " Stop all ports or port_id.\n\n"
564 "port close (port_id|all)\n"
565 " Close all ports or port_id.\n\n"
567 "port config (port_id|all)"
568 " speed (10|100|1000|10000|40000|auto)"
569 " duplex (half|full|auto)\n"
570 " Set speed and duplex for all ports or port_id\n\n"
572 "port config all (rxq|txq|rxd|txd) (value)\n"
573 " Set number for rxq/txq/rxd/txd.\n\n"
575 "port config all max-pkt-len (value)\n"
576 " Set the max packet length.\n\n"
578 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
580 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
583 "port config all rss (ip|udp|none)\n"
584 " Set the RSS mode.\n\n"
586 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
587 " Set the RSS redirection table.\n\n"
589 "port config (port_id) dcb vt (on|off) (traffic_class)"
591 " Set the DCB mode.\n\n"
593 "port config all burst (value)\n"
594 " Set the number of packets per burst.\n\n"
596 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
598 " Set the ring prefetch/host/writeback threshold"
599 " for tx/rx queue.\n\n"
601 "port config all (txfreet|txrst|rxfreet) (value)\n"
602 " Set free threshold for rx/tx, or set"
603 " tx rs bit threshold.\n\n"
604 "port config mtu X value\n"
605 " Set the MTU of port X to a given value\n\n"
607 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
608 " Start/stop a rx/tx queue of port X. Only take effect"
609 " when port X is started\n"
613 if (show_all || !strcmp(res->section, "registers")) {
621 "read reg (port_id) (address)\n"
622 " Display value of a port register.\n\n"
624 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
625 " Display a port register bit field.\n\n"
627 "read regbit (port_id) (address) (bit_x)\n"
628 " Display a single port register bit.\n\n"
630 "write reg (port_id) (address) (value)\n"
631 " Set value of a port register.\n\n"
633 "write regfield (port_id) (address) (bit_x) (bit_y)"
635 " Set bit field of a port register.\n\n"
637 "write regbit (port_id) (address) (bit_x) (value)\n"
638 " Set single bit value of a port register.\n\n"
641 if (show_all || !strcmp(res->section, "filters")) {
649 "add_ethertype_filter (port_id) ethertype (eth_value)"
650 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
651 " add an ethertype filter.\n\n"
653 "remove_ethertype_filter (port_id) index (idx)\n"
654 " remove an ethertype filter.\n\n"
656 "get_ethertype_filter (port_id) index (idx)\n"
657 " get info of a ethertype filter.\n\n"
659 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
660 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
661 " queue (queue_id) index (idx)\n"
662 " add a 2tuple filter.\n\n"
664 "remove_2tuple_filter (port_id) index (idx)\n"
665 " remove a 2tuple filter.\n\n"
667 "get_2tuple_filter (port_id) index (idx)\n"
668 " get info of a 2tuple filter.\n\n"
670 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
671 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
672 " mask (mask_value) flags (flags_value) priority (prio_value)"
673 " queue (queue_id) index (idx)\n"
674 " add a 5tuple filter.\n\n"
676 "remove_5tuple_filter (port_id) index (idx)\n"
677 " remove a 5tuple filter.\n\n"
679 "get_5tuple_filter (port_id) index (idx)\n"
680 " get info of a 5tuple filter.\n\n"
682 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
683 " add syn filter.\n\n"
685 "remove_syn_filter (port_id)"
686 " remove syn filter.\n\n"
688 "get_syn_filter (port_id) "
689 " get syn filter info.\n\n"
691 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
692 " priority (prio_value) queue (queue_id) index (idx)\n"
693 " add a flex filter.\n\n"
695 "remove_flex_filter (port_id) index (idx)\n"
696 " remove a flex filter.\n\n"
698 "get_flex_filter (port_id) index (idx)\n"
699 " get info of a flex filter.\n\n"
701 "flow_director_filter (port_id) (add|del)"
702 " flow (ip4|ip4-frag|ip6|ip6-frag)"
703 " src (src_ip_address) dst (dst_ip_address)"
704 " flexbytes (flexbytes_value)"
705 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
706 " Add/Del an IP type flow director filter.\n\n"
708 "flow_director_filter (port_id) (add|del)"
709 " flow (udp4|tcp4|udp6|tcp6)"
710 " src (src_ip_address) (src_port)"
711 " dst (dst_ip_address) (dst_port)"
712 " flexbytes (flexbytes_value)"
713 " (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
714 " Add/Del an UDP/TCP type flow director filter.\n\n"
716 "flow_director_filter (port_id) (add|del)"
717 " flow (sctp4|sctp6)"
718 " src (src_ip_address) dst (dst_ip_address)"
719 " tag (verification_tag)"
720 " flexbytes (flexbytes_value) (drop|fwd)"
721 " queue (queue_id) fd_id (fd_id_value)\n"
722 " Add/Del a SCTP type flow director filter.\n\n"
724 "flush_flow_director (port_id)\n"
725 " Flush all flow director entries of a device.\n\n"
727 "flow_director_flex_mask (port_id)"
728 " flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
730 " Configure mask of flex payload.\n\n"
732 "flow_director_flex_payload (port_id)"
733 " (l2|l3|l4) (config)\n"
734 " Configure flex payload selection.\n\n"
739 cmdline_parse_token_string_t cmd_help_long_help =
740 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
742 cmdline_parse_token_string_t cmd_help_long_section =
743 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
744 "all#control#display#config#flowdir#"
745 "ports#registers#filters");
747 cmdline_parse_inst_t cmd_help_long = {
748 .f = cmd_help_long_parsed,
750 .help_str = "show help",
752 (void *)&cmd_help_long_help,
753 (void *)&cmd_help_long_section,
759 /* *** start/stop/close all ports *** */
760 struct cmd_operate_port_result {
761 cmdline_fixed_string_t keyword;
762 cmdline_fixed_string_t name;
763 cmdline_fixed_string_t value;
766 static void cmd_operate_port_parsed(void *parsed_result,
767 __attribute__((unused)) struct cmdline *cl,
768 __attribute__((unused)) void *data)
770 struct cmd_operate_port_result *res = parsed_result;
772 if (!strcmp(res->name, "start"))
773 start_port(RTE_PORT_ALL);
774 else if (!strcmp(res->name, "stop"))
775 stop_port(RTE_PORT_ALL);
776 else if (!strcmp(res->name, "close"))
777 close_port(RTE_PORT_ALL);
779 printf("Unknown parameter\n");
782 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
783 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
785 cmdline_parse_token_string_t cmd_operate_port_all_port =
786 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
788 cmdline_parse_token_string_t cmd_operate_port_all_all =
789 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
791 cmdline_parse_inst_t cmd_operate_port = {
792 .f = cmd_operate_port_parsed,
794 .help_str = "port start|stop|close all: start/stop/close all ports",
796 (void *)&cmd_operate_port_all_cmd,
797 (void *)&cmd_operate_port_all_port,
798 (void *)&cmd_operate_port_all_all,
803 /* *** start/stop/close specific port *** */
804 struct cmd_operate_specific_port_result {
805 cmdline_fixed_string_t keyword;
806 cmdline_fixed_string_t name;
810 static void cmd_operate_specific_port_parsed(void *parsed_result,
811 __attribute__((unused)) struct cmdline *cl,
812 __attribute__((unused)) void *data)
814 struct cmd_operate_specific_port_result *res = parsed_result;
816 if (!strcmp(res->name, "start"))
817 start_port(res->value);
818 else if (!strcmp(res->name, "stop"))
819 stop_port(res->value);
820 else if (!strcmp(res->name, "close"))
821 close_port(res->value);
823 printf("Unknown parameter\n");
826 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
827 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
829 cmdline_parse_token_string_t cmd_operate_specific_port_port =
830 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
831 name, "start#stop#close");
832 cmdline_parse_token_num_t cmd_operate_specific_port_id =
833 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
836 cmdline_parse_inst_t cmd_operate_specific_port = {
837 .f = cmd_operate_specific_port_parsed,
839 .help_str = "port start|stop|close X: start/stop/close port X",
841 (void *)&cmd_operate_specific_port_cmd,
842 (void *)&cmd_operate_specific_port_port,
843 (void *)&cmd_operate_specific_port_id,
848 /* *** configure speed for all ports *** */
849 struct cmd_config_speed_all {
850 cmdline_fixed_string_t port;
851 cmdline_fixed_string_t keyword;
852 cmdline_fixed_string_t all;
853 cmdline_fixed_string_t item1;
854 cmdline_fixed_string_t item2;
855 cmdline_fixed_string_t value1;
856 cmdline_fixed_string_t value2;
860 cmd_config_speed_all_parsed(void *parsed_result,
861 __attribute__((unused)) struct cmdline *cl,
862 __attribute__((unused)) void *data)
864 struct cmd_config_speed_all *res = parsed_result;
865 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
866 uint16_t link_duplex = 0;
869 if (!all_ports_stopped()) {
870 printf("Please stop all ports first\n");
874 if (!strcmp(res->value1, "10"))
875 link_speed = ETH_LINK_SPEED_10;
876 else if (!strcmp(res->value1, "100"))
877 link_speed = ETH_LINK_SPEED_100;
878 else if (!strcmp(res->value1, "1000"))
879 link_speed = ETH_LINK_SPEED_1000;
880 else if (!strcmp(res->value1, "10000"))
881 link_speed = ETH_LINK_SPEED_10G;
882 else if (!strcmp(res->value1, "40000"))
883 link_speed = ETH_LINK_SPEED_40G;
884 else if (!strcmp(res->value1, "auto"))
885 link_speed = ETH_LINK_SPEED_AUTONEG;
887 printf("Unknown parameter\n");
891 if (!strcmp(res->value2, "half"))
892 link_duplex = ETH_LINK_HALF_DUPLEX;
893 else if (!strcmp(res->value2, "full"))
894 link_duplex = ETH_LINK_FULL_DUPLEX;
895 else if (!strcmp(res->value2, "auto"))
896 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
898 printf("Unknown parameter\n");
902 for (pid = 0; pid < nb_ports; pid++) {
903 ports[pid].dev_conf.link_speed = link_speed;
904 ports[pid].dev_conf.link_duplex = link_duplex;
907 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
910 cmdline_parse_token_string_t cmd_config_speed_all_port =
911 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
912 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
913 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
915 cmdline_parse_token_string_t cmd_config_speed_all_all =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
917 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
918 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
919 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
920 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
921 "10#100#1000#10000#40000#auto");
922 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
923 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
924 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
925 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
928 cmdline_parse_inst_t cmd_config_speed_all = {
929 .f = cmd_config_speed_all_parsed,
931 .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
934 (void *)&cmd_config_speed_all_port,
935 (void *)&cmd_config_speed_all_keyword,
936 (void *)&cmd_config_speed_all_all,
937 (void *)&cmd_config_speed_all_item1,
938 (void *)&cmd_config_speed_all_value1,
939 (void *)&cmd_config_speed_all_item2,
940 (void *)&cmd_config_speed_all_value2,
945 /* *** configure speed for specific port *** */
946 struct cmd_config_speed_specific {
947 cmdline_fixed_string_t port;
948 cmdline_fixed_string_t keyword;
950 cmdline_fixed_string_t item1;
951 cmdline_fixed_string_t item2;
952 cmdline_fixed_string_t value1;
953 cmdline_fixed_string_t value2;
957 cmd_config_speed_specific_parsed(void *parsed_result,
958 __attribute__((unused)) struct cmdline *cl,
959 __attribute__((unused)) void *data)
961 struct cmd_config_speed_specific *res = parsed_result;
962 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
963 uint16_t link_duplex = 0;
965 if (!all_ports_stopped()) {
966 printf("Please stop all ports first\n");
970 if (res->id >= nb_ports) {
971 printf("Port id %d must be less than %d\n", res->id, nb_ports);
975 if (!strcmp(res->value1, "10"))
976 link_speed = ETH_LINK_SPEED_10;
977 else if (!strcmp(res->value1, "100"))
978 link_speed = ETH_LINK_SPEED_100;
979 else if (!strcmp(res->value1, "1000"))
980 link_speed = ETH_LINK_SPEED_1000;
981 else if (!strcmp(res->value1, "10000"))
982 link_speed = ETH_LINK_SPEED_10000;
983 else if (!strcmp(res->value1, "40000"))
984 link_speed = ETH_LINK_SPEED_40G;
985 else if (!strcmp(res->value1, "auto"))
986 link_speed = ETH_LINK_SPEED_AUTONEG;
988 printf("Unknown parameter\n");
992 if (!strcmp(res->value2, "half"))
993 link_duplex = ETH_LINK_HALF_DUPLEX;
994 else if (!strcmp(res->value2, "full"))
995 link_duplex = ETH_LINK_FULL_DUPLEX;
996 else if (!strcmp(res->value2, "auto"))
997 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
999 printf("Unknown parameter\n");
1003 ports[res->id].dev_conf.link_speed = link_speed;
1004 ports[res->id].dev_conf.link_duplex = link_duplex;
1006 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1010 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1011 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1013 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1014 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1016 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1017 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1018 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1019 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1021 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1022 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1023 "10#100#1000#10000#40000#auto");
1024 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1025 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1027 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1028 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1031 cmdline_parse_inst_t cmd_config_speed_specific = {
1032 .f = cmd_config_speed_specific_parsed,
1034 .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
1037 (void *)&cmd_config_speed_specific_port,
1038 (void *)&cmd_config_speed_specific_keyword,
1039 (void *)&cmd_config_speed_specific_id,
1040 (void *)&cmd_config_speed_specific_item1,
1041 (void *)&cmd_config_speed_specific_value1,
1042 (void *)&cmd_config_speed_specific_item2,
1043 (void *)&cmd_config_speed_specific_value2,
1048 /* *** configure txq/rxq, txd/rxd *** */
1049 struct cmd_config_rx_tx {
1050 cmdline_fixed_string_t port;
1051 cmdline_fixed_string_t keyword;
1052 cmdline_fixed_string_t all;
1053 cmdline_fixed_string_t name;
1058 cmd_config_rx_tx_parsed(void *parsed_result,
1059 __attribute__((unused)) struct cmdline *cl,
1060 __attribute__((unused)) void *data)
1062 struct cmd_config_rx_tx *res = parsed_result;
1064 if (!all_ports_stopped()) {
1065 printf("Please stop all ports first\n");
1069 if (!strcmp(res->name, "rxq")) {
1070 if (res->value <= 0) {
1071 printf("rxq %d invalid - must be > 0\n", res->value);
1074 nb_rxq = res->value;
1076 else if (!strcmp(res->name, "txq")) {
1077 if (res->value <= 0) {
1078 printf("txq %d invalid - must be > 0\n", res->value);
1081 nb_txq = res->value;
1083 else if (!strcmp(res->name, "rxd")) {
1084 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1085 printf("rxd %d invalid - must be > 0 && <= %d\n",
1086 res->value, RTE_TEST_RX_DESC_MAX);
1089 nb_rxd = res->value;
1090 } else if (!strcmp(res->name, "txd")) {
1091 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1092 printf("txd %d invalid - must be > 0 && <= %d\n",
1093 res->value, RTE_TEST_TX_DESC_MAX);
1096 nb_txd = res->value;
1098 printf("Unknown parameter\n");
1104 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1107 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1108 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1109 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1111 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1113 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1114 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1116 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1117 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1119 cmdline_parse_inst_t cmd_config_rx_tx = {
1120 .f = cmd_config_rx_tx_parsed,
1122 .help_str = "port config all rxq|txq|rxd|txd value",
1124 (void *)&cmd_config_rx_tx_port,
1125 (void *)&cmd_config_rx_tx_keyword,
1126 (void *)&cmd_config_rx_tx_all,
1127 (void *)&cmd_config_rx_tx_name,
1128 (void *)&cmd_config_rx_tx_value,
1133 /* *** config max packet length *** */
1134 struct cmd_config_max_pkt_len_result {
1135 cmdline_fixed_string_t port;
1136 cmdline_fixed_string_t keyword;
1137 cmdline_fixed_string_t all;
1138 cmdline_fixed_string_t name;
1143 cmd_config_max_pkt_len_parsed(void *parsed_result,
1144 __attribute__((unused)) struct cmdline *cl,
1145 __attribute__((unused)) void *data)
1147 struct cmd_config_max_pkt_len_result *res = parsed_result;
1149 if (!all_ports_stopped()) {
1150 printf("Please stop all ports first\n");
1154 if (!strcmp(res->name, "max-pkt-len")) {
1155 if (res->value < ETHER_MIN_LEN) {
1156 printf("max-pkt-len can not be less than %d\n",
1160 if (res->value == rx_mode.max_rx_pkt_len)
1163 rx_mode.max_rx_pkt_len = res->value;
1164 if (res->value > ETHER_MAX_LEN)
1165 rx_mode.jumbo_frame = 1;
1167 rx_mode.jumbo_frame = 0;
1169 printf("Unknown parameter\n");
1175 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1178 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1179 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1181 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1184 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1185 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1187 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1188 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1190 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1191 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1194 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1195 .f = cmd_config_max_pkt_len_parsed,
1197 .help_str = "port config all max-pkt-len value",
1199 (void *)&cmd_config_max_pkt_len_port,
1200 (void *)&cmd_config_max_pkt_len_keyword,
1201 (void *)&cmd_config_max_pkt_len_all,
1202 (void *)&cmd_config_max_pkt_len_name,
1203 (void *)&cmd_config_max_pkt_len_value,
1208 /* *** configure port MTU *** */
1209 struct cmd_config_mtu_result {
1210 cmdline_fixed_string_t port;
1211 cmdline_fixed_string_t keyword;
1212 cmdline_fixed_string_t mtu;
1218 cmd_config_mtu_parsed(void *parsed_result,
1219 __attribute__((unused)) struct cmdline *cl,
1220 __attribute__((unused)) void *data)
1222 struct cmd_config_mtu_result *res = parsed_result;
1224 if (res->value < ETHER_MIN_LEN) {
1225 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1228 port_mtu_set(res->port_id, res->value);
1231 cmdline_parse_token_string_t cmd_config_mtu_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1234 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1235 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1237 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1238 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1240 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1241 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1242 cmdline_parse_token_num_t cmd_config_mtu_value =
1243 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1245 cmdline_parse_inst_t cmd_config_mtu = {
1246 .f = cmd_config_mtu_parsed,
1248 .help_str = "port config mtu value",
1250 (void *)&cmd_config_mtu_port,
1251 (void *)&cmd_config_mtu_keyword,
1252 (void *)&cmd_config_mtu_mtu,
1253 (void *)&cmd_config_mtu_port_id,
1254 (void *)&cmd_config_mtu_value,
1259 /* *** configure rx mode *** */
1260 struct cmd_config_rx_mode_flag {
1261 cmdline_fixed_string_t port;
1262 cmdline_fixed_string_t keyword;
1263 cmdline_fixed_string_t all;
1264 cmdline_fixed_string_t name;
1265 cmdline_fixed_string_t value;
1269 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1270 __attribute__((unused)) struct cmdline *cl,
1271 __attribute__((unused)) void *data)
1273 struct cmd_config_rx_mode_flag *res = parsed_result;
1275 if (!all_ports_stopped()) {
1276 printf("Please stop all ports first\n");
1280 if (!strcmp(res->name, "crc-strip")) {
1281 if (!strcmp(res->value, "on"))
1282 rx_mode.hw_strip_crc = 1;
1283 else if (!strcmp(res->value, "off"))
1284 rx_mode.hw_strip_crc = 0;
1286 printf("Unknown parameter\n");
1289 } else if (!strcmp(res->name, "rx-cksum")) {
1290 if (!strcmp(res->value, "on"))
1291 rx_mode.hw_ip_checksum = 1;
1292 else if (!strcmp(res->value, "off"))
1293 rx_mode.hw_ip_checksum = 0;
1295 printf("Unknown parameter\n");
1298 } else if (!strcmp(res->name, "hw-vlan")) {
1299 if (!strcmp(res->value, "on")) {
1300 rx_mode.hw_vlan_filter = 1;
1301 rx_mode.hw_vlan_strip = 1;
1303 else if (!strcmp(res->value, "off")) {
1304 rx_mode.hw_vlan_filter = 0;
1305 rx_mode.hw_vlan_strip = 0;
1308 printf("Unknown parameter\n");
1311 } else if (!strcmp(res->name, "drop-en")) {
1312 if (!strcmp(res->value, "on"))
1314 else if (!strcmp(res->value, "off"))
1317 printf("Unknown parameter\n");
1321 printf("Unknown parameter\n");
1327 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1330 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1331 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1332 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1333 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1335 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1336 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1337 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1338 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1339 "crc-strip#rx-cksum#hw-vlan");
1340 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1341 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1344 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1345 .f = cmd_config_rx_mode_flag_parsed,
1347 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1349 (void *)&cmd_config_rx_mode_flag_port,
1350 (void *)&cmd_config_rx_mode_flag_keyword,
1351 (void *)&cmd_config_rx_mode_flag_all,
1352 (void *)&cmd_config_rx_mode_flag_name,
1353 (void *)&cmd_config_rx_mode_flag_value,
1358 /* *** configure rss *** */
1359 struct cmd_config_rss {
1360 cmdline_fixed_string_t port;
1361 cmdline_fixed_string_t keyword;
1362 cmdline_fixed_string_t all;
1363 cmdline_fixed_string_t name;
1364 cmdline_fixed_string_t value;
1368 cmd_config_rss_parsed(void *parsed_result,
1369 __attribute__((unused)) struct cmdline *cl,
1370 __attribute__((unused)) void *data)
1372 struct cmd_config_rss *res = parsed_result;
1373 struct rte_eth_rss_conf rss_conf;
1376 if (!strcmp(res->value, "ip"))
1377 rss_conf.rss_hf = ETH_RSS_IP;
1378 else if (!strcmp(res->value, "udp"))
1379 rss_conf.rss_hf = ETH_RSS_UDP;
1380 else if (!strcmp(res->value, "none"))
1381 rss_conf.rss_hf = 0;
1383 printf("Unknown parameter\n");
1386 rss_conf.rss_key = NULL;
1387 for (i = 0; i < rte_eth_dev_count(); i++)
1388 rte_eth_dev_rss_hash_update(i, &rss_conf);
1391 cmdline_parse_token_string_t cmd_config_rss_port =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1393 cmdline_parse_token_string_t cmd_config_rss_keyword =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1395 cmdline_parse_token_string_t cmd_config_rss_all =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1397 cmdline_parse_token_string_t cmd_config_rss_name =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1399 cmdline_parse_token_string_t cmd_config_rss_value =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1402 cmdline_parse_inst_t cmd_config_rss = {
1403 .f = cmd_config_rss_parsed,
1405 .help_str = "port config all rss ip|udp|none",
1407 (void *)&cmd_config_rss_port,
1408 (void *)&cmd_config_rss_keyword,
1409 (void *)&cmd_config_rss_all,
1410 (void *)&cmd_config_rss_name,
1411 (void *)&cmd_config_rss_value,
1416 /* *** configure rss hash key *** */
1417 struct cmd_config_rss_hash_key {
1418 cmdline_fixed_string_t port;
1419 cmdline_fixed_string_t config;
1421 cmdline_fixed_string_t rss_hash_key;
1422 cmdline_fixed_string_t key;
1425 #define RSS_HASH_KEY_LENGTH 40
1427 hexa_digit_to_value(char hexa_digit)
1429 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1430 return (uint8_t) (hexa_digit - '0');
1431 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1432 return (uint8_t) ((hexa_digit - 'a') + 10);
1433 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1434 return (uint8_t) ((hexa_digit - 'A') + 10);
1435 /* Invalid hexa digit */
1440 parse_and_check_key_hexa_digit(char *key, int idx)
1444 hexa_v = hexa_digit_to_value(key[idx]);
1446 printf("invalid key: character %c at position %d is not a "
1447 "valid hexa digit\n", key[idx], idx);
1452 cmd_config_rss_hash_key_parsed(void *parsed_result,
1453 __attribute__((unused)) struct cmdline *cl,
1454 __attribute__((unused)) void *data)
1456 struct cmd_config_rss_hash_key *res = parsed_result;
1457 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1462 /* Check the length of the RSS hash key */
1463 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1464 printf("key length: %d invalid - key must be a string of %d"
1465 "hexa-decimal numbers\n", (int) strlen(res->key),
1466 RSS_HASH_KEY_LENGTH * 2);
1469 /* Translate RSS hash key into binary representation */
1470 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1471 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1474 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1477 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1479 port_rss_hash_key_update(res->port_id, hash_key);
1482 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1484 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1485 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1487 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1488 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1489 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1491 rss_hash_key, "rss-hash-key");
1492 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1495 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1496 .f = cmd_config_rss_hash_key_parsed,
1498 .help_str = "port config X rss-hash-key 80 hexa digits",
1500 (void *)&cmd_config_rss_hash_key_port,
1501 (void *)&cmd_config_rss_hash_key_config,
1502 (void *)&cmd_config_rss_hash_key_port_id,
1503 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1504 (void *)&cmd_config_rss_hash_key_value,
1509 /* *** configure port rxq/txq start/stop *** */
1510 struct cmd_config_rxtx_queue {
1511 cmdline_fixed_string_t port;
1513 cmdline_fixed_string_t rxtxq;
1515 cmdline_fixed_string_t opname;
1519 cmd_config_rxtx_queue_parsed(void *parsed_result,
1520 __attribute__((unused)) struct cmdline *cl,
1521 __attribute__((unused)) void *data)
1523 struct cmd_config_rxtx_queue *res = parsed_result;
1528 if (test_done == 0) {
1529 printf("Please stop forwarding first\n");
1533 if (port_id_is_invalid(res->portid))
1536 if (port_is_started(res->portid) != 1) {
1537 printf("Please start port %u first\n", res->portid);
1541 if (!strcmp(res->rxtxq, "rxq"))
1543 else if (!strcmp(res->rxtxq, "txq"))
1546 printf("Unknown parameter\n");
1550 if (isrx && rx_queue_id_is_invalid(res->qid))
1552 else if (!isrx && tx_queue_id_is_invalid(res->qid))
1555 if (!strcmp(res->opname, "start"))
1557 else if (!strcmp(res->opname, "stop"))
1560 printf("Unknown parameter\n");
1564 if (isstart && isrx)
1565 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
1566 else if (!isstart && isrx)
1567 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
1568 else if (isstart && !isrx)
1569 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
1571 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
1573 if (ret == -ENOTSUP)
1574 printf("Function not supported in PMD driver\n");
1577 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
1579 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
1580 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
1581 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
1583 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
1584 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
1585 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
1589 cmdline_parse_inst_t cmd_config_rxtx_queue = {
1590 .f = cmd_config_rxtx_queue_parsed,
1592 .help_str = "port X rxq|txq ID start|stop",
1594 (void *)&cmd_config_speed_all_port,
1595 (void *)&cmd_config_rxtx_queue_portid,
1596 (void *)&cmd_config_rxtx_queue_rxtxq,
1597 (void *)&cmd_config_rxtx_queue_qid,
1598 (void *)&cmd_config_rxtx_queue_opname,
1603 /* *** Configure RSS RETA *** */
1604 struct cmd_config_rss_reta {
1605 cmdline_fixed_string_t port;
1606 cmdline_fixed_string_t keyword;
1608 cmdline_fixed_string_t name;
1609 cmdline_fixed_string_t list_name;
1610 cmdline_fixed_string_t list_of_items;
1614 parse_reta_config(const char *str,
1615 struct rte_eth_rss_reta_entry64 *reta_conf,
1616 uint16_t nb_entries)
1620 uint16_t hash_index, idx, shift;
1623 const char *p, *p0 = str;
1630 unsigned long int_fld[_NUM_FLD];
1631 char *str_fld[_NUM_FLD];
1633 while ((p = strchr(p0,'(')) != NULL) {
1635 if((p0 = strchr(p,')')) == NULL)
1639 if(size >= sizeof(s))
1642 snprintf(s, sizeof(s), "%.*s", size, p);
1643 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1645 for (i = 0; i < _NUM_FLD; i++) {
1647 int_fld[i] = strtoul(str_fld[i], &end, 0);
1648 if (errno != 0 || end == str_fld[i] ||
1653 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
1654 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1656 if (hash_index >= nb_entries) {
1657 printf("Invalid RETA hash index=%d\n", hash_index);
1661 idx = hash_index / RTE_RETA_GROUP_SIZE;
1662 shift = hash_index % RTE_RETA_GROUP_SIZE;
1663 reta_conf[idx].mask |= (1ULL << shift);
1664 reta_conf[idx].reta[shift] = nb_queue;
1671 cmd_set_rss_reta_parsed(void *parsed_result,
1672 __attribute__((unused)) struct cmdline *cl,
1673 __attribute__((unused)) void *data)
1676 struct rte_eth_dev_info dev_info;
1677 struct rte_eth_rss_reta_entry64 reta_conf[8];
1678 struct cmd_config_rss_reta *res = parsed_result;
1680 memset(&dev_info, 0, sizeof(dev_info));
1681 rte_eth_dev_info_get(res->port_id, &dev_info);
1682 if (dev_info.reta_size == 0) {
1683 printf("Redirection table size is 0 which is "
1684 "invalid for RSS\n");
1687 printf("The reta size of port %d is %u\n",
1688 res->port_id, dev_info.reta_size);
1689 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
1690 printf("Currently do not support more than %u entries of "
1691 "redirection table\n", ETH_RSS_RETA_SIZE_512);
1695 memset(reta_conf, 0, sizeof(reta_conf));
1696 if (!strcmp(res->list_name, "reta")) {
1697 if (parse_reta_config(res->list_of_items, reta_conf,
1698 dev_info.reta_size)) {
1699 printf("Invalid RSS Redirection Table "
1700 "config entered\n");
1703 ret = rte_eth_dev_rss_reta_update(res->port_id,
1704 reta_conf, dev_info.reta_size);
1706 printf("Bad redirection table parameter, "
1707 "return code = %d \n", ret);
1711 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1713 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1715 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1716 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1717 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1719 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1721 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1724 cmdline_parse_inst_t cmd_config_rss_reta = {
1725 .f = cmd_set_rss_reta_parsed,
1727 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1729 (void *)&cmd_config_rss_reta_port,
1730 (void *)&cmd_config_rss_reta_keyword,
1731 (void *)&cmd_config_rss_reta_port_id,
1732 (void *)&cmd_config_rss_reta_name,
1733 (void *)&cmd_config_rss_reta_list_name,
1734 (void *)&cmd_config_rss_reta_list_of_items,
1739 /* *** SHOW PORT RETA INFO *** */
1740 struct cmd_showport_reta {
1741 cmdline_fixed_string_t show;
1742 cmdline_fixed_string_t port;
1744 cmdline_fixed_string_t rss;
1745 cmdline_fixed_string_t reta;
1747 cmdline_fixed_string_t list_of_items;
1751 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
1752 uint16_t nb_entries,
1756 const char *p, *p0 = str;
1760 uint16_t i, num = nb_entries / RTE_RETA_GROUP_SIZE;
1763 p = strchr(p0, '(');
1767 p0 = strchr(p, ')');
1771 if (size >= sizeof(s)) {
1772 printf("The string size exceeds the internal buffer size\n");
1775 snprintf(s, sizeof(s), "%.*s", size, p);
1776 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
1777 if (ret <= 0 || ret != num) {
1778 printf("The bits of masks do not match the number of "
1779 "reta entries: %u\n", num);
1782 for (i = 0; i < ret; i++)
1783 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
1789 cmd_showport_reta_parsed(void *parsed_result,
1790 __attribute__((unused)) struct cmdline *cl,
1791 __attribute__((unused)) void *data)
1793 struct cmd_showport_reta *res = parsed_result;
1794 struct rte_eth_rss_reta_entry64 reta_conf[8];
1795 struct rte_eth_dev_info dev_info;
1797 memset(&dev_info, 0, sizeof(dev_info));
1798 rte_eth_dev_info_get(res->port_id, &dev_info);
1799 if (dev_info.reta_size == 0 || res->size != dev_info.reta_size ||
1800 res->size > ETH_RSS_RETA_SIZE_512) {
1801 printf("Invalid redirection table size: %u\n", res->size);
1805 memset(reta_conf, 0, sizeof(reta_conf));
1806 if (showport_parse_reta_config(reta_conf, res->size,
1807 res->list_of_items) < 0) {
1808 printf("Invalid string: %s for reta masks\n",
1809 res->list_of_items);
1812 port_rss_reta_info(res->port_id, reta_conf, res->size);
1815 cmdline_parse_token_string_t cmd_showport_reta_show =
1816 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1817 cmdline_parse_token_string_t cmd_showport_reta_port =
1818 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1819 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1820 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1821 cmdline_parse_token_string_t cmd_showport_reta_rss =
1822 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1823 cmdline_parse_token_string_t cmd_showport_reta_reta =
1824 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1825 cmdline_parse_token_num_t cmd_showport_reta_size =
1826 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
1827 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
1828 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
1829 list_of_items, NULL);
1831 cmdline_parse_inst_t cmd_showport_reta = {
1832 .f = cmd_showport_reta_parsed,
1834 .help_str = "show port X rss reta (size) (mask0,mask1,...)",
1836 (void *)&cmd_showport_reta_show,
1837 (void *)&cmd_showport_reta_port,
1838 (void *)&cmd_showport_reta_port_id,
1839 (void *)&cmd_showport_reta_rss,
1840 (void *)&cmd_showport_reta_reta,
1841 (void *)&cmd_showport_reta_size,
1842 (void *)&cmd_showport_reta_list_of_items,
1847 /* *** Show RSS hash configuration *** */
1848 struct cmd_showport_rss_hash {
1849 cmdline_fixed_string_t show;
1850 cmdline_fixed_string_t port;
1852 cmdline_fixed_string_t rss_hash;
1853 cmdline_fixed_string_t key; /* optional argument */
1856 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1857 __attribute__((unused)) struct cmdline *cl,
1860 struct cmd_showport_rss_hash *res = parsed_result;
1862 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1865 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1866 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1867 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1868 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1869 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1870 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1871 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1872 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1874 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1875 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1877 cmdline_parse_inst_t cmd_showport_rss_hash = {
1878 .f = cmd_showport_rss_hash_parsed,
1880 .help_str = "show port X rss-hash (X = port number)\n",
1882 (void *)&cmd_showport_rss_hash_show,
1883 (void *)&cmd_showport_rss_hash_port,
1884 (void *)&cmd_showport_rss_hash_port_id,
1885 (void *)&cmd_showport_rss_hash_rss_hash,
1890 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1891 .f = cmd_showport_rss_hash_parsed,
1893 .help_str = "show port X rss-hash key (X = port number)\n",
1895 (void *)&cmd_showport_rss_hash_show,
1896 (void *)&cmd_showport_rss_hash_port,
1897 (void *)&cmd_showport_rss_hash_port_id,
1898 (void *)&cmd_showport_rss_hash_rss_hash,
1899 (void *)&cmd_showport_rss_hash_rss_key,
1904 /* *** Configure DCB *** */
1905 struct cmd_config_dcb {
1906 cmdline_fixed_string_t port;
1907 cmdline_fixed_string_t config;
1909 cmdline_fixed_string_t dcb;
1910 cmdline_fixed_string_t vt;
1911 cmdline_fixed_string_t vt_en;
1913 cmdline_fixed_string_t pfc;
1914 cmdline_fixed_string_t pfc_en;
1918 cmd_config_dcb_parsed(void *parsed_result,
1919 __attribute__((unused)) struct cmdline *cl,
1920 __attribute__((unused)) void *data)
1922 struct cmd_config_dcb *res = parsed_result;
1923 struct dcb_config dcb_conf;
1924 portid_t port_id = res->port_id;
1925 struct rte_port *port;
1927 port = &ports[port_id];
1928 /** Check if the port is not started **/
1929 if (port->port_status != RTE_PORT_STOPPED) {
1930 printf("Please stop port %d first\n",port_id);
1934 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1935 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1936 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1940 /* DCB in VT mode */
1941 if (!strncmp(res->vt_en, "on",2))
1942 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1944 dcb_conf.dcb_mode = DCB_ENABLED;
1946 if (!strncmp(res->pfc_en, "on",2)) {
1947 dcb_conf.pfc_en = 1;
1950 dcb_conf.pfc_en = 0;
1952 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1953 printf("Cannot initialize network ports\n");
1957 cmd_reconfig_device_queue(port_id, 1, 1);
1960 cmdline_parse_token_string_t cmd_config_dcb_port =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1962 cmdline_parse_token_string_t cmd_config_dcb_config =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1964 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1965 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1966 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1968 cmdline_parse_token_string_t cmd_config_dcb_vt =
1969 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1970 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1971 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1972 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1973 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1974 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1975 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1976 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1977 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1979 cmdline_parse_inst_t cmd_config_dcb = {
1980 .f = cmd_config_dcb_parsed,
1982 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1984 (void *)&cmd_config_dcb_port,
1985 (void *)&cmd_config_dcb_config,
1986 (void *)&cmd_config_dcb_port_id,
1987 (void *)&cmd_config_dcb_dcb,
1988 (void *)&cmd_config_dcb_vt,
1989 (void *)&cmd_config_dcb_vt_en,
1990 (void *)&cmd_config_dcb_num_tcs,
1991 (void *)&cmd_config_dcb_pfc,
1992 (void *)&cmd_config_dcb_pfc_en,
1997 /* *** configure number of packets per burst *** */
1998 struct cmd_config_burst {
1999 cmdline_fixed_string_t port;
2000 cmdline_fixed_string_t keyword;
2001 cmdline_fixed_string_t all;
2002 cmdline_fixed_string_t name;
2007 cmd_config_burst_parsed(void *parsed_result,
2008 __attribute__((unused)) struct cmdline *cl,
2009 __attribute__((unused)) void *data)
2011 struct cmd_config_burst *res = parsed_result;
2013 if (!all_ports_stopped()) {
2014 printf("Please stop all ports first\n");
2018 if (!strcmp(res->name, "burst")) {
2019 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2020 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2023 nb_pkt_per_burst = res->value;
2025 printf("Unknown parameter\n");
2031 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2034 cmdline_parse_token_string_t cmd_config_burst_port =
2035 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2036 cmdline_parse_token_string_t cmd_config_burst_keyword =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2038 cmdline_parse_token_string_t cmd_config_burst_all =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2040 cmdline_parse_token_string_t cmd_config_burst_name =
2041 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2042 cmdline_parse_token_num_t cmd_config_burst_value =
2043 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2045 cmdline_parse_inst_t cmd_config_burst = {
2046 .f = cmd_config_burst_parsed,
2048 .help_str = "port config all burst value",
2050 (void *)&cmd_config_burst_port,
2051 (void *)&cmd_config_burst_keyword,
2052 (void *)&cmd_config_burst_all,
2053 (void *)&cmd_config_burst_name,
2054 (void *)&cmd_config_burst_value,
2059 /* *** configure rx/tx queues *** */
2060 struct cmd_config_thresh {
2061 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t keyword;
2063 cmdline_fixed_string_t all;
2064 cmdline_fixed_string_t name;
2069 cmd_config_thresh_parsed(void *parsed_result,
2070 __attribute__((unused)) struct cmdline *cl,
2071 __attribute__((unused)) void *data)
2073 struct cmd_config_thresh *res = parsed_result;
2075 if (!all_ports_stopped()) {
2076 printf("Please stop all ports first\n");
2080 if (!strcmp(res->name, "txpt"))
2081 tx_thresh.pthresh = res->value;
2082 else if(!strcmp(res->name, "txht"))
2083 tx_thresh.hthresh = res->value;
2084 else if(!strcmp(res->name, "txwt"))
2085 tx_thresh.wthresh = res->value;
2086 else if(!strcmp(res->name, "rxpt"))
2087 rx_thresh.pthresh = res->value;
2088 else if(!strcmp(res->name, "rxht"))
2089 rx_thresh.hthresh = res->value;
2090 else if(!strcmp(res->name, "rxwt"))
2091 rx_thresh.wthresh = res->value;
2093 printf("Unknown parameter\n");
2099 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2102 cmdline_parse_token_string_t cmd_config_thresh_port =
2103 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2104 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2106 cmdline_parse_token_string_t cmd_config_thresh_all =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2108 cmdline_parse_token_string_t cmd_config_thresh_name =
2109 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2110 "txpt#txht#txwt#rxpt#rxht#rxwt");
2111 cmdline_parse_token_num_t cmd_config_thresh_value =
2112 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2114 cmdline_parse_inst_t cmd_config_thresh = {
2115 .f = cmd_config_thresh_parsed,
2117 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
2119 (void *)&cmd_config_thresh_port,
2120 (void *)&cmd_config_thresh_keyword,
2121 (void *)&cmd_config_thresh_all,
2122 (void *)&cmd_config_thresh_name,
2123 (void *)&cmd_config_thresh_value,
2128 /* *** configure free/rs threshold *** */
2129 struct cmd_config_threshold {
2130 cmdline_fixed_string_t port;
2131 cmdline_fixed_string_t keyword;
2132 cmdline_fixed_string_t all;
2133 cmdline_fixed_string_t name;
2138 cmd_config_threshold_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_config_threshold *res = parsed_result;
2144 if (!all_ports_stopped()) {
2145 printf("Please stop all ports first\n");
2149 if (!strcmp(res->name, "txfreet"))
2150 tx_free_thresh = res->value;
2151 else if (!strcmp(res->name, "txrst"))
2152 tx_rs_thresh = res->value;
2153 else if (!strcmp(res->name, "rxfreet"))
2154 rx_free_thresh = res->value;
2156 printf("Unknown parameter\n");
2162 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2165 cmdline_parse_token_string_t cmd_config_threshold_port =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2167 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2170 cmdline_parse_token_string_t cmd_config_threshold_all =
2171 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2172 cmdline_parse_token_string_t cmd_config_threshold_name =
2173 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2174 "txfreet#txrst#rxfreet");
2175 cmdline_parse_token_num_t cmd_config_threshold_value =
2176 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2178 cmdline_parse_inst_t cmd_config_threshold = {
2179 .f = cmd_config_threshold_parsed,
2181 .help_str = "port config all txfreet|txrst|rxfreet value",
2183 (void *)&cmd_config_threshold_port,
2184 (void *)&cmd_config_threshold_keyword,
2185 (void *)&cmd_config_threshold_all,
2186 (void *)&cmd_config_threshold_name,
2187 (void *)&cmd_config_threshold_value,
2193 struct cmd_stop_result {
2194 cmdline_fixed_string_t stop;
2197 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2198 __attribute__((unused)) struct cmdline *cl,
2199 __attribute__((unused)) void *data)
2201 stop_packet_forwarding();
2204 cmdline_parse_token_string_t cmd_stop_stop =
2205 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2207 cmdline_parse_inst_t cmd_stop = {
2208 .f = cmd_stop_parsed,
2210 .help_str = "stop - stop packet forwarding",
2212 (void *)&cmd_stop_stop,
2217 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2220 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2221 unsigned int *parsed_items, int check_unique_values)
2223 unsigned int nb_item;
2231 * First parse all items in the list and store their value.
2236 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2238 if ((c >= '0') && (c <= '9')) {
2239 value = (unsigned int) (value * 10 + (c - '0'));
2244 printf("character %c is not a decimal digit\n", c);
2248 printf("No valid value before comma\n");
2251 if (nb_item < max_items) {
2252 parsed_items[nb_item] = value;
2258 if (nb_item >= max_items) {
2259 printf("Number of %s = %u > %u (maximum items)\n",
2260 item_name, nb_item + 1, max_items);
2263 parsed_items[nb_item++] = value;
2264 if (! check_unique_values)
2268 * Then, check that all values in the list are differents.
2269 * No optimization here...
2271 for (i = 0; i < nb_item; i++) {
2272 for (j = i + 1; j < nb_item; j++) {
2273 if (parsed_items[j] == parsed_items[i]) {
2274 printf("duplicated %s %u at index %u and %u\n",
2275 item_name, parsed_items[i], i, j);
2283 struct cmd_set_list_result {
2284 cmdline_fixed_string_t cmd_keyword;
2285 cmdline_fixed_string_t list_name;
2286 cmdline_fixed_string_t list_of_items;
2289 static void cmd_set_list_parsed(void *parsed_result,
2290 __attribute__((unused)) struct cmdline *cl,
2291 __attribute__((unused)) void *data)
2293 struct cmd_set_list_result *res;
2295 unsigned int lcorelist[RTE_MAX_LCORE];
2296 unsigned int portlist[RTE_MAX_ETHPORTS];
2298 unsigned int nb_item;
2300 res = parsed_result;
2301 if (!strcmp(res->list_name, "corelist")) {
2302 nb_item = parse_item_list(res->list_of_items, "core",
2304 parsed_items.lcorelist, 1);
2306 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2309 if (!strcmp(res->list_name, "portlist")) {
2310 nb_item = parse_item_list(res->list_of_items, "port",
2312 parsed_items.portlist, 1);
2314 set_fwd_ports_list(parsed_items.portlist, nb_item);
2318 cmdline_parse_token_string_t cmd_set_list_keyword =
2319 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2321 cmdline_parse_token_string_t cmd_set_list_name =
2322 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2323 "corelist#portlist");
2324 cmdline_parse_token_string_t cmd_set_list_of_items =
2325 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2328 cmdline_parse_inst_t cmd_set_fwd_list = {
2329 .f = cmd_set_list_parsed,
2331 .help_str = "set corelist|portlist x[,y]*",
2333 (void *)&cmd_set_list_keyword,
2334 (void *)&cmd_set_list_name,
2335 (void *)&cmd_set_list_of_items,
2340 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2342 struct cmd_setmask_result {
2343 cmdline_fixed_string_t set;
2344 cmdline_fixed_string_t mask;
2348 static void cmd_set_mask_parsed(void *parsed_result,
2349 __attribute__((unused)) struct cmdline *cl,
2350 __attribute__((unused)) void *data)
2352 struct cmd_setmask_result *res = parsed_result;
2354 if (!strcmp(res->mask, "coremask"))
2355 set_fwd_lcores_mask(res->hexavalue);
2356 else if (!strcmp(res->mask, "portmask"))
2357 set_fwd_ports_mask(res->hexavalue);
2360 cmdline_parse_token_string_t cmd_setmask_set =
2361 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2362 cmdline_parse_token_string_t cmd_setmask_mask =
2363 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2364 "coremask#portmask");
2365 cmdline_parse_token_num_t cmd_setmask_value =
2366 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2368 cmdline_parse_inst_t cmd_set_fwd_mask = {
2369 .f = cmd_set_mask_parsed,
2371 .help_str = "set coremask|portmask hexadecimal value",
2373 (void *)&cmd_setmask_set,
2374 (void *)&cmd_setmask_mask,
2375 (void *)&cmd_setmask_value,
2381 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2383 struct cmd_set_result {
2384 cmdline_fixed_string_t set;
2385 cmdline_fixed_string_t what;
2389 static void cmd_set_parsed(void *parsed_result,
2390 __attribute__((unused)) struct cmdline *cl,
2391 __attribute__((unused)) void *data)
2393 struct cmd_set_result *res = parsed_result;
2394 if (!strcmp(res->what, "nbport"))
2395 set_fwd_ports_number(res->value);
2396 else if (!strcmp(res->what, "nbcore"))
2397 set_fwd_lcores_number(res->value);
2398 else if (!strcmp(res->what, "burst"))
2399 set_nb_pkt_per_burst(res->value);
2400 else if (!strcmp(res->what, "verbose"))
2401 set_verbose_level(res->value);
2404 cmdline_parse_token_string_t cmd_set_set =
2405 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2406 cmdline_parse_token_string_t cmd_set_what =
2407 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2408 "nbport#nbcore#burst#verbose");
2409 cmdline_parse_token_num_t cmd_set_value =
2410 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2412 cmdline_parse_inst_t cmd_set_numbers = {
2413 .f = cmd_set_parsed,
2415 .help_str = "set nbport|nbcore|burst|verbose value",
2417 (void *)&cmd_set_set,
2418 (void *)&cmd_set_what,
2419 (void *)&cmd_set_value,
2424 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2426 struct cmd_set_txpkts_result {
2427 cmdline_fixed_string_t cmd_keyword;
2428 cmdline_fixed_string_t txpkts;
2429 cmdline_fixed_string_t seg_lengths;
2433 cmd_set_txpkts_parsed(void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_set_txpkts_result *res;
2438 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2439 unsigned int nb_segs;
2441 res = parsed_result;
2442 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2443 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2445 set_tx_pkt_segments(seg_lengths, nb_segs);
2448 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2449 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2450 cmd_keyword, "set");
2451 cmdline_parse_token_string_t cmd_set_txpkts_name =
2452 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2454 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2455 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2458 cmdline_parse_inst_t cmd_set_txpkts = {
2459 .f = cmd_set_txpkts_parsed,
2461 .help_str = "set txpkts x[,y]*",
2463 (void *)&cmd_set_txpkts_keyword,
2464 (void *)&cmd_set_txpkts_name,
2465 (void *)&cmd_set_txpkts_lengths,
2470 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2471 struct cmd_rx_vlan_filter_all_result {
2472 cmdline_fixed_string_t rx_vlan;
2473 cmdline_fixed_string_t what;
2474 cmdline_fixed_string_t all;
2479 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2480 __attribute__((unused)) struct cmdline *cl,
2481 __attribute__((unused)) void *data)
2483 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2485 if (!strcmp(res->what, "add"))
2486 rx_vlan_all_filter_set(res->port_id, 1);
2488 rx_vlan_all_filter_set(res->port_id, 0);
2491 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2492 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2493 rx_vlan, "rx_vlan");
2494 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2495 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2497 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2498 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2500 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2501 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2504 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2505 .f = cmd_rx_vlan_filter_all_parsed,
2507 .help_str = "add/remove all identifiers to/from the set of VLAN "
2508 "Identifiers filtered by a port",
2510 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2511 (void *)&cmd_rx_vlan_filter_all_what,
2512 (void *)&cmd_rx_vlan_filter_all_all,
2513 (void *)&cmd_rx_vlan_filter_all_portid,
2518 /* *** VLAN OFFLOAD SET ON A PORT *** */
2519 struct cmd_vlan_offload_result {
2520 cmdline_fixed_string_t vlan;
2521 cmdline_fixed_string_t set;
2522 cmdline_fixed_string_t what;
2523 cmdline_fixed_string_t on;
2524 cmdline_fixed_string_t port_id;
2528 cmd_vlan_offload_parsed(void *parsed_result,
2529 __attribute__((unused)) struct cmdline *cl,
2530 __attribute__((unused)) void *data)
2533 struct cmd_vlan_offload_result *res = parsed_result;
2536 portid_t port_id = 0;
2540 len = strnlen(str, STR_TOKEN_SIZE);
2542 /* Get port_id first */
2550 tmp = strtoul(str, NULL, 0);
2551 /* If port_id greater that what portid_t can represent, return */
2552 if(tmp >= RTE_MAX_ETHPORTS)
2554 port_id = (portid_t)tmp;
2556 if (!strcmp(res->on, "on"))
2561 if (!strcmp(res->what, "strip"))
2562 rx_vlan_strip_set(port_id, on);
2563 else if(!strcmp(res->what, "stripq")){
2564 uint16_t queue_id = 0;
2566 /* No queue_id, return */
2568 printf("must specify (port,queue_id)\n");
2571 tmp = strtoul(str + i + 1, NULL, 0);
2572 /* If queue_id greater that what 16-bits can represent, return */
2576 queue_id = (uint16_t)tmp;
2577 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2579 else if (!strcmp(res->what, "filter"))
2580 rx_vlan_filter_set(port_id, on);
2582 vlan_extend_set(port_id, on);
2587 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2588 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2590 cmdline_parse_token_string_t cmd_vlan_offload_set =
2591 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2593 cmdline_parse_token_string_t cmd_vlan_offload_what =
2594 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2595 what, "strip#filter#qinq#stripq");
2596 cmdline_parse_token_string_t cmd_vlan_offload_on =
2597 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2599 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2600 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2603 cmdline_parse_inst_t cmd_vlan_offload = {
2604 .f = cmd_vlan_offload_parsed,
2606 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2607 " qinq(extended) for both rx/tx sides ",
2609 (void *)&cmd_vlan_offload_vlan,
2610 (void *)&cmd_vlan_offload_set,
2611 (void *)&cmd_vlan_offload_what,
2612 (void *)&cmd_vlan_offload_on,
2613 (void *)&cmd_vlan_offload_portid,
2618 /* *** VLAN TPID SET ON A PORT *** */
2619 struct cmd_vlan_tpid_result {
2620 cmdline_fixed_string_t vlan;
2621 cmdline_fixed_string_t set;
2622 cmdline_fixed_string_t what;
2628 cmd_vlan_tpid_parsed(void *parsed_result,
2629 __attribute__((unused)) struct cmdline *cl,
2630 __attribute__((unused)) void *data)
2632 struct cmd_vlan_tpid_result *res = parsed_result;
2633 vlan_tpid_set(res->port_id, res->tp_id);
2637 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2638 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2640 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2641 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2643 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2644 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2646 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2647 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2649 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2650 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2653 cmdline_parse_inst_t cmd_vlan_tpid = {
2654 .f = cmd_vlan_tpid_parsed,
2656 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2658 (void *)&cmd_vlan_tpid_vlan,
2659 (void *)&cmd_vlan_tpid_set,
2660 (void *)&cmd_vlan_tpid_what,
2661 (void *)&cmd_vlan_tpid_tpid,
2662 (void *)&cmd_vlan_tpid_portid,
2667 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2668 struct cmd_rx_vlan_filter_result {
2669 cmdline_fixed_string_t rx_vlan;
2670 cmdline_fixed_string_t what;
2676 cmd_rx_vlan_filter_parsed(void *parsed_result,
2677 __attribute__((unused)) struct cmdline *cl,
2678 __attribute__((unused)) void *data)
2680 struct cmd_rx_vlan_filter_result *res = parsed_result;
2682 if (!strcmp(res->what, "add"))
2683 rx_vft_set(res->port_id, res->vlan_id, 1);
2685 rx_vft_set(res->port_id, res->vlan_id, 0);
2688 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2689 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2690 rx_vlan, "rx_vlan");
2691 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2692 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2694 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2695 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2697 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2698 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2701 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2702 .f = cmd_rx_vlan_filter_parsed,
2704 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2705 "Identifiers filtered by a port",
2707 (void *)&cmd_rx_vlan_filter_rx_vlan,
2708 (void *)&cmd_rx_vlan_filter_what,
2709 (void *)&cmd_rx_vlan_filter_vlanid,
2710 (void *)&cmd_rx_vlan_filter_portid,
2715 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2716 struct cmd_tx_vlan_set_result {
2717 cmdline_fixed_string_t tx_vlan;
2718 cmdline_fixed_string_t set;
2724 cmd_tx_vlan_set_parsed(void *parsed_result,
2725 __attribute__((unused)) struct cmdline *cl,
2726 __attribute__((unused)) void *data)
2728 struct cmd_tx_vlan_set_result *res = parsed_result;
2729 tx_vlan_set(res->port_id, res->vlan_id);
2732 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2733 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2734 tx_vlan, "tx_vlan");
2735 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2736 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2738 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2739 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2741 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2742 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2745 cmdline_parse_inst_t cmd_tx_vlan_set = {
2746 .f = cmd_tx_vlan_set_parsed,
2748 .help_str = "enable hardware insertion of a VLAN header with a given "
2749 "TAG Identifier in packets sent on a port",
2751 (void *)&cmd_tx_vlan_set_tx_vlan,
2752 (void *)&cmd_tx_vlan_set_set,
2753 (void *)&cmd_tx_vlan_set_vlanid,
2754 (void *)&cmd_tx_vlan_set_portid,
2759 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2760 struct cmd_tx_vlan_set_pvid_result {
2761 cmdline_fixed_string_t tx_vlan;
2762 cmdline_fixed_string_t set;
2763 cmdline_fixed_string_t pvid;
2766 cmdline_fixed_string_t mode;
2770 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2771 __attribute__((unused)) struct cmdline *cl,
2772 __attribute__((unused)) void *data)
2774 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2776 if (strcmp(res->mode, "on") == 0)
2777 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2779 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2782 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2783 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2784 tx_vlan, "tx_vlan");
2785 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2786 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2788 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2789 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2791 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2792 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2794 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2795 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2797 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2798 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2801 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2802 .f = cmd_tx_vlan_set_pvid_parsed,
2804 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2806 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2807 (void *)&cmd_tx_vlan_set_pvid_set,
2808 (void *)&cmd_tx_vlan_set_pvid_pvid,
2809 (void *)&cmd_tx_vlan_set_pvid_port_id,
2810 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2811 (void *)&cmd_tx_vlan_set_pvid_mode,
2816 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2817 struct cmd_tx_vlan_reset_result {
2818 cmdline_fixed_string_t tx_vlan;
2819 cmdline_fixed_string_t reset;
2824 cmd_tx_vlan_reset_parsed(void *parsed_result,
2825 __attribute__((unused)) struct cmdline *cl,
2826 __attribute__((unused)) void *data)
2828 struct cmd_tx_vlan_reset_result *res = parsed_result;
2830 tx_vlan_reset(res->port_id);
2833 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2834 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2835 tx_vlan, "tx_vlan");
2836 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2837 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2839 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2840 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2843 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2844 .f = cmd_tx_vlan_reset_parsed,
2846 .help_str = "disable hardware insertion of a VLAN header in packets "
2849 (void *)&cmd_tx_vlan_reset_tx_vlan,
2850 (void *)&cmd_tx_vlan_reset_reset,
2851 (void *)&cmd_tx_vlan_reset_portid,
2857 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2858 struct cmd_tx_cksum_set_result {
2859 cmdline_fixed_string_t tx_cksum;
2860 cmdline_fixed_string_t set;
2866 cmd_tx_cksum_set_parsed(void *parsed_result,
2867 __attribute__((unused)) struct cmdline *cl,
2868 __attribute__((unused)) void *data)
2870 struct cmd_tx_cksum_set_result *res = parsed_result;
2872 tx_cksum_set(res->port_id, res->cksum_mask);
2875 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2876 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2877 tx_cksum, "tx_checksum");
2878 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2879 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2881 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2882 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2884 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2885 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2888 cmdline_parse_inst_t cmd_tx_cksum_set = {
2889 .f = cmd_tx_cksum_set_parsed,
2891 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2892 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip, "
2893 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP, Bit 4 for inner ip, "
2894 "Bit 5 for inner UDP, Bit 6 for inner TCP, Bit 7 for inner SCTP",
2896 (void *)&cmd_tx_cksum_set_tx_cksum,
2897 (void *)&cmd_tx_cksum_set_set,
2898 (void *)&cmd_tx_cksum_set_cksum_mask,
2899 (void *)&cmd_tx_cksum_set_portid,
2904 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2905 struct cmd_set_flush_rx {
2906 cmdline_fixed_string_t set;
2907 cmdline_fixed_string_t flush_rx;
2908 cmdline_fixed_string_t mode;
2912 cmd_set_flush_rx_parsed(void *parsed_result,
2913 __attribute__((unused)) struct cmdline *cl,
2914 __attribute__((unused)) void *data)
2916 struct cmd_set_flush_rx *res = parsed_result;
2917 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2920 cmdline_parse_token_string_t cmd_setflushrx_set =
2921 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2923 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2924 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2925 flush_rx, "flush_rx");
2926 cmdline_parse_token_string_t cmd_setflushrx_mode =
2927 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2931 cmdline_parse_inst_t cmd_set_flush_rx = {
2932 .f = cmd_set_flush_rx_parsed,
2933 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2936 (void *)&cmd_setflushrx_set,
2937 (void *)&cmd_setflushrx_flush_rx,
2938 (void *)&cmd_setflushrx_mode,
2943 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2944 struct cmd_set_link_check {
2945 cmdline_fixed_string_t set;
2946 cmdline_fixed_string_t link_check;
2947 cmdline_fixed_string_t mode;
2951 cmd_set_link_check_parsed(void *parsed_result,
2952 __attribute__((unused)) struct cmdline *cl,
2953 __attribute__((unused)) void *data)
2955 struct cmd_set_link_check *res = parsed_result;
2956 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2959 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2960 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2962 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2963 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2964 link_check, "link_check");
2965 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2966 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2970 cmdline_parse_inst_t cmd_set_link_check = {
2971 .f = cmd_set_link_check_parsed,
2972 .help_str = "set link_check on|off: enable/disable link status check "
2973 "when starting/stopping a port",
2976 (void *)&cmd_setlinkcheck_set,
2977 (void *)&cmd_setlinkcheck_link_check,
2978 (void *)&cmd_setlinkcheck_mode,
2983 #ifdef RTE_NIC_BYPASS
2984 /* *** SET NIC BYPASS MODE *** */
2985 struct cmd_set_bypass_mode_result {
2986 cmdline_fixed_string_t set;
2987 cmdline_fixed_string_t bypass;
2988 cmdline_fixed_string_t mode;
2989 cmdline_fixed_string_t value;
2994 cmd_set_bypass_mode_parsed(void *parsed_result,
2995 __attribute__((unused)) struct cmdline *cl,
2996 __attribute__((unused)) void *data)
2998 struct cmd_set_bypass_mode_result *res = parsed_result;
2999 portid_t port_id = res->port_id;
3000 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3002 if (!bypass_is_supported(port_id))
3005 if (!strcmp(res->value, "bypass"))
3006 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3007 else if (!strcmp(res->value, "isolate"))
3008 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3010 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3012 /* Set the bypass mode for the relevant port. */
3013 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
3014 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
3018 cmdline_parse_token_string_t cmd_setbypass_mode_set =
3019 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3021 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
3022 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3024 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
3025 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3027 cmdline_parse_token_string_t cmd_setbypass_mode_value =
3028 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
3029 value, "normal#bypass#isolate");
3030 cmdline_parse_token_num_t cmd_setbypass_mode_port =
3031 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
3034 cmdline_parse_inst_t cmd_set_bypass_mode = {
3035 .f = cmd_set_bypass_mode_parsed,
3036 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
3037 "Set the NIC bypass mode for port_id",
3040 (void *)&cmd_setbypass_mode_set,
3041 (void *)&cmd_setbypass_mode_bypass,
3042 (void *)&cmd_setbypass_mode_mode,
3043 (void *)&cmd_setbypass_mode_value,
3044 (void *)&cmd_setbypass_mode_port,
3049 /* *** SET NIC BYPASS EVENT *** */
3050 struct cmd_set_bypass_event_result {
3051 cmdline_fixed_string_t set;
3052 cmdline_fixed_string_t bypass;
3053 cmdline_fixed_string_t event;
3054 cmdline_fixed_string_t event_value;
3055 cmdline_fixed_string_t mode;
3056 cmdline_fixed_string_t mode_value;
3061 cmd_set_bypass_event_parsed(void *parsed_result,
3062 __attribute__((unused)) struct cmdline *cl,
3063 __attribute__((unused)) void *data)
3066 struct cmd_set_bypass_event_result *res = parsed_result;
3067 portid_t port_id = res->port_id;
3068 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
3069 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
3071 if (!bypass_is_supported(port_id))
3074 if (!strcmp(res->event_value, "timeout"))
3075 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
3076 else if (!strcmp(res->event_value, "os_on"))
3077 bypass_event = RTE_BYPASS_EVENT_OS_ON;
3078 else if (!strcmp(res->event_value, "os_off"))
3079 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
3080 else if (!strcmp(res->event_value, "power_on"))
3081 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
3082 else if (!strcmp(res->event_value, "power_off"))
3083 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
3085 bypass_event = RTE_BYPASS_EVENT_NONE;
3087 if (!strcmp(res->mode_value, "bypass"))
3088 bypass_mode = RTE_BYPASS_MODE_BYPASS;
3089 else if (!strcmp(res->mode_value, "isolate"))
3090 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
3092 bypass_mode = RTE_BYPASS_MODE_NORMAL;
3094 /* Set the watchdog timeout. */
3095 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
3098 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
3099 (rc = rte_eth_dev_wd_timeout_store(port_id,
3100 bypass_timeout)) != 0) {
3101 printf("Failed to set timeout value %u "
3102 "for port %d, errto code: %d.\n",
3103 bypass_timeout, port_id, rc);
3107 /* Set the bypass event to transition to bypass mode. */
3108 if (0 != rte_eth_dev_bypass_event_store(port_id,
3109 bypass_event, bypass_mode)) {
3110 printf("\t Failed to set bypass event for port = %d.\n", port_id);
3115 cmdline_parse_token_string_t cmd_setbypass_event_set =
3116 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3118 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
3119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3121 cmdline_parse_token_string_t cmd_setbypass_event_event =
3122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3124 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
3125 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3126 event_value, "none#timeout#os_off#os_on#power_on#power_off");
3127 cmdline_parse_token_string_t cmd_setbypass_event_mode =
3128 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3130 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
3131 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
3132 mode_value, "normal#bypass#isolate");
3133 cmdline_parse_token_num_t cmd_setbypass_event_port =
3134 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
3137 cmdline_parse_inst_t cmd_set_bypass_event = {
3138 .f = cmd_set_bypass_event_parsed,
3139 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
3140 "mode (normal|bypass|isolate) (port_id): "
3141 "Set the NIC bypass event mode for port_id",
3144 (void *)&cmd_setbypass_event_set,
3145 (void *)&cmd_setbypass_event_bypass,
3146 (void *)&cmd_setbypass_event_event,
3147 (void *)&cmd_setbypass_event_event_value,
3148 (void *)&cmd_setbypass_event_mode,
3149 (void *)&cmd_setbypass_event_mode_value,
3150 (void *)&cmd_setbypass_event_port,
3156 /* *** SET NIC BYPASS TIMEOUT *** */
3157 struct cmd_set_bypass_timeout_result {
3158 cmdline_fixed_string_t set;
3159 cmdline_fixed_string_t bypass;
3160 cmdline_fixed_string_t timeout;
3161 cmdline_fixed_string_t value;
3165 cmd_set_bypass_timeout_parsed(void *parsed_result,
3166 __attribute__((unused)) struct cmdline *cl,
3167 __attribute__((unused)) void *data)
3169 struct cmd_set_bypass_timeout_result *res = parsed_result;
3171 if (!strcmp(res->value, "1.5"))
3172 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
3173 else if (!strcmp(res->value, "2"))
3174 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
3175 else if (!strcmp(res->value, "3"))
3176 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
3177 else if (!strcmp(res->value, "4"))
3178 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
3179 else if (!strcmp(res->value, "8"))
3180 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
3181 else if (!strcmp(res->value, "16"))
3182 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
3183 else if (!strcmp(res->value, "32"))
3184 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
3186 bypass_timeout = RTE_BYPASS_TMT_OFF;
3189 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
3190 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3192 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
3193 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3195 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
3196 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3197 timeout, "timeout");
3198 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
3199 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
3200 value, "0#1.5#2#3#4#8#16#32");
3202 cmdline_parse_inst_t cmd_set_bypass_timeout = {
3203 .f = cmd_set_bypass_timeout_parsed,
3204 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
3205 "Set the NIC bypass watchdog timeout",
3208 (void *)&cmd_setbypass_timeout_set,
3209 (void *)&cmd_setbypass_timeout_bypass,
3210 (void *)&cmd_setbypass_timeout_timeout,
3211 (void *)&cmd_setbypass_timeout_value,
3216 /* *** SHOW NIC BYPASS MODE *** */
3217 struct cmd_show_bypass_config_result {
3218 cmdline_fixed_string_t show;
3219 cmdline_fixed_string_t bypass;
3220 cmdline_fixed_string_t config;
3225 cmd_show_bypass_config_parsed(void *parsed_result,
3226 __attribute__((unused)) struct cmdline *cl,
3227 __attribute__((unused)) void *data)
3229 struct cmd_show_bypass_config_result *res = parsed_result;
3230 uint32_t event_mode;
3231 uint32_t bypass_mode;
3232 portid_t port_id = res->port_id;
3233 uint32_t timeout = bypass_timeout;
3236 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
3237 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
3238 static const char * const modes[RTE_BYPASS_MODE_NUM] =
3239 {"UNKNOWN", "normal", "bypass", "isolate"};
3240 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
3247 int num_events = (sizeof events) / (sizeof events[0]);
3249 if (!bypass_is_supported(port_id))
3252 /* Display the bypass mode.*/
3253 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
3254 printf("\tFailed to get bypass mode for port = %d\n", port_id);
3258 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
3259 bypass_mode = RTE_BYPASS_MODE_NONE;
3261 printf("\tbypass mode = %s\n", modes[bypass_mode]);
3264 /* Display the bypass timeout.*/
3265 if (!RTE_BYPASS_TMT_VALID(timeout))
3266 timeout = RTE_BYPASS_TMT_OFF;
3268 printf("\tbypass timeout = %s\n", timeouts[timeout]);
3270 /* Display the bypass events and associated modes. */
3271 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
3273 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
3274 printf("\tFailed to get bypass mode for event = %s\n",
3277 if (!RTE_BYPASS_MODE_VALID(event_mode))
3278 event_mode = RTE_BYPASS_MODE_NONE;
3280 printf("\tbypass event: %-16s = %s\n", events[i],
3286 cmdline_parse_token_string_t cmd_showbypass_config_show =
3287 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3289 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3290 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3292 cmdline_parse_token_string_t cmd_showbypass_config_config =
3293 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3295 cmdline_parse_token_num_t cmd_showbypass_config_port =
3296 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3299 cmdline_parse_inst_t cmd_show_bypass_config = {
3300 .f = cmd_show_bypass_config_parsed,
3301 .help_str = "show bypass config (port_id): "
3302 "Show the NIC bypass config for port_id",
3305 (void *)&cmd_showbypass_config_show,
3306 (void *)&cmd_showbypass_config_bypass,
3307 (void *)&cmd_showbypass_config_config,
3308 (void *)&cmd_showbypass_config_port,
3314 #ifdef RTE_LIBRTE_PMD_BOND
3315 /* *** SET BONDING MODE *** */
3316 struct cmd_set_bonding_mode_result {
3317 cmdline_fixed_string_t set;
3318 cmdline_fixed_string_t bonding;
3319 cmdline_fixed_string_t mode;
3324 static void cmd_set_bonding_mode_parsed(void *parsed_result,
3325 __attribute__((unused)) struct cmdline *cl,
3326 __attribute__((unused)) void *data)
3328 struct cmd_set_bonding_mode_result *res = parsed_result;
3329 portid_t port_id = res->port_id;
3331 /* Set the bonding mode for the relevant port. */
3332 if (0 != rte_eth_bond_mode_set(port_id, res->value))
3333 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
3336 cmdline_parse_token_string_t cmd_setbonding_mode_set =
3337 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3339 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
3340 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3341 bonding, "bonding");
3342 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
3343 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
3345 cmdline_parse_token_num_t cmd_setbonding_mode_value =
3346 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3348 cmdline_parse_token_num_t cmd_setbonding_mode_port =
3349 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
3352 cmdline_parse_inst_t cmd_set_bonding_mode = {
3353 .f = cmd_set_bonding_mode_parsed,
3354 .help_str = "set bonding mode (mode_value) (port_id): Set the bonding mode for port_id",
3357 (void *) &cmd_setbonding_mode_set,
3358 (void *) &cmd_setbonding_mode_bonding,
3359 (void *) &cmd_setbonding_mode_mode,
3360 (void *) &cmd_setbonding_mode_value,
3361 (void *) &cmd_setbonding_mode_port,
3366 /* *** SET BALANCE XMIT POLICY *** */
3367 struct cmd_set_bonding_balance_xmit_policy_result {
3368 cmdline_fixed_string_t set;
3369 cmdline_fixed_string_t bonding;
3370 cmdline_fixed_string_t balance_xmit_policy;
3372 cmdline_fixed_string_t policy;
3375 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
3376 __attribute__((unused)) struct cmdline *cl,
3377 __attribute__((unused)) void *data)
3379 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
3380 portid_t port_id = res->port_id;
3383 if (!strcmp(res->policy, "l2")) {
3384 policy = BALANCE_XMIT_POLICY_LAYER2;
3385 } else if (!strcmp(res->policy, "l23")) {
3386 policy = BALANCE_XMIT_POLICY_LAYER23;
3387 } else if (!strcmp(res->policy, "l34")) {
3388 policy = BALANCE_XMIT_POLICY_LAYER34;
3390 printf("\t Invalid xmit policy selection");
3394 /* Set the bonding mode for the relevant port. */
3395 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
3396 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
3401 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
3402 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3404 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
3405 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3406 bonding, "bonding");
3407 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
3408 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3409 balance_xmit_policy, "balance_xmit_policy");
3410 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
3411 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3413 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
3414 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
3415 policy, "l2#l23#l34");
3417 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
3418 .f = cmd_set_bonding_balance_xmit_policy_parsed,
3419 .help_str = "set bonding balance_xmit_policy (port_id) (policy_value): Set the bonding balance_xmit_policy for port_id",
3422 (void *)&cmd_setbonding_balance_xmit_policy_set,
3423 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
3424 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
3425 (void *)&cmd_setbonding_balance_xmit_policy_port,
3426 (void *)&cmd_setbonding_balance_xmit_policy_policy,
3431 /* *** SHOW NIC BONDING CONFIGURATION *** */
3432 struct cmd_show_bonding_config_result {
3433 cmdline_fixed_string_t show;
3434 cmdline_fixed_string_t bonding;
3435 cmdline_fixed_string_t config;
3439 static void cmd_show_bonding_config_parsed(void *parsed_result,
3440 __attribute__((unused)) struct cmdline *cl,
3441 __attribute__((unused)) void *data)
3443 struct cmd_show_bonding_config_result *res = parsed_result;
3445 uint8_t slaves[RTE_MAX_ETHPORTS];
3446 int num_slaves, num_active_slaves;
3449 portid_t port_id = res->port_id;
3451 /* Display the bonding mode.*/
3452 bonding_mode = rte_eth_bond_mode_get(port_id);
3453 if (bonding_mode < 0) {
3454 printf("\tFailed to get bonding mode for port = %d\n", port_id);
3457 printf("\tBonding mode: %d\n", bonding_mode);
3459 if (bonding_mode == BONDING_MODE_BALANCE) {
3460 int balance_xmit_policy;
3462 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
3463 if (balance_xmit_policy < 0) {
3464 printf("\tFailed to get balance xmit policy for port = %d\n",
3468 printf("\tBalance Xmit Policy: ");
3470 switch (balance_xmit_policy) {
3471 case BALANCE_XMIT_POLICY_LAYER2:
3472 printf("BALANCE_XMIT_POLICY_LAYER2");
3474 case BALANCE_XMIT_POLICY_LAYER23:
3475 printf("BALANCE_XMIT_POLICY_LAYER23");
3477 case BALANCE_XMIT_POLICY_LAYER34:
3478 printf("BALANCE_XMIT_POLICY_LAYER34");
3485 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
3487 if (num_slaves < 0) {
3488 printf("\tFailed to get slave list for port = %d\n", port_id);
3491 if (num_slaves > 0) {
3492 printf("\tSlaves (%d): [", num_slaves);
3493 for (i = 0; i < num_slaves - 1; i++)
3494 printf("%d ", slaves[i]);
3496 printf("%d]\n", slaves[num_slaves - 1]);
3498 printf("\tSlaves: []\n");
3502 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
3505 if (num_active_slaves < 0) {
3506 printf("\tFailed to get active slave list for port = %d\n", port_id);
3509 if (num_active_slaves > 0) {
3510 printf("\tActive Slaves (%d): [", num_active_slaves);
3511 for (i = 0; i < num_active_slaves - 1; i++)
3512 printf("%d ", slaves[i]);
3514 printf("%d]\n", slaves[num_active_slaves - 1]);
3517 printf("\tActive Slaves: []\n");
3521 primary_id = rte_eth_bond_primary_get(port_id);
3522 if (primary_id < 0) {
3523 printf("\tFailed to get primary slave for port = %d\n", port_id);
3526 printf("\tPrimary: [%d]\n", primary_id);
3530 cmdline_parse_token_string_t cmd_showbonding_config_show =
3531 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3533 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
3534 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3535 bonding, "bonding");
3536 cmdline_parse_token_string_t cmd_showbonding_config_config =
3537 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
3539 cmdline_parse_token_num_t cmd_showbonding_config_port =
3540 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
3543 cmdline_parse_inst_t cmd_show_bonding_config = {
3544 .f = cmd_show_bonding_config_parsed,
3545 .help_str = "show bonding config (port_id): Show the bonding config for port_id",
3548 (void *)&cmd_showbonding_config_show,
3549 (void *)&cmd_showbonding_config_bonding,
3550 (void *)&cmd_showbonding_config_config,
3551 (void *)&cmd_showbonding_config_port,
3556 /* *** SET BONDING PRIMARY *** */
3557 struct cmd_set_bonding_primary_result {
3558 cmdline_fixed_string_t set;
3559 cmdline_fixed_string_t bonding;
3560 cmdline_fixed_string_t primary;
3565 static void cmd_set_bonding_primary_parsed(void *parsed_result,
3566 __attribute__((unused)) struct cmdline *cl,
3567 __attribute__((unused)) void *data)
3569 struct cmd_set_bonding_primary_result *res = parsed_result;
3570 portid_t master_port_id = res->port_id;
3571 portid_t slave_port_id = res->slave_id;
3573 /* Set the primary slave for a bonded device. */
3574 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
3575 printf("\t Failed to set primary slave for port = %d.\n",
3582 cmdline_parse_token_string_t cmd_setbonding_primary_set =
3583 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3585 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
3586 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3587 bonding, "bonding");
3588 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
3589 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
3590 primary, "primary");
3591 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
3592 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3594 cmdline_parse_token_num_t cmd_setbonding_primary_port =
3595 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
3598 cmdline_parse_inst_t cmd_set_bonding_primary = {
3599 .f = cmd_set_bonding_primary_parsed,
3600 .help_str = "set bonding primary (slave_id) (port_id): Set the primary slave for port_id",
3603 (void *)&cmd_setbonding_primary_set,
3604 (void *)&cmd_setbonding_primary_bonding,
3605 (void *)&cmd_setbonding_primary_primary,
3606 (void *)&cmd_setbonding_primary_slave,
3607 (void *)&cmd_setbonding_primary_port,
3612 /* *** ADD SLAVE *** */
3613 struct cmd_add_bonding_slave_result {
3614 cmdline_fixed_string_t add;
3615 cmdline_fixed_string_t bonding;
3616 cmdline_fixed_string_t slave;
3621 static void cmd_add_bonding_slave_parsed(void *parsed_result,
3622 __attribute__((unused)) struct cmdline *cl,
3623 __attribute__((unused)) void *data)
3625 struct cmd_add_bonding_slave_result *res = parsed_result;
3626 portid_t master_port_id = res->port_id;
3627 portid_t slave_port_id = res->slave_id;
3629 /* Set the primary slave for a bonded device. */
3630 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
3631 printf("\t Failed to add slave %d to master port = %d.\n",
3632 slave_port_id, master_port_id);
3638 cmdline_parse_token_string_t cmd_addbonding_slave_add =
3639 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3641 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
3642 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3643 bonding, "bonding");
3644 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
3645 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
3647 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
3648 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3650 cmdline_parse_token_num_t cmd_addbonding_slave_port =
3651 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
3654 cmdline_parse_inst_t cmd_add_bonding_slave = {
3655 .f = cmd_add_bonding_slave_parsed,
3656 .help_str = "add bonding slave (slave_id) (port_id): Add a slave device to a bonded device",
3659 (void *)&cmd_addbonding_slave_add,
3660 (void *)&cmd_addbonding_slave_bonding,
3661 (void *)&cmd_addbonding_slave_slave,
3662 (void *)&cmd_addbonding_slave_slaveid,
3663 (void *)&cmd_addbonding_slave_port,
3668 /* *** REMOVE SLAVE *** */
3669 struct cmd_remove_bonding_slave_result {
3670 cmdline_fixed_string_t remove;
3671 cmdline_fixed_string_t bonding;
3672 cmdline_fixed_string_t slave;
3677 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
3678 __attribute__((unused)) struct cmdline *cl,
3679 __attribute__((unused)) void *data)
3681 struct cmd_remove_bonding_slave_result *res = parsed_result;
3682 portid_t master_port_id = res->port_id;
3683 portid_t slave_port_id = res->slave_id;
3685 /* Set the primary slave for a bonded device. */
3686 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
3687 printf("\t Failed to remove slave %d from master port = %d.\n",
3688 slave_port_id, master_port_id);
3694 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
3695 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3697 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
3698 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3699 bonding, "bonding");
3700 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
3701 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
3703 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
3704 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3706 cmdline_parse_token_num_t cmd_removebonding_slave_port =
3707 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
3710 cmdline_parse_inst_t cmd_remove_bonding_slave = {
3711 .f = cmd_remove_bonding_slave_parsed,
3712 .help_str = "remove bonding slave (slave_id) (port_id): Remove a slave device from a bonded device",
3715 (void *)&cmd_removebonding_slave_remove,
3716 (void *)&cmd_removebonding_slave_bonding,
3717 (void *)&cmd_removebonding_slave_slave,
3718 (void *)&cmd_removebonding_slave_slaveid,
3719 (void *)&cmd_removebonding_slave_port,
3724 /* *** CREATE BONDED DEVICE *** */
3725 struct cmd_create_bonded_device_result {
3726 cmdline_fixed_string_t create;
3727 cmdline_fixed_string_t bonded;
3728 cmdline_fixed_string_t device;
3733 static int bond_dev_num = 0;
3735 static void cmd_create_bonded_device_parsed(void *parsed_result,
3736 __attribute__((unused)) struct cmdline *cl,
3737 __attribute__((unused)) void *data)
3739 struct cmd_create_bonded_device_result *res = parsed_result;
3740 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
3743 if (test_done == 0) {
3744 printf("Please stop forwarding first\n");
3748 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "eth_bond_testpmd_%d",
3751 /* Create a new bonded device. */
3752 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
3754 printf("\t Failed to create bonded device.\n");
3757 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
3760 /* Update number of ports */
3761 nb_ports = rte_eth_dev_count();
3762 reconfig(port_id, res->socket);
3763 rte_eth_promiscuous_enable(port_id);
3768 cmdline_parse_token_string_t cmd_createbonded_device_create =
3769 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3771 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
3772 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3774 cmdline_parse_token_string_t cmd_createbonded_device_device =
3775 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
3777 cmdline_parse_token_num_t cmd_createbonded_device_mode =
3778 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3780 cmdline_parse_token_num_t cmd_createbonded_device_socket =
3781 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
3784 cmdline_parse_inst_t cmd_create_bonded_device = {
3785 .f = cmd_create_bonded_device_parsed,
3786 .help_str = "create bonded device (mode) (socket): Create a new bonded device with specific bonding mode and socket",
3789 (void *)&cmd_createbonded_device_create,
3790 (void *)&cmd_createbonded_device_bonded,
3791 (void *)&cmd_createbonded_device_device,
3792 (void *)&cmd_createbonded_device_mode,
3793 (void *)&cmd_createbonded_device_socket,
3798 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
3799 struct cmd_set_bond_mac_addr_result {
3800 cmdline_fixed_string_t set;
3801 cmdline_fixed_string_t bonding;
3802 cmdline_fixed_string_t mac_addr;
3804 struct ether_addr address;
3807 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
3808 __attribute__((unused)) struct cmdline *cl,
3809 __attribute__((unused)) void *data)
3811 struct cmd_set_bond_mac_addr_result *res = parsed_result;
3814 if (res->port_num >= nb_ports) {
3815 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3819 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
3821 /* check the return value and print it if is < 0 */
3823 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3826 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
3828 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
3829 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
3831 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
3832 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
3834 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
3835 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, port_num, UINT8);
3836 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
3837 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
3839 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
3840 .f = cmd_set_bond_mac_addr_parsed,
3842 .help_str = "set bonding mac_addr (port_id) (address): ",
3844 (void *)&cmd_set_bond_mac_addr_set,
3845 (void *)&cmd_set_bond_mac_addr_bonding,
3846 (void *)&cmd_set_bond_mac_addr_mac,
3847 (void *)&cmd_set_bond_mac_addr_portnum,
3848 (void *)&cmd_set_bond_mac_addr_addr,
3854 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
3855 struct cmd_set_bond_mon_period_result {
3856 cmdline_fixed_string_t set;
3857 cmdline_fixed_string_t bonding;
3858 cmdline_fixed_string_t mon_period;
3863 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
3864 __attribute__((unused)) struct cmdline *cl,
3865 __attribute__((unused)) void *data)
3867 struct cmd_set_bond_mon_period_result *res = parsed_result;
3870 if (res->port_num >= nb_ports) {
3871 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
3875 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
3877 /* check the return value and print it if is < 0 */
3879 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
3882 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3885 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3887 bonding, "bonding");
3888 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
3890 mon_period, "mon_period");
3891 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
3892 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3894 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
3895 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
3898 cmdline_parse_inst_t cmd_set_bond_mon_period = {
3899 .f = cmd_set_bond_mon_period_parsed,
3901 .help_str = "set bonding mon_period (port_id) (period_ms): ",
3903 (void *)&cmd_set_bond_mon_period_set,
3904 (void *)&cmd_set_bond_mon_period_bonding,
3905 (void *)&cmd_set_bond_mon_period_mon_period,
3906 (void *)&cmd_set_bond_mon_period_portnum,
3907 (void *)&cmd_set_bond_mon_period_period_ms,
3912 #endif /* RTE_LIBRTE_PMD_BOND */
3914 /* *** SET FORWARDING MODE *** */
3915 struct cmd_set_fwd_mode_result {
3916 cmdline_fixed_string_t set;
3917 cmdline_fixed_string_t fwd;
3918 cmdline_fixed_string_t mode;
3921 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3922 __attribute__((unused)) struct cmdline *cl,
3923 __attribute__((unused)) void *data)
3925 struct cmd_set_fwd_mode_result *res = parsed_result;
3927 set_pkt_forwarding_mode(res->mode);
3930 cmdline_parse_token_string_t cmd_setfwd_set =
3931 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3932 cmdline_parse_token_string_t cmd_setfwd_fwd =
3933 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3934 cmdline_parse_token_string_t cmd_setfwd_mode =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3936 "" /* defined at init */);
3938 cmdline_parse_inst_t cmd_set_fwd_mode = {
3939 .f = cmd_set_fwd_mode_parsed,
3941 .help_str = NULL, /* defined at init */
3943 (void *)&cmd_setfwd_set,
3944 (void *)&cmd_setfwd_fwd,
3945 (void *)&cmd_setfwd_mode,
3950 static void cmd_set_fwd_mode_init(void)
3953 static char token[128];
3954 static char help[256];
3955 cmdline_parse_token_string_t *token_struct;
3957 modes = list_pkt_forwarding_modes();
3958 snprintf(help, sizeof help, "set fwd %s - "
3959 "set packet forwarding mode", modes);
3960 cmd_set_fwd_mode.help_str = help;
3962 /* string token separator is # */
3963 for (c = token; *modes != '\0'; modes++)
3968 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3969 token_struct->string_data.str = token;
3972 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3973 struct cmd_set_burst_tx_retry_result {
3974 cmdline_fixed_string_t set;
3975 cmdline_fixed_string_t burst;
3976 cmdline_fixed_string_t tx;
3977 cmdline_fixed_string_t delay;
3979 cmdline_fixed_string_t retry;
3983 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3984 __attribute__((unused)) struct cmdline *cl,
3985 __attribute__((unused)) void *data)
3987 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3989 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3990 && !strcmp(res->tx, "tx")) {
3991 if (!strcmp(res->delay, "delay"))
3992 burst_tx_delay_time = res->time;
3993 if (!strcmp(res->retry, "retry"))
3994 burst_tx_retry_num = res->retry_num;
3999 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
4001 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
4004 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
4006 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
4008 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
4009 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
4010 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
4012 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
4013 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
4015 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
4016 .f = cmd_set_burst_tx_retry_parsed,
4017 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
4019 (void *)&cmd_set_burst_tx_retry_set,
4020 (void *)&cmd_set_burst_tx_retry_burst,
4021 (void *)&cmd_set_burst_tx_retry_tx,
4022 (void *)&cmd_set_burst_tx_retry_delay,
4023 (void *)&cmd_set_burst_tx_retry_time,
4024 (void *)&cmd_set_burst_tx_retry_retry,
4025 (void *)&cmd_set_burst_tx_retry_retry_num,
4030 /* *** SET PROMISC MODE *** */
4031 struct cmd_set_promisc_mode_result {
4032 cmdline_fixed_string_t set;
4033 cmdline_fixed_string_t promisc;
4034 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4035 uint8_t port_num; /* valid if "allports" argument == 0 */
4036 cmdline_fixed_string_t mode;
4039 static void cmd_set_promisc_mode_parsed(void *parsed_result,
4040 __attribute__((unused)) struct cmdline *cl,
4043 struct cmd_set_promisc_mode_result *res = parsed_result;
4047 if (!strcmp(res->mode, "on"))
4054 for (i = 0; i < nb_ports; i++) {
4056 rte_eth_promiscuous_enable(i);
4058 rte_eth_promiscuous_disable(i);
4063 rte_eth_promiscuous_enable(res->port_num);
4065 rte_eth_promiscuous_disable(res->port_num);
4069 cmdline_parse_token_string_t cmd_setpromisc_set =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
4071 cmdline_parse_token_string_t cmd_setpromisc_promisc =
4072 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
4074 cmdline_parse_token_string_t cmd_setpromisc_portall =
4075 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
4077 cmdline_parse_token_num_t cmd_setpromisc_portnum =
4078 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
4080 cmdline_parse_token_string_t cmd_setpromisc_mode =
4081 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
4084 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
4085 .f = cmd_set_promisc_mode_parsed,
4087 .help_str = "set promisc all on|off: set promisc mode for all ports",
4089 (void *)&cmd_setpromisc_set,
4090 (void *)&cmd_setpromisc_promisc,
4091 (void *)&cmd_setpromisc_portall,
4092 (void *)&cmd_setpromisc_mode,
4097 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
4098 .f = cmd_set_promisc_mode_parsed,
4100 .help_str = "set promisc X on|off: set promisc mode on port X",
4102 (void *)&cmd_setpromisc_set,
4103 (void *)&cmd_setpromisc_promisc,
4104 (void *)&cmd_setpromisc_portnum,
4105 (void *)&cmd_setpromisc_mode,
4110 /* *** SET ALLMULTI MODE *** */
4111 struct cmd_set_allmulti_mode_result {
4112 cmdline_fixed_string_t set;
4113 cmdline_fixed_string_t allmulti;
4114 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
4115 uint8_t port_num; /* valid if "allports" argument == 0 */
4116 cmdline_fixed_string_t mode;
4119 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
4120 __attribute__((unused)) struct cmdline *cl,
4123 struct cmd_set_allmulti_mode_result *res = parsed_result;
4127 if (!strcmp(res->mode, "on"))
4134 for (i = 0; i < nb_ports; i++) {
4136 rte_eth_allmulticast_enable(i);
4138 rte_eth_allmulticast_disable(i);
4143 rte_eth_allmulticast_enable(res->port_num);
4145 rte_eth_allmulticast_disable(res->port_num);
4149 cmdline_parse_token_string_t cmd_setallmulti_set =
4150 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
4151 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
4152 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
4154 cmdline_parse_token_string_t cmd_setallmulti_portall =
4155 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
4157 cmdline_parse_token_num_t cmd_setallmulti_portnum =
4158 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
4160 cmdline_parse_token_string_t cmd_setallmulti_mode =
4161 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
4164 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
4165 .f = cmd_set_allmulti_mode_parsed,
4167 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
4169 (void *)&cmd_setallmulti_set,
4170 (void *)&cmd_setallmulti_allmulti,
4171 (void *)&cmd_setallmulti_portall,
4172 (void *)&cmd_setallmulti_mode,
4177 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
4178 .f = cmd_set_allmulti_mode_parsed,
4180 .help_str = "set allmulti X on|off: set allmulti mode on port X",
4182 (void *)&cmd_setallmulti_set,
4183 (void *)&cmd_setallmulti_allmulti,
4184 (void *)&cmd_setallmulti_portnum,
4185 (void *)&cmd_setallmulti_mode,
4190 /* *** ADD/REMOVE A PKT FILTER *** */
4191 struct cmd_pkt_filter_result {
4192 cmdline_fixed_string_t pkt_filter;
4194 cmdline_fixed_string_t protocol;
4195 cmdline_fixed_string_t src;
4196 cmdline_ipaddr_t ip_src;
4198 cmdline_fixed_string_t dst;
4199 cmdline_ipaddr_t ip_dst;
4201 cmdline_fixed_string_t flexbytes;
4202 uint16_t flexbytes_value;
4203 cmdline_fixed_string_t vlan;
4205 cmdline_fixed_string_t queue;
4207 cmdline_fixed_string_t soft;
4212 cmd_pkt_filter_parsed(void *parsed_result,
4213 __attribute__((unused)) struct cmdline *cl,
4214 __attribute__((unused)) void *data)
4216 struct rte_fdir_filter fdir_filter;
4217 struct cmd_pkt_filter_result *res = parsed_result;
4219 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
4221 if (res->ip_src.family == AF_INET)
4222 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
4224 memcpy(&(fdir_filter.ip_src.ipv6_addr),
4225 &(res->ip_src.addr.ipv6),
4226 sizeof(struct in6_addr));
4228 if (res->ip_dst.family == AF_INET)
4229 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
4231 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
4232 &(res->ip_dst.addr.ipv6),
4233 sizeof(struct in6_addr));
4235 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
4236 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
4238 if (!strcmp(res->protocol, "udp"))
4239 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
4240 else if (!strcmp(res->protocol, "tcp"))
4241 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
4242 else if (!strcmp(res->protocol, "sctp"))
4243 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
4244 else /* default only IP */
4245 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
4247 if (res->ip_dst.family == AF_INET6)
4248 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
4250 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
4252 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
4253 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
4255 if (!strcmp(res->pkt_filter, "add_signature_filter"))
4256 fdir_add_signature_filter(res->port_id, res->queue_id,
4258 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
4259 fdir_update_signature_filter(res->port_id, res->queue_id,
4261 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
4262 fdir_remove_signature_filter(res->port_id, &fdir_filter);
4263 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
4264 fdir_add_perfect_filter(res->port_id, res->soft_id,
4266 (uint8_t) (res->queue_id < 0),
4268 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
4269 fdir_update_perfect_filter(res->port_id, res->soft_id,
4271 (uint8_t) (res->queue_id < 0),
4273 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
4274 fdir_remove_perfect_filter(res->port_id, res->soft_id,
4280 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
4281 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4283 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
4284 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4285 protocol, "ip#tcp#udp#sctp");
4286 cmdline_parse_token_string_t cmd_pkt_filter_src =
4287 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4289 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
4290 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4292 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
4293 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4295 cmdline_parse_token_string_t cmd_pkt_filter_dst =
4296 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4298 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
4299 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
4301 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
4302 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4304 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
4305 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4306 flexbytes, "flexbytes");
4307 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
4308 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4309 flexbytes_value, UINT16);
4310 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
4311 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4313 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
4314 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4316 cmdline_parse_token_string_t cmd_pkt_filter_queue =
4317 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4319 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
4320 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4322 cmdline_parse_token_string_t cmd_pkt_filter_soft =
4323 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4325 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
4326 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
4330 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
4331 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4332 pkt_filter, "add_signature_filter");
4333 cmdline_parse_inst_t cmd_add_signature_filter = {
4334 .f = cmd_pkt_filter_parsed,
4336 .help_str = "add a signature filter",
4338 (void *)&cmd_pkt_filter_add_signature_filter,
4339 (void *)&cmd_pkt_filter_port_id,
4340 (void *)&cmd_pkt_filter_protocol,
4341 (void *)&cmd_pkt_filter_src,
4342 (void *)&cmd_pkt_filter_ip_src,
4343 (void *)&cmd_pkt_filter_port_src,
4344 (void *)&cmd_pkt_filter_dst,
4345 (void *)&cmd_pkt_filter_ip_dst,
4346 (void *)&cmd_pkt_filter_port_dst,
4347 (void *)&cmd_pkt_filter_flexbytes,
4348 (void *)&cmd_pkt_filter_flexbytes_value,
4349 (void *)&cmd_pkt_filter_vlan,
4350 (void *)&cmd_pkt_filter_vlan_id,
4351 (void *)&cmd_pkt_filter_queue,
4352 (void *)&cmd_pkt_filter_queue_id,
4358 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
4359 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4360 pkt_filter, "upd_signature_filter");
4361 cmdline_parse_inst_t cmd_upd_signature_filter = {
4362 .f = cmd_pkt_filter_parsed,
4364 .help_str = "update a signature filter",
4366 (void *)&cmd_pkt_filter_upd_signature_filter,
4367 (void *)&cmd_pkt_filter_port_id,
4368 (void *)&cmd_pkt_filter_protocol,
4369 (void *)&cmd_pkt_filter_src,
4370 (void *)&cmd_pkt_filter_ip_src,
4371 (void *)&cmd_pkt_filter_port_src,
4372 (void *)&cmd_pkt_filter_dst,
4373 (void *)&cmd_pkt_filter_ip_dst,
4374 (void *)&cmd_pkt_filter_port_dst,
4375 (void *)&cmd_pkt_filter_flexbytes,
4376 (void *)&cmd_pkt_filter_flexbytes_value,
4377 (void *)&cmd_pkt_filter_vlan,
4378 (void *)&cmd_pkt_filter_vlan_id,
4379 (void *)&cmd_pkt_filter_queue,
4380 (void *)&cmd_pkt_filter_queue_id,
4386 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
4387 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4388 pkt_filter, "rm_signature_filter");
4389 cmdline_parse_inst_t cmd_rm_signature_filter = {
4390 .f = cmd_pkt_filter_parsed,
4392 .help_str = "remove a signature filter",
4394 (void *)&cmd_pkt_filter_rm_signature_filter,
4395 (void *)&cmd_pkt_filter_port_id,
4396 (void *)&cmd_pkt_filter_protocol,
4397 (void *)&cmd_pkt_filter_src,
4398 (void *)&cmd_pkt_filter_ip_src,
4399 (void *)&cmd_pkt_filter_port_src,
4400 (void *)&cmd_pkt_filter_dst,
4401 (void *)&cmd_pkt_filter_ip_dst,
4402 (void *)&cmd_pkt_filter_port_dst,
4403 (void *)&cmd_pkt_filter_flexbytes,
4404 (void *)&cmd_pkt_filter_flexbytes_value,
4405 (void *)&cmd_pkt_filter_vlan,
4406 (void *)&cmd_pkt_filter_vlan_id,
4412 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
4413 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4414 pkt_filter, "add_perfect_filter");
4415 cmdline_parse_inst_t cmd_add_perfect_filter = {
4416 .f = cmd_pkt_filter_parsed,
4418 .help_str = "add a perfect filter",
4420 (void *)&cmd_pkt_filter_add_perfect_filter,
4421 (void *)&cmd_pkt_filter_port_id,
4422 (void *)&cmd_pkt_filter_protocol,
4423 (void *)&cmd_pkt_filter_src,
4424 (void *)&cmd_pkt_filter_ip_src,
4425 (void *)&cmd_pkt_filter_port_src,
4426 (void *)&cmd_pkt_filter_dst,
4427 (void *)&cmd_pkt_filter_ip_dst,
4428 (void *)&cmd_pkt_filter_port_dst,
4429 (void *)&cmd_pkt_filter_flexbytes,
4430 (void *)&cmd_pkt_filter_flexbytes_value,
4431 (void *)&cmd_pkt_filter_vlan,
4432 (void *)&cmd_pkt_filter_vlan_id,
4433 (void *)&cmd_pkt_filter_queue,
4434 (void *)&cmd_pkt_filter_queue_id,
4435 (void *)&cmd_pkt_filter_soft,
4436 (void *)&cmd_pkt_filter_soft_id,
4442 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
4443 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4444 pkt_filter, "upd_perfect_filter");
4445 cmdline_parse_inst_t cmd_upd_perfect_filter = {
4446 .f = cmd_pkt_filter_parsed,
4448 .help_str = "update a perfect filter",
4450 (void *)&cmd_pkt_filter_upd_perfect_filter,
4451 (void *)&cmd_pkt_filter_port_id,
4452 (void *)&cmd_pkt_filter_protocol,
4453 (void *)&cmd_pkt_filter_src,
4454 (void *)&cmd_pkt_filter_ip_src,
4455 (void *)&cmd_pkt_filter_port_src,
4456 (void *)&cmd_pkt_filter_dst,
4457 (void *)&cmd_pkt_filter_ip_dst,
4458 (void *)&cmd_pkt_filter_port_dst,
4459 (void *)&cmd_pkt_filter_flexbytes,
4460 (void *)&cmd_pkt_filter_flexbytes_value,
4461 (void *)&cmd_pkt_filter_vlan,
4462 (void *)&cmd_pkt_filter_vlan_id,
4463 (void *)&cmd_pkt_filter_queue,
4464 (void *)&cmd_pkt_filter_queue_id,
4465 (void *)&cmd_pkt_filter_soft,
4466 (void *)&cmd_pkt_filter_soft_id,
4472 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
4473 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
4474 pkt_filter, "rm_perfect_filter");
4475 cmdline_parse_inst_t cmd_rm_perfect_filter = {
4476 .f = cmd_pkt_filter_parsed,
4478 .help_str = "remove a perfect filter",
4480 (void *)&cmd_pkt_filter_rm_perfect_filter,
4481 (void *)&cmd_pkt_filter_port_id,
4482 (void *)&cmd_pkt_filter_protocol,
4483 (void *)&cmd_pkt_filter_src,
4484 (void *)&cmd_pkt_filter_ip_src,
4485 (void *)&cmd_pkt_filter_port_src,
4486 (void *)&cmd_pkt_filter_dst,
4487 (void *)&cmd_pkt_filter_ip_dst,
4488 (void *)&cmd_pkt_filter_port_dst,
4489 (void *)&cmd_pkt_filter_flexbytes,
4490 (void *)&cmd_pkt_filter_flexbytes_value,
4491 (void *)&cmd_pkt_filter_vlan,
4492 (void *)&cmd_pkt_filter_vlan_id,
4493 (void *)&cmd_pkt_filter_soft,
4494 (void *)&cmd_pkt_filter_soft_id,
4499 /* *** SETUP MASKS FILTER *** */
4500 struct cmd_pkt_filter_masks_result {
4501 cmdline_fixed_string_t filter_mask;
4503 cmdline_fixed_string_t src_mask;
4504 uint32_t ip_src_mask;
4505 uint16_t ipv6_src_mask;
4506 uint16_t port_src_mask;
4507 cmdline_fixed_string_t dst_mask;
4508 uint32_t ip_dst_mask;
4509 uint16_t ipv6_dst_mask;
4510 uint16_t port_dst_mask;
4511 cmdline_fixed_string_t flexbytes;
4512 uint8_t flexbytes_value;
4513 cmdline_fixed_string_t vlan_id;
4514 uint8_t vlan_id_value;
4515 cmdline_fixed_string_t vlan_prio;
4516 uint8_t vlan_prio_value;
4517 cmdline_fixed_string_t only_ip_flow;
4518 uint8_t only_ip_flow_value;
4519 cmdline_fixed_string_t comp_ipv6_dst;
4520 uint8_t comp_ipv6_dst_value;
4524 cmd_pkt_filter_masks_parsed(void *parsed_result,
4525 __attribute__((unused)) struct cmdline *cl,
4526 __attribute__((unused)) void *data)
4528 struct rte_fdir_masks fdir_masks;
4529 struct cmd_pkt_filter_masks_result *res = parsed_result;
4531 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4533 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4534 fdir_masks.vlan_id = res->vlan_id_value;
4535 fdir_masks.vlan_prio = res->vlan_prio_value;
4536 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
4537 fdir_masks.src_ipv4_mask = res->ip_src_mask;
4538 fdir_masks.src_port_mask = res->port_src_mask;
4539 fdir_masks.dst_port_mask = res->port_dst_mask;
4540 fdir_masks.flexbytes = res->flexbytes_value;
4542 fdir_set_masks(res->port_id, &fdir_masks);
4545 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
4546 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4547 filter_mask, "set_masks_filter");
4548 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
4549 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4551 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
4552 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4553 only_ip_flow, "only_ip_flow");
4554 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
4555 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4556 only_ip_flow_value, UINT8);
4557 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
4558 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4559 src_mask, "src_mask");
4560 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
4561 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4562 ip_src_mask, UINT32);
4563 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
4564 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4565 port_src_mask, UINT16);
4566 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
4567 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4568 dst_mask, "dst_mask");
4569 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
4570 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4571 ip_dst_mask, UINT32);
4572 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
4573 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4574 port_dst_mask, UINT16);
4575 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
4576 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4577 flexbytes, "flexbytes");
4578 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
4579 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4580 flexbytes_value, UINT8);
4581 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
4582 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4583 vlan_id, "vlan_id");
4584 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
4585 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4586 vlan_id_value, UINT8);
4587 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
4588 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4589 vlan_prio, "vlan_prio");
4590 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
4591 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4592 vlan_prio_value, UINT8);
4594 cmdline_parse_inst_t cmd_set_masks_filter = {
4595 .f = cmd_pkt_filter_masks_parsed,
4597 .help_str = "setup masks filter",
4599 (void *)&cmd_pkt_filter_masks_filter_mask,
4600 (void *)&cmd_pkt_filter_masks_port_id,
4601 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4602 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4603 (void *)&cmd_pkt_filter_masks_src_mask,
4604 (void *)&cmd_pkt_filter_masks_ip_src_mask,
4605 (void *)&cmd_pkt_filter_masks_port_src_mask,
4606 (void *)&cmd_pkt_filter_masks_dst_mask,
4607 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
4608 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4609 (void *)&cmd_pkt_filter_masks_flexbytes,
4610 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4611 (void *)&cmd_pkt_filter_masks_vlan_id,
4612 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4613 (void *)&cmd_pkt_filter_masks_vlan_prio,
4614 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4620 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
4621 __attribute__((unused)) struct cmdline *cl,
4622 __attribute__((unused)) void *data)
4624 struct rte_fdir_masks fdir_masks;
4625 struct cmd_pkt_filter_masks_result *res = parsed_result;
4627 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
4629 fdir_masks.set_ipv6_mask = 1;
4630 fdir_masks.only_ip_flow = res->only_ip_flow_value;
4631 fdir_masks.vlan_id = res->vlan_id_value;
4632 fdir_masks.vlan_prio = res->vlan_prio_value;
4633 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
4634 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
4635 fdir_masks.src_port_mask = res->port_src_mask;
4636 fdir_masks.dst_port_mask = res->port_dst_mask;
4637 fdir_masks.flexbytes = res->flexbytes_value;
4638 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
4640 fdir_set_masks(res->port_id, &fdir_masks);
4643 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
4644 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4645 filter_mask, "set_ipv6_masks_filter");
4646 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
4647 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4648 ipv6_src_mask, UINT16);
4649 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
4650 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4651 ipv6_dst_mask, UINT16);
4653 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
4654 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
4655 comp_ipv6_dst, "compare_dst");
4656 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
4657 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
4658 comp_ipv6_dst_value, UINT8);
4660 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
4661 .f = cmd_pkt_filter_masks_ipv6_parsed,
4663 .help_str = "setup ipv6 masks filter",
4665 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
4666 (void *)&cmd_pkt_filter_masks_port_id,
4667 (void *)&cmd_pkt_filter_masks_only_ip_flow,
4668 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
4669 (void *)&cmd_pkt_filter_masks_src_mask,
4670 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
4671 (void *)&cmd_pkt_filter_masks_port_src_mask,
4672 (void *)&cmd_pkt_filter_masks_dst_mask,
4673 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
4674 (void *)&cmd_pkt_filter_masks_port_dst_mask,
4675 (void *)&cmd_pkt_filter_masks_flexbytes,
4676 (void *)&cmd_pkt_filter_masks_flexbytes_value,
4677 (void *)&cmd_pkt_filter_masks_vlan_id,
4678 (void *)&cmd_pkt_filter_masks_vlan_id_value,
4679 (void *)&cmd_pkt_filter_masks_vlan_prio,
4680 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
4681 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
4682 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
4687 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
4688 struct cmd_link_flow_ctrl_set_result {
4689 cmdline_fixed_string_t set;
4690 cmdline_fixed_string_t flow_ctrl;
4691 cmdline_fixed_string_t rx;
4692 cmdline_fixed_string_t rx_lfc_mode;
4693 cmdline_fixed_string_t tx;
4694 cmdline_fixed_string_t tx_lfc_mode;
4695 cmdline_fixed_string_t mac_ctrl_frame_fwd;
4696 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
4697 cmdline_fixed_string_t autoneg_str;
4698 cmdline_fixed_string_t autoneg;
4699 cmdline_fixed_string_t hw_str;
4700 uint32_t high_water;
4701 cmdline_fixed_string_t lw_str;
4703 cmdline_fixed_string_t pt_str;
4704 uint16_t pause_time;
4705 cmdline_fixed_string_t xon_str;
4710 cmdline_parse_token_string_t cmd_lfc_set_set =
4711 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4713 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
4714 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4715 flow_ctrl, "flow_ctrl");
4716 cmdline_parse_token_string_t cmd_lfc_set_rx =
4717 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4719 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
4720 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4721 rx_lfc_mode, "on#off");
4722 cmdline_parse_token_string_t cmd_lfc_set_tx =
4723 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4725 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
4726 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4727 tx_lfc_mode, "on#off");
4728 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
4729 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4730 hw_str, "high_water");
4731 cmdline_parse_token_num_t cmd_lfc_set_high_water =
4732 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4733 high_water, UINT32);
4734 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
4735 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4736 lw_str, "low_water");
4737 cmdline_parse_token_num_t cmd_lfc_set_low_water =
4738 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4740 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
4741 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4742 pt_str, "pause_time");
4743 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
4744 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4745 pause_time, UINT16);
4746 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
4747 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4748 xon_str, "send_xon");
4749 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
4750 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4752 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
4753 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4754 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
4755 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
4756 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4757 mac_ctrl_frame_fwd_mode, "on#off");
4758 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
4759 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4760 autoneg_str, "autoneg");
4761 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
4762 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4764 cmdline_parse_token_num_t cmd_lfc_set_portid =
4765 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
4768 /* forward declaration */
4770 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
4773 cmdline_parse_inst_t cmd_link_flow_control_set = {
4774 .f = cmd_link_flow_ctrl_set_parsed,
4776 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
4777 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
4778 autoneg on|off port_id",
4780 (void *)&cmd_lfc_set_set,
4781 (void *)&cmd_lfc_set_flow_ctrl,
4782 (void *)&cmd_lfc_set_rx,
4783 (void *)&cmd_lfc_set_rx_mode,
4784 (void *)&cmd_lfc_set_tx,
4785 (void *)&cmd_lfc_set_tx_mode,
4786 (void *)&cmd_lfc_set_high_water,
4787 (void *)&cmd_lfc_set_low_water,
4788 (void *)&cmd_lfc_set_pause_time,
4789 (void *)&cmd_lfc_set_send_xon,
4790 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4791 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4792 (void *)&cmd_lfc_set_autoneg_str,
4793 (void *)&cmd_lfc_set_autoneg,
4794 (void *)&cmd_lfc_set_portid,
4799 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
4800 .f = cmd_link_flow_ctrl_set_parsed,
4801 .data = (void *)&cmd_link_flow_control_set_rx,
4802 .help_str = "Change rx flow control parameter: set flow_ctrl "
4803 "rx on|off port_id",
4805 (void *)&cmd_lfc_set_set,
4806 (void *)&cmd_lfc_set_flow_ctrl,
4807 (void *)&cmd_lfc_set_rx,
4808 (void *)&cmd_lfc_set_rx_mode,
4809 (void *)&cmd_lfc_set_portid,
4814 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
4815 .f = cmd_link_flow_ctrl_set_parsed,
4816 .data = (void *)&cmd_link_flow_control_set_tx,
4817 .help_str = "Change tx flow control parameter: set flow_ctrl "
4818 "tx on|off port_id",
4820 (void *)&cmd_lfc_set_set,
4821 (void *)&cmd_lfc_set_flow_ctrl,
4822 (void *)&cmd_lfc_set_tx,
4823 (void *)&cmd_lfc_set_tx_mode,
4824 (void *)&cmd_lfc_set_portid,
4829 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
4830 .f = cmd_link_flow_ctrl_set_parsed,
4831 .data = (void *)&cmd_link_flow_control_set_hw,
4832 .help_str = "Change high water flow control parameter: set flow_ctrl "
4833 "high_water value port_id",
4835 (void *)&cmd_lfc_set_set,
4836 (void *)&cmd_lfc_set_flow_ctrl,
4837 (void *)&cmd_lfc_set_high_water_str,
4838 (void *)&cmd_lfc_set_high_water,
4839 (void *)&cmd_lfc_set_portid,
4844 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
4845 .f = cmd_link_flow_ctrl_set_parsed,
4846 .data = (void *)&cmd_link_flow_control_set_lw,
4847 .help_str = "Change low water flow control parameter: set flow_ctrl "
4848 "low_water value port_id",
4850 (void *)&cmd_lfc_set_set,
4851 (void *)&cmd_lfc_set_flow_ctrl,
4852 (void *)&cmd_lfc_set_low_water_str,
4853 (void *)&cmd_lfc_set_low_water,
4854 (void *)&cmd_lfc_set_portid,
4859 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
4860 .f = cmd_link_flow_ctrl_set_parsed,
4861 .data = (void *)&cmd_link_flow_control_set_pt,
4862 .help_str = "Change pause time flow control parameter: set flow_ctrl "
4863 "pause_time value port_id",
4865 (void *)&cmd_lfc_set_set,
4866 (void *)&cmd_lfc_set_flow_ctrl,
4867 (void *)&cmd_lfc_set_pause_time_str,
4868 (void *)&cmd_lfc_set_pause_time,
4869 (void *)&cmd_lfc_set_portid,
4874 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
4875 .f = cmd_link_flow_ctrl_set_parsed,
4876 .data = (void *)&cmd_link_flow_control_set_xon,
4877 .help_str = "Change send_xon flow control parameter: set flow_ctrl "
4878 "send_xon value port_id",
4880 (void *)&cmd_lfc_set_set,
4881 (void *)&cmd_lfc_set_flow_ctrl,
4882 (void *)&cmd_lfc_set_send_xon_str,
4883 (void *)&cmd_lfc_set_send_xon,
4884 (void *)&cmd_lfc_set_portid,
4889 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
4890 .f = cmd_link_flow_ctrl_set_parsed,
4891 .data = (void *)&cmd_link_flow_control_set_macfwd,
4892 .help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
4893 "mac_ctrl_frame_fwd on|off port_id",
4895 (void *)&cmd_lfc_set_set,
4896 (void *)&cmd_lfc_set_flow_ctrl,
4897 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
4898 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
4899 (void *)&cmd_lfc_set_portid,
4904 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
4905 .f = cmd_link_flow_ctrl_set_parsed,
4906 .data = (void *)&cmd_link_flow_control_set_autoneg,
4907 .help_str = "Change autoneg flow control parameter: set flow_ctrl "
4908 "autoneg on|off port_id",
4910 (void *)&cmd_lfc_set_set,
4911 (void *)&cmd_lfc_set_flow_ctrl,
4912 (void *)&cmd_lfc_set_autoneg_str,
4913 (void *)&cmd_lfc_set_autoneg,
4914 (void *)&cmd_lfc_set_portid,
4920 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
4921 __attribute__((unused)) struct cmdline *cl,
4924 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
4925 cmdline_parse_inst_t *cmd = data;
4926 struct rte_eth_fc_conf fc_conf;
4927 int rx_fc_en, tx_fc_en;
4931 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
4932 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
4933 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
4934 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
4936 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
4937 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
4940 /* Partial command line, retrieve current configuration */
4942 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
4944 printf("cannot get current flow ctrl parameters, return"
4945 "code = %d\n", ret);
4949 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
4950 (fc_conf.mode == RTE_FC_FULL))
4952 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
4953 (fc_conf.mode == RTE_FC_FULL))
4957 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
4958 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
4960 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
4961 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
4963 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
4965 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
4966 fc_conf.high_water = res->high_water;
4968 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
4969 fc_conf.low_water = res->low_water;
4971 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
4972 fc_conf.pause_time = res->pause_time;
4974 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
4975 fc_conf.send_xon = res->send_xon;
4977 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
4978 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
4979 fc_conf.mac_ctrl_frame_fwd = 1;
4981 fc_conf.mac_ctrl_frame_fwd = 0;
4984 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
4985 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
4987 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
4989 printf("bad flow contrl parameter, return code = %d \n", ret);
4992 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
4993 struct cmd_priority_flow_ctrl_set_result {
4994 cmdline_fixed_string_t set;
4995 cmdline_fixed_string_t pfc_ctrl;
4996 cmdline_fixed_string_t rx;
4997 cmdline_fixed_string_t rx_pfc_mode;
4998 cmdline_fixed_string_t tx;
4999 cmdline_fixed_string_t tx_pfc_mode;
5000 uint32_t high_water;
5002 uint16_t pause_time;
5008 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
5009 __attribute__((unused)) struct cmdline *cl,
5010 __attribute__((unused)) void *data)
5012 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
5013 struct rte_eth_pfc_conf pfc_conf;
5014 int rx_fc_enable, tx_fc_enable;
5018 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
5019 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
5020 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
5021 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
5023 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
5024 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
5027 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
5028 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
5029 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
5030 pfc_conf.fc.high_water = res->high_water;
5031 pfc_conf.fc.low_water = res->low_water;
5032 pfc_conf.fc.pause_time = res->pause_time;
5033 pfc_conf.priority = res->priority;
5035 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
5037 printf("bad priority flow contrl parameter, return code = %d \n", ret);
5040 cmdline_parse_token_string_t cmd_pfc_set_set =
5041 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5043 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
5044 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5045 pfc_ctrl, "pfc_ctrl");
5046 cmdline_parse_token_string_t cmd_pfc_set_rx =
5047 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5049 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
5050 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5051 rx_pfc_mode, "on#off");
5052 cmdline_parse_token_string_t cmd_pfc_set_tx =
5053 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5055 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
5056 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5057 tx_pfc_mode, "on#off");
5058 cmdline_parse_token_num_t cmd_pfc_set_high_water =
5059 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5060 high_water, UINT32);
5061 cmdline_parse_token_num_t cmd_pfc_set_low_water =
5062 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5064 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
5065 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5066 pause_time, UINT16);
5067 cmdline_parse_token_num_t cmd_pfc_set_priority =
5068 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5070 cmdline_parse_token_num_t cmd_pfc_set_portid =
5071 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
5074 cmdline_parse_inst_t cmd_priority_flow_control_set = {
5075 .f = cmd_priority_flow_ctrl_set_parsed,
5077 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
5078 tx on|off high_water low_water pause_time priority port_id",
5080 (void *)&cmd_pfc_set_set,
5081 (void *)&cmd_pfc_set_flow_ctrl,
5082 (void *)&cmd_pfc_set_rx,
5083 (void *)&cmd_pfc_set_rx_mode,
5084 (void *)&cmd_pfc_set_tx,
5085 (void *)&cmd_pfc_set_tx_mode,
5086 (void *)&cmd_pfc_set_high_water,
5087 (void *)&cmd_pfc_set_low_water,
5088 (void *)&cmd_pfc_set_pause_time,
5089 (void *)&cmd_pfc_set_priority,
5090 (void *)&cmd_pfc_set_portid,
5095 /* *** RESET CONFIGURATION *** */
5096 struct cmd_reset_result {
5097 cmdline_fixed_string_t reset;
5098 cmdline_fixed_string_t def;
5101 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
5103 __attribute__((unused)) void *data)
5105 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
5106 set_def_fwd_config();
5109 cmdline_parse_token_string_t cmd_reset_set =
5110 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
5111 cmdline_parse_token_string_t cmd_reset_def =
5112 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
5115 cmdline_parse_inst_t cmd_reset = {
5116 .f = cmd_reset_parsed,
5118 .help_str = "set default: reset default forwarding configuration",
5120 (void *)&cmd_reset_set,
5121 (void *)&cmd_reset_def,
5126 /* *** START FORWARDING *** */
5127 struct cmd_start_result {
5128 cmdline_fixed_string_t start;
5131 cmdline_parse_token_string_t cmd_start_start =
5132 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
5134 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
5135 __attribute__((unused)) struct cmdline *cl,
5136 __attribute__((unused)) void *data)
5138 start_packet_forwarding(0);
5141 cmdline_parse_inst_t cmd_start = {
5142 .f = cmd_start_parsed,
5144 .help_str = "start packet forwarding",
5146 (void *)&cmd_start_start,
5151 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
5152 struct cmd_start_tx_first_result {
5153 cmdline_fixed_string_t start;
5154 cmdline_fixed_string_t tx_first;
5158 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
5159 __attribute__((unused)) struct cmdline *cl,
5160 __attribute__((unused)) void *data)
5162 start_packet_forwarding(1);
5165 cmdline_parse_token_string_t cmd_start_tx_first_start =
5166 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
5168 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
5169 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
5170 tx_first, "tx_first");
5172 cmdline_parse_inst_t cmd_start_tx_first = {
5173 .f = cmd_start_tx_first_parsed,
5175 .help_str = "start packet forwarding, after sending 1 burst of packets",
5177 (void *)&cmd_start_tx_first_start,
5178 (void *)&cmd_start_tx_first_tx_first,
5183 /* *** SET LINK UP *** */
5184 struct cmd_set_link_up_result {
5185 cmdline_fixed_string_t set;
5186 cmdline_fixed_string_t link_up;
5187 cmdline_fixed_string_t port;
5191 cmdline_parse_token_string_t cmd_set_link_up_set =
5192 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
5193 cmdline_parse_token_string_t cmd_set_link_up_link_up =
5194 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
5196 cmdline_parse_token_string_t cmd_set_link_up_port =
5197 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
5198 cmdline_parse_token_num_t cmd_set_link_up_port_id =
5199 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
5201 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
5202 __attribute__((unused)) struct cmdline *cl,
5203 __attribute__((unused)) void *data)
5205 struct cmd_set_link_up_result *res = parsed_result;
5206 dev_set_link_up(res->port_id);
5209 cmdline_parse_inst_t cmd_set_link_up = {
5210 .f = cmd_set_link_up_parsed,
5212 .help_str = "set link-up port (port id)",
5214 (void *)&cmd_set_link_up_set,
5215 (void *)&cmd_set_link_up_link_up,
5216 (void *)&cmd_set_link_up_port,
5217 (void *)&cmd_set_link_up_port_id,
5222 /* *** SET LINK DOWN *** */
5223 struct cmd_set_link_down_result {
5224 cmdline_fixed_string_t set;
5225 cmdline_fixed_string_t link_down;
5226 cmdline_fixed_string_t port;
5230 cmdline_parse_token_string_t cmd_set_link_down_set =
5231 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
5232 cmdline_parse_token_string_t cmd_set_link_down_link_down =
5233 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
5235 cmdline_parse_token_string_t cmd_set_link_down_port =
5236 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
5237 cmdline_parse_token_num_t cmd_set_link_down_port_id =
5238 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
5240 static void cmd_set_link_down_parsed(
5241 __attribute__((unused)) void *parsed_result,
5242 __attribute__((unused)) struct cmdline *cl,
5243 __attribute__((unused)) void *data)
5245 struct cmd_set_link_down_result *res = parsed_result;
5246 dev_set_link_down(res->port_id);
5249 cmdline_parse_inst_t cmd_set_link_down = {
5250 .f = cmd_set_link_down_parsed,
5252 .help_str = "set link-down port (port id)",
5254 (void *)&cmd_set_link_down_set,
5255 (void *)&cmd_set_link_down_link_down,
5256 (void *)&cmd_set_link_down_port,
5257 (void *)&cmd_set_link_down_port_id,
5262 /* *** SHOW CFG *** */
5263 struct cmd_showcfg_result {
5264 cmdline_fixed_string_t show;
5265 cmdline_fixed_string_t cfg;
5266 cmdline_fixed_string_t what;
5269 static void cmd_showcfg_parsed(void *parsed_result,
5270 __attribute__((unused)) struct cmdline *cl,
5271 __attribute__((unused)) void *data)
5273 struct cmd_showcfg_result *res = parsed_result;
5274 if (!strcmp(res->what, "rxtx"))
5275 rxtx_config_display();
5276 else if (!strcmp(res->what, "cores"))
5277 fwd_lcores_config_display();
5278 else if (!strcmp(res->what, "fwd"))
5279 fwd_config_display();
5282 cmdline_parse_token_string_t cmd_showcfg_show =
5283 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
5284 cmdline_parse_token_string_t cmd_showcfg_port =
5285 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
5286 cmdline_parse_token_string_t cmd_showcfg_what =
5287 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
5290 cmdline_parse_inst_t cmd_showcfg = {
5291 .f = cmd_showcfg_parsed,
5293 .help_str = "show config rxtx|cores|fwd",
5295 (void *)&cmd_showcfg_show,
5296 (void *)&cmd_showcfg_port,
5297 (void *)&cmd_showcfg_what,
5302 /* *** SHOW ALL PORT INFO *** */
5303 struct cmd_showportall_result {
5304 cmdline_fixed_string_t show;
5305 cmdline_fixed_string_t port;
5306 cmdline_fixed_string_t what;
5307 cmdline_fixed_string_t all;
5310 static void cmd_showportall_parsed(void *parsed_result,
5311 __attribute__((unused)) struct cmdline *cl,
5312 __attribute__((unused)) void *data)
5316 struct cmd_showportall_result *res = parsed_result;
5317 if (!strcmp(res->show, "clear")) {
5318 if (!strcmp(res->what, "stats"))
5319 for (i = 0; i < nb_ports; i++)
5321 else if (!strcmp(res->what, "xstats"))
5322 for (i = 0; i < nb_ports; i++)
5323 nic_xstats_clear(i);
5324 } else if (!strcmp(res->what, "info"))
5325 for (i = 0; i < nb_ports; i++)
5326 port_infos_display(i);
5327 else if (!strcmp(res->what, "stats"))
5328 for (i = 0; i < nb_ports; i++)
5329 nic_stats_display(i);
5330 else if (!strcmp(res->what, "xstats"))
5331 for (i = 0; i < nb_ports; i++)
5332 nic_xstats_display(i);
5333 else if (!strcmp(res->what, "fdir"))
5334 for (i = 0; i < nb_ports; i++)
5336 else if (!strcmp(res->what, "stat_qmap"))
5337 for (i = 0; i < nb_ports; i++)
5338 nic_stats_mapping_display(i);
5341 cmdline_parse_token_string_t cmd_showportall_show =
5342 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
5344 cmdline_parse_token_string_t cmd_showportall_port =
5345 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
5346 cmdline_parse_token_string_t cmd_showportall_what =
5347 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
5348 "info#stats#xstats#fdir#stat_qmap");
5349 cmdline_parse_token_string_t cmd_showportall_all =
5350 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
5351 cmdline_parse_inst_t cmd_showportall = {
5352 .f = cmd_showportall_parsed,
5354 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
5356 (void *)&cmd_showportall_show,
5357 (void *)&cmd_showportall_port,
5358 (void *)&cmd_showportall_what,
5359 (void *)&cmd_showportall_all,
5364 /* *** SHOW PORT INFO *** */
5365 struct cmd_showport_result {
5366 cmdline_fixed_string_t show;
5367 cmdline_fixed_string_t port;
5368 cmdline_fixed_string_t what;
5372 static void cmd_showport_parsed(void *parsed_result,
5373 __attribute__((unused)) struct cmdline *cl,
5374 __attribute__((unused)) void *data)
5376 struct cmd_showport_result *res = parsed_result;
5377 if (!strcmp(res->show, "clear")) {
5378 if (!strcmp(res->what, "stats"))
5379 nic_stats_clear(res->portnum);
5380 else if (!strcmp(res->what, "xstats"))
5381 nic_xstats_clear(res->portnum);
5382 } else if (!strcmp(res->what, "info"))
5383 port_infos_display(res->portnum);
5384 else if (!strcmp(res->what, "stats"))
5385 nic_stats_display(res->portnum);
5386 else if (!strcmp(res->what, "xstats"))
5387 nic_xstats_display(res->portnum);
5388 else if (!strcmp(res->what, "fdir"))
5389 fdir_get_infos(res->portnum);
5390 else if (!strcmp(res->what, "stat_qmap"))
5391 nic_stats_mapping_display(res->portnum);
5394 cmdline_parse_token_string_t cmd_showport_show =
5395 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
5397 cmdline_parse_token_string_t cmd_showport_port =
5398 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
5399 cmdline_parse_token_string_t cmd_showport_what =
5400 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
5401 "info#stats#xstats#fdir#stat_qmap");
5402 cmdline_parse_token_num_t cmd_showport_portnum =
5403 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
5405 cmdline_parse_inst_t cmd_showport = {
5406 .f = cmd_showport_parsed,
5408 .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
5410 (void *)&cmd_showport_show,
5411 (void *)&cmd_showport_port,
5412 (void *)&cmd_showport_what,
5413 (void *)&cmd_showport_portnum,
5418 /* *** READ PORT REGISTER *** */
5419 struct cmd_read_reg_result {
5420 cmdline_fixed_string_t read;
5421 cmdline_fixed_string_t reg;
5427 cmd_read_reg_parsed(void *parsed_result,
5428 __attribute__((unused)) struct cmdline *cl,
5429 __attribute__((unused)) void *data)
5431 struct cmd_read_reg_result *res = parsed_result;
5432 port_reg_display(res->port_id, res->reg_off);
5435 cmdline_parse_token_string_t cmd_read_reg_read =
5436 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
5437 cmdline_parse_token_string_t cmd_read_reg_reg =
5438 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
5439 cmdline_parse_token_num_t cmd_read_reg_port_id =
5440 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
5441 cmdline_parse_token_num_t cmd_read_reg_reg_off =
5442 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
5444 cmdline_parse_inst_t cmd_read_reg = {
5445 .f = cmd_read_reg_parsed,
5447 .help_str = "read reg port_id reg_off",
5449 (void *)&cmd_read_reg_read,
5450 (void *)&cmd_read_reg_reg,
5451 (void *)&cmd_read_reg_port_id,
5452 (void *)&cmd_read_reg_reg_off,
5457 /* *** READ PORT REGISTER BIT FIELD *** */
5458 struct cmd_read_reg_bit_field_result {
5459 cmdline_fixed_string_t read;
5460 cmdline_fixed_string_t regfield;
5468 cmd_read_reg_bit_field_parsed(void *parsed_result,
5469 __attribute__((unused)) struct cmdline *cl,
5470 __attribute__((unused)) void *data)
5472 struct cmd_read_reg_bit_field_result *res = parsed_result;
5473 port_reg_bit_field_display(res->port_id, res->reg_off,
5474 res->bit1_pos, res->bit2_pos);
5477 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
5478 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
5480 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
5481 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
5482 regfield, "regfield");
5483 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
5484 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
5486 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
5487 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
5489 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
5490 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
5492 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
5493 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
5496 cmdline_parse_inst_t cmd_read_reg_bit_field = {
5497 .f = cmd_read_reg_bit_field_parsed,
5499 .help_str = "read regfield port_id reg_off bit_x bit_y "
5500 "(read register bit field between bit_x and bit_y included)",
5502 (void *)&cmd_read_reg_bit_field_read,
5503 (void *)&cmd_read_reg_bit_field_regfield,
5504 (void *)&cmd_read_reg_bit_field_port_id,
5505 (void *)&cmd_read_reg_bit_field_reg_off,
5506 (void *)&cmd_read_reg_bit_field_bit1_pos,
5507 (void *)&cmd_read_reg_bit_field_bit2_pos,
5512 /* *** READ PORT REGISTER BIT *** */
5513 struct cmd_read_reg_bit_result {
5514 cmdline_fixed_string_t read;
5515 cmdline_fixed_string_t regbit;
5522 cmd_read_reg_bit_parsed(void *parsed_result,
5523 __attribute__((unused)) struct cmdline *cl,
5524 __attribute__((unused)) void *data)
5526 struct cmd_read_reg_bit_result *res = parsed_result;
5527 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
5530 cmdline_parse_token_string_t cmd_read_reg_bit_read =
5531 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
5532 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
5533 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
5535 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
5536 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
5537 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
5538 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
5539 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
5540 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
5542 cmdline_parse_inst_t cmd_read_reg_bit = {
5543 .f = cmd_read_reg_bit_parsed,
5545 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
5547 (void *)&cmd_read_reg_bit_read,
5548 (void *)&cmd_read_reg_bit_regbit,
5549 (void *)&cmd_read_reg_bit_port_id,
5550 (void *)&cmd_read_reg_bit_reg_off,
5551 (void *)&cmd_read_reg_bit_bit_pos,
5556 /* *** WRITE PORT REGISTER *** */
5557 struct cmd_write_reg_result {
5558 cmdline_fixed_string_t write;
5559 cmdline_fixed_string_t reg;
5566 cmd_write_reg_parsed(void *parsed_result,
5567 __attribute__((unused)) struct cmdline *cl,
5568 __attribute__((unused)) void *data)
5570 struct cmd_write_reg_result *res = parsed_result;
5571 port_reg_set(res->port_id, res->reg_off, res->value);
5574 cmdline_parse_token_string_t cmd_write_reg_write =
5575 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
5576 cmdline_parse_token_string_t cmd_write_reg_reg =
5577 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
5578 cmdline_parse_token_num_t cmd_write_reg_port_id =
5579 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
5580 cmdline_parse_token_num_t cmd_write_reg_reg_off =
5581 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
5582 cmdline_parse_token_num_t cmd_write_reg_value =
5583 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
5585 cmdline_parse_inst_t cmd_write_reg = {
5586 .f = cmd_write_reg_parsed,
5588 .help_str = "write reg port_id reg_off reg_value",
5590 (void *)&cmd_write_reg_write,
5591 (void *)&cmd_write_reg_reg,
5592 (void *)&cmd_write_reg_port_id,
5593 (void *)&cmd_write_reg_reg_off,
5594 (void *)&cmd_write_reg_value,
5599 /* *** WRITE PORT REGISTER BIT FIELD *** */
5600 struct cmd_write_reg_bit_field_result {
5601 cmdline_fixed_string_t write;
5602 cmdline_fixed_string_t regfield;
5611 cmd_write_reg_bit_field_parsed(void *parsed_result,
5612 __attribute__((unused)) struct cmdline *cl,
5613 __attribute__((unused)) void *data)
5615 struct cmd_write_reg_bit_field_result *res = parsed_result;
5616 port_reg_bit_field_set(res->port_id, res->reg_off,
5617 res->bit1_pos, res->bit2_pos, res->value);
5620 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
5621 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
5623 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
5624 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
5625 regfield, "regfield");
5626 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
5627 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
5629 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
5630 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
5632 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
5633 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
5635 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
5636 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
5638 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
5639 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
5642 cmdline_parse_inst_t cmd_write_reg_bit_field = {
5643 .f = cmd_write_reg_bit_field_parsed,
5645 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
5646 "(set register bit field between bit_x and bit_y included)",
5648 (void *)&cmd_write_reg_bit_field_write,
5649 (void *)&cmd_write_reg_bit_field_regfield,
5650 (void *)&cmd_write_reg_bit_field_port_id,
5651 (void *)&cmd_write_reg_bit_field_reg_off,
5652 (void *)&cmd_write_reg_bit_field_bit1_pos,
5653 (void *)&cmd_write_reg_bit_field_bit2_pos,
5654 (void *)&cmd_write_reg_bit_field_value,
5659 /* *** WRITE PORT REGISTER BIT *** */
5660 struct cmd_write_reg_bit_result {
5661 cmdline_fixed_string_t write;
5662 cmdline_fixed_string_t regbit;
5670 cmd_write_reg_bit_parsed(void *parsed_result,
5671 __attribute__((unused)) struct cmdline *cl,
5672 __attribute__((unused)) void *data)
5674 struct cmd_write_reg_bit_result *res = parsed_result;
5675 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
5678 cmdline_parse_token_string_t cmd_write_reg_bit_write =
5679 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
5681 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
5682 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
5684 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
5685 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
5686 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
5687 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
5688 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
5689 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
5690 cmdline_parse_token_num_t cmd_write_reg_bit_value =
5691 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
5693 cmdline_parse_inst_t cmd_write_reg_bit = {
5694 .f = cmd_write_reg_bit_parsed,
5696 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
5698 (void *)&cmd_write_reg_bit_write,
5699 (void *)&cmd_write_reg_bit_regbit,
5700 (void *)&cmd_write_reg_bit_port_id,
5701 (void *)&cmd_write_reg_bit_reg_off,
5702 (void *)&cmd_write_reg_bit_bit_pos,
5703 (void *)&cmd_write_reg_bit_value,
5708 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
5709 struct cmd_read_rxd_txd_result {
5710 cmdline_fixed_string_t read;
5711 cmdline_fixed_string_t rxd_txd;
5718 cmd_read_rxd_txd_parsed(void *parsed_result,
5719 __attribute__((unused)) struct cmdline *cl,
5720 __attribute__((unused)) void *data)
5722 struct cmd_read_rxd_txd_result *res = parsed_result;
5724 if (!strcmp(res->rxd_txd, "rxd"))
5725 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5726 else if (!strcmp(res->rxd_txd, "txd"))
5727 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
5730 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
5731 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
5732 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
5733 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
5735 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
5736 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
5737 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
5738 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
5739 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
5740 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
5742 cmdline_parse_inst_t cmd_read_rxd_txd = {
5743 .f = cmd_read_rxd_txd_parsed,
5745 .help_str = "read rxd|txd port_id queue_id rxd_id",
5747 (void *)&cmd_read_rxd_txd_read,
5748 (void *)&cmd_read_rxd_txd_rxd_txd,
5749 (void *)&cmd_read_rxd_txd_port_id,
5750 (void *)&cmd_read_rxd_txd_queue_id,
5751 (void *)&cmd_read_rxd_txd_desc_id,
5757 struct cmd_quit_result {
5758 cmdline_fixed_string_t quit;
5761 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
5763 __attribute__((unused)) void *data)
5769 cmdline_parse_token_string_t cmd_quit_quit =
5770 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
5772 cmdline_parse_inst_t cmd_quit = {
5773 .f = cmd_quit_parsed,
5775 .help_str = "exit application",
5777 (void *)&cmd_quit_quit,
5782 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
5783 struct cmd_mac_addr_result {
5784 cmdline_fixed_string_t mac_addr_cmd;
5785 cmdline_fixed_string_t what;
5787 struct ether_addr address;
5790 static void cmd_mac_addr_parsed(void *parsed_result,
5791 __attribute__((unused)) struct cmdline *cl,
5792 __attribute__((unused)) void *data)
5794 struct cmd_mac_addr_result *res = parsed_result;
5797 if (strcmp(res->what, "add") == 0)
5798 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
5800 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
5802 /* check the return value and print it if is < 0 */
5804 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
5808 cmdline_parse_token_string_t cmd_mac_addr_cmd =
5809 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
5811 cmdline_parse_token_string_t cmd_mac_addr_what =
5812 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
5814 cmdline_parse_token_num_t cmd_mac_addr_portnum =
5815 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
5816 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
5817 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
5819 cmdline_parse_inst_t cmd_mac_addr = {
5820 .f = cmd_mac_addr_parsed,
5822 .help_str = "mac_addr add|remove X <address>: "
5823 "add/remove MAC address on port X",
5825 (void *)&cmd_mac_addr_cmd,
5826 (void *)&cmd_mac_addr_what,
5827 (void *)&cmd_mac_addr_portnum,
5828 (void *)&cmd_mac_addr_addr,
5834 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
5835 struct cmd_set_qmap_result {
5836 cmdline_fixed_string_t set;
5837 cmdline_fixed_string_t qmap;
5838 cmdline_fixed_string_t what;
5845 cmd_set_qmap_parsed(void *parsed_result,
5846 __attribute__((unused)) struct cmdline *cl,
5847 __attribute__((unused)) void *data)
5849 struct cmd_set_qmap_result *res = parsed_result;
5850 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
5852 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
5855 cmdline_parse_token_string_t cmd_setqmap_set =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5858 cmdline_parse_token_string_t cmd_setqmap_qmap =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5861 cmdline_parse_token_string_t cmd_setqmap_what =
5862 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
5864 cmdline_parse_token_num_t cmd_setqmap_portid =
5865 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5867 cmdline_parse_token_num_t cmd_setqmap_queueid =
5868 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5870 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
5871 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
5874 cmdline_parse_inst_t cmd_set_qmap = {
5875 .f = cmd_set_qmap_parsed,
5877 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
5879 (void *)&cmd_setqmap_set,
5880 (void *)&cmd_setqmap_qmap,
5881 (void *)&cmd_setqmap_what,
5882 (void *)&cmd_setqmap_portid,
5883 (void *)&cmd_setqmap_queueid,
5884 (void *)&cmd_setqmap_mapvalue,
5889 /* *** CONFIGURE UNICAST HASH TABLE *** */
5890 struct cmd_set_uc_hash_table {
5891 cmdline_fixed_string_t set;
5892 cmdline_fixed_string_t port;
5894 cmdline_fixed_string_t what;
5895 struct ether_addr address;
5896 cmdline_fixed_string_t mode;
5900 cmd_set_uc_hash_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5905 struct cmd_set_uc_hash_table *res = parsed_result;
5907 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5909 if (strcmp(res->what, "uta") == 0)
5910 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
5911 &res->address,(uint8_t)is_on);
5913 printf("bad unicast hash table parameter, return code = %d \n", ret);
5917 cmdline_parse_token_string_t cmd_set_uc_hash_set =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5920 cmdline_parse_token_string_t cmd_set_uc_hash_port =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5923 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
5924 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
5926 cmdline_parse_token_string_t cmd_set_uc_hash_what =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5929 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
5930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
5932 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
5936 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
5937 .f = cmd_set_uc_hash_parsed,
5939 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
5941 (void *)&cmd_set_uc_hash_set,
5942 (void *)&cmd_set_uc_hash_port,
5943 (void *)&cmd_set_uc_hash_portid,
5944 (void *)&cmd_set_uc_hash_what,
5945 (void *)&cmd_set_uc_hash_mac,
5946 (void *)&cmd_set_uc_hash_mode,
5951 struct cmd_set_uc_all_hash_table {
5952 cmdline_fixed_string_t set;
5953 cmdline_fixed_string_t port;
5955 cmdline_fixed_string_t what;
5956 cmdline_fixed_string_t value;
5957 cmdline_fixed_string_t mode;
5961 cmd_set_uc_all_hash_parsed(void *parsed_result,
5962 __attribute__((unused)) struct cmdline *cl,
5963 __attribute__((unused)) void *data)
5966 struct cmd_set_uc_all_hash_table *res = parsed_result;
5968 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
5970 if ((strcmp(res->what, "uta") == 0) &&
5971 (strcmp(res->value, "all") == 0))
5972 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
5974 printf("bad unicast hash table parameter,"
5975 "return code = %d \n", ret);
5978 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
5979 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5981 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
5982 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5984 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
5985 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
5987 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
5988 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5990 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
5991 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5993 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
5997 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
5998 .f = cmd_set_uc_all_hash_parsed,
6000 .help_str = "set port X uta all on|off (X = port number)",
6002 (void *)&cmd_set_uc_all_hash_set,
6003 (void *)&cmd_set_uc_all_hash_port,
6004 (void *)&cmd_set_uc_all_hash_portid,
6005 (void *)&cmd_set_uc_all_hash_what,
6006 (void *)&cmd_set_uc_all_hash_value,
6007 (void *)&cmd_set_uc_all_hash_mode,
6012 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
6013 struct cmd_set_vf_macvlan_filter {
6014 cmdline_fixed_string_t set;
6015 cmdline_fixed_string_t port;
6017 cmdline_fixed_string_t vf;
6019 struct ether_addr address;
6020 cmdline_fixed_string_t filter_type;
6021 cmdline_fixed_string_t mode;
6025 cmd_set_vf_macvlan_parsed(void *parsed_result,
6026 __attribute__((unused)) struct cmdline *cl,
6027 __attribute__((unused)) void *data)
6030 struct cmd_set_vf_macvlan_filter *res = parsed_result;
6031 struct rte_eth_mac_filter filter;
6033 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
6035 (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
6037 /* set VF MAC filter */
6041 filter.dst_id = res->vf_id;
6043 if (!strcmp(res->filter_type, "exact-mac"))
6044 filter.filter_type = RTE_MAC_PERFECT_MATCH;
6045 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
6046 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
6047 else if (!strcmp(res->filter_type, "hashmac"))
6048 filter.filter_type = RTE_MAC_HASH_MATCH;
6049 else if (!strcmp(res->filter_type, "hashmac-vlan"))
6050 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
6052 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6055 ret = rte_eth_dev_filter_ctrl(res->port_id,
6056 RTE_ETH_FILTER_MACVLAN,
6060 ret = rte_eth_dev_filter_ctrl(res->port_id,
6061 RTE_ETH_FILTER_MACVLAN,
6062 RTE_ETH_FILTER_DELETE,
6066 printf("bad set MAC hash parameter, return code = %d\n", ret);
6070 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6073 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
6074 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6076 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
6077 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6079 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
6080 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6082 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
6083 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6085 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
6086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6088 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6090 filter_type, "exact-mac#exact-mac-vlan"
6091 "#hashmac#hashmac-vlan");
6092 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
6093 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
6096 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
6097 .f = cmd_set_vf_macvlan_parsed,
6099 .help_str = "set port (portid) vf (vfid) (mac-addr) "
6100 "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) "
6102 "exact match rule:exact match of MAC or MAC and VLAN; "
6103 "hash match rule: hash match of MAC and exact match "
6106 (void *)&cmd_set_vf_macvlan_set,
6107 (void *)&cmd_set_vf_macvlan_port,
6108 (void *)&cmd_set_vf_macvlan_portid,
6109 (void *)&cmd_set_vf_macvlan_vf,
6110 (void *)&cmd_set_vf_macvlan_vf_id,
6111 (void *)&cmd_set_vf_macvlan_mac,
6112 (void *)&cmd_set_vf_macvlan_filter_type,
6113 (void *)&cmd_set_vf_macvlan_mode,
6118 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
6119 struct cmd_set_vf_traffic {
6120 cmdline_fixed_string_t set;
6121 cmdline_fixed_string_t port;
6123 cmdline_fixed_string_t vf;
6125 cmdline_fixed_string_t what;
6126 cmdline_fixed_string_t mode;
6130 cmd_set_vf_traffic_parsed(void *parsed_result,
6131 __attribute__((unused)) struct cmdline *cl,
6132 __attribute__((unused)) void *data)
6134 struct cmd_set_vf_traffic *res = parsed_result;
6135 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
6136 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
6138 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
6141 cmdline_parse_token_string_t cmd_setvf_traffic_set =
6142 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6144 cmdline_parse_token_string_t cmd_setvf_traffic_port =
6145 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6147 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
6148 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6150 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
6151 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6153 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
6154 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
6156 cmdline_parse_token_string_t cmd_setvf_traffic_what =
6157 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6159 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
6160 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
6163 cmdline_parse_inst_t cmd_set_vf_traffic = {
6164 .f = cmd_set_vf_traffic_parsed,
6166 .help_str = "set port X vf Y rx|tx on|off"
6167 "(X = port number,Y = vf id)",
6169 (void *)&cmd_setvf_traffic_set,
6170 (void *)&cmd_setvf_traffic_port,
6171 (void *)&cmd_setvf_traffic_portid,
6172 (void *)&cmd_setvf_traffic_vf,
6173 (void *)&cmd_setvf_traffic_vfid,
6174 (void *)&cmd_setvf_traffic_what,
6175 (void *)&cmd_setvf_traffic_mode,
6180 /* *** CONFIGURE VF RECEIVE MODE *** */
6181 struct cmd_set_vf_rxmode {
6182 cmdline_fixed_string_t set;
6183 cmdline_fixed_string_t port;
6185 cmdline_fixed_string_t vf;
6187 cmdline_fixed_string_t what;
6188 cmdline_fixed_string_t mode;
6189 cmdline_fixed_string_t on;
6193 cmd_set_vf_rxmode_parsed(void *parsed_result,
6194 __attribute__((unused)) struct cmdline *cl,
6195 __attribute__((unused)) void *data)
6198 uint16_t rx_mode = 0;
6199 struct cmd_set_vf_rxmode *res = parsed_result;
6201 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
6202 if (!strcmp(res->what,"rxmode")) {
6203 if (!strcmp(res->mode, "AUPE"))
6204 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
6205 else if (!strcmp(res->mode, "ROPE"))
6206 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
6207 else if (!strcmp(res->mode, "BAM"))
6208 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
6209 else if (!strncmp(res->mode, "MPE",3))
6210 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
6213 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
6215 printf("bad VF receive mode parameter, return code = %d \n",
6219 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
6220 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6222 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
6223 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6225 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
6226 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6228 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6231 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
6232 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
6234 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
6235 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6237 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
6238 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6239 mode, "AUPE#ROPE#BAM#MPE");
6240 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
6241 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
6244 cmdline_parse_inst_t cmd_set_vf_rxmode = {
6245 .f = cmd_set_vf_rxmode_parsed,
6247 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
6249 (void *)&cmd_set_vf_rxmode_set,
6250 (void *)&cmd_set_vf_rxmode_port,
6251 (void *)&cmd_set_vf_rxmode_portid,
6252 (void *)&cmd_set_vf_rxmode_vf,
6253 (void *)&cmd_set_vf_rxmode_vfid,
6254 (void *)&cmd_set_vf_rxmode_what,
6255 (void *)&cmd_set_vf_rxmode_mode,
6256 (void *)&cmd_set_vf_rxmode_on,
6261 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
6262 struct cmd_vf_mac_addr_result {
6263 cmdline_fixed_string_t mac_addr_cmd;
6264 cmdline_fixed_string_t what;
6265 cmdline_fixed_string_t port;
6267 cmdline_fixed_string_t vf;
6269 struct ether_addr address;
6272 static void cmd_vf_mac_addr_parsed(void *parsed_result,
6273 __attribute__((unused)) struct cmdline *cl,
6274 __attribute__((unused)) void *data)
6276 struct cmd_vf_mac_addr_result *res = parsed_result;
6279 if (strcmp(res->what, "add") == 0)
6280 ret = rte_eth_dev_mac_addr_add(res->port_num,
6281 &res->address, res->vf_num);
6283 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
6287 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
6288 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6289 mac_addr_cmd,"mac_addr");
6290 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
6291 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6293 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
6294 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6296 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
6297 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6299 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
6300 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
6302 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
6303 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
6305 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
6306 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
6309 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
6310 .f = cmd_vf_mac_addr_parsed,
6312 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
6313 "Y = VF number)add MAC address filtering for a VF on port X",
6315 (void *)&cmd_vf_mac_addr_cmd,
6316 (void *)&cmd_vf_mac_addr_what,
6317 (void *)&cmd_vf_mac_addr_port,
6318 (void *)&cmd_vf_mac_addr_portnum,
6319 (void *)&cmd_vf_mac_addr_vf,
6320 (void *)&cmd_vf_mac_addr_vfnum,
6321 (void *)&cmd_vf_mac_addr_addr,
6326 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
6327 struct cmd_vf_rx_vlan_filter {
6328 cmdline_fixed_string_t rx_vlan;
6329 cmdline_fixed_string_t what;
6331 cmdline_fixed_string_t port;
6333 cmdline_fixed_string_t vf;
6338 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
6339 __attribute__((unused)) struct cmdline *cl,
6340 __attribute__((unused)) void *data)
6342 struct cmd_vf_rx_vlan_filter *res = parsed_result;
6344 if (!strcmp(res->what, "add"))
6345 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
6347 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
6350 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
6351 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6352 rx_vlan, "rx_vlan");
6353 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
6354 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6356 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
6357 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6359 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
6360 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6362 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
6363 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6365 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
6366 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6368 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
6369 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
6372 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
6373 .f = cmd_vf_rx_vlan_filter_parsed,
6375 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
6376 "Y = port number,Z = hexadecimal VF mask)",
6378 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
6379 (void *)&cmd_vf_rx_vlan_filter_what,
6380 (void *)&cmd_vf_rx_vlan_filter_vlanid,
6381 (void *)&cmd_vf_rx_vlan_filter_port,
6382 (void *)&cmd_vf_rx_vlan_filter_portid,
6383 (void *)&cmd_vf_rx_vlan_filter_vf,
6384 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
6389 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
6390 struct cmd_queue_rate_limit_result {
6391 cmdline_fixed_string_t set;
6392 cmdline_fixed_string_t port;
6394 cmdline_fixed_string_t queue;
6396 cmdline_fixed_string_t rate;
6400 static void cmd_queue_rate_limit_parsed(void *parsed_result,
6401 __attribute__((unused)) struct cmdline *cl,
6402 __attribute__((unused)) void *data)
6404 struct cmd_queue_rate_limit_result *res = parsed_result;
6407 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6408 && (strcmp(res->queue, "queue") == 0)
6409 && (strcmp(res->rate, "rate") == 0))
6410 ret = set_queue_rate_limit(res->port_num, res->queue_num,
6413 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
6417 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
6418 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6420 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
6421 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6423 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
6424 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6426 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
6427 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6429 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
6430 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6432 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
6433 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
6435 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
6436 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
6439 cmdline_parse_inst_t cmd_queue_rate_limit = {
6440 .f = cmd_queue_rate_limit_parsed,
6442 .help_str = "set port X queue Y rate Z:(X = port number,"
6443 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
6445 (void *)&cmd_queue_rate_limit_set,
6446 (void *)&cmd_queue_rate_limit_port,
6447 (void *)&cmd_queue_rate_limit_portnum,
6448 (void *)&cmd_queue_rate_limit_queue,
6449 (void *)&cmd_queue_rate_limit_queuenum,
6450 (void *)&cmd_queue_rate_limit_rate,
6451 (void *)&cmd_queue_rate_limit_ratenum,
6456 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
6457 struct cmd_vf_rate_limit_result {
6458 cmdline_fixed_string_t set;
6459 cmdline_fixed_string_t port;
6461 cmdline_fixed_string_t vf;
6463 cmdline_fixed_string_t rate;
6465 cmdline_fixed_string_t q_msk;
6469 static void cmd_vf_rate_limit_parsed(void *parsed_result,
6470 __attribute__((unused)) struct cmdline *cl,
6471 __attribute__((unused)) void *data)
6473 struct cmd_vf_rate_limit_result *res = parsed_result;
6476 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
6477 && (strcmp(res->vf, "vf") == 0)
6478 && (strcmp(res->rate, "rate") == 0)
6479 && (strcmp(res->q_msk, "queue_mask") == 0))
6480 ret = set_vf_rate_limit(res->port_num, res->vf_num,
6481 res->rate_num, res->q_msk_val);
6483 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
6487 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
6488 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6490 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
6491 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6493 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
6494 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6496 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
6497 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6499 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
6500 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6502 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
6503 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6505 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
6506 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6508 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
6509 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
6510 q_msk, "queue_mask");
6511 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
6512 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
6515 cmdline_parse_inst_t cmd_vf_rate_limit = {
6516 .f = cmd_vf_rate_limit_parsed,
6518 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
6519 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
6520 "for queues of VF on port X",
6522 (void *)&cmd_vf_rate_limit_set,
6523 (void *)&cmd_vf_rate_limit_port,
6524 (void *)&cmd_vf_rate_limit_portnum,
6525 (void *)&cmd_vf_rate_limit_vf,
6526 (void *)&cmd_vf_rate_limit_vfnum,
6527 (void *)&cmd_vf_rate_limit_rate,
6528 (void *)&cmd_vf_rate_limit_ratenum,
6529 (void *)&cmd_vf_rate_limit_q_msk,
6530 (void *)&cmd_vf_rate_limit_q_msk_val,
6535 /* *** ADD TUNNEL FILTER OF A PORT *** */
6536 struct cmd_tunnel_filter_result {
6537 cmdline_fixed_string_t cmd;
6538 cmdline_fixed_string_t what;
6540 struct ether_addr outer_mac;
6541 struct ether_addr inner_mac;
6542 cmdline_ipaddr_t ip_value;
6543 uint16_t inner_vlan;
6544 cmdline_fixed_string_t tunnel_type;
6545 cmdline_fixed_string_t filter_type;
6551 cmd_tunnel_filter_parsed(void *parsed_result,
6552 __attribute__((unused)) struct cmdline *cl,
6553 __attribute__((unused)) void *data)
6555 struct cmd_tunnel_filter_result *res = parsed_result;
6556 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
6559 tunnel_filter_conf.outer_mac = &res->outer_mac;
6560 tunnel_filter_conf.inner_mac = &res->inner_mac;
6561 tunnel_filter_conf.inner_vlan = res->inner_vlan;
6563 if (res->ip_value.family == AF_INET) {
6564 tunnel_filter_conf.ip_addr.ipv4_addr =
6565 res->ip_value.addr.ipv4.s_addr;
6566 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
6568 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
6569 &(res->ip_value.addr.ipv6),
6570 sizeof(struct in6_addr));
6571 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
6574 if (!strcmp(res->filter_type, "imac-ivlan"))
6575 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
6576 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
6577 tunnel_filter_conf.filter_type =
6578 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
6579 else if (!strcmp(res->filter_type, "imac-tenid"))
6580 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
6581 else if (!strcmp(res->filter_type, "imac"))
6582 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
6583 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
6584 tunnel_filter_conf.filter_type =
6585 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
6587 printf("The filter type is not supported");
6591 if (!strcmp(res->tunnel_type, "vxlan"))
6592 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
6594 printf("Only VXLAN is supported now.\n");
6598 tunnel_filter_conf.tenant_id = res->tenant_id;
6599 tunnel_filter_conf.queue_id = res->queue_num;
6600 if (!strcmp(res->what, "add"))
6601 ret = rte_eth_dev_filter_ctrl(res->port_id,
6602 RTE_ETH_FILTER_TUNNEL,
6604 &tunnel_filter_conf);
6606 ret = rte_eth_dev_filter_ctrl(res->port_id,
6607 RTE_ETH_FILTER_TUNNEL,
6608 RTE_ETH_FILTER_DELETE,
6609 &tunnel_filter_conf);
6611 printf("cmd_tunnel_filter_parsed error: (%s)\n",
6615 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
6616 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6617 cmd, "tunnel_filter");
6618 cmdline_parse_token_string_t cmd_tunnel_filter_what =
6619 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6621 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
6622 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6624 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
6625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6627 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
6628 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6630 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
6631 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6632 inner_vlan, UINT16);
6633 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
6634 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
6636 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
6637 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6638 tunnel_type, "vxlan");
6640 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
6641 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
6642 filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#"
6643 "imac#omac-imac-tenid");
6644 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
6645 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6647 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
6648 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
6651 cmdline_parse_inst_t cmd_tunnel_filter = {
6652 .f = cmd_tunnel_filter_parsed,
6654 .help_str = "add/rm tunnel filter of a port: "
6655 "tunnel_filter add port_id outer_mac inner_mac ip "
6656 "inner_vlan tunnel_type(vxlan) filter_type "
6657 "(imac-ivlan|imac-ivlan-tenid|imac-tenid|"
6658 "imac|omac-imac-tenid) "
6659 "tenant_id queue_num",
6661 (void *)&cmd_tunnel_filter_cmd,
6662 (void *)&cmd_tunnel_filter_what,
6663 (void *)&cmd_tunnel_filter_port_id,
6664 (void *)&cmd_tunnel_filter_outer_mac,
6665 (void *)&cmd_tunnel_filter_inner_mac,
6666 (void *)&cmd_tunnel_filter_ip_value,
6667 (void *)&cmd_tunnel_filter_innner_vlan,
6668 (void *)&cmd_tunnel_filter_tunnel_type,
6669 (void *)&cmd_tunnel_filter_filter_type,
6670 (void *)&cmd_tunnel_filter_tenant_id,
6671 (void *)&cmd_tunnel_filter_queue_num,
6676 /* *** CONFIGURE TUNNEL UDP PORT *** */
6677 struct cmd_tunnel_udp_config {
6678 cmdline_fixed_string_t cmd;
6679 cmdline_fixed_string_t what;
6685 cmd_tunnel_udp_config_parsed(void *parsed_result,
6686 __attribute__((unused)) struct cmdline *cl,
6687 __attribute__((unused)) void *data)
6689 struct cmd_tunnel_udp_config *res = parsed_result;
6690 struct rte_eth_udp_tunnel tunnel_udp;
6693 tunnel_udp.udp_port = res->udp_port;
6695 if (!strcmp(res->cmd, "rx_vxlan_port"))
6696 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
6698 if (!strcmp(res->what, "add"))
6699 ret = rte_eth_dev_udp_tunnel_add(res->port_id, &tunnel_udp);
6701 ret = rte_eth_dev_udp_tunnel_delete(res->port_id, &tunnel_udp);
6704 printf("udp tunneling add error: (%s)\n", strerror(-ret));
6707 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
6708 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6709 cmd, "rx_vxlan_port");
6710 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
6711 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
6713 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
6714 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6716 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
6717 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
6720 cmdline_parse_inst_t cmd_tunnel_udp_config = {
6721 .f = cmd_tunnel_udp_config_parsed,
6723 .help_str = "add/rm an tunneling UDP port filter: "
6724 "rx_vxlan_port add udp_port port_id",
6726 (void *)&cmd_tunnel_udp_config_cmd,
6727 (void *)&cmd_tunnel_udp_config_what,
6728 (void *)&cmd_tunnel_udp_config_udp_port,
6729 (void *)&cmd_tunnel_udp_config_port_id,
6734 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
6735 struct cmd_set_mirror_mask_result {
6736 cmdline_fixed_string_t set;
6737 cmdline_fixed_string_t port;
6739 cmdline_fixed_string_t mirror;
6741 cmdline_fixed_string_t what;
6742 cmdline_fixed_string_t value;
6743 cmdline_fixed_string_t dstpool;
6745 cmdline_fixed_string_t on;
6748 cmdline_parse_token_string_t cmd_mirror_mask_set =
6749 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6751 cmdline_parse_token_string_t cmd_mirror_mask_port =
6752 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6754 cmdline_parse_token_num_t cmd_mirror_mask_portid =
6755 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6757 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6759 mirror, "mirror-rule");
6760 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
6761 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6763 cmdline_parse_token_string_t cmd_mirror_mask_what =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6765 what, "pool-mirror#vlan-mirror");
6766 cmdline_parse_token_string_t cmd_mirror_mask_value =
6767 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6769 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
6770 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6771 dstpool, "dst-pool");
6772 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
6773 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
6775 cmdline_parse_token_string_t cmd_mirror_mask_on =
6776 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
6780 cmd_set_mirror_mask_parsed(void *parsed_result,
6781 __attribute__((unused)) struct cmdline *cl,
6782 __attribute__((unused)) void *data)
6785 struct cmd_set_mirror_mask_result *res = parsed_result;
6786 struct rte_eth_vmdq_mirror_conf mr_conf;
6788 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6790 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
6792 mr_conf.dst_pool = res->dstpool_id;
6794 if (!strcmp(res->what, "pool-mirror")) {
6795 mr_conf.pool_mask = strtoull(res->value,NULL,16);
6796 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
6797 } else if(!strcmp(res->what, "vlan-mirror")) {
6798 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
6799 nb_item = parse_item_list(res->value, "core",
6800 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
6804 for(i=0; i < nb_item; i++) {
6805 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
6806 printf("Invalid vlan_id: must be < 4096\n");
6810 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
6811 mr_conf.vlan.vlan_mask |= 1ULL << i;
6815 if(!strcmp(res->on, "on"))
6816 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6819 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6822 printf("mirror rule add error: (%s)\n", strerror(-ret));
6825 cmdline_parse_inst_t cmd_set_mirror_mask = {
6826 .f = cmd_set_mirror_mask_parsed,
6828 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
6829 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
6831 (void *)&cmd_mirror_mask_set,
6832 (void *)&cmd_mirror_mask_port,
6833 (void *)&cmd_mirror_mask_portid,
6834 (void *)&cmd_mirror_mask_mirror,
6835 (void *)&cmd_mirror_mask_ruleid,
6836 (void *)&cmd_mirror_mask_what,
6837 (void *)&cmd_mirror_mask_value,
6838 (void *)&cmd_mirror_mask_dstpool,
6839 (void *)&cmd_mirror_mask_poolid,
6840 (void *)&cmd_mirror_mask_on,
6845 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
6846 struct cmd_set_mirror_link_result {
6847 cmdline_fixed_string_t set;
6848 cmdline_fixed_string_t port;
6850 cmdline_fixed_string_t mirror;
6852 cmdline_fixed_string_t what;
6853 cmdline_fixed_string_t dstpool;
6855 cmdline_fixed_string_t on;
6858 cmdline_parse_token_string_t cmd_mirror_link_set =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6861 cmdline_parse_token_string_t cmd_mirror_link_port =
6862 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6864 cmdline_parse_token_num_t cmd_mirror_link_portid =
6865 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6867 cmdline_parse_token_string_t cmd_mirror_link_mirror =
6868 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6869 mirror, "mirror-rule");
6870 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
6871 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6873 cmdline_parse_token_string_t cmd_mirror_link_what =
6874 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6875 what, "uplink-mirror#downlink-mirror");
6876 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
6877 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6878 dstpool, "dst-pool");
6879 cmdline_parse_token_num_t cmd_mirror_link_poolid =
6880 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
6882 cmdline_parse_token_string_t cmd_mirror_link_on =
6883 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
6887 cmd_set_mirror_link_parsed(void *parsed_result,
6888 __attribute__((unused)) struct cmdline *cl,
6889 __attribute__((unused)) void *data)
6892 struct cmd_set_mirror_link_result *res = parsed_result;
6893 struct rte_eth_vmdq_mirror_conf mr_conf;
6895 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
6896 if(!strcmp(res->what, "uplink-mirror")) {
6897 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
6898 }else if(!strcmp(res->what, "downlink-mirror"))
6899 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
6901 mr_conf.dst_pool = res->dstpool_id;
6903 if(!strcmp(res->on, "on"))
6904 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6907 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
6910 /* check the return value and print it if is < 0 */
6912 printf("mirror rule add error: (%s)\n", strerror(-ret));
6916 cmdline_parse_inst_t cmd_set_mirror_link = {
6917 .f = cmd_set_mirror_link_parsed,
6919 .help_str = "set port X mirror-rule Y uplink-mirror|"
6920 "downlink-mirror dst-pool Z on|off",
6922 (void *)&cmd_mirror_link_set,
6923 (void *)&cmd_mirror_link_port,
6924 (void *)&cmd_mirror_link_portid,
6925 (void *)&cmd_mirror_link_mirror,
6926 (void *)&cmd_mirror_link_ruleid,
6927 (void *)&cmd_mirror_link_what,
6928 (void *)&cmd_mirror_link_dstpool,
6929 (void *)&cmd_mirror_link_poolid,
6930 (void *)&cmd_mirror_link_on,
6935 /* *** RESET VM MIRROR RULE *** */
6936 struct cmd_rm_mirror_rule_result {
6937 cmdline_fixed_string_t reset;
6938 cmdline_fixed_string_t port;
6940 cmdline_fixed_string_t mirror;
6944 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
6945 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6947 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
6948 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6950 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
6951 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6953 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
6954 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
6955 mirror, "mirror-rule");
6956 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
6957 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
6961 cmd_reset_mirror_rule_parsed(void *parsed_result,
6962 __attribute__((unused)) struct cmdline *cl,
6963 __attribute__((unused)) void *data)
6966 struct cmd_set_mirror_link_result *res = parsed_result;
6968 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
6970 printf("mirror rule remove error: (%s)\n", strerror(-ret));
6973 cmdline_parse_inst_t cmd_reset_mirror_rule = {
6974 .f = cmd_reset_mirror_rule_parsed,
6976 .help_str = "reset port X mirror-rule Y",
6978 (void *)&cmd_rm_mirror_rule_reset,
6979 (void *)&cmd_rm_mirror_rule_port,
6980 (void *)&cmd_rm_mirror_rule_portid,
6981 (void *)&cmd_rm_mirror_rule_mirror,
6982 (void *)&cmd_rm_mirror_rule_ruleid,
6987 /* ******************************************************************************** */
6989 struct cmd_dump_result {
6990 cmdline_fixed_string_t dump;
6994 dump_struct_sizes(void)
6996 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
6997 DUMP_SIZE(struct rte_mbuf);
6998 DUMP_SIZE(struct rte_mempool);
6999 DUMP_SIZE(struct rte_ring);
7003 static void cmd_dump_parsed(void *parsed_result,
7004 __attribute__((unused)) struct cmdline *cl,
7005 __attribute__((unused)) void *data)
7007 struct cmd_dump_result *res = parsed_result;
7009 if (!strcmp(res->dump, "dump_physmem"))
7010 rte_dump_physmem_layout(stdout);
7011 else if (!strcmp(res->dump, "dump_memzone"))
7012 rte_memzone_dump(stdout);
7013 else if (!strcmp(res->dump, "dump_log_history"))
7014 rte_log_dump_history(stdout);
7015 else if (!strcmp(res->dump, "dump_struct_sizes"))
7016 dump_struct_sizes();
7017 else if (!strcmp(res->dump, "dump_ring"))
7018 rte_ring_list_dump(stdout);
7019 else if (!strcmp(res->dump, "dump_mempool"))
7020 rte_mempool_list_dump(stdout);
7021 else if (!strcmp(res->dump, "dump_devargs"))
7022 rte_eal_devargs_dump(stdout);
7025 cmdline_parse_token_string_t cmd_dump_dump =
7026 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
7030 "dump_struct_sizes#"
7035 cmdline_parse_inst_t cmd_dump = {
7036 .f = cmd_dump_parsed, /* function to call */
7037 .data = NULL, /* 2nd arg of func */
7038 .help_str = "dump status",
7039 .tokens = { /* token list, NULL terminated */
7040 (void *)&cmd_dump_dump,
7045 /* ******************************************************************************** */
7047 struct cmd_dump_one_result {
7048 cmdline_fixed_string_t dump;
7049 cmdline_fixed_string_t name;
7052 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
7053 __attribute__((unused)) void *data)
7055 struct cmd_dump_one_result *res = parsed_result;
7057 if (!strcmp(res->dump, "dump_ring")) {
7059 r = rte_ring_lookup(res->name);
7061 cmdline_printf(cl, "Cannot find ring\n");
7064 rte_ring_dump(stdout, r);
7065 } else if (!strcmp(res->dump, "dump_mempool")) {
7066 struct rte_mempool *mp;
7067 mp = rte_mempool_lookup(res->name);
7069 cmdline_printf(cl, "Cannot find mempool\n");
7072 rte_mempool_dump(stdout, mp);
7076 cmdline_parse_token_string_t cmd_dump_one_dump =
7077 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
7078 "dump_ring#dump_mempool");
7080 cmdline_parse_token_string_t cmd_dump_one_name =
7081 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
7083 cmdline_parse_inst_t cmd_dump_one = {
7084 .f = cmd_dump_one_parsed, /* function to call */
7085 .data = NULL, /* 2nd arg of func */
7086 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
7087 .tokens = { /* token list, NULL terminated */
7088 (void *)&cmd_dump_one_dump,
7089 (void *)&cmd_dump_one_name,
7094 /* *** ADD/REMOVE an ethertype FILTER *** */
7095 struct cmd_ethertype_filter_result {
7096 cmdline_fixed_string_t filter;
7098 cmdline_fixed_string_t ethertype;
7099 uint16_t ethertype_value;
7100 cmdline_fixed_string_t priority;
7101 cmdline_fixed_string_t priority_en;
7102 uint8_t priority_value;
7103 cmdline_fixed_string_t queue;
7105 cmdline_fixed_string_t index;
7106 uint16_t index_value;
7110 cmd_ethertype_filter_parsed(void *parsed_result,
7111 __attribute__((unused)) struct cmdline *cl,
7112 __attribute__((unused)) void *data)
7115 struct cmd_ethertype_filter_result *res = parsed_result;
7116 struct rte_ethertype_filter filter;
7118 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
7119 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
7120 filter.priority = res->priority_value;
7122 if (!strcmp(res->priority_en, "enable"))
7123 filter.priority_en = 1;
7124 if (!strcmp(res->filter, "add_ethertype_filter"))
7125 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
7127 &filter, res->queue_id);
7128 else if (!strcmp(res->filter, "remove_ethertype_filter"))
7129 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
7131 else if (!strcmp(res->filter, "get_ethertype_filter"))
7132 get_ethertype_filter(res->port_id, res->index_value);
7135 printf("ethertype filter setting error: (%s)\n",
7139 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
7140 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7142 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
7143 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7144 ethertype, "ethertype");
7145 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
7146 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7147 ethertype_value, UINT16);
7148 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
7149 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7150 priority, "priority");
7151 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
7152 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7153 priority_en, "enable#disable");
7154 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
7155 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7156 priority_value, UINT8);
7157 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
7158 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7160 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
7161 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7163 cmdline_parse_token_string_t cmd_ethertype_filter_index =
7164 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7166 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
7167 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
7168 index_value, UINT16);
7169 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
7170 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7171 filter, "add_ethertype_filter");
7172 cmdline_parse_inst_t cmd_add_ethertype_filter = {
7173 .f = cmd_ethertype_filter_parsed,
7175 .help_str = "add an ethertype filter",
7177 (void *)&cmd_ethertype_filter_add_filter,
7178 (void *)&cmd_ethertype_filter_port_id,
7179 (void *)&cmd_ethertype_filter_ethertype,
7180 (void *)&cmd_ethertype_filter_ethertype_value,
7181 (void *)&cmd_ethertype_filter_priority,
7182 (void *)&cmd_ethertype_filter_priority_en,
7183 (void *)&cmd_ethertype_filter_priority_value,
7184 (void *)&cmd_ethertype_filter_queue,
7185 (void *)&cmd_ethertype_filter_queue_id,
7186 (void *)&cmd_ethertype_filter_index,
7187 (void *)&cmd_ethertype_filter_index_value,
7192 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
7193 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7194 filter, "remove_ethertype_filter");
7195 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
7196 .f = cmd_ethertype_filter_parsed,
7198 .help_str = "remove an ethertype filter",
7200 (void *)&cmd_ethertype_filter_remove_filter,
7201 (void *)&cmd_ethertype_filter_port_id,
7202 (void *)&cmd_ethertype_filter_index,
7203 (void *)&cmd_ethertype_filter_index_value,
7207 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
7208 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
7209 filter, "get_ethertype_filter");
7210 cmdline_parse_inst_t cmd_get_ethertype_filter = {
7211 .f = cmd_ethertype_filter_parsed,
7213 .help_str = "get an ethertype filter",
7215 (void *)&cmd_ethertype_filter_get_filter,
7216 (void *)&cmd_ethertype_filter_port_id,
7217 (void *)&cmd_ethertype_filter_index,
7218 (void *)&cmd_ethertype_filter_index_value,
7223 /* *** set SYN filter *** */
7224 struct cmd_set_syn_filter_result {
7225 cmdline_fixed_string_t filter;
7227 cmdline_fixed_string_t priority;
7228 cmdline_fixed_string_t high;
7229 cmdline_fixed_string_t queue;
7234 cmd_set_syn_filter_parsed(void *parsed_result,
7235 __attribute__((unused)) struct cmdline *cl,
7236 __attribute__((unused)) void *data)
7239 struct cmd_set_syn_filter_result *res = parsed_result;
7240 struct rte_syn_filter filter;
7242 if (!strcmp(res->filter, "add_syn_filter")) {
7243 if (!strcmp(res->high, "high"))
7247 ret = rte_eth_dev_add_syn_filter(res->port_id,
7248 &filter, res->queue_id);
7249 } else if (!strcmp(res->filter, "remove_syn_filter"))
7250 ret = rte_eth_dev_remove_syn_filter(res->port_id);
7251 else if (!strcmp(res->filter, "get_syn_filter"))
7252 get_syn_filter(res->port_id);
7254 printf("syn filter setting error: (%s)\n", strerror(-ret));
7257 cmdline_parse_token_num_t cmd_syn_filter_portid =
7258 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7260 cmdline_parse_token_string_t cmd_syn_filter_priority =
7261 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7262 priority, "priority");
7263 cmdline_parse_token_string_t cmd_syn_filter_high =
7264 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7266 cmdline_parse_token_string_t cmd_syn_filter_queue =
7267 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7269 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
7270 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
7272 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
7273 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7274 filter, "add_syn_filter");
7275 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
7276 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7277 filter, "remove_syn_filter");
7278 cmdline_parse_inst_t cmd_add_syn_filter = {
7279 .f = cmd_set_syn_filter_parsed,
7281 .help_str = "add syn filter",
7283 (void *)&cmd_syn_filter_add_filter,
7284 (void *)&cmd_syn_filter_portid,
7285 (void *)&cmd_syn_filter_priority,
7286 (void *)&cmd_syn_filter_high,
7287 (void *)&cmd_syn_filter_queue,
7288 (void *)&cmd_syn_filter_queue_id,
7292 cmdline_parse_inst_t cmd_remove_syn_filter = {
7293 .f = cmd_set_syn_filter_parsed,
7295 .help_str = "remove syn filter",
7297 (void *)&cmd_syn_filter_remove_filter,
7298 (void *)&cmd_syn_filter_portid,
7303 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
7304 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
7305 filter, "get_syn_filter");
7307 cmdline_parse_inst_t cmd_get_syn_filter = {
7308 .f = cmd_set_syn_filter_parsed,
7310 .help_str = "get syn filter",
7312 (void *)&cmd_syn_filter_get_filter,
7313 (void *)&cmd_syn_filter_portid,
7318 /* *** ADD/REMOVE A 2tuple FILTER *** */
7319 struct cmd_2tuple_filter_result {
7320 cmdline_fixed_string_t filter;
7322 cmdline_fixed_string_t protocol;
7323 uint8_t protocol_value;
7324 uint8_t protocol_mask;
7325 cmdline_fixed_string_t dst_port;
7326 uint16_t dst_port_value;
7327 uint16_t dst_port_mask;
7328 cmdline_fixed_string_t flags;
7329 uint8_t flags_value;
7330 cmdline_fixed_string_t priority;
7331 uint8_t priority_value;
7332 cmdline_fixed_string_t queue;
7334 cmdline_fixed_string_t index;
7335 uint16_t index_value;
7339 cmd_2tuple_filter_parsed(void *parsed_result,
7340 __attribute__((unused)) struct cmdline *cl,
7341 __attribute__((unused)) void *data)
7344 struct rte_2tuple_filter filter;
7345 struct cmd_2tuple_filter_result *res = parsed_result;
7347 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
7349 if (!strcmp(res->filter, "add_2tuple_filter")) {
7350 /* need convert to big endian. */
7351 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7352 filter.protocol = res->protocol_value;
7353 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
7354 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
7355 filter.priority = res->priority_value;
7356 filter.tcp_flags = res->flags_value;
7357 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
7358 res->index_value, &filter, res->queue_id);
7359 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
7360 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
7362 else if (!strcmp(res->filter, "get_2tuple_filter"))
7363 get_2tuple_filter(res->port_id, res->index_value);
7366 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
7369 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
7370 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7372 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
7373 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7374 protocol, "protocol");
7375 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
7376 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7377 protocol_value, UINT8);
7378 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
7379 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7380 protocol_mask, UINT8);
7381 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
7382 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7383 dst_port, "dst_port");
7384 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
7385 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7386 dst_port_value, UINT16);
7387 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
7388 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7389 dst_port_mask, UINT16);
7390 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
7391 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7393 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
7394 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7395 flags_value, UINT8);
7396 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
7397 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7398 priority, "priority");
7399 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
7400 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7401 priority_value, UINT8);
7402 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
7403 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7405 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
7406 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7408 cmdline_parse_token_string_t cmd_2tuple_filter_index =
7409 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7411 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
7412 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
7413 index_value, UINT16);
7414 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
7415 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7416 filter, "add_2tuple_filter");
7417 cmdline_parse_inst_t cmd_add_2tuple_filter = {
7418 .f = cmd_2tuple_filter_parsed,
7420 .help_str = "add a 2tuple filter",
7422 (void *)&cmd_2tuple_filter_add_filter,
7423 (void *)&cmd_2tuple_filter_port_id,
7424 (void *)&cmd_2tuple_filter_protocol,
7425 (void *)&cmd_2tuple_filter_protocol_value,
7426 (void *)&cmd_2tuple_filter_protocol_mask,
7427 (void *)&cmd_2tuple_filter_dst_port,
7428 (void *)&cmd_2tuple_filter_dst_port_value,
7429 (void *)&cmd_2tuple_filter_dst_port_mask,
7430 (void *)&cmd_2tuple_filter_flags,
7431 (void *)&cmd_2tuple_filter_flags_value,
7432 (void *)&cmd_2tuple_filter_priority,
7433 (void *)&cmd_2tuple_filter_priority_value,
7434 (void *)&cmd_2tuple_filter_queue,
7435 (void *)&cmd_2tuple_filter_queue_id,
7436 (void *)&cmd_2tuple_filter_index,
7437 (void *)&cmd_2tuple_filter_index_value,
7442 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
7443 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7444 filter, "remove_2tuple_filter");
7445 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
7446 .f = cmd_2tuple_filter_parsed,
7448 .help_str = "remove a 2tuple filter",
7450 (void *)&cmd_2tuple_filter_remove_filter,
7451 (void *)&cmd_2tuple_filter_port_id,
7452 (void *)&cmd_2tuple_filter_index,
7453 (void *)&cmd_2tuple_filter_index_value,
7457 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
7458 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
7459 filter, "get_2tuple_filter");
7460 cmdline_parse_inst_t cmd_get_2tuple_filter = {
7461 .f = cmd_2tuple_filter_parsed,
7463 .help_str = "get a 2tuple filter",
7465 (void *)&cmd_2tuple_filter_get_filter,
7466 (void *)&cmd_2tuple_filter_port_id,
7467 (void *)&cmd_2tuple_filter_index,
7468 (void *)&cmd_2tuple_filter_index_value,
7473 /* *** ADD/REMOVE A 5tuple FILTER *** */
7474 struct cmd_5tuple_filter_result {
7475 cmdline_fixed_string_t filter;
7477 cmdline_fixed_string_t dst_ip;
7478 cmdline_ipaddr_t dst_ip_value;
7479 cmdline_fixed_string_t src_ip;
7480 cmdline_ipaddr_t src_ip_value;
7481 cmdline_fixed_string_t dst_port;
7482 uint16_t dst_port_value;
7483 cmdline_fixed_string_t src_port;
7484 uint16_t src_port_value;
7485 cmdline_fixed_string_t protocol;
7486 uint8_t protocol_value;
7487 cmdline_fixed_string_t mask;
7489 cmdline_fixed_string_t flags;
7490 uint8_t flags_value;
7491 cmdline_fixed_string_t priority;
7492 uint8_t priority_value;
7493 cmdline_fixed_string_t queue;
7495 cmdline_fixed_string_t index;
7496 uint16_t index_value;
7500 cmd_5tuple_filter_parsed(void *parsed_result,
7501 __attribute__((unused)) struct cmdline *cl,
7502 __attribute__((unused)) void *data)
7505 struct rte_5tuple_filter filter;
7506 struct cmd_5tuple_filter_result *res = parsed_result;
7508 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
7510 if (!strcmp(res->filter, "add_5tuple_filter")) {
7511 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
7512 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
7513 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
7514 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
7515 filter.protocol = res->protocol_value;
7516 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
7517 filter.priority = res->priority_value;
7518 filter.tcp_flags = res->flags_value;
7520 if (res->dst_ip_value.family == AF_INET)
7521 /* no need to convert, already big endian. */
7522 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
7524 if (filter.dst_ip_mask == 0) {
7525 printf("can not support ipv6 involved compare.\n");
7531 if (res->src_ip_value.family == AF_INET)
7532 /* no need to convert, already big endian. */
7533 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
7535 if (filter.src_ip_mask == 0) {
7536 printf("can not support ipv6 involved compare.\n");
7541 /* need convert to big endian. */
7542 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
7543 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
7545 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
7546 res->index_value, &filter, res->queue_id);
7547 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
7548 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
7550 else if (!strcmp(res->filter, "get_5tuple_filter"))
7551 get_5tuple_filter(res->port_id, res->index_value);
7553 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
7557 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
7558 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7560 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
7561 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7563 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
7564 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7566 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
7567 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7569 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
7570 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
7572 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
7573 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7574 dst_port, "dst_port");
7575 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
7576 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7577 dst_port_value, UINT16);
7578 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
7579 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7580 src_port, "src_port");
7581 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
7582 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7583 src_port_value, UINT16);
7584 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
7585 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7586 protocol, "protocol");
7587 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
7588 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7589 protocol_value, UINT8);
7590 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
7591 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7593 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
7594 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7596 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
7597 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7599 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
7600 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7601 flags_value, UINT8);
7602 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
7603 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7604 priority, "priority");
7605 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
7606 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7607 priority_value, UINT8);
7608 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
7609 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7611 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
7612 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7614 cmdline_parse_token_string_t cmd_5tuple_filter_index =
7615 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7617 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
7618 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
7619 index_value, UINT16);
7621 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
7622 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7623 filter, "add_5tuple_filter");
7624 cmdline_parse_inst_t cmd_add_5tuple_filter = {
7625 .f = cmd_5tuple_filter_parsed,
7627 .help_str = "add a 5tuple filter",
7629 (void *)&cmd_5tuple_filter_add_filter,
7630 (void *)&cmd_5tuple_filter_port_id,
7631 (void *)&cmd_5tuple_filter_dst_ip,
7632 (void *)&cmd_5tuple_filter_dst_ip_value,
7633 (void *)&cmd_5tuple_filter_src_ip,
7634 (void *)&cmd_5tuple_filter_src_ip_value,
7635 (void *)&cmd_5tuple_filter_dst_port,
7636 (void *)&cmd_5tuple_filter_dst_port_value,
7637 (void *)&cmd_5tuple_filter_src_port,
7638 (void *)&cmd_5tuple_filter_src_port_value,
7639 (void *)&cmd_5tuple_filter_protocol,
7640 (void *)&cmd_5tuple_filter_protocol_value,
7641 (void *)&cmd_5tuple_filter_mask,
7642 (void *)&cmd_5tuple_filter_mask_value,
7643 (void *)&cmd_5tuple_filter_flags,
7644 (void *)&cmd_5tuple_filter_flags_value,
7645 (void *)&cmd_5tuple_filter_priority,
7646 (void *)&cmd_5tuple_filter_priority_value,
7647 (void *)&cmd_5tuple_filter_queue,
7648 (void *)&cmd_5tuple_filter_queue_id,
7649 (void *)&cmd_5tuple_filter_index,
7650 (void *)&cmd_5tuple_filter_index_value,
7655 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
7656 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7657 filter, "remove_5tuple_filter");
7658 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
7659 .f = cmd_5tuple_filter_parsed,
7661 .help_str = "remove a 5tuple filter",
7663 (void *)&cmd_5tuple_filter_remove_filter,
7664 (void *)&cmd_5tuple_filter_port_id,
7665 (void *)&cmd_5tuple_filter_index,
7666 (void *)&cmd_5tuple_filter_index_value,
7671 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
7672 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
7673 filter, "get_5tuple_filter");
7674 cmdline_parse_inst_t cmd_get_5tuple_filter = {
7675 .f = cmd_5tuple_filter_parsed,
7677 .help_str = "get a 5tuple filter",
7679 (void *)&cmd_5tuple_filter_get_filter,
7680 (void *)&cmd_5tuple_filter_port_id,
7681 (void *)&cmd_5tuple_filter_index,
7682 (void *)&cmd_5tuple_filter_index_value,
7687 /* *** ADD/REMOVE A flex FILTER *** */
7688 struct cmd_flex_filter_result {
7689 cmdline_fixed_string_t filter;
7691 cmdline_fixed_string_t len;
7693 cmdline_fixed_string_t bytes;
7694 cmdline_fixed_string_t bytes_value;
7695 cmdline_fixed_string_t mask;
7696 cmdline_fixed_string_t mask_value;
7697 cmdline_fixed_string_t priority;
7698 uint8_t priority_value;
7699 cmdline_fixed_string_t queue;
7701 cmdline_fixed_string_t index;
7702 uint16_t index_value;
7705 static int xdigit2val(unsigned char c)
7710 else if (isupper(c))
7718 cmd_flex_filter_parsed(void *parsed_result,
7719 __attribute__((unused)) struct cmdline *cl,
7720 __attribute__((unused)) void *data)
7723 struct rte_flex_filter filter;
7724 struct cmd_flex_filter_result *res = parsed_result;
7725 char *bytes_ptr, *mask_ptr;
7733 if (!strcmp(res->filter, "add_flex_filter")) {
7734 if (res->len_value > 128) {
7735 printf("the len exceed the max length 128\n");
7738 memset(&filter, 0, sizeof(struct rte_flex_filter));
7739 filter.len = res->len_value;
7740 filter.priority = res->priority_value;
7741 bytes_ptr = res->bytes_value;
7742 mask_ptr = res->mask_value;
7745 /* translate bytes string to uint_32 array. */
7746 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
7747 (bytes_ptr[1] == 'X')))
7749 len = strnlen(bytes_ptr, res->len_value * 2);
7750 if (len == 0 || (len % 8 != 0)) {
7751 printf("please check len and bytes input\n");
7754 for (i = 0; i < len; i++) {
7756 if (isxdigit(c) == 0) {
7757 /* invalid characters. */
7758 printf("invalid input\n");
7761 val = xdigit2val(c);
7765 dword |= byte << (4 * mod - 4);
7770 filter.dwords[j] = dword;
7771 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
7777 /* translate mask string to uint8_t array. */
7779 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
7780 (mask_ptr[1] == 'X')))
7782 len = strnlen(mask_ptr, (res->len_value+3)/4);
7784 printf("invalid input\n");
7787 for (i = 0; i < len; i++) {
7789 if (isxdigit(c) == 0) {
7790 /* invalid characters. */
7791 printf("invalid input\n");
7794 val = xdigit2val(c);
7795 hex |= (uint8_t)(val & 0x8) >> 3;
7796 hex |= (uint8_t)(val & 0x4) >> 1;
7797 hex |= (uint8_t)(val & 0x2) << 1;
7798 hex |= (uint8_t)(val & 0x1) << 3;
7801 filter.mask[j] = byte;
7802 printf("mask[%d]:%02x ", j, filter.mask[j]);
7810 printf("call function rte_eth_dev_add_flex_filter: "
7811 "index = %d, queue-id = %d, len = %d, priority = %d\n",
7812 res->index_value, res->queue_id,
7813 filter.len, filter.priority);
7814 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
7815 &filter, res->queue_id);
7817 } else if (!strcmp(res->filter, "remove_flex_filter"))
7818 ret = rte_eth_dev_remove_flex_filter(res->port_id,
7820 else if (!strcmp(res->filter, "get_flex_filter"))
7821 get_flex_filter(res->port_id, res->index_value);
7824 printf("flex filter setting error: (%s)\n", strerror(-ret));
7827 cmdline_parse_token_num_t cmd_flex_filter_port_id =
7828 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7830 cmdline_parse_token_string_t cmd_flex_filter_len =
7831 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7833 cmdline_parse_token_num_t cmd_flex_filter_len_value =
7834 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7836 cmdline_parse_token_string_t cmd_flex_filter_bytes =
7837 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7839 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
7840 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7842 cmdline_parse_token_string_t cmd_flex_filter_mask =
7843 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7845 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
7846 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7848 cmdline_parse_token_string_t cmd_flex_filter_priority =
7849 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7850 priority, "priority");
7851 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
7852 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7853 priority_value, UINT8);
7854 cmdline_parse_token_string_t cmd_flex_filter_queue =
7855 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7857 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
7858 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7860 cmdline_parse_token_string_t cmd_flex_filter_index =
7861 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7863 cmdline_parse_token_num_t cmd_flex_filter_index_value =
7864 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
7865 index_value, UINT16);
7866 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
7867 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7868 filter, "add_flex_filter");
7869 cmdline_parse_inst_t cmd_add_flex_filter = {
7870 .f = cmd_flex_filter_parsed,
7872 .help_str = "add a flex filter",
7874 (void *)&cmd_flex_filter_add_filter,
7875 (void *)&cmd_flex_filter_port_id,
7876 (void *)&cmd_flex_filter_len,
7877 (void *)&cmd_flex_filter_len_value,
7878 (void *)&cmd_flex_filter_bytes,
7879 (void *)&cmd_flex_filter_bytes_value,
7880 (void *)&cmd_flex_filter_mask,
7881 (void *)&cmd_flex_filter_mask_value,
7882 (void *)&cmd_flex_filter_priority,
7883 (void *)&cmd_flex_filter_priority_value,
7884 (void *)&cmd_flex_filter_queue,
7885 (void *)&cmd_flex_filter_queue_id,
7886 (void *)&cmd_flex_filter_index,
7887 (void *)&cmd_flex_filter_index_value,
7892 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
7893 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7894 filter, "remove_flex_filter");
7895 cmdline_parse_inst_t cmd_remove_flex_filter = {
7896 .f = cmd_flex_filter_parsed,
7898 .help_str = "remove a flex filter",
7900 (void *)&cmd_flex_filter_remove_filter,
7901 (void *)&cmd_flex_filter_port_id,
7902 (void *)&cmd_flex_filter_index,
7903 (void *)&cmd_flex_filter_index_value,
7908 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
7909 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
7910 filter, "get_flex_filter");
7911 cmdline_parse_inst_t cmd_get_flex_filter = {
7912 .f = cmd_flex_filter_parsed,
7914 .help_str = "get a flex filter",
7916 (void *)&cmd_flex_filter_get_filter,
7917 (void *)&cmd_flex_filter_port_id,
7918 (void *)&cmd_flex_filter_index,
7919 (void *)&cmd_flex_filter_index_value,
7924 /* *** Filters Control *** */
7926 /* *** deal with flow director filter *** */
7927 struct cmd_flow_director_result {
7928 cmdline_fixed_string_t flow_director_filter;
7930 cmdline_fixed_string_t ops;
7931 cmdline_fixed_string_t flow;
7932 cmdline_fixed_string_t flow_type;
7933 cmdline_fixed_string_t src;
7934 cmdline_ipaddr_t ip_src;
7936 cmdline_fixed_string_t dst;
7937 cmdline_ipaddr_t ip_dst;
7939 cmdline_fixed_string_t verify_tag;
7940 uint32_t verify_tag_value;
7941 cmdline_fixed_string_t flexbytes;
7942 cmdline_fixed_string_t flexbytes_value;
7943 cmdline_fixed_string_t drop;
7944 cmdline_fixed_string_t queue;
7946 cmdline_fixed_string_t fd_id;
7947 uint32_t fd_id_value;
7951 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
7954 const char *p, *p0 = q_arg;
7956 unsigned long int_fld;
7957 char *str_fld[max_num];
7962 p = strchr(p0, '(');
7966 p0 = strchr(p, ')');
7971 if (size >= sizeof(s))
7974 snprintf(s, sizeof(s), "%.*s", size, p);
7975 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
7976 if (ret < 0 || ret > max_num)
7978 for (i = 0; i < ret; i++) {
7980 int_fld = strtoul(str_fld[i], &end, 0);
7981 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
7983 flexbytes[i] = (uint8_t)int_fld;
7988 static enum rte_eth_flow_type
7989 str2flowtype(char *string)
7992 static const struct {
7994 enum rte_eth_flow_type type;
7995 } flowtype_str[] = {
7996 {"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
7997 {"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
7998 {"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
7999 {"tcp4", RTE_ETH_FLOW_TYPE_TCPV4},
8000 {"sctp4", RTE_ETH_FLOW_TYPE_SCTPV4},
8001 {"ip6", RTE_ETH_FLOW_TYPE_IPV6_OTHER},
8002 {"ip6-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV6},
8003 {"udp6", RTE_ETH_FLOW_TYPE_UDPV6},
8004 {"tcp6", RTE_ETH_FLOW_TYPE_TCPV6},
8005 {"sctp6", RTE_ETH_FLOW_TYPE_TCPV6},
8008 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
8009 if (!strcmp(flowtype_str[i].str, string))
8010 return flowtype_str[i].type;
8012 return RTE_ETH_FLOW_TYPE_NONE;
8015 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8017 if ((ip_addr).family == AF_INET) \
8018 (ip) = (ip_addr).addr.ipv4.s_addr; \
8020 printf("invalid parameter.\n"); \
8025 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8027 if ((ip_addr).family == AF_INET6) \
8028 (void)rte_memcpy(&(ip), \
8029 &((ip_addr).addr.ipv6), \
8030 sizeof(struct in6_addr)); \
8032 printf("invalid parameter.\n"); \
8038 cmd_flow_director_filter_parsed(void *parsed_result,
8039 __attribute__((unused)) struct cmdline *cl,
8040 __attribute__((unused)) void *data)
8042 struct cmd_flow_director_result *res = parsed_result;
8043 struct rte_eth_fdir_filter entry;
8044 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
8047 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8049 printf("flow director is not supported on port %u.\n",
8053 memset(flexbytes, 0, sizeof(flexbytes));
8054 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
8055 ret = parse_flexbytes(res->flexbytes_value,
8057 RTE_ETH_FDIR_MAX_FLEXLEN);
8059 printf("error: Cannot parse flexbytes input.\n");
8063 entry.input.flow_type = str2flowtype(res->flow_type);
8064 switch (entry.input.flow_type) {
8065 case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
8066 case RTE_ETH_FLOW_TYPE_UDPV4:
8067 case RTE_ETH_FLOW_TYPE_TCPV4:
8068 IPV4_ADDR_TO_UINT(res->ip_dst,
8069 entry.input.flow.ip4_flow.dst_ip);
8070 IPV4_ADDR_TO_UINT(res->ip_src,
8071 entry.input.flow.ip4_flow.src_ip);
8072 /* need convert to big endian. */
8073 entry.input.flow.udp4_flow.dst_port =
8074 rte_cpu_to_be_16(res->port_dst);
8075 entry.input.flow.udp4_flow.src_port =
8076 rte_cpu_to_be_16(res->port_src);
8078 case RTE_ETH_FLOW_TYPE_SCTPV4:
8079 IPV4_ADDR_TO_UINT(res->ip_dst,
8080 entry.input.flow.sctp4_flow.ip.dst_ip);
8081 IPV4_ADDR_TO_UINT(res->ip_src,
8082 entry.input.flow.sctp4_flow.ip.src_ip);
8083 /* need convert to big endian. */
8084 entry.input.flow.sctp4_flow.verify_tag =
8085 rte_cpu_to_be_32(res->verify_tag_value);
8087 case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
8088 case RTE_ETH_FLOW_TYPE_UDPV6:
8089 case RTE_ETH_FLOW_TYPE_TCPV6:
8090 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8091 entry.input.flow.ip6_flow.dst_ip);
8092 IPV6_ADDR_TO_ARRAY(res->ip_src,
8093 entry.input.flow.ip6_flow.src_ip);
8094 /* need convert to big endian. */
8095 entry.input.flow.udp6_flow.dst_port =
8096 rte_cpu_to_be_16(res->port_dst);
8097 entry.input.flow.udp6_flow.src_port =
8098 rte_cpu_to_be_16(res->port_src);
8100 case RTE_ETH_FLOW_TYPE_SCTPV6:
8101 IPV6_ADDR_TO_ARRAY(res->ip_dst,
8102 entry.input.flow.sctp6_flow.ip.dst_ip);
8103 IPV6_ADDR_TO_ARRAY(res->ip_src,
8104 entry.input.flow.sctp6_flow.ip.src_ip);
8105 /* need convert to big endian. */
8106 entry.input.flow.sctp6_flow.verify_tag =
8107 rte_cpu_to_be_32(res->verify_tag_value);
8110 printf("invalid parameter.\n");
8113 (void)rte_memcpy(entry.input.flow_ext.flexbytes,
8115 RTE_ETH_FDIR_MAX_FLEXLEN);
8117 entry.action.flex_off = 0; /*use 0 by default */
8118 if (!strcmp(res->drop, "drop"))
8119 entry.action.behavior = RTE_ETH_FDIR_REJECT;
8121 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
8122 /* set to report FD ID by default */
8123 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
8124 entry.action.rx_queue = res->queue_id;
8125 entry.soft_id = res->fd_id_value;
8126 if (!strcmp(res->ops, "add"))
8127 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8128 RTE_ETH_FILTER_ADD, &entry);
8130 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8131 RTE_ETH_FILTER_DELETE, &entry);
8133 printf("flow director programming error: (%s)\n",
8137 cmdline_parse_token_string_t cmd_flow_director_filter =
8138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8139 flow_director_filter, "flow_director_filter");
8140 cmdline_parse_token_num_t cmd_flow_director_port_id =
8141 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8143 cmdline_parse_token_string_t cmd_flow_director_ops =
8144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8146 cmdline_parse_token_string_t cmd_flow_director_flow =
8147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8149 cmdline_parse_token_string_t cmd_flow_director_flow_type =
8150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8152 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8153 "ip6#ip6-frag#tcp6#udp6#sctp6");
8154 cmdline_parse_token_string_t cmd_flow_director_src =
8155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8157 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
8158 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8160 cmdline_parse_token_num_t cmd_flow_director_port_src =
8161 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8163 cmdline_parse_token_string_t cmd_flow_director_dst =
8164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8166 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
8167 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
8169 cmdline_parse_token_num_t cmd_flow_director_port_dst =
8170 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8172 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
8173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8174 verify_tag, "verify_tag");
8175 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
8176 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8177 verify_tag_value, UINT32);
8178 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
8179 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8180 flexbytes, "flexbytes");
8181 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
8182 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8183 flexbytes_value, NULL);
8184 cmdline_parse_token_string_t cmd_flow_director_drop =
8185 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8187 cmdline_parse_token_string_t cmd_flow_director_queue =
8188 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8190 cmdline_parse_token_num_t cmd_flow_director_queue_id =
8191 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8193 cmdline_parse_token_string_t cmd_flow_director_fd_id =
8194 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
8196 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
8197 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
8198 fd_id_value, UINT32);
8200 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
8201 .f = cmd_flow_director_filter_parsed,
8203 .help_str = "add or delete an ip flow director entry on NIC",
8205 (void *)&cmd_flow_director_filter,
8206 (void *)&cmd_flow_director_port_id,
8207 (void *)&cmd_flow_director_ops,
8208 (void *)&cmd_flow_director_flow,
8209 (void *)&cmd_flow_director_flow_type,
8210 (void *)&cmd_flow_director_src,
8211 (void *)&cmd_flow_director_ip_src,
8212 (void *)&cmd_flow_director_dst,
8213 (void *)&cmd_flow_director_ip_dst,
8214 (void *)&cmd_flow_director_flexbytes,
8215 (void *)&cmd_flow_director_flexbytes_value,
8216 (void *)&cmd_flow_director_drop,
8217 (void *)&cmd_flow_director_queue,
8218 (void *)&cmd_flow_director_queue_id,
8219 (void *)&cmd_flow_director_fd_id,
8220 (void *)&cmd_flow_director_fd_id_value,
8225 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
8226 .f = cmd_flow_director_filter_parsed,
8228 .help_str = "add or delete an udp/tcp flow director entry on NIC",
8230 (void *)&cmd_flow_director_filter,
8231 (void *)&cmd_flow_director_port_id,
8232 (void *)&cmd_flow_director_ops,
8233 (void *)&cmd_flow_director_flow,
8234 (void *)&cmd_flow_director_flow_type,
8235 (void *)&cmd_flow_director_src,
8236 (void *)&cmd_flow_director_ip_src,
8237 (void *)&cmd_flow_director_port_src,
8238 (void *)&cmd_flow_director_dst,
8239 (void *)&cmd_flow_director_ip_dst,
8240 (void *)&cmd_flow_director_port_dst,
8241 (void *)&cmd_flow_director_flexbytes,
8242 (void *)&cmd_flow_director_flexbytes_value,
8243 (void *)&cmd_flow_director_drop,
8244 (void *)&cmd_flow_director_queue,
8245 (void *)&cmd_flow_director_queue_id,
8246 (void *)&cmd_flow_director_fd_id,
8247 (void *)&cmd_flow_director_fd_id_value,
8252 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
8253 .f = cmd_flow_director_filter_parsed,
8255 .help_str = "add or delete a sctp flow director entry on NIC",
8257 (void *)&cmd_flow_director_filter,
8258 (void *)&cmd_flow_director_port_id,
8259 (void *)&cmd_flow_director_ops,
8260 (void *)&cmd_flow_director_flow,
8261 (void *)&cmd_flow_director_flow_type,
8262 (void *)&cmd_flow_director_src,
8263 (void *)&cmd_flow_director_ip_src,
8264 (void *)&cmd_flow_director_dst,
8265 (void *)&cmd_flow_director_ip_dst,
8266 (void *)&cmd_flow_director_verify_tag,
8267 (void *)&cmd_flow_director_verify_tag_value,
8268 (void *)&cmd_flow_director_flexbytes,
8269 (void *)&cmd_flow_director_flexbytes_value,
8270 (void *)&cmd_flow_director_drop,
8271 (void *)&cmd_flow_director_queue,
8272 (void *)&cmd_flow_director_queue_id,
8273 (void *)&cmd_flow_director_fd_id,
8274 (void *)&cmd_flow_director_fd_id_value,
8279 struct cmd_flush_flow_director_result {
8280 cmdline_fixed_string_t flush_flow_director;
8284 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
8285 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
8286 flush_flow_director, "flush_flow_director");
8287 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
8288 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
8292 cmd_flush_flow_director_parsed(void *parsed_result,
8293 __attribute__((unused)) struct cmdline *cl,
8294 __attribute__((unused)) void *data)
8296 struct cmd_flow_director_result *res = parsed_result;
8299 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
8301 printf("flow director is not supported on port %u.\n",
8306 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
8307 RTE_ETH_FILTER_FLUSH, NULL);
8309 printf("flow director table flushing error: (%s)\n",
8313 cmdline_parse_inst_t cmd_flush_flow_director = {
8314 .f = cmd_flush_flow_director_parsed,
8316 .help_str = "flush all flow director entries of a device on NIC",
8318 (void *)&cmd_flush_flow_director_flush,
8319 (void *)&cmd_flush_flow_director_port_id,
8324 /* *** deal with flow director mask on flexible payload *** */
8325 struct cmd_flow_director_flex_mask_result {
8326 cmdline_fixed_string_t flow_director_flexmask;
8328 cmdline_fixed_string_t flow;
8329 cmdline_fixed_string_t flow_type;
8330 cmdline_fixed_string_t mask;
8334 cmd_flow_director_flex_mask_parsed(void *parsed_result,
8335 __attribute__((unused)) struct cmdline *cl,
8336 __attribute__((unused)) void *data)
8338 struct cmd_flow_director_flex_mask_result *res = parsed_result;
8339 struct rte_eth_fdir_flex_mask flex_mask;
8340 struct rte_port *port;
8341 enum rte_eth_flow_type i;
8344 if (res->port_id > nb_ports) {
8345 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8349 port = &ports[res->port_id];
8350 /** Check if the port is not started **/
8351 if (port->port_status != RTE_PORT_STOPPED) {
8352 printf("Please stop port %d first\n", res->port_id);
8356 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
8357 ret = parse_flexbytes(res->mask,
8359 RTE_ETH_FDIR_MAX_FLEXLEN);
8361 printf("error: Cannot parse mask input.\n");
8364 if (!strcmp(res->flow_type, "all")) {
8365 for (i = RTE_ETH_FLOW_TYPE_UDPV4;
8366 i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
8368 flex_mask.flow_type = i;
8369 fdir_set_flex_mask(res->port_id, &flex_mask);
8371 cmd_reconfig_device_queue(res->port_id, 1, 0);
8374 flex_mask.flow_type = str2flowtype(res->flow_type);
8375 fdir_set_flex_mask(res->port_id, &flex_mask);
8376 cmd_reconfig_device_queue(res->port_id, 1, 0);
8379 cmdline_parse_token_string_t cmd_flow_director_flexmask =
8380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8381 flow_director_flexmask,
8382 "flow_director_flex_mask");
8383 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
8384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8386 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
8387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8389 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
8390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8392 "ip4#ip4-frag#tcp4#udp4#sctp4#"
8393 "ip6#ip6-frag#tcp6#udp6#sctp6#all");
8394 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
8395 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
8398 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
8399 .f = cmd_flow_director_flex_mask_parsed,
8401 .help_str = "set flow director's flex mask on NIC",
8403 (void *)&cmd_flow_director_flexmask,
8404 (void *)&cmd_flow_director_flexmask_port_id,
8405 (void *)&cmd_flow_director_flexmask_flow,
8406 (void *)&cmd_flow_director_flexmask_flow_type,
8407 (void *)&cmd_flow_director_flexmask_mask,
8412 /* *** deal with flow director flexible payload configuration *** */
8413 struct cmd_flow_director_flexpayload_result {
8414 cmdline_fixed_string_t flow_director_flexpayload;
8416 cmdline_fixed_string_t payload_layer;
8417 cmdline_fixed_string_t payload_cfg;
8421 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
8424 const char *p, *p0 = q_arg;
8426 unsigned long int_fld;
8427 char *str_fld[max_num];
8432 p = strchr(p0, '(');
8436 p0 = strchr(p, ')');
8441 if (size >= sizeof(s))
8444 snprintf(s, sizeof(s), "%.*s", size, p);
8445 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
8446 if (ret < 0 || ret > max_num)
8448 for (i = 0; i < ret; i++) {
8450 int_fld = strtoul(str_fld[i], &end, 0);
8451 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
8453 offsets[i] = (uint16_t)int_fld;
8459 cmd_flow_director_flxpld_parsed(void *parsed_result,
8460 __attribute__((unused)) struct cmdline *cl,
8461 __attribute__((unused)) void *data)
8463 struct cmd_flow_director_flexpayload_result *res = parsed_result;
8464 struct rte_eth_flex_payload_cfg flex_cfg;
8465 struct rte_port *port;
8468 if (res->port_id > nb_ports) {
8469 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
8473 port = &ports[res->port_id];
8474 /** Check if the port is not started **/
8475 if (port->port_status != RTE_PORT_STOPPED) {
8476 printf("Please stop port %d first\n", res->port_id);
8480 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
8482 if (!strcmp(res->payload_layer, "l2"))
8483 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
8484 else if (!strcmp(res->payload_layer, "l3"))
8485 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
8486 else if (!strcmp(res->payload_layer, "l4"))
8487 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
8489 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
8490 RTE_ETH_FDIR_MAX_FLEXLEN);
8492 printf("error: Cannot parse flex payload input.\n");
8496 fdir_set_flex_payload(res->port_id, &flex_cfg);
8497 cmd_reconfig_device_queue(res->port_id, 1, 0);
8500 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
8501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8502 flow_director_flexpayload,
8503 "flow_director_flex_payload");
8504 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
8505 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8507 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
8508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8509 payload_layer, "l2#l3#l4");
8510 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
8511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
8514 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
8515 .f = cmd_flow_director_flxpld_parsed,
8517 .help_str = "set flow director's flex payload on NIC",
8519 (void *)&cmd_flow_director_flexpayload,
8520 (void *)&cmd_flow_director_flexpayload_port_id,
8521 (void *)&cmd_flow_director_flexpayload_payload_layer,
8522 (void *)&cmd_flow_director_flexpayload_payload_cfg,
8527 /* ******************************************************************************** */
8529 /* list of instructions */
8530 cmdline_parse_ctx_t main_ctx[] = {
8531 (cmdline_parse_inst_t *)&cmd_help_brief,
8532 (cmdline_parse_inst_t *)&cmd_help_long,
8533 (cmdline_parse_inst_t *)&cmd_quit,
8534 (cmdline_parse_inst_t *)&cmd_showport,
8535 (cmdline_parse_inst_t *)&cmd_showportall,
8536 (cmdline_parse_inst_t *)&cmd_showcfg,
8537 (cmdline_parse_inst_t *)&cmd_start,
8538 (cmdline_parse_inst_t *)&cmd_start_tx_first,
8539 (cmdline_parse_inst_t *)&cmd_set_link_up,
8540 (cmdline_parse_inst_t *)&cmd_set_link_down,
8541 (cmdline_parse_inst_t *)&cmd_reset,
8542 (cmdline_parse_inst_t *)&cmd_set_numbers,
8543 (cmdline_parse_inst_t *)&cmd_set_txpkts,
8544 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
8545 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
8546 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
8547 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
8548 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
8549 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
8550 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
8551 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
8552 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
8553 (cmdline_parse_inst_t *)&cmd_set_link_check,
8554 #ifdef RTE_NIC_BYPASS
8555 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
8556 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
8557 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
8558 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
8560 #ifdef RTE_LIBRTE_PMD_BOND
8561 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
8562 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
8563 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
8564 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
8565 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
8566 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
8567 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
8568 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
8569 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
8571 (cmdline_parse_inst_t *)&cmd_vlan_offload,
8572 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
8573 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
8574 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
8575 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
8576 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
8577 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
8578 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
8579 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
8580 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
8581 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
8582 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
8583 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
8584 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
8585 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
8586 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
8587 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
8588 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
8589 (cmdline_parse_inst_t *)&cmd_config_dcb,
8590 (cmdline_parse_inst_t *)&cmd_read_reg,
8591 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
8592 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
8593 (cmdline_parse_inst_t *)&cmd_write_reg,
8594 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
8595 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
8596 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
8597 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
8598 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
8599 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
8600 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
8601 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
8602 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
8603 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
8604 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
8605 (cmdline_parse_inst_t *)&cmd_stop,
8606 (cmdline_parse_inst_t *)&cmd_mac_addr,
8607 (cmdline_parse_inst_t *)&cmd_set_qmap,
8608 (cmdline_parse_inst_t *)&cmd_operate_port,
8609 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
8610 (cmdline_parse_inst_t *)&cmd_config_speed_all,
8611 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
8612 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
8613 (cmdline_parse_inst_t *)&cmd_config_mtu,
8614 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
8615 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
8616 (cmdline_parse_inst_t *)&cmd_config_rss,
8617 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
8618 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
8619 (cmdline_parse_inst_t *)&cmd_showport_reta,
8620 (cmdline_parse_inst_t *)&cmd_config_burst,
8621 (cmdline_parse_inst_t *)&cmd_config_thresh,
8622 (cmdline_parse_inst_t *)&cmd_config_threshold,
8623 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
8624 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
8625 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
8626 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
8627 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
8628 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
8629 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
8630 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
8631 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
8632 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
8633 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
8634 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
8635 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
8636 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
8637 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
8638 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
8639 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
8640 (cmdline_parse_inst_t *)&cmd_dump,
8641 (cmdline_parse_inst_t *)&cmd_dump_one,
8642 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
8643 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
8644 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
8645 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
8646 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
8647 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
8648 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
8649 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
8650 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
8651 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
8652 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
8653 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
8654 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
8655 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
8656 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
8657 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
8658 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
8659 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
8660 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
8661 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
8662 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
8666 /* prompt function, called from main on MASTER lcore */
8672 /* initialize non-constant commands */
8673 cmd_set_fwd_mode_init();
8675 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
8679 cmdline_interact(cl);
8680 cmdline_stdin_exit(cl);
8684 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
8686 if (id < nb_ports) {
8687 /* check if need_reconfig has been set to 1 */
8688 if (ports[id].need_reconfig == 0)
8689 ports[id].need_reconfig = dev;
8690 /* check if need_reconfig_queues has been set to 1 */
8691 if (ports[id].need_reconfig_queues == 0)
8692 ports[id].need_reconfig_queues = queue;
8696 for (pid = 0; pid < nb_ports; pid++) {
8697 /* check if need_reconfig has been set to 1 */
8698 if (ports[pid].need_reconfig == 0)
8699 ports[pid].need_reconfig = dev;
8700 /* check if need_reconfig_queues has been set to 1 */
8701 if (ports[pid].need_reconfig_queues == 0)
8702 ports[pid].need_reconfig_queues = queue;
8707 #ifdef RTE_NIC_BYPASS
8709 bypass_is_supported(portid_t port_id)
8711 struct rte_port *port;
8712 struct rte_pci_id *pci_id;
8714 if (port_id >= nb_ports) {
8715 printf("\tPort id must be less than %d.\n", nb_ports);
8719 /* Get the device id. */
8720 port = &ports[port_id];
8721 pci_id = &port->dev_info.pci_dev->id;
8723 /* Check if NIC supports bypass. */
8724 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
8728 printf("\tBypass not supported for port_id = %d.\n", port_id);