Commit 1b9d8bc1 authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'add-update_pn-flag'

Radu Pirea says:

====================
Add update_pn flag

Patches extracted from
https://lore.kernel.org/all/20230928084430.1882670-1-radu-nicolae.pirea@oss.nxp.com/
Update_pn flag will let the offloaded MACsec implementations to know when
the PN is updated.
====================

Link: https://lore.kernel.org/r/20231005180636.672791-1-radu-nicolae.pirea@oss.nxp.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 26c29961 fde2f2d7
...@@ -1357,10 +1357,12 @@ static int cn10k_mdo_upd_txsa(struct macsec_context *ctx) ...@@ -1357,10 +1357,12 @@ static int cn10k_mdo_upd_txsa(struct macsec_context *ctx)
if (netif_running(secy->netdev)) { if (netif_running(secy->netdev)) {
/* Keys cannot be changed after creation */ /* Keys cannot be changed after creation */
if (ctx->sa.update_pn) {
err = cn10k_write_tx_sa_pn(pfvf, txsc, sa_num, err = cn10k_write_tx_sa_pn(pfvf, txsc, sa_num,
sw_tx_sa->next_pn); sw_tx_sa->next_pn);
if (err) if (err)
return err; return err;
}
err = cn10k_mcs_link_tx_sa2sc(pfvf, secy, txsc, err = cn10k_mcs_link_tx_sa2sc(pfvf, secy, txsc,
sa_num, sw_tx_sa->active); sa_num, sw_tx_sa->active);
...@@ -1529,6 +1531,9 @@ static int cn10k_mdo_upd_rxsa(struct macsec_context *ctx) ...@@ -1529,6 +1531,9 @@ static int cn10k_mdo_upd_rxsa(struct macsec_context *ctx)
if (err) if (err)
return err; return err;
if (!ctx->sa.update_pn)
return 0;
err = cn10k_mcs_write_rx_sa_pn(pfvf, rxsc, sa_num, err = cn10k_mcs_write_rx_sa_pn(pfvf, rxsc, sa_num,
rx_sa->next_pn); rx_sa->next_pn);
if (err) if (err)
......
...@@ -580,7 +580,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx) ...@@ -580,7 +580,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx)
goto out; goto out;
} }
if (tx_sa->next_pn != ctx_tx_sa->next_pn_halves.lower) { if (ctx->sa.update_pn) {
netdev_err(netdev, "MACsec offload: update TX sa %d PN isn't supported\n", netdev_err(netdev, "MACsec offload: update TX sa %d PN isn't supported\n",
assoc_num); assoc_num);
err = -EINVAL; err = -EINVAL;
...@@ -973,7 +973,7 @@ static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx) ...@@ -973,7 +973,7 @@ static int mlx5e_macsec_upd_rxsa(struct macsec_context *ctx)
goto out; goto out;
} }
if (rx_sa->next_pn != ctx_rx_sa->next_pn_halves.lower) { if (ctx->sa.update_pn) {
netdev_err(ctx->netdev, netdev_err(ctx->netdev,
"MACsec offload update RX sa %d PN isn't supported\n", "MACsec offload update RX sa %d PN isn't supported\n",
assoc_num); assoc_num);
......
...@@ -2383,6 +2383,7 @@ static int macsec_upd_txsa(struct sk_buff *skb, struct genl_info *info) ...@@ -2383,6 +2383,7 @@ static int macsec_upd_txsa(struct sk_buff *skb, struct genl_info *info)
ctx.sa.assoc_num = assoc_num; ctx.sa.assoc_num = assoc_num;
ctx.sa.tx_sa = tx_sa; ctx.sa.tx_sa = tx_sa;
ctx.sa.update_pn = !!prev_pn.full64;
ctx.secy = secy; ctx.secy = secy;
ret = macsec_offload(ops->mdo_upd_txsa, &ctx); ret = macsec_offload(ops->mdo_upd_txsa, &ctx);
...@@ -2476,6 +2477,7 @@ static int macsec_upd_rxsa(struct sk_buff *skb, struct genl_info *info) ...@@ -2476,6 +2477,7 @@ static int macsec_upd_rxsa(struct sk_buff *skb, struct genl_info *info)
ctx.sa.assoc_num = assoc_num; ctx.sa.assoc_num = assoc_num;
ctx.sa.rx_sa = rx_sa; ctx.sa.rx_sa = rx_sa;
ctx.sa.update_pn = !!prev_pn.full64;
ctx.secy = secy; ctx.secy = secy;
ret = macsec_offload(ops->mdo_upd_rxsa, &ctx); ret = macsec_offload(ops->mdo_upd_rxsa, &ctx);
......
...@@ -849,6 +849,9 @@ static int vsc8584_macsec_upd_rxsa(struct macsec_context *ctx) ...@@ -849,6 +849,9 @@ static int vsc8584_macsec_upd_rxsa(struct macsec_context *ctx)
struct macsec_flow *flow; struct macsec_flow *flow;
int ret; int ret;
if (ctx->sa.update_pn)
return -EINVAL;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_INGR); flow = vsc8584_macsec_find_flow(ctx, MACSEC_INGR);
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
...@@ -900,6 +903,9 @@ static int vsc8584_macsec_upd_txsa(struct macsec_context *ctx) ...@@ -900,6 +903,9 @@ static int vsc8584_macsec_upd_txsa(struct macsec_context *ctx)
struct macsec_flow *flow; struct macsec_flow *flow;
int ret; int ret;
if (ctx->sa.update_pn)
return -EINVAL;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_EGR); flow = vsc8584_macsec_find_flow(ctx, MACSEC_EGR);
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
......
...@@ -258,6 +258,7 @@ struct macsec_context { ...@@ -258,6 +258,7 @@ struct macsec_context {
struct macsec_secy *secy; struct macsec_secy *secy;
struct macsec_rx_sc *rx_sc; struct macsec_rx_sc *rx_sc;
struct { struct {
bool update_pn;
unsigned char assoc_num; unsigned char assoc_num;
u8 key[MACSEC_MAX_KEY_LEN]; u8 key[MACSEC_MAX_KEY_LEN];
union { union {
......
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