Commit ed5f9cf0 authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by Saeed Mahameed

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: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 62f7991f
...@@ -113,7 +113,7 @@ static int mlx5e_get_dscp_up(struct mlx5e_priv *priv, struct sk_buff *skb) ...@@ -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) static int mlx5e_get_up(struct mlx5e_priv *priv, struct sk_buff *skb)
{ {
#ifdef CONFIG_MLX5_CORE_EN_DCB #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); return mlx5e_get_dscp_up(priv, skb);
#endif #endif
if (skb_vlan_tag_present(skb)) if (skb_vlan_tag_present(skb))
......
...@@ -1142,7 +1142,7 @@ static int mlx5e_update_trust_state_hw(struct mlx5e_priv *priv, void *context) ...@@ -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); err = mlx5_set_trust_state(priv->mdev, *trust_state);
if (err) if (err)
return err; return err;
priv->dcbx_dp.trust_state = *trust_state; WRITE_ONCE(priv->dcbx_dp.trust_state, *trust_state);
return 0; return 0;
} }
...@@ -1187,16 +1187,18 @@ static int mlx5e_set_dscp2prio(struct mlx5e_priv *priv, u8 dscp, u8 prio) ...@@ -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) static int mlx5e_trust_initialize(struct mlx5e_priv *priv)
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u8 trust_state;
int err; int err;
priv->dcbx_dp.trust_state = MLX5_QPTS_TRUST_PCP; if (!MLX5_DSCP_SUPPORTED(mdev)) {
WRITE_ONCE(priv->dcbx_dp.trust_state, MLX5_QPTS_TRUST_PCP);
if (!MLX5_DSCP_SUPPORTED(mdev))
return 0; 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) if (err)
return 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, mlx5e_params_calc_trust_tx_min_inline_mode(priv->mdev, &priv->channels.params,
priv->dcbx_dp.trust_state); priv->dcbx_dp.trust_state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment