git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/sfc: check mbufs allocated using mempool API for Rx
[dpdk.git]
/
examples
/
packet_ordering
/
main.c
diff --git
a/examples/packet_ordering/main.c
b/examples/packet_ordering/main.c
index
88f0493
..
149bfdd
100644
(file)
--- a/
examples/packet_ordering/main.c
+++ b/
examples/packet_ordering/main.c
@@
-16,8
+16,8
@@
#include <rte_ring.h>
#include <rte_reorder.h>
#include <rte_ring.h>
#include <rte_reorder.h>
-#define RX_DESC_PER_QUEUE 1
28
-#define TX_DESC_PER_QUEUE
512
+#define RX_DESC_PER_QUEUE 1
024
+#define TX_DESC_PER_QUEUE
1024
#define MAX_PKTS_BURST 32
#define REORDER_BUFFER_SIZE 8192
#define MAX_PKTS_BURST 32
#define REORDER_BUFFER_SIZE 8192
@@
-207,11
+207,10
@@
flush_tx_error_callback(struct rte_mbuf **unsent, uint16_t count,
static inline int
free_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[]) {
static inline int
free_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[]) {
- const uint8_t nb_ports = rte_eth_dev_count();
- unsigned port_id;
+ uint16_t port_id;
/* initialize buffers for all ports */
/* initialize buffers for all ports */
-
for (port_id = 0; port_id < nb_ports; port_id++
) {
+
RTE_ETH_FOREACH_DEV(port_id
) {
/* skip ports that are not enabled */
if ((portmask & (1 << port_id)) == 0)
continue;
/* skip ports that are not enabled */
if ((portmask & (1 << port_id)) == 0)
continue;
@@
-224,12
+223,11
@@
free_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[]) {
static inline int
configure_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[])
{
static inline int
configure_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[])
{
- const uint8_t nb_ports = rte_eth_dev_count();
- unsigned port_id;
+ uint16_t port_id;
int ret;
/* initialize buffers for all ports */
int ret;
/* initialize buffers for all ports */
-
for (port_id = 0; port_id < nb_ports; port_id++
) {
+
RTE_ETH_FOREACH_DEV(port_id
) {
/* skip ports that are not enabled */
if ((portmask & (1 << port_id)) == 0)
continue;
/* skip ports that are not enabled */
if ((portmask & (1 << port_id)) == 0)
continue;
@@
-259,15
+257,21
@@
configure_eth_port(uint16_t port_id)
{
struct ether_addr addr;
const uint16_t rxRings = 1, txRings = 1;
{
struct ether_addr addr;
const uint16_t rxRings = 1, txRings = 1;
- const uint8_t nb_ports = rte_eth_dev_count();
int ret;
uint16_t q;
uint16_t nb_rxd = RX_DESC_PER_QUEUE;
uint16_t nb_txd = TX_DESC_PER_QUEUE;
int ret;
uint16_t q;
uint16_t nb_rxd = RX_DESC_PER_QUEUE;
uint16_t nb_txd = TX_DESC_PER_QUEUE;
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_txconf txconf;
+ struct rte_eth_conf port_conf = port_conf_default;
- if (
port_id > nb_ports
)
+ if (
!rte_eth_dev_is_valid_port(port_id)
)
return -1;
return -1;
+ rte_eth_dev_info_get(port_id, &dev_info);
+ if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+ port_conf.txmode.offloads |=
+ DEV_TX_OFFLOAD_MBUF_FAST_FREE;
ret = rte_eth_dev_configure(port_id, rxRings, txRings, &port_conf_default);
if (ret != 0)
return ret;
ret = rte_eth_dev_configure(port_id, rxRings, txRings, &port_conf_default);
if (ret != 0)
return ret;
@@
-284,9
+288,11
@@
configure_eth_port(uint16_t port_id)
return ret;
}
return ret;
}
+ txconf = dev_info.default_txconf;
+ txconf.offloads = port_conf.txmode.offloads;
for (q = 0; q < txRings; q++) {
ret = rte_eth_tx_queue_setup(port_id, q, nb_txd,
for (q = 0; q < txRings; q++) {
ret = rte_eth_tx_queue_setup(port_id, q, nb_txd,
- rte_eth_dev_socket_id(port_id),
NULL
);
+ rte_eth_dev_socket_id(port_id),
&txconf
);
if (ret < 0)
return ret;
}
if (ret < 0)
return ret;
}
@@
-311,8
+317,7
@@
configure_eth_port(uint16_t port_id)
static void
print_stats(void)
{
static void
print_stats(void)
{
- const uint8_t nb_ports = rte_eth_dev_count();
- unsigned i;
+ uint16_t i;
struct rte_eth_stats eth_stats;
printf("\nRX thread stats:\n");
struct rte_eth_stats eth_stats;
printf("\nRX thread stats:\n");
@@
-341,7
+346,7
@@
print_stats(void)
printf(" - Pkts tx failed w/o reorder: %"PRIu64"\n",
app_stats.tx.early_pkts_tx_failed_woro);
printf(" - Pkts tx failed w/o reorder: %"PRIu64"\n",
app_stats.tx.early_pkts_tx_failed_woro);
-
for (i = 0; i < nb_ports; i++
) {
+
RTE_ETH_FOREACH_DEV(i
) {
rte_eth_stats_get(i, ð_stats);
printf("\nPort %u stats:\n", i);
printf(" - Pkts in: %"PRIu64"\n", eth_stats.ipackets);
rte_eth_stats_get(i, ð_stats);
printf("\nPort %u stats:\n", i);
printf(" - Pkts in: %"PRIu64"\n", eth_stats.ipackets);
@@
-369,7
+374,6
@@
int_handler(int sig_num)
static int
rx_thread(struct rte_ring *ring_out)
{
static int
rx_thread(struct rte_ring *ring_out)
{
- const uint8_t nb_ports = rte_eth_dev_count();
uint32_t seqn = 0;
uint16_t i, ret = 0;
uint16_t nb_rx_pkts;
uint32_t seqn = 0;
uint16_t i, ret = 0;
uint16_t nb_rx_pkts;
@@
-381,7
+385,7
@@
rx_thread(struct rte_ring *ring_out)
while (!quit_signal) {
while (!quit_signal) {
-
for (port_id = 0; port_id < nb_ports; port_id++
) {
+
RTE_ETH_FOREACH_DEV(port_id
) {
if ((portmask & (1 << port_id)) != 0) {
/* receive packets */
if ((portmask & (1 << port_id)) != 0) {
/* receive packets */
@@
-421,7
+425,7
@@
rx_thread(struct rte_ring *ring_out)
static int
worker_thread(void *args_ptr)
{
static int
worker_thread(void *args_ptr)
{
- const uint
8_t nb_ports = rte_eth_dev_count
();
+ const uint
16_t nb_ports = rte_eth_dev_count_avail
();
uint16_t i, ret = 0;
uint16_t burst_size = 0;
struct worker_thread_args *args;
uint16_t i, ret = 0;
uint16_t burst_size = 0;
struct worker_thread_args *args;
@@
-635,7
+639,7
@@
main(int argc, char **argv)
"1 lcore for packet TX\n"
"and at least 1 lcore for worker threads\n");
"1 lcore for packet TX\n"
"and at least 1 lcore for worker threads\n");
- nb_ports = rte_eth_dev_count();
+ nb_ports = rte_eth_dev_count
_avail
();
if (nb_ports == 0)
rte_exit(EXIT_FAILURE, "Error: no ethernet ports detected\n");
if (nb_ports != 1 && (nb_ports & 1))
if (nb_ports == 0)
rte_exit(EXIT_FAILURE, "Error: no ethernet ports detected\n");
if (nb_ports != 1 && (nb_ports & 1))
@@
-651,7
+655,7
@@
main(int argc, char **argv)
nb_ports_available = nb_ports;
/* initialize all ports */
nb_ports_available = nb_ports;
/* initialize all ports */
-
for (port_id = 0; port_id < nb_ports; port_id++
) {
+
RTE_ETH_FOREACH_DEV(port_id
) {
/* skip ports that are not enabled */
if ((portmask & (1 << port_id)) == 0) {
printf("\nSkipping disabled port %d\n", port_id);
/* skip ports that are not enabled */
if ((portmask & (1 << port_id)) == 0) {
printf("\nSkipping disabled port %d\n", port_id);