diff mbox series

[net-next,2/7] net: atlantic: macsec: make the prepare phase a noop

Message ID 20220921135118.968595-3-atenart@kernel.org (mailing list archive)
State Accepted
Commit 135435f90b94e02842dd52c2cf23b6c2b6a90930
Delegated to: Netdev Maintainers
Headers show
Series net: macsec: remove the preparation phase when offloading operations | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: edumazet@google.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 244 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Antoine Tenart Sept. 21, 2022, 1:51 p.m. UTC
In preparation for removing the MACsec h/w offloading preparation phase,
make it a no-op in the Atlantic driver.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
 .../ethernet/aquantia/atlantic/aq_macsec.c    | 90 +++++++++----------
 1 file changed, 45 insertions(+), 45 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_macsec.c b/drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
index 02058fe79f52..9dbd348ac714 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
@@ -452,6 +452,9 @@  static int aq_mdo_add_secy(struct macsec_context *ctx)
 	u32 txsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	if (secy->xpn)
 		return -EOPNOTSUPP;
 
@@ -466,9 +469,6 @@  static int aq_mdo_add_secy(struct macsec_context *ctx)
 	if (txsc_idx == AQ_MACSEC_MAX_SC)
 		return -ENOSPC;
 
-	if (ctx->prepare)
-		return 0;
-
 	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].sw_secy = secy;
@@ -488,13 +488,13 @@  static int aq_mdo_upd_secy(struct macsec_context *ctx)
 	int txsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy);
 	if (txsc_idx < 0)
 		return -ENOENT;
 
-	if (ctx->prepare)
-		return 0;
-
 	if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev))
 		ret = aq_set_txsc(nic, txsc_idx);
 
@@ -597,13 +597,13 @@  static int aq_mdo_add_txsa(struct macsec_context *ctx)
 	int txsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	txsc_idx = aq_get_txsc_idx_from_secy(cfg, secy);
 	if (txsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_txsc = &cfg->aq_txsc[txsc_idx];
 	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)
 	int txsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	txsc_idx = aq_get_txsc_idx_from_secy(cfg, secy);
 	if (txsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_txsc = &cfg->aq_txsc[txsc_idx];
 	if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev))
 		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)
 	int txsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	txsc_idx = aq_get_txsc_idx_from_secy(cfg, ctx->secy);
 	if (txsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	ret = aq_clear_txsa(nic, &cfg->aq_txsc[txsc_idx], ctx->sa.assoc_num,
 			    AQ_CLEAR_ALL);
 
@@ -773,6 +773,9 @@  static int aq_mdo_add_rxsc(struct macsec_context *ctx)
 	u32 rxsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	if (hweight32(cfg->rxsc_idx_busy) >= rxsc_idx_max)
 		return -ENOSPC;
 
@@ -780,9 +783,6 @@  static int aq_mdo_add_rxsc(struct macsec_context *ctx)
 	if (rxsc_idx >= rxsc_idx_max)
 		return -ENOSPC;
 
-	if (ctx->prepare)
-		return 0;
-
 	cfg->aq_rxsc[rxsc_idx].hw_sc_idx = aq_to_hw_sc_idx(rxsc_idx,
 							   cfg->sc_sa);
 	cfg->aq_rxsc[rxsc_idx].sw_secy = ctx->secy;
@@ -805,13 +805,13 @@  static int aq_mdo_upd_rxsc(struct macsec_context *ctx)
 	int rxsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc);
 	if (rxsc_idx < 0)
 		return -ENOENT;
 
-	if (ctx->prepare)
-		return 0;
-
 	if (netif_carrier_ok(nic->ndev) && netif_running(ctx->secy->netdev))
 		ret = aq_set_rxsc(nic, rxsc_idx);
 
@@ -872,13 +872,13 @@  static int aq_mdo_del_rxsc(struct macsec_context *ctx)
 	int rxsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, ctx->rx_sc);
 	if (rxsc_idx < 0)
 		return -ENOENT;
 
-	if (ctx->prepare)
-		return 0;
-
 	if (netif_carrier_ok(nic->ndev))
 		clear_type = AQ_CLEAR_ALL;
 
@@ -944,13 +944,13 @@  static int aq_mdo_add_rxsa(struct macsec_context *ctx)
 	int rxsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc);
 	if (rxsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_rxsc = &nic->macsec_cfg->aq_rxsc[rxsc_idx];
 	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)
 	int rxsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, rx_sc);
 	if (rxsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	if (netif_carrier_ok(nic->ndev) && netif_running(secy->netdev))
 		ret = aq_update_rxsa(nic, cfg->aq_rxsc[rxsc_idx].hw_sc_idx,
 				     secy, ctx->sa.rx_sa, NULL,
@@ -1025,13 +1025,13 @@  static int aq_mdo_del_rxsa(struct macsec_context *ctx)
 	int rxsc_idx;
 	int ret = 0;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, rx_sc);
 	if (rxsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	ret = aq_clear_rxsa(nic, &cfg->aq_rxsc[rxsc_idx], ctx->sa.assoc_num,
 			    AQ_CLEAR_ALL);
 
@@ -1069,13 +1069,13 @@  static int aq_mdo_get_tx_sc_stats(struct macsec_context *ctx)
 	struct aq_macsec_txsc *aq_txsc;
 	int txsc_idx;
 
+	if (ctx->prepare)
+		return 0;
+
 	txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, ctx->secy);
 	if (txsc_idx < 0)
 		return -ENOENT;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_txsc = &nic->macsec_cfg->aq_txsc[txsc_idx];
 	stats = &aq_txsc->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)
 	u32 next_pn;
 	int ret;
 
+	if (ctx->prepare)
+		return 0;
+
 	txsc_idx = aq_get_txsc_idx_from_secy(cfg, ctx->secy);
 	if (txsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_txsc = &cfg->aq_txsc[txsc_idx];
 	sa_idx = aq_txsc->hw_sc_idx | 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)
 	int ret = 0;
 	int i;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, ctx->rx_sc);
 	if (rxsc_idx < 0)
 		return -ENOENT;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_rxsc = &cfg->aq_rxsc[rxsc_idx];
 	for (i = 0; i < MACSEC_NUM_AN; i++) {
 		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)
 	u32 next_pn;
 	int ret;
 
+	if (ctx->prepare)
+		return 0;
+
 	rxsc_idx = aq_get_rxsc_idx_from_rxsc(cfg, ctx->rx_sc);
 	if (rxsc_idx < 0)
 		return -EINVAL;
 
-	if (ctx->prepare)
-		return 0;
-
 	aq_rxsc = &cfg->aq_rxsc[rxsc_idx];
 	stats = &aq_rxsc->rx_sa_stats[ctx->sa.assoc_num];
 	sa_idx = aq_rxsc->hw_sc_idx | ctx->sa.assoc_num;