Commit ceb51b27 authored by Raed Salem's avatar Raed Salem Committed by Saeed Mahameed

net/mlx5e: MACsec, fix mlx5e_macsec_update_rxsa bail condition and functionality

Fix update Rx SA wrong bail condition, naturally update functionality
needs to check that something changed otherwise bailout currently the
active state check does just the opposite, furthermore unlike deactivate
path which remove the macsec rules to deactivate the offload, the
activation path does not include the counter part installation of the
macsec rules.

Fix by using correct bailout condition and when Rx SA changes state to
active then add the relevant macsec rules.

While at it, refine function name to reflect more precisely its role.

Fixes: aae3454e ("net/mlx5e: Add MACsec offload Rx command support")
Signed-off-by: default avatarRaed Salem <raeds@nvidia.com>
Reviewed-by: default avatarEmeel Hakim <ehakim@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent eead5ea2
...@@ -427,15 +427,15 @@ mlx5e_macsec_get_rx_sc_from_sc_list(const struct list_head *list, sci_t sci) ...@@ -427,15 +427,15 @@ mlx5e_macsec_get_rx_sc_from_sc_list(const struct list_head *list, sci_t sci)
return NULL; return NULL;
} }
static int mlx5e_macsec_update_rx_sa(struct mlx5e_macsec *macsec, static int macsec_rx_sa_active_update(struct macsec_context *ctx,
struct mlx5e_macsec_sa *rx_sa, struct mlx5e_macsec_sa *rx_sa,
bool active) bool active)
{ {
struct mlx5_core_dev *mdev = macsec->mdev; struct mlx5e_priv *priv = netdev_priv(ctx->netdev);
struct mlx5_macsec_obj_attrs attrs = {}; struct mlx5e_macsec *macsec = priv->macsec;
int err = 0; int err = 0;
if (rx_sa->active != active) if (rx_sa->active == active)
return 0; return 0;
rx_sa->active = active; rx_sa->active = active;
...@@ -444,13 +444,11 @@ static int mlx5e_macsec_update_rx_sa(struct mlx5e_macsec *macsec, ...@@ -444,13 +444,11 @@ static int mlx5e_macsec_update_rx_sa(struct mlx5e_macsec *macsec,
return 0; return 0;
} }
attrs.sci = cpu_to_be64((__force u64)rx_sa->sci); err = mlx5e_macsec_init_sa(ctx, rx_sa, true, false);
attrs.enc_key_id = rx_sa->enc_key_id;
err = mlx5e_macsec_create_object(mdev, &attrs, false, &rx_sa->macsec_obj_id);
if (err) if (err)
return err; rx_sa->active = false;
return 0; return err;
} }
static bool mlx5e_macsec_secy_features_validate(struct macsec_context *ctx) static bool mlx5e_macsec_secy_features_validate(struct macsec_context *ctx)
...@@ -812,7 +810,7 @@ static int mlx5e_macsec_upd_rxsc(struct macsec_context *ctx) ...@@ -812,7 +810,7 @@ static int mlx5e_macsec_upd_rxsc(struct macsec_context *ctx)
if (!rx_sa) if (!rx_sa)
continue; continue;
err = mlx5e_macsec_update_rx_sa(macsec, rx_sa, rx_sa->active && ctx_rx_sc->active); err = macsec_rx_sa_active_update(ctx, rx_sa, rx_sa->active && ctx_rx_sc->active);
if (err) if (err)
goto out; goto out;
} }
...@@ -1023,7 +1021,7 @@ static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx) ...@@ -1023,7 +1021,7 @@ static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx)
goto out; goto out;
} }
err = mlx5e_macsec_update_rx_sa(macsec, rx_sa, ctx_rx_sa->active); err = macsec_rx_sa_active_update(ctx, rx_sa, ctx_rx_sa->active);
out: out:
mutex_unlock(&macsec->lock); mutex_unlock(&macsec->lock);
......
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