From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC525A04B5; Tue, 27 Oct 2020 13:30:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 78B044C9B; Tue, 27 Oct 2020 13:28:07 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 1228F2C27 for ; Tue, 27 Oct 2020 13:27:53 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from suanmingm@nvidia.com) with SMTP; 27 Oct 2020 14:27:51 +0200 Received: from nvidia.com (mtbc-r640-04.mtbc.labs.mlnx [10.75.70.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RCRZ76024637; Tue, 27 Oct 2020 14:27:49 +0200 From: Suanming Mou To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org Date: Tue, 27 Oct 2020 20:27:03 +0800 Message-Id: <1603801650-442376-9-git-send-email-suanmingm@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603801650-442376-1-git-send-email-suanmingm@nvidia.com> References: <1601984948-313027-1-git-send-email-suanmingm@nvidia.com> <1603801650-442376-1-git-send-email-suanmingm@nvidia.com> Subject: [dpdk-dev] [PATCH v3 08/34] net/mlx5: make VLAN network interface thread safe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit protects the VLAN VM workaround area using a spinlock in multiple-thread flow insertion to make it thread safe. Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/common/mlx5/linux/mlx5_nl.h | 1 + drivers/net/mlx5/linux/mlx5_vlan_os.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/common/mlx5/linux/mlx5_nl.h b/drivers/common/mlx5/linux/mlx5_nl.h index 53021e1..15129ff 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.h +++ b/drivers/common/mlx5/linux/mlx5_nl.h @@ -25,6 +25,7 @@ struct mlx5_nl_vlan_dev { struct mlx5_nl_vlan_vmwa_context { int nl_socket; uint32_t vf_ifindex; + rte_spinlock_t sl; struct mlx5_nl_vlan_dev vlan_dev[4096]; }; diff --git a/drivers/net/mlx5/linux/mlx5_vlan_os.c b/drivers/net/mlx5/linux/mlx5_vlan_os.c index 92fc17d..40e895e 100644 --- a/drivers/net/mlx5/linux/mlx5_vlan_os.c +++ b/drivers/net/mlx5/linux/mlx5_vlan_os.c @@ -44,12 +44,14 @@ if (!vlan->created || !vmwa) return; vlan->created = 0; + rte_spinlock_lock(&vmwa->sl); MLX5_ASSERT(vlan_dev[vlan->tag].refcnt); if (--vlan_dev[vlan->tag].refcnt == 0 && vlan_dev[vlan->tag].ifindex) { mlx5_nl_vlan_vmwa_delete(vmwa, vlan_dev[vlan->tag].ifindex); vlan_dev[vlan->tag].ifindex = 0; } + rte_spinlock_unlock(&vmwa->sl); } /** @@ -72,6 +74,7 @@ MLX5_ASSERT(priv->vmwa_context); if (vlan->created || !vmwa) return; + rte_spinlock_lock(&vmwa->sl); if (vlan_dev[vlan->tag].refcnt == 0) { MLX5_ASSERT(!vlan_dev[vlan->tag].ifindex); vlan_dev[vlan->tag].ifindex = @@ -82,6 +85,7 @@ vlan_dev[vlan->tag].refcnt++; vlan->created = 1; } + rte_spinlock_unlock(&vmwa->sl); } /* @@ -131,6 +135,7 @@ " for VLAN workaround context"); return NULL; } + rte_spinlock_init(&vmwa->sl); vmwa->nl_socket = mlx5_nl_init(NETLINK_ROUTE); if (vmwa->nl_socket < 0) { DRV_LOG(WARNING, -- 1.8.3.1