4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * Copyright(c) 2013 6WIND.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
41 * * Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * * Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in
45 * the documentation and/or other materials provided with the
47 * * Neither the name of 6WIND S.A. nor the names of its
48 * contributors may be used to endorse or promote products derived
49 * from this software without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72 #include <sys/queue.h>
74 #include <rte_common.h>
75 #include <rte_byteorder.h>
76 #include <rte_debug.h>
78 #include <rte_memory.h>
79 #include <rte_memcpy.h>
80 #include <rte_memzone.h>
81 #include <rte_launch.h>
82 #include <rte_tailq.h>
84 #include <rte_per_lcore.h>
85 #include <rte_lcore.h>
86 #include <rte_atomic.h>
87 #include <rte_branch_prediction.h>
89 #include <rte_mempool.h>
91 #include <rte_interrupts.h>
93 #include <rte_ether.h>
94 #include <rte_ethdev.h>
95 #include <rte_string_fns.h>
100 print_ethaddr(const char *name, struct ether_addr *eth_addr)
102 printf("%s%02X:%02X:%02X:%02X:%02X:%02X", name,
103 eth_addr->addr_bytes[0],
104 eth_addr->addr_bytes[1],
105 eth_addr->addr_bytes[2],
106 eth_addr->addr_bytes[3],
107 eth_addr->addr_bytes[4],
108 eth_addr->addr_bytes[5]);
112 nic_stats_display(portid_t port_id)
114 struct rte_eth_stats stats;
115 struct rte_port *port = &ports[port_id];
118 static const char *nic_stats_border = "########################";
120 if (port_id >= nb_ports) {
121 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
124 rte_eth_stats_get(port_id, &stats);
125 printf("\n %s NIC statistics for port %-2d %s\n",
126 nic_stats_border, port_id, nic_stats_border);
128 if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) {
129 printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64"RX-bytes: "
131 " TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64"TX-bytes: "
133 stats.ipackets, stats.ierrors, stats.ibytes,
134 stats.opackets, stats.oerrors, stats.obytes);
137 printf(" RX-packets: %10"PRIu64" RX-errors: %10"PRIu64
138 " RX-bytes: %10"PRIu64"\n"
139 " TX-packets: %10"PRIu64" TX-errors: %10"PRIu64
140 " TX-bytes: %10"PRIu64"\n",
141 stats.ipackets, stats.ierrors, stats.ibytes,
142 stats.opackets, stats.oerrors, stats.obytes);
146 if (fdir_conf.mode != RTE_FDIR_MODE_NONE)
147 printf(" Fdirmiss: %-10"PRIu64" Fdirmatch: %-10"PRIu64"\n",
151 if (port->rx_queue_stats_mapping_enabled) {
153 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
154 printf(" Stats reg %2d RX-packets: %10"PRIu64
155 " RX-errors: %10"PRIu64
156 " RX-bytes: %10"PRIu64"\n",
157 i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]);
160 if (port->tx_queue_stats_mapping_enabled) {
162 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
163 printf(" Stats reg %2d TX-packets: %10"PRIu64
164 " TX-bytes: %10"PRIu64"\n",
165 i, stats.q_opackets[i], stats.q_obytes[i]);
169 /* Display statistics of XON/XOFF pause frames, if any. */
170 if ((stats.tx_pause_xon | stats.rx_pause_xon |
171 stats.tx_pause_xoff | stats.rx_pause_xoff) > 0) {
172 printf(" RX-XOFF: %-10"PRIu64" RX-XON: %-10"PRIu64"\n",
173 stats.rx_pause_xoff, stats.rx_pause_xon);
174 printf(" TX-XOFF: %-10"PRIu64" TX-XON: %-10"PRIu64"\n",
175 stats.tx_pause_xoff, stats.tx_pause_xon);
177 printf(" %s############################%s\n",
178 nic_stats_border, nic_stats_border);
182 nic_stats_clear(portid_t port_id)
184 if (port_id >= nb_ports) {
185 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
188 rte_eth_stats_reset(port_id);
189 printf("\n NIC statistics for port %d cleared\n", port_id);
194 nic_stats_mapping_display(portid_t port_id)
196 struct rte_port *port = &ports[port_id];
199 static const char *nic_stats_mapping_border = "########################";
201 if (port_id >= nb_ports) {
202 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
206 if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) {
207 printf("Port id %d - either does not support queue statistic mapping or"
208 " no queue statistic mapping set\n", port_id);
212 printf("\n %s NIC statistics mapping for port %-2d %s\n",
213 nic_stats_mapping_border, port_id, nic_stats_mapping_border);
215 if (port->rx_queue_stats_mapping_enabled) {
216 for (i = 0; i < nb_rx_queue_stats_mappings; i++) {
217 if (rx_queue_stats_mappings[i].port_id == port_id) {
218 printf(" RX-queue %2d mapped to Stats Reg %2d\n",
219 rx_queue_stats_mappings[i].queue_id,
220 rx_queue_stats_mappings[i].stats_counter_id);
227 if (port->tx_queue_stats_mapping_enabled) {
228 for (i = 0; i < nb_tx_queue_stats_mappings; i++) {
229 if (tx_queue_stats_mappings[i].port_id == port_id) {
230 printf(" TX-queue %2d mapped to Stats Reg %2d\n",
231 tx_queue_stats_mappings[i].queue_id,
232 tx_queue_stats_mappings[i].stats_counter_id);
237 printf(" %s####################################%s\n",
238 nic_stats_mapping_border, nic_stats_mapping_border);
242 port_infos_display(portid_t port_id)
244 struct rte_port *port;
245 struct rte_eth_link link;
248 struct rte_mempool * mp;
249 static const char *info_border = "*********************";
251 if (port_id >= nb_ports) {
252 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
255 port = &ports[port_id];
256 rte_eth_link_get_nowait(port_id, &link);
257 socket_id = rte_eth_dev_socket_id(port_id);
258 printf("\n%s Infos for port %-2d %s\n",
259 info_border, port_id, info_border);
260 print_ethaddr("MAC address: ", &port->eth_addr);
261 printf("\nConnect to socket: %d",socket_id);
263 if (port_numa[port_id] != NUMA_NO_CONFIG) {
264 mp = mbuf_pool_find(port_numa[port_id]);
266 printf("\nmemory allocation on the socket: %d",
269 printf("\nmemory allocation on the socket: %d",socket_id);
271 printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down"));
272 printf("Link speed: %u Mbps\n", (unsigned) link.link_speed);
273 printf("Link duplex: %s\n", (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
274 ("full-duplex") : ("half-duplex"));
275 printf("Promiscuous mode: %s\n",
276 rte_eth_promiscuous_get(port_id) ? "enabled" : "disabled");
277 printf("Allmulticast mode: %s\n",
278 rte_eth_allmulticast_get(port_id) ? "enabled" : "disabled");
279 printf("Maximum number of MAC addresses: %u\n",
280 (unsigned int)(port->dev_info.max_mac_addrs));
281 printf("Maximum number of MAC addresses of hash filtering: %u\n",
282 (unsigned int)(port->dev_info.max_hash_mac_addrs));
284 vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
285 if (vlan_offload >= 0){
286 printf("VLAN offload: \n");
287 if (vlan_offload & ETH_VLAN_STRIP_OFFLOAD)
288 printf(" strip on \n");
290 printf(" strip off \n");
292 if (vlan_offload & ETH_VLAN_FILTER_OFFLOAD)
293 printf(" filter on \n");
295 printf(" filter off \n");
297 if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)
298 printf(" qinq(extend) on \n");
300 printf(" qinq(extend) off \n");
305 port_id_is_invalid(portid_t port_id)
307 if (port_id < nb_ports)
309 printf("Invalid port %d (must be < nb_ports=%d)\n", port_id, nb_ports);
314 vlan_id_is_invalid(uint16_t vlan_id)
318 printf("Invalid vlan_id %d (must be < 4096)\n", vlan_id);
323 port_reg_off_is_invalid(portid_t port_id, uint32_t reg_off)
328 printf("Port register offset 0x%X not aligned on a 4-byte "
333 pci_len = ports[port_id].dev_info.pci_dev->mem_resource[0].len;
334 if (reg_off >= pci_len) {
335 printf("Port %d: register offset %u (0x%X) out of port PCI "
336 "resource (length=%"PRIu64")\n",
337 port_id, (unsigned)reg_off, (unsigned)reg_off, pci_len);
344 reg_bit_pos_is_invalid(uint8_t bit_pos)
348 printf("Invalid bit position %d (must be <= 31)\n", bit_pos);
352 #define display_port_and_reg_off(port_id, reg_off) \
353 printf("port %d PCI register at offset 0x%X: ", (port_id), (reg_off))
356 display_port_reg_value(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
358 display_port_and_reg_off(port_id, (unsigned)reg_off);
359 printf("0x%08X (%u)\n", (unsigned)reg_v, (unsigned)reg_v);
363 port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_x)
368 if (port_id_is_invalid(port_id))
370 if (port_reg_off_is_invalid(port_id, reg_off))
372 if (reg_bit_pos_is_invalid(bit_x))
374 reg_v = port_id_pci_reg_read(port_id, reg_off);
375 display_port_and_reg_off(port_id, (unsigned)reg_off);
376 printf("bit %d=%d\n", bit_x, (int) ((reg_v & (1 << bit_x)) >> bit_x));
380 port_reg_bit_field_display(portid_t port_id, uint32_t reg_off,
381 uint8_t bit1_pos, uint8_t bit2_pos)
387 if (port_id_is_invalid(port_id))
389 if (port_reg_off_is_invalid(port_id, reg_off))
391 if (reg_bit_pos_is_invalid(bit1_pos))
393 if (reg_bit_pos_is_invalid(bit2_pos))
395 if (bit1_pos > bit2_pos)
396 l_bit = bit2_pos, h_bit = bit1_pos;
398 l_bit = bit1_pos, h_bit = bit2_pos;
400 reg_v = port_id_pci_reg_read(port_id, reg_off);
403 reg_v &= ((1 << (h_bit - l_bit + 1)) - 1);
404 display_port_and_reg_off(port_id, (unsigned)reg_off);
405 printf("bits[%d, %d]=0x%0*X (%u)\n", l_bit, h_bit,
406 ((h_bit - l_bit) / 4) + 1, (unsigned)reg_v, (unsigned)reg_v);
410 port_reg_display(portid_t port_id, uint32_t reg_off)
414 if (port_id_is_invalid(port_id))
416 if (port_reg_off_is_invalid(port_id, reg_off))
418 reg_v = port_id_pci_reg_read(port_id, reg_off);
419 display_port_reg_value(port_id, reg_off, reg_v);
423 port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
428 if (port_id_is_invalid(port_id))
430 if (port_reg_off_is_invalid(port_id, reg_off))
432 if (reg_bit_pos_is_invalid(bit_pos))
435 printf("Invalid bit value %d (must be 0 or 1)\n", (int) bit_v);
438 reg_v = port_id_pci_reg_read(port_id, reg_off);
440 reg_v &= ~(1 << bit_pos);
442 reg_v |= (1 << bit_pos);
443 port_id_pci_reg_write(port_id, reg_off, reg_v);
444 display_port_reg_value(port_id, reg_off, reg_v);
448 port_reg_bit_field_set(portid_t port_id, uint32_t reg_off,
449 uint8_t bit1_pos, uint8_t bit2_pos, uint32_t value)
456 if (port_id_is_invalid(port_id))
458 if (port_reg_off_is_invalid(port_id, reg_off))
460 if (reg_bit_pos_is_invalid(bit1_pos))
462 if (reg_bit_pos_is_invalid(bit2_pos))
464 if (bit1_pos > bit2_pos)
465 l_bit = bit2_pos, h_bit = bit1_pos;
467 l_bit = bit1_pos, h_bit = bit2_pos;
469 if ((h_bit - l_bit) < 31)
470 max_v = (1 << (h_bit - l_bit + 1)) - 1;
475 printf("Invalid value %u (0x%x) must be < %u (0x%x)\n",
476 (unsigned)value, (unsigned)value,
477 (unsigned)max_v, (unsigned)max_v);
480 reg_v = port_id_pci_reg_read(port_id, reg_off);
481 reg_v &= ~(max_v << l_bit); /* Keep unchanged bits */
482 reg_v |= (value << l_bit); /* Set changed bits */
483 port_id_pci_reg_write(port_id, reg_off, reg_v);
484 display_port_reg_value(port_id, reg_off, reg_v);
488 port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
490 if (port_id_is_invalid(port_id))
492 if (port_reg_off_is_invalid(port_id, reg_off))
494 port_id_pci_reg_write(port_id, reg_off, reg_v);
495 display_port_reg_value(port_id, reg_off, reg_v);
499 * RX/TX ring descriptors display functions.
502 rx_queue_id_is_invalid(queueid_t rxq_id)
506 printf("Invalid RX queue %d (must be < nb_rxq=%d)\n", rxq_id, nb_rxq);
511 tx_queue_id_is_invalid(queueid_t txq_id)
515 printf("Invalid TX queue %d (must be < nb_rxq=%d)\n", txq_id, nb_txq);
520 rx_desc_id_is_invalid(uint16_t rxdesc_id)
522 if (rxdesc_id < nb_rxd)
524 printf("Invalid RX descriptor %d (must be < nb_rxd=%d)\n",
530 tx_desc_id_is_invalid(uint16_t txdesc_id)
532 if (txdesc_id < nb_txd)
534 printf("Invalid TX descriptor %d (must be < nb_txd=%d)\n",
539 static const struct rte_memzone *
540 ring_dma_zone_lookup(const char *ring_name, uint8_t port_id, uint16_t q_id)
542 char mz_name[RTE_MEMZONE_NAMESIZE];
543 const struct rte_memzone *mz;
545 rte_snprintf(mz_name, sizeof(mz_name), "%s_%s_%d_%d",
546 ports[port_id].dev_info.driver_name, ring_name, port_id, q_id);
547 mz = rte_memzone_lookup(mz_name);
549 printf("%s ring memory zoneof (port %d, queue %d) not"
550 "found (zone name = %s\n",
551 ring_name, port_id, q_id, mz_name);
555 union igb_ring_dword {
563 struct igb_ring_desc {
564 union igb_ring_dword lo_dword;
565 union igb_ring_dword hi_dword;
569 ring_descriptor_display(const struct rte_memzone *ring_mz, uint16_t desc_id)
571 struct igb_ring_desc *ring;
572 struct igb_ring_desc rd;
574 ring = (struct igb_ring_desc *) ring_mz->addr;
575 rd.lo_dword = rte_le_to_cpu_64(ring[desc_id].lo_dword);
576 rd.hi_dword = rte_le_to_cpu_64(ring[desc_id].hi_dword);
577 printf(" 0x%08X - 0x%08X / 0x%08X - 0x%08X\n",
578 (unsigned)rd.lo_dword.words.lo, (unsigned)rd.lo_dword.words.hi,
579 (unsigned)rd.hi_dword.words.lo, (unsigned)rd.hi_dword.words.hi);
583 rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id)
585 const struct rte_memzone *rx_mz;
587 if (port_id_is_invalid(port_id))
589 if (rx_queue_id_is_invalid(rxq_id))
591 if (rx_desc_id_is_invalid(rxd_id))
593 rx_mz = ring_dma_zone_lookup("rx_ring", port_id, rxq_id);
596 ring_descriptor_display(rx_mz, rxd_id);
600 tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id)
602 const struct rte_memzone *tx_mz;
604 if (port_id_is_invalid(port_id))
606 if (tx_queue_id_is_invalid(txq_id))
608 if (tx_desc_id_is_invalid(txd_id))
610 tx_mz = ring_dma_zone_lookup("tx_ring", port_id, txq_id);
613 ring_descriptor_display(tx_mz, txd_id);
617 fwd_lcores_config_display(void)
621 printf("List of forwarding lcores:");
622 for (lc_id = 0; lc_id < nb_cfg_lcores; lc_id++)
623 printf(" %2u", fwd_lcores_cpuids[lc_id]);
627 rxtx_config_display(void)
629 printf(" %s packet forwarding - CRC stripping %s - "
630 "packets/burst=%d\n", cur_fwd_eng->fwd_mode_name,
631 rx_mode.hw_strip_crc ? "enabled" : "disabled",
634 if (cur_fwd_eng == &tx_only_engine)
635 printf(" packet len=%u - nb packet segments=%d\n",
636 (unsigned)tx_pkt_length, (int) tx_pkt_nb_segs);
638 printf(" nb forwarding cores=%d - nb forwarding ports=%d\n",
639 nb_fwd_lcores, nb_fwd_ports);
640 printf(" RX queues=%d - RX desc=%d - RX free threshold=%d\n",
641 nb_rxq, nb_rxd, rx_free_thresh);
642 printf(" RX threshold registers: pthresh=%d hthresh=%d wthresh=%d\n",
643 rx_thresh.pthresh, rx_thresh.hthresh, rx_thresh.wthresh);
644 printf(" TX queues=%d - TX desc=%d - TX free threshold=%d\n",
645 nb_txq, nb_txd, tx_free_thresh);
646 printf(" TX threshold registers: pthresh=%d hthresh=%d wthresh=%d\n",
647 tx_thresh.pthresh, tx_thresh.hthresh, tx_thresh.wthresh);
648 printf(" TX RS bit threshold=%d - TXQ flags=0x%"PRIx32"\n",
649 tx_rs_thresh, txq_flags);
653 port_rss_reta_info(portid_t port_id,struct rte_eth_rss_reta *reta_conf)
658 if (port_id_is_invalid(port_id))
661 ret = rte_eth_dev_rss_reta_query(port_id, reta_conf);
663 printf("Failed to get RSS RETA info, return code = %d\n", ret);
667 if (reta_conf->mask_lo != 0) {
668 for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
669 if (reta_conf->mask_lo & (uint64_t)(1ULL << i))
670 printf("RSS RETA configuration: hash index=%d,"
671 "queue=%d\n",i,reta_conf->reta[i]);
675 if (reta_conf->mask_hi != 0) {
676 for (i = 0; i< ETH_RSS_RETA_NUM_ENTRIES/2; i++) {
677 if(reta_conf->mask_hi & (uint64_t)(1ULL << i)) {
678 j = (uint8_t)(i + ETH_RSS_RETA_NUM_ENTRIES/2);
679 printf("RSS RETA configuration: hash index=%d,"
680 "queue=%d\n",j,reta_conf->reta[j]);
687 * Setup forwarding configuration for each logical core.
690 setup_fwd_config_of_each_lcore(struct fwd_config *cfg)
692 streamid_t nb_fs_per_lcore;
700 nb_fs = cfg->nb_fwd_streams;
701 nb_fc = cfg->nb_fwd_lcores;
702 if (nb_fs <= nb_fc) {
706 nb_fs_per_lcore = (streamid_t) (nb_fs / nb_fc);
707 nb_extra = (lcoreid_t) (nb_fs % nb_fc);
710 nb_lc = (lcoreid_t) (nb_fc - nb_extra);
712 for (lc_id = 0; lc_id < nb_lc; lc_id++) {
713 fwd_lcores[lc_id]->stream_idx = sm_id;
714 fwd_lcores[lc_id]->stream_nb = nb_fs_per_lcore;
715 sm_id = (streamid_t) (sm_id + nb_fs_per_lcore);
719 * Assign extra remaining streams, if any.
721 nb_fs_per_lcore = (streamid_t) (nb_fs_per_lcore + 1);
722 for (lc_id = 0; lc_id < nb_extra; lc_id++) {
723 fwd_lcores[nb_lc + lc_id]->stream_idx = sm_id;
724 fwd_lcores[nb_lc + lc_id]->stream_nb = nb_fs_per_lcore;
725 sm_id = (streamid_t) (sm_id + nb_fs_per_lcore);
730 simple_fwd_config_setup(void)
736 if (port_topology == PORT_TOPOLOGY_CHAINED) {
738 } else if (nb_fwd_ports % 2) {
739 printf("\nWarning! Cannot handle an odd number of ports "
740 "with the current port topology. Configuration "
741 "must be changed to have an even number of ports, "
742 "or relaunch application with "
743 "--port-topology=chained\n\n");
746 cur_fwd_config.nb_fwd_ports = (portid_t) nb_fwd_ports;
747 cur_fwd_config.nb_fwd_streams =
748 (streamid_t) cur_fwd_config.nb_fwd_ports;
750 /* reinitialize forwarding streams */
754 * In the simple forwarding test, the number of forwarding cores
755 * must be lower or equal to the number of forwarding ports.
757 cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores;
758 if (cur_fwd_config.nb_fwd_lcores > cur_fwd_config.nb_fwd_ports)
759 cur_fwd_config.nb_fwd_lcores =
760 (lcoreid_t) cur_fwd_config.nb_fwd_ports;
761 setup_fwd_config_of_each_lcore(&cur_fwd_config);
763 for (i = 0; i < cur_fwd_config.nb_fwd_ports; i = (portid_t) (i + inc)) {
764 j = (portid_t) ((i + 1) % cur_fwd_config.nb_fwd_ports);
765 fwd_streams[i]->rx_port = fwd_ports_ids[i];
766 fwd_streams[i]->rx_queue = 0;
767 fwd_streams[i]->tx_port = fwd_ports_ids[j];
768 fwd_streams[i]->tx_queue = 0;
769 fwd_streams[i]->peer_addr = j;
771 if (port_topology == PORT_TOPOLOGY_PAIRED) {
772 fwd_streams[j]->rx_port = fwd_ports_ids[j];
773 fwd_streams[j]->rx_queue = 0;
774 fwd_streams[j]->tx_port = fwd_ports_ids[i];
775 fwd_streams[j]->tx_queue = 0;
776 fwd_streams[j]->peer_addr = i;
782 * For the RSS forwarding test, each core is assigned on every port a transmit
783 * queue whose index is the index of the core itself. This approach limits the
784 * maximumm number of processing cores of the RSS test to the maximum number of
785 * TX queues supported by the devices.
787 * Each core is assigned a single stream, each stream being composed of
788 * a RX queue to poll on a RX port for input messages, associated with
789 * a TX queue of a TX port where to send forwarded packets.
790 * All packets received on the RX queue of index "RxQj" of the RX port "RxPi"
791 * are sent on the TX queue "TxQl" of the TX port "TxPk" according to the two
793 * - TxPk = (RxPi + 1) if RxPi is even, (RxPi - 1) if RxPi is odd
797 rss_fwd_config_setup(void)
808 cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores;
809 cur_fwd_config.nb_fwd_ports = nb_fwd_ports;
810 cur_fwd_config.nb_fwd_streams =
811 (streamid_t) (nb_q * cur_fwd_config.nb_fwd_ports);
812 if (cur_fwd_config.nb_fwd_streams > cur_fwd_config.nb_fwd_lcores)
813 cur_fwd_config.nb_fwd_streams =
814 (streamid_t)cur_fwd_config.nb_fwd_lcores;
816 cur_fwd_config.nb_fwd_lcores =
817 (lcoreid_t)cur_fwd_config.nb_fwd_streams;
819 /* reinitialize forwarding streams */
822 setup_fwd_config_of_each_lcore(&cur_fwd_config);
824 for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) {
825 struct fwd_stream *fs;
827 fs = fwd_streams[lc_id];
828 if ((rxp & 0x1) == 0)
829 txp = (portid_t) (rxp + 1);
831 txp = (portid_t) (rxp - 1);
832 fs->rx_port = fwd_ports_ids[rxp];
834 fs->tx_port = fwd_ports_ids[txp];
836 fs->peer_addr = fs->tx_port;
837 rxq = (queueid_t) (rxq + 1);
842 * Restart from RX queue 0 on next RX port
845 if (numa_support && (nb_fwd_ports <= (nb_ports >> 1)))
847 (rxp + ((nb_ports >> 1) / nb_fwd_ports));
849 rxp = (portid_t) (rxp + 1);
854 * In DCB and VT on,the mapping of 128 receive queues to 128 transmit queues.
857 dcb_rxq_2_txq_mapping(queueid_t rxq, queueid_t *txq)
859 if(dcb_q_mapping == DCB_4_TCS_Q_MAPPING) {
866 *txq = (uint16_t)(rxq + 32);
869 /* tc2: 96-111;tc3:112-127 */
870 *txq = (uint16_t)(rxq/2 + 64);
879 *txq = (uint16_t)(rxq + 16);
883 *txq = (uint16_t)(rxq + 32);
886 /* tc4,tc5,tc6 and tc7 mapping */
887 *txq = (uint16_t)(rxq/2 + 64);
893 * For the DCB forwarding test, each core is assigned on every port multi-transmit
896 * Each core is assigned a multi-stream, each stream being composed of
897 * a RX queue to poll on a RX port for input messages, associated with
898 * a TX queue of a TX port where to send forwarded packets.
899 * All packets received on the RX queue of index "RxQj" of the RX port "RxPi"
900 * are sent on the TX queue "TxQl" of the TX port "TxPk" according to the two
903 * - TxPk = (RxPi + 1) if RxPi is even, (RxPi - 1) if RxPi is odd
906 * - TxPk = (RxPi + 1) if RxPi is even, (RxPi - 1) if RxPi is odd
907 * There is a mapping of RxQj to TxQl to be required,and the mapping was implemented
908 * in dcb_rxq_2_txq_mapping function.
911 dcb_fwd_config_setup(void)
922 cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores;
923 cur_fwd_config.nb_fwd_ports = nb_fwd_ports;
924 cur_fwd_config.nb_fwd_streams =
925 (streamid_t) (nb_q * cur_fwd_config.nb_fwd_ports);
927 /* reinitialize forwarding streams */
930 setup_fwd_config_of_each_lcore(&cur_fwd_config);
932 for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) {
933 /* a fwd core can run multi-streams */
934 for (sm_id = 0; sm_id < fwd_lcores[lc_id]->stream_nb; sm_id++)
936 struct fwd_stream *fs;
937 fs = fwd_streams[fwd_lcores[lc_id]->stream_idx + sm_id];
938 if ((rxp & 0x1) == 0)
939 txp = (portid_t) (rxp + 1);
941 txp = (portid_t) (rxp - 1);
942 fs->rx_port = fwd_ports_ids[rxp];
944 fs->tx_port = fwd_ports_ids[txp];
945 if (dcb_q_mapping == DCB_VT_Q_MAPPING)
948 dcb_rxq_2_txq_mapping(rxq, &fs->tx_queue);
949 fs->peer_addr = fs->tx_port;
950 rxq = (queueid_t) (rxq + 1);
954 if (numa_support && (nb_fwd_ports <= (nb_ports >> 1)))
956 (rxp + ((nb_ports >> 1) / nb_fwd_ports));
958 rxp = (portid_t) (rxp + 1);
964 fwd_config_setup(void)
966 cur_fwd_config.fwd_eng = cur_fwd_eng;
967 if ((nb_rxq > 1) && (nb_txq > 1)){
969 dcb_fwd_config_setup();
971 rss_fwd_config_setup();
974 simple_fwd_config_setup();
978 pkt_fwd_config_display(struct fwd_config *cfg)
980 struct fwd_stream *fs;
984 printf("%s packet forwarding - ports=%d - cores=%d - streams=%d - "
985 "NUMA support %s, MP over anonymous pages %s\n",
986 cfg->fwd_eng->fwd_mode_name,
987 cfg->nb_fwd_ports, cfg->nb_fwd_lcores, cfg->nb_fwd_streams,
988 numa_support == 1 ? "enabled" : "disabled",
989 mp_anon != 0 ? "enabled" : "disabled");
991 if (strcmp(cfg->fwd_eng->fwd_mode_name, "mac_retry") == 0)
992 printf("TX retry num: %u, delay between TX retries: %uus\n",
993 burst_tx_retry_num, burst_tx_delay_time);
994 for (lc_id = 0; lc_id < cfg->nb_fwd_lcores; lc_id++) {
995 printf("Logical Core %u (socket %u) forwards packets on "
997 fwd_lcores_cpuids[lc_id],
998 rte_lcore_to_socket_id(fwd_lcores_cpuids[lc_id]),
999 fwd_lcores[lc_id]->stream_nb);
1000 for (sm_id = 0; sm_id < fwd_lcores[lc_id]->stream_nb; sm_id++) {
1001 fs = fwd_streams[fwd_lcores[lc_id]->stream_idx + sm_id];
1002 printf("\n RX P=%d/Q=%d (socket %u) -> TX "
1003 "P=%d/Q=%d (socket %u) ",
1004 fs->rx_port, fs->rx_queue,
1005 ports[fs->rx_port].socket_id,
1006 fs->tx_port, fs->tx_queue,
1007 ports[fs->tx_port].socket_id);
1008 print_ethaddr("peer=",
1009 &peer_eth_addrs[fs->peer_addr]);
1018 fwd_config_display(void)
1020 if((dcb_config) && (nb_fwd_lcores == 1)) {
1021 printf("In DCB mode,the nb forwarding cores should be larger than 1\n");
1025 pkt_fwd_config_display(&cur_fwd_config);
1029 set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc)
1032 unsigned int lcore_cpuid;
1037 for (i = 0; i < nb_lc; i++) {
1038 lcore_cpuid = lcorelist[i];
1039 if (! rte_lcore_is_enabled(lcore_cpuid)) {
1040 printf("lcore %u not enabled\n", lcore_cpuid);
1043 if (lcore_cpuid == rte_get_master_lcore()) {
1044 printf("lcore %u cannot be masked on for running "
1045 "packet forwarding, which is the master lcore "
1046 "and reserved for command line parsing only\n",
1051 fwd_lcores_cpuids[i] = lcore_cpuid;
1053 if (record_now == 0) {
1057 nb_cfg_lcores = (lcoreid_t) nb_lc;
1058 if (nb_fwd_lcores != (lcoreid_t) nb_lc) {
1059 printf("previous number of forwarding cores %u - changed to "
1060 "number of configured cores %u\n",
1061 (unsigned int) nb_fwd_lcores, nb_lc);
1062 nb_fwd_lcores = (lcoreid_t) nb_lc;
1069 set_fwd_lcores_mask(uint64_t lcoremask)
1071 unsigned int lcorelist[64];
1075 if (lcoremask == 0) {
1076 printf("Invalid NULL mask of cores\n");
1080 for (i = 0; i < 64; i++) {
1081 if (! ((uint64_t)(1ULL << i) & lcoremask))
1083 lcorelist[nb_lc++] = i;
1085 return set_fwd_lcores_list(lcorelist, nb_lc);
1089 set_fwd_lcores_number(uint16_t nb_lc)
1091 if (nb_lc > nb_cfg_lcores) {
1092 printf("nb fwd cores %u > %u (max. number of configured "
1093 "lcores) - ignored\n",
1094 (unsigned int) nb_lc, (unsigned int) nb_cfg_lcores);
1097 nb_fwd_lcores = (lcoreid_t) nb_lc;
1098 printf("Number of forwarding cores set to %u\n",
1099 (unsigned int) nb_fwd_lcores);
1103 set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt)
1111 for (i = 0; i < nb_pt; i++) {
1112 port_id = (portid_t) portlist[i];
1113 if (port_id >= nb_ports) {
1114 printf("Invalid port id %u >= %u\n",
1115 (unsigned int) port_id,
1116 (unsigned int) nb_ports);
1120 fwd_ports_ids[i] = port_id;
1122 if (record_now == 0) {
1126 nb_cfg_ports = (portid_t) nb_pt;
1127 if (nb_fwd_ports != (portid_t) nb_pt) {
1128 printf("previous number of forwarding ports %u - changed to "
1129 "number of configured ports %u\n",
1130 (unsigned int) nb_fwd_ports, nb_pt);
1131 nb_fwd_ports = (portid_t) nb_pt;
1136 set_fwd_ports_mask(uint64_t portmask)
1138 unsigned int portlist[64];
1142 if (portmask == 0) {
1143 printf("Invalid NULL mask of ports\n");
1147 for (i = 0; i < 64; i++) {
1148 if (! ((uint64_t)(1ULL << i) & portmask))
1150 portlist[nb_pt++] = i;
1152 set_fwd_ports_list(portlist, nb_pt);
1156 set_fwd_ports_number(uint16_t nb_pt)
1158 if (nb_pt > nb_cfg_ports) {
1159 printf("nb fwd ports %u > %u (number of configured "
1160 "ports) - ignored\n",
1161 (unsigned int) nb_pt, (unsigned int) nb_cfg_ports);
1164 nb_fwd_ports = (portid_t) nb_pt;
1165 printf("Number of forwarding ports set to %u\n",
1166 (unsigned int) nb_fwd_ports);
1170 set_nb_pkt_per_burst(uint16_t nb)
1172 if (nb > MAX_PKT_BURST) {
1173 printf("nb pkt per burst: %u > %u (maximum packet per burst) "
1175 (unsigned int) nb, (unsigned int) MAX_PKT_BURST);
1178 nb_pkt_per_burst = nb;
1179 printf("Number of packets per burst set to %u\n",
1180 (unsigned int) nb_pkt_per_burst);
1184 set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs)
1186 uint16_t tx_pkt_len;
1189 if (nb_segs >= (unsigned) nb_txd) {
1190 printf("nb segments per TX packets=%u >= nb_txd=%u - ignored\n",
1191 nb_segs, (unsigned int) nb_txd);
1196 * Check that each segment length is greater or equal than
1197 * the mbuf data sise.
1198 * Check also that the total packet length is greater or equal than the
1199 * size of an empty UDP/IP packet (sizeof(struct ether_hdr) + 20 + 8).
1202 for (i = 0; i < nb_segs; i++) {
1203 if (seg_lengths[i] > (unsigned) mbuf_data_size) {
1204 printf("length[%u]=%u > mbuf_data_size=%u - give up\n",
1205 i, seg_lengths[i], (unsigned) mbuf_data_size);
1208 tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]);
1210 if (tx_pkt_len < (sizeof(struct ether_hdr) + 20 + 8)) {
1211 printf("total packet length=%u < %d - give up\n",
1212 (unsigned) tx_pkt_len,
1213 (int)(sizeof(struct ether_hdr) + 20 + 8));
1217 for (i = 0; i < nb_segs; i++)
1218 tx_pkt_seg_lengths[i] = (uint16_t) seg_lengths[i];
1220 tx_pkt_length = tx_pkt_len;
1221 tx_pkt_nb_segs = (uint8_t) nb_segs;
1225 set_pkt_forwarding_mode(const char *fwd_mode_name)
1227 struct fwd_engine *fwd_eng;
1231 while ((fwd_eng = fwd_engines[i]) != NULL) {
1232 if (! strcmp(fwd_eng->fwd_mode_name, fwd_mode_name)) {
1233 printf("Set %s packet forwarding mode\n",
1235 cur_fwd_eng = fwd_eng;
1240 printf("Invalid %s packet forwarding mode\n", fwd_mode_name);
1244 set_verbose_level(uint16_t vb_level)
1246 printf("Change verbose level from %u to %u\n",
1247 (unsigned int) verbose_level, (unsigned int) vb_level);
1248 verbose_level = vb_level;
1252 vlan_extend_set(portid_t port_id, int on)
1257 if (port_id_is_invalid(port_id))
1260 vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
1263 vlan_offload |= ETH_VLAN_EXTEND_OFFLOAD;
1265 vlan_offload &= ~ETH_VLAN_EXTEND_OFFLOAD;
1267 diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload);
1269 printf("rx_vlan_extend_set(port_pi=%d, on=%d) failed "
1270 "diag=%d\n", port_id, on, diag);
1274 rx_vlan_strip_set(portid_t port_id, int on)
1279 if (port_id_is_invalid(port_id))
1282 vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
1285 vlan_offload |= ETH_VLAN_STRIP_OFFLOAD;
1287 vlan_offload &= ~ETH_VLAN_STRIP_OFFLOAD;
1289 diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload);
1291 printf("rx_vlan_strip_set(port_pi=%d, on=%d) failed "
1292 "diag=%d\n", port_id, on, diag);
1296 rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on)
1300 if (port_id_is_invalid(port_id))
1303 diag = rte_eth_dev_set_vlan_strip_on_queue(port_id, queue_id, on);
1305 printf("rx_vlan_strip_set_on_queue(port_pi=%d, queue_id=%d, on=%d) failed "
1306 "diag=%d\n", port_id, queue_id, on, diag);
1310 rx_vlan_filter_set(portid_t port_id, int on)
1315 if (port_id_is_invalid(port_id))
1318 vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
1321 vlan_offload |= ETH_VLAN_FILTER_OFFLOAD;
1323 vlan_offload &= ~ETH_VLAN_FILTER_OFFLOAD;
1325 diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload);
1327 printf("rx_vlan_filter_set(port_pi=%d, on=%d) failed "
1328 "diag=%d\n", port_id, on, diag);
1332 rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
1336 if (port_id_is_invalid(port_id))
1338 if (vlan_id_is_invalid(vlan_id))
1340 diag = rte_eth_dev_vlan_filter(port_id, vlan_id, on);
1343 printf("rte_eth_dev_vlan_filter(port_pi=%d, vlan_id=%d, on=%d) failed "
1345 port_id, vlan_id, on, diag);
1349 rx_vlan_all_filter_set(portid_t port_id, int on)
1353 if (port_id_is_invalid(port_id))
1355 for (vlan_id = 0; vlan_id < 4096; vlan_id++)
1356 rx_vft_set(port_id, vlan_id, on);
1360 vlan_tpid_set(portid_t port_id, uint16_t tp_id)
1363 if (port_id_is_invalid(port_id))
1366 diag = rte_eth_dev_set_vlan_ether_type(port_id, tp_id);
1370 printf("tx_vlan_tpid_set(port_pi=%d, tpid=%d) failed "
1372 port_id, tp_id, diag);
1376 tx_vlan_set(portid_t port_id, uint16_t vlan_id)
1378 if (port_id_is_invalid(port_id))
1380 if (vlan_id_is_invalid(vlan_id))
1382 ports[port_id].tx_ol_flags |= PKT_TX_VLAN_PKT;
1383 ports[port_id].tx_vlan_id = vlan_id;
1387 tx_vlan_reset(portid_t port_id)
1389 if (port_id_is_invalid(port_id))
1391 ports[port_id].tx_ol_flags &= ~PKT_TX_VLAN_PKT;
1395 set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value)
1398 uint8_t existing_mapping_found = 0;
1400 if (port_id_is_invalid(port_id))
1403 if (is_rx ? (rx_queue_id_is_invalid(queue_id)) : (tx_queue_id_is_invalid(queue_id)))
1406 if (map_value >= RTE_ETHDEV_QUEUE_STAT_CNTRS) {
1407 printf("map_value not in required range 0..%d\n",
1408 RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
1412 if (!is_rx) { /*then tx*/
1413 for (i = 0; i < nb_tx_queue_stats_mappings; i++) {
1414 if ((tx_queue_stats_mappings[i].port_id == port_id) &&
1415 (tx_queue_stats_mappings[i].queue_id == queue_id)) {
1416 tx_queue_stats_mappings[i].stats_counter_id = map_value;
1417 existing_mapping_found = 1;
1421 if (!existing_mapping_found) { /* A new additional mapping... */
1422 tx_queue_stats_mappings[nb_tx_queue_stats_mappings].port_id = port_id;
1423 tx_queue_stats_mappings[nb_tx_queue_stats_mappings].queue_id = queue_id;
1424 tx_queue_stats_mappings[nb_tx_queue_stats_mappings].stats_counter_id = map_value;
1425 nb_tx_queue_stats_mappings++;
1429 for (i = 0; i < nb_rx_queue_stats_mappings; i++) {
1430 if ((rx_queue_stats_mappings[i].port_id == port_id) &&
1431 (rx_queue_stats_mappings[i].queue_id == queue_id)) {
1432 rx_queue_stats_mappings[i].stats_counter_id = map_value;
1433 existing_mapping_found = 1;
1437 if (!existing_mapping_found) { /* A new additional mapping... */
1438 rx_queue_stats_mappings[nb_rx_queue_stats_mappings].port_id = port_id;
1439 rx_queue_stats_mappings[nb_rx_queue_stats_mappings].queue_id = queue_id;
1440 rx_queue_stats_mappings[nb_rx_queue_stats_mappings].stats_counter_id = map_value;
1441 nb_rx_queue_stats_mappings++;
1447 tx_cksum_set(portid_t port_id, uint8_t cksum_mask)
1449 uint16_t tx_ol_flags;
1450 if (port_id_is_invalid(port_id))
1452 /* Clear last 4 bits and then set L3/4 checksum mask again */
1453 tx_ol_flags = (uint16_t) (ports[port_id].tx_ol_flags & 0xFFF0);
1454 ports[port_id].tx_ol_flags = (uint16_t) ((cksum_mask & 0xf) | tx_ol_flags);
1458 fdir_add_signature_filter(portid_t port_id, uint8_t queue_id,
1459 struct rte_fdir_filter *fdir_filter)
1463 if (port_id_is_invalid(port_id))
1466 diag = rte_eth_dev_fdir_add_signature_filter(port_id, fdir_filter,
1471 printf("rte_eth_dev_fdir_add_signature_filter for port_id=%d failed "
1472 "diag=%d\n", port_id, diag);
1476 fdir_update_signature_filter(portid_t port_id, uint8_t queue_id,
1477 struct rte_fdir_filter *fdir_filter)
1481 if (port_id_is_invalid(port_id))
1484 diag = rte_eth_dev_fdir_update_signature_filter(port_id, fdir_filter,
1489 printf("rte_eth_dev_fdir_update_signature_filter for port_id=%d failed "
1490 "diag=%d\n", port_id, diag);
1494 fdir_remove_signature_filter(portid_t port_id,
1495 struct rte_fdir_filter *fdir_filter)
1499 if (port_id_is_invalid(port_id))
1502 diag = rte_eth_dev_fdir_remove_signature_filter(port_id, fdir_filter);
1506 printf("rte_eth_dev_fdir_add_signature_filter for port_id=%d failed "
1507 "diag=%d\n", port_id, diag);
1512 fdir_get_infos(portid_t port_id)
1514 struct rte_eth_fdir fdir_infos;
1516 static const char *fdir_stats_border = "########################";
1518 if (port_id_is_invalid(port_id))
1521 rte_eth_dev_fdir_get_infos(port_id, &fdir_infos);
1523 printf("\n %s FDIR infos for port %-2d %s\n",
1524 fdir_stats_border, port_id, fdir_stats_border);
1526 printf(" collision: %-10"PRIu64" free: %"PRIu64"\n"
1527 " maxhash: %-10"PRIu64" maxlen: %"PRIu64"\n"
1528 " add: %-10"PRIu64" remove: %"PRIu64"\n"
1529 " f_add: %-10"PRIu64" f_remove: %"PRIu64"\n",
1530 (uint64_t)(fdir_infos.collision), (uint64_t)(fdir_infos.free),
1531 (uint64_t)(fdir_infos.maxhash), (uint64_t)(fdir_infos.maxlen),
1532 fdir_infos.add, fdir_infos.remove,
1533 fdir_infos.f_add, fdir_infos.f_remove);
1534 printf(" %s############################%s\n",
1535 fdir_stats_border, fdir_stats_border);
1539 fdir_add_perfect_filter(portid_t port_id, uint16_t soft_id, uint8_t queue_id,
1540 uint8_t drop, struct rte_fdir_filter *fdir_filter)
1544 if (port_id_is_invalid(port_id))
1547 diag = rte_eth_dev_fdir_add_perfect_filter(port_id, fdir_filter,
1548 soft_id, queue_id, drop);
1552 printf("rte_eth_dev_fdir_add_perfect_filter for port_id=%d failed "
1553 "diag=%d\n", port_id, diag);
1557 fdir_update_perfect_filter(portid_t port_id, uint16_t soft_id, uint8_t queue_id,
1558 uint8_t drop, struct rte_fdir_filter *fdir_filter)
1562 if (port_id_is_invalid(port_id))
1565 diag = rte_eth_dev_fdir_update_perfect_filter(port_id, fdir_filter,
1566 soft_id, queue_id, drop);
1570 printf("rte_eth_dev_fdir_update_perfect_filter for port_id=%d failed "
1571 "diag=%d\n", port_id, diag);
1575 fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id,
1576 struct rte_fdir_filter *fdir_filter)
1580 if (port_id_is_invalid(port_id))
1583 diag = rte_eth_dev_fdir_remove_perfect_filter(port_id, fdir_filter,
1588 printf("rte_eth_dev_fdir_update_perfect_filter for port_id=%d failed "
1589 "diag=%d\n", port_id, diag);
1593 fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks)
1597 if (port_id_is_invalid(port_id))
1600 diag = rte_eth_dev_fdir_set_masks(port_id, fdir_masks);
1604 printf("rte_eth_dev_set_masks_filter for port_id=%d failed "
1605 "diag=%d\n", port_id, diag);
1609 set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on)
1613 if (port_id_is_invalid(port_id))
1616 diag = rte_eth_dev_set_vf_rx(port_id,vf,on);
1618 diag = rte_eth_dev_set_vf_tx(port_id,vf,on);
1622 printf("rte_eth_dev_set_vf_rx for port_id=%d failed "
1623 "diag=%d\n", port_id, diag);
1625 printf("rte_eth_dev_set_vf_tx for port_id=%d failed "
1626 "diag=%d\n", port_id, diag);
1631 set_vf_rx_vlan(portid_t port_id, uint16_t vlan_id, uint64_t vf_mask, uint8_t on)
1635 if (port_id_is_invalid(port_id))
1637 if (vlan_id_is_invalid(vlan_id))
1639 diag = rte_eth_dev_set_vf_vlan_filter(port_id, vlan_id, vf_mask, on);
1642 printf("rte_eth_dev_set_vf_vlan_filter for port_id=%d failed "
1643 "diag=%d\n", port_id, diag);