From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cbtest1.netronome.com (unknown [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 79F693208 for ; Tue, 26 Apr 2016 14:14:22 +0200 (CEST) Received: from cbtest1.netronome.com (localhost [127.0.0.1]) by cbtest1.netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id u3QCEFZq044754 for ; Tue, 26 Apr 2016 13:14:15 +0100 Received: (from alucero@localhost) by cbtest1.netronome.com (8.14.4/8.14.4/Submit) id u3QCEFjU044753 for dev@dpdk.org; Tue, 26 Apr 2016 13:14:15 +0100 From: Alejandro Lucero To: dev@dpdk.org Date: Tue, 26 Apr 2016 13:14:15 +0100 Message-Id: <1461672855-44715-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] nfp: avoiding concurrency when hardware reconfig 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, 26 Apr 2016 12:14:22 -0000 Some apps calling some functions from different threads at the same time could lead to reconfig problems. Reconfig mechanism is based on a hardware queue where incrementing a counter signals the firmware to do the reconfig. If there are two increments before the first one has been processed the firmware will stop and a device reset is necessary. Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfp_net.c | 8 ++++++++ drivers/net/nfp/nfp_net_pmd.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index bc0a3d8..ba0ee04 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -58,6 +58,7 @@ #include "nfp_net_pmd.h" #include "nfp_net_logs.h" #include "nfp_net_ctrl.h" +#include /* Prototypes */ static void nfp_net_close(struct rte_eth_dev *dev); @@ -407,6 +408,8 @@ nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update) PMD_DRV_LOG(DEBUG, "nfp_net_reconfig: ctrl=%08x update=%08x\n", ctrl, update); + rte_spinlock_lock(&hw->reconfig_lock); + nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl); nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update); @@ -414,6 +417,8 @@ nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update) err = __nfp_net_reconfig(hw, update); + rte_spinlock_unlock(&hw->reconfig_lock); + if (!err) return 0; @@ -2399,6 +2404,9 @@ nfp_net_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u\n", hw->max_rx_queues, hw->max_tx_queues); + /* Initializing spinlock for reconfigs */ + rte_spinlock_init(&hw->reconfig_lock); + /* Allocating memory for mac addr */ eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", ETHER_ADDR_LEN, 0); if (eth_dev->data->mac_addrs == NULL) { diff --git a/drivers/net/nfp/nfp_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h index 232ce5c..c180972 100644 --- a/drivers/net/nfp/nfp_net_pmd.h +++ b/drivers/net/nfp/nfp_net_pmd.h @@ -406,6 +406,7 @@ struct nfp_net_hw { int stride_tx; uint8_t *qcp_cfg; + rte_spinlock_t reconfig_lock; uint32_t max_tx_queues; uint32_t max_rx_queues; -- 1.9.1