From: Suanming Mou Date: Wed, 28 Oct 2020 09:33:52 +0000 (+0800) Subject: net/mlx5: make shared action list thread safe X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cc608e4df4c4ad5cf2335b9ef424ac2c4efff755;p=dpdk.git net/mlx5: make shared action list thread safe This commit uses spinlock to protect the shared action list in multiple thread. Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 5856981293..8612cabd68 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1534,6 +1534,7 @@ err_secondary: } 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 ac7a026292..be21a9a57e 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 08bbc5ddfb..cf484025b7 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -11191,7 +11191,9 @@ __flow_dv_action_create(struct rte_eth_dev *dev, 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 @@ __flow_dv_action_destroy(struct rte_eth_dev *dev, 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 @@ __flow_dv_action_destroy(struct rte_eth_dev *dev, } 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; }