net/mlx5e: Use READ_ONCE/WRITE_ONCE for DCBX trust state
trust_state can be written while mlx5e_select_queue() is reading it. To avoid inconsistencies, use READ_ONCE and WRITE_ONCE for access and updates, and touch the variable only once per operation. Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
62f7991fea
commit
ed5f9cf06b
@ -113,7 +113,7 @@ static int mlx5e_get_dscp_up(struct mlx5e_priv *priv, struct sk_buff *skb)
|
||||
static int mlx5e_get_up(struct mlx5e_priv *priv, struct sk_buff *skb)
|
||||
{
|
||||
#ifdef CONFIG_MLX5_CORE_EN_DCB
|
||||
if (priv->dcbx_dp.trust_state == MLX5_QPTS_TRUST_DSCP)
|
||||
if (READ_ONCE(priv->dcbx_dp.trust_state) == MLX5_QPTS_TRUST_DSCP)
|
||||
return mlx5e_get_dscp_up(priv, skb);
|
||||
#endif
|
||||
if (skb_vlan_tag_present(skb))
|
||||
|
@ -1142,7 +1142,7 @@ static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context)
|
||||
err = mlx5_set_trust_state(priv->mdev, *trust_state);
|
||||
if (err)
|
||||
return err;
|
||||
priv->dcbx_dp.trust_state = *trust_state;
|
||||
WRITE_ONCE(priv->dcbx_dp.trust_state, *trust_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1187,16 +1187,18 @@ static int mlx5e_set_dscp2prio(struct mlx5e_priv *priv, u8 dscp, u8 prio)
|
||||
static int mlx5e_trust_initialize(struct mlx5e_priv *priv)
|
||||
{
|
||||
struct mlx5_core_dev *mdev = priv->mdev;
|
||||
u8 trust_state;
|
||||
int err;
|
||||
|
||||
priv->dcbx_dp.trust_state = MLX5_QPTS_TRUST_PCP;
|
||||
|
||||
if (!MLX5_DSCP_SUPPORTED(mdev))
|
||||
if (!MLX5_DSCP_SUPPORTED(mdev)) {
|
||||
WRITE_ONCE(priv->dcbx_dp.trust_state, MLX5_QPTS_TRUST_PCP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = mlx5_query_trust_state(priv->mdev, &priv->dcbx_dp.trust_state);
|
||||
err = mlx5_query_trust_state(priv->mdev, &trust_state);
|
||||
if (err)
|
||||
return err;
|
||||
WRITE_ONCE(priv->dcbx_dp.trust_state, trust_state);
|
||||
|
||||
mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &priv->channels.params,
|
||||
priv->dcbx_dp.trust_state);
|
||||
|
Loading…
x
Reference in New Issue
Block a user