Commit 135435f9 authored by Antoine Tenart's avatar Antoine Tenart Committed by Jakub Kicinski

net: atlantic: macsec: make the prepare phase a noop

In preparation for removing the MACsec h/w offloading preparation phase,
make it a no-op in the Atlantic driver.
Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 920d998e
...@@ -452,6 +452,9 @@ static int aq_mdo_add_secy(struct macsec_context *ctx) ...@@ -452,6 +452,9 @@ static int aq_mdo_add_secy(struct macsec_context *ctx)
u32 txsc_idx; u32 txsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
if (secy->xpn) if (secy->xpn)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -466,9 +469,6 @@ static int aq_mdo_add_secy(struct macsec_context *ctx) ...@@ -466,9 +469,6 @@ static int aq_mdo_add_secy(struct macsec_context *ctx)
if (txsc_idx == AQ_MACSEC_MAX_SC) if (txsc_idx == AQ_MACSEC_MAX_SC)
return -ENOSPC; return -ENOSPC;
if (ctx->prepare)
return 0;
cfg->sc_sa = sc_sa; cfg->sc_sa = sc_sa;
cfg->aq_txsc[txsc_idx].hw_sc_idx = aq_to_hw_sc_idx(txsc_idx, sc_sa); cfg->aq_txsc[txsc_idx].hw_sc_idx = aq_to_hw_sc_idx(txsc_idx, sc_sa);
cfg->aq_txsc[txsc_idx].sw_secy = secy; cfg->aq_txsc[txsc_idx].sw_secy = secy;
...@@ -488,13 +488,13 @@ static int aq_mdo_upd_secy(struct macsec_context *ctx) ...@@ -488,13 +488,13 @@ static int aq_mdo_upd_secy(struct macsec_context *ctx)
int txsc_idx; int txsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy); txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy);
if (txsc_idx < 0) if (txsc_idx < 0)
return -ENOENT; return -ENOENT;
if (ctx->prepare)
return 0;
if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev))
ret = aq_set_txsc(nic, txsc_idx); ret = aq_set_txsc(nic, txsc_idx);
...@@ -597,13 +597,13 @@ static int aq_mdo_add_txsa(struct macsec_context *ctx) ...@@ -597,13 +597,13 @@ static int aq_mdo_add_txsa(struct macsec_context *ctx)
int txsc_idx; int txsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
txsc_idx = aq_get_txsc_idx_from_secy(cfg, secy); txsc_idx = aq_get_txsc_idx_from_secy(cfg, secy);
if (txsc_idx < 0) if (txsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
aq_txsc = &cfg->aq_txsc[txsc_idx]; aq_txsc = &cfg->aq_txsc[txsc_idx];
set_bit(ctx->sa.assoc_num, &aq_txsc->tx_sa_idx_busy); set_bit(ctx->sa.assoc_num, &aq_txsc->tx_sa_idx_busy);
...@@ -627,13 +627,13 @@ static int aq_mdo_upd_txsa(struct macsec_context *ctx) ...@@ -627,13 +627,13 @@ static int aq_mdo_upd_txsa(struct macsec_context *ctx)
int txsc_idx; int txsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
txsc_idx = aq_get_txsc_idx_from_secy(cfg, secy); txsc_idx = aq_get_txsc_idx_from_secy(cfg, secy);
if (txsc_idx < 0) if (txsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
aq_txsc = &cfg->aq_txsc[txsc_idx]; aq_txsc = &cfg->aq_txsc[txsc_idx];
if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev))
ret = aq_update_txsa(nic, aq_txsc->hw_sc_idx, secy, ret = aq_update_txsa(nic, aq_txsc->hw_sc_idx, secy,
...@@ -677,13 +677,13 @@ static int aq_mdo_del_txsa(struct macsec_context *ctx) ...@@ -677,13 +677,13 @@ static int aq_mdo_del_txsa(struct macsec_context *ctx)
int txsc_idx; int txsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
txsc_idx = aq_get_txsc_idx_from_secy(cfg, ctx->secy); txsc_idx = aq_get_txsc_idx_from_secy(cfg, ctx->secy);
if (txsc_idx < 0) if (txsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
ret = aq_clear_txsa(nic, &cfg->aq_txsc[txsc_idx], ctx->sa.assoc_num, ret = aq_clear_txsa(nic, &cfg->aq_txsc[txsc_idx], ctx->sa.assoc_num,
AQ_CLEAR_ALL); AQ_CLEAR_ALL);
...@@ -773,6 +773,9 @@ static int aq_mdo_add_rxsc(struct macsec_context *ctx) ...@@ -773,6 +773,9 @@ static int aq_mdo_add_rxsc(struct macsec_context *ctx)
u32 rxsc_idx; u32 rxsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
if (hweight32(cfg->rxsc_idx_busy) >= rxsc_idx_max) if (hweight32(cfg->rxsc_idx_busy) >= rxsc_idx_max)
return -ENOSPC; return -ENOSPC;
...@@ -780,9 +783,6 @@ static int aq_mdo_add_rxsc(struct macsec_context *ctx) ...@@ -780,9 +783,6 @@ static int aq_mdo_add_rxsc(struct macsec_context *ctx)
if (rxsc_idx >= rxsc_idx_max) if (rxsc_idx >= rxsc_idx_max)
return -ENOSPC; return -ENOSPC;
if (ctx->prepare)
return 0;
cfg->aq_rxsc[rxsc_idx].hw_sc_idx = aq_to_hw_sc_idx(rxsc_idx, cfg->aq_rxsc[rxsc_idx].hw_sc_idx = aq_to_hw_sc_idx(rxsc_idx,
cfg->sc_sa); cfg->sc_sa);
cfg->aq_rxsc[rxsc_idx].sw_secy = ctx->secy; cfg->aq_rxsc[rxsc_idx].sw_secy = ctx->secy;
...@@ -805,13 +805,13 @@ static int aq_mdo_upd_rxsc(struct macsec_context *ctx) ...@@ -805,13 +805,13 @@ static int aq_mdo_upd_rxsc(struct macsec_context *ctx)
int rxsc_idx; int rxsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -ENOENT; return -ENOENT;
if (ctx->prepare)
return 0;
if (netif_carrier_ok(nic->ndev) && netif_running(ctx->secy->netdev)) if (netif_carrier_ok(nic->ndev) && netif_running(ctx->secy->netdev))
ret = aq_set_rxsc(nic, rxsc_idx); ret = aq_set_rxsc(nic, rxsc_idx);
...@@ -872,13 +872,13 @@ static int aq_mdo_del_rxsc(struct macsec_context *ctx) ...@@ -872,13 +872,13 @@ static int aq_mdo_del_rxsc(struct macsec_context *ctx)
int rxsc_idx; int rxsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -ENOENT; return -ENOENT;
if (ctx->prepare)
return 0;
if (netif_carrier_ok(nic->ndev)) if (netif_carrier_ok(nic->ndev))
clear_type = AQ_CLEAR_ALL; clear_type = AQ_CLEAR_ALL;
...@@ -944,13 +944,13 @@ static int aq_mdo_add_rxsa(struct macsec_context *ctx) ...@@ -944,13 +944,13 @@ static int aq_mdo_add_rxsa(struct macsec_context *ctx)
int rxsc_idx; int rxsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
aq_rxsc = &nic->macsec_cfg->aq_rxsc[rxsc_idx]; aq_rxsc = &nic->macsec_cfg->aq_rxsc[rxsc_idx];
set_bit(ctx->sa.assoc_num, &aq_rxsc->rx_sa_idx_busy); set_bit(ctx->sa.assoc_num, &aq_rxsc->rx_sa_idx_busy);
...@@ -974,13 +974,13 @@ static int aq_mdo_upd_rxsa(struct macsec_context *ctx) ...@@ -974,13 +974,13 @@ static int aq_mdo_upd_rxsa(struct macsec_context *ctx)
int rxsc_idx; int rxsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev)) if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev))
ret = aq_update_rxsa(nic, cfg->aq_rxsc[rxsc_idx].hw_sc_idx, ret = aq_update_rxsa(nic, cfg->aq_rxsc[rxsc_idx].hw_sc_idx,
secy, ctx->sa.rx_sa, NULL, secy, ctx->sa.rx_sa, NULL,
...@@ -1025,13 +1025,13 @@ static int aq_mdo_del_rxsa(struct macsec_context *ctx) ...@@ -1025,13 +1025,13 @@ static int aq_mdo_del_rxsa(struct macsec_context *ctx)
int rxsc_idx; int rxsc_idx;
int ret = 0; int ret = 0;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
ret = aq_clear_rxsa(nic, &cfg->aq_rxsc[rxsc_idx], ctx->sa.assoc_num, ret = aq_clear_rxsa(nic, &cfg->aq_rxsc[rxsc_idx], ctx->sa.assoc_num,
AQ_CLEAR_ALL); AQ_CLEAR_ALL);
...@@ -1069,13 +1069,13 @@ static int aq_mdo_get_tx_sc_stats(struct macsec_context *ctx) ...@@ -1069,13 +1069,13 @@ static int aq_mdo_get_tx_sc_stats(struct macsec_context *ctx)
struct aq_macsec_txsc *aq_txsc; struct aq_macsec_txsc *aq_txsc;
int txsc_idx; int txsc_idx;
if (ctx->prepare)
return 0;
txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, ctx->secy); txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, ctx->secy);
if (txsc_idx < 0) if (txsc_idx < 0)
return -ENOENT; return -ENOENT;
if (ctx->prepare)
return 0;
aq_txsc = &nic->macsec_cfg->aq_txsc[txsc_idx]; aq_txsc = &nic->macsec_cfg->aq_txsc[txsc_idx];
stats = &aq_txsc->stats; stats = &aq_txsc->stats;
aq_get_txsc_stats(hw, aq_txsc->hw_sc_idx, stats); aq_get_txsc_stats(hw, aq_txsc->hw_sc_idx, stats);
...@@ -1102,13 +1102,13 @@ static int aq_mdo_get_tx_sa_stats(struct macsec_context *ctx) ...@@ -1102,13 +1102,13 @@ static int aq_mdo_get_tx_sa_stats(struct macsec_context *ctx)
u32 next_pn; u32 next_pn;
int ret; int ret;
if (ctx->prepare)
return 0;
txsc_idx = aq_get_txsc_idx_from_secy(cfg, ctx->secy); txsc_idx = aq_get_txsc_idx_from_secy(cfg, ctx->secy);
if (txsc_idx < 0) if (txsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
aq_txsc = &cfg->aq_txsc[txsc_idx]; aq_txsc = &cfg->aq_txsc[txsc_idx];
sa_idx = aq_txsc->hw_sc_idx | ctx->sa.assoc_num; sa_idx = aq_txsc->hw_sc_idx | ctx->sa.assoc_num;
stats = &aq_txsc->tx_sa_stats[ctx->sa.assoc_num]; stats = &aq_txsc->tx_sa_stats[ctx->sa.assoc_num];
...@@ -1143,13 +1143,13 @@ static int aq_mdo_get_rx_sc_stats(struct macsec_context *ctx) ...@@ -1143,13 +1143,13 @@ static int aq_mdo_get_rx_sc_stats(struct macsec_context *ctx)
int ret = 0; int ret = 0;
int i; int i;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, ctx->rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, ctx->rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -ENOENT; return -ENOENT;
if (ctx->prepare)
return 0;
aq_rxsc = &cfg->aq_rxsc[rxsc_idx]; aq_rxsc = &cfg->aq_rxsc[rxsc_idx];
for (i = 0; i < MACSEC_NUM_AN; i++) { for (i = 0; i < MACSEC_NUM_AN; i++) {
if (!test_bit(i, &aq_rxsc->rx_sa_idx_busy)) if (!test_bit(i, &aq_rxsc->rx_sa_idx_busy))
...@@ -1192,13 +1192,13 @@ static int aq_mdo_get_rx_sa_stats(struct macsec_context *ctx) ...@@ -1192,13 +1192,13 @@ static int aq_mdo_get_rx_sa_stats(struct macsec_context *ctx)
u32 next_pn; u32 next_pn;
int ret; int ret;
if (ctx->prepare)
return 0;
rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, ctx->rx_sc); rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, ctx->rx_sc);
if (rxsc_idx < 0) if (rxsc_idx < 0)
return -EINVAL; return -EINVAL;
if (ctx->prepare)
return 0;
aq_rxsc = &cfg->aq_rxsc[rxsc_idx]; aq_rxsc = &cfg->aq_rxsc[rxsc_idx];
stats = &aq_rxsc->rx_sa_stats[ctx->sa.assoc_num]; stats = &aq_rxsc->rx_sa_stats[ctx->sa.assoc_num];
sa_idx = aq_rxsc->hw_sc_idx | ctx->sa.assoc_num; sa_idx = aq_rxsc->hw_sc_idx | ctx->sa.assoc_num;
......
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