summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mrzyglod <danielx.t.mrzyglod@intel.com>2014-07-08 12:16:24 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-12-11 01:42:03 +0100
commitc062d3eb71e1a0026256d651d1ff7fcbbc03a2e5 (patch)
tree51f191873aa62d1e66bd24e303cff859bde6d87a
parentc2ab5162dbd8837bf381be4627e3ba8efccf4562 (diff)
downloaddpdk-c062d3eb71e1a0026256d651d1ff7fcbbc03a2e5.zip
dpdk-c062d3eb71e1a0026256d651d1ff7fcbbc03a2e5.tar.gz
dpdk-c062d3eb71e1a0026256d651d1ff7fcbbc03a2e5.tar.xz
examples/l3fwd-vf: fix race condition
When the routing is through the same queue, the app crashed. Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
-rw-r--r--examples/l3fwd-vf/main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 59a7907..7cc7228 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -54,6 +54,7 @@
#include <rte_per_lcore.h>
#include <rte_launch.h>
#include <rte_atomic.h>
+#include <rte_spinlock.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_lcore.h>
@@ -302,7 +303,7 @@ struct lcore_conf {
} __rte_cache_aligned;
static struct lcore_conf lcore_conf[RTE_MAX_LCORE];
-
+static rte_spinlock_t spinlock_conf[RTE_MAX_ETHPORTS] = {RTE_SPINLOCK_INITIALIZER};
/* Send burst of packets on an output interface */
static inline int
send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port)
@@ -314,7 +315,10 @@ send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port)
queueid = qconf->tx_queue_id;
m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
+ rte_spinlock_lock(&spinlock_conf[port]);
ret = rte_eth_tx_burst(port, queueid, m_table, n);
+ rte_spinlock_unlock(&spinlock_conf[port]);
+
if (unlikely(ret < n)) {
do {
rte_pktmbuf_free(m_table[ret]);