From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by dpdk.org (Postfix) with ESMTP id 980465960 for ; Tue, 8 Jul 2014 13:16:10 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 08 Jul 2014 04:16:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,625,1400050800"; d="scan'208";a="454423196" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 08 Jul 2014 04:16:29 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s68BGTEJ018706; Tue, 8 Jul 2014 12:16:29 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s68BGTAc031304; Tue, 8 Jul 2014 12:16:29 +0100 Received: (from dtmrzglx@localhost) by sivswdev01.ir.intel.com with id s68BGTQK031236; Tue, 8 Jul 2014 12:16:29 +0100 From: Daniel Mrzyglod To: dev@dpdk.org Date: Tue, 8 Jul 2014 12:16:24 +0100 Message-Id: <1404818184-29388-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] Added Spinlock to l3fwd-vf example to prevent race conditioning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jul 2014 11:16:11 -0000 Signed-off-by: Daniel Mrzyglod --- examples/l3fwd-vf/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c index 2ca5c21..57852d0 100644 --- a/examples/l3fwd-vf/main.c +++ b/examples/l3fwd-vf/main.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -328,7 +329,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) @@ -340,7 +341,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]); -- 1.7.9.5