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 366EDA04DD; Wed, 28 Oct 2020 10:45:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB45BCA86; Wed, 28 Oct 2020 10:37:40 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 6578EC9FE for ; Wed, 28 Oct 2020 10:35:14 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from suanmingm@nvidia.com) with SMTP; 28 Oct 2020 11:35:09 +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 09S9Y0SF014036; Wed, 28 Oct 2020 11:35:08 +0200 From: Suanming Mou To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org, rasland@nvidia.com Date: Wed, 28 Oct 2020 17:33:52 +0800 Message-Id: <1603877633-293405-34-git-send-email-suanmingm@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603877633-293405-1-git-send-email-suanmingm@nvidia.com> References: <1601984948-313027-1-git-send-email-suanmingm@nvidia.com> <1603877633-293405-1-git-send-email-suanmingm@nvidia.com> Subject: [dpdk-dev] [PATCH v5 33/34] net/mlx5: make shared action list 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 uses spinlock to protect the shared action list in multiple thread. Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 5856981..8612cab 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1534,6 +1534,7 @@ } priv->mreg_cp_tbl->ctx = eth_dev; } + rte_spinlock_init(&priv->shared_act_sl); mlx5_flow_counter_mode_config(eth_dev); return eth_dev; error: diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index ac7a026..be21a9a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -912,6 +912,7 @@ struct mlx5_priv { uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id; /* ID of a multi-process process */ LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */ + rte_spinlock_t shared_act_sl; /* Shared actions spinlock. */ LIST_HEAD(shared_action, rte_flow_shared_action) shared_actions; /* shared actions */ }; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 08bbc5d..cf48402 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -11191,7 +11191,9 @@ struct mlx5_cache_entry * if (shared_action) { __atomic_add_fetch(&shared_action->refcnt, 1, __ATOMIC_RELAXED); + rte_spinlock_lock(&priv->shared_act_sl); LIST_INSERT_HEAD(&priv->shared_actions, shared_action, next); + rte_spinlock_unlock(&priv->shared_act_sl); } return shared_action; } @@ -11218,6 +11220,7 @@ struct mlx5_cache_entry * struct rte_flow_shared_action *action, struct rte_flow_error *error) { + struct mlx5_priv *priv = dev->data->dev_private; int ret; switch (action->type) { @@ -11232,7 +11235,9 @@ struct mlx5_cache_entry * } if (ret) return ret; + rte_spinlock_lock(&priv->shared_act_sl); LIST_REMOVE(action, next); + rte_spinlock_unlock(&priv->shared_act_sl); rte_free(action); return 0; } -- 1.8.3.1