Commit 920d998e authored by Antoine Tenart's avatar Antoine Tenart Committed by Jakub Kicinski

net: phy: mscc: 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 MSCC phy driver.
Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent aacdecda
...@@ -706,14 +706,6 @@ static int __vsc8584_macsec_add_rxsa(struct macsec_context *ctx, ...@@ -706,14 +706,6 @@ static int __vsc8584_macsec_add_rxsa(struct macsec_context *ctx,
struct phy_device *phydev = ctx->phydev; struct phy_device *phydev = ctx->phydev;
struct vsc8531_private *priv = phydev->priv; struct vsc8531_private *priv = phydev->priv;
if (!flow) {
flow = vsc8584_macsec_alloc_flow(priv, MACSEC_INGR);
if (IS_ERR(flow))
return PTR_ERR(flow);
memcpy(flow->key, ctx->sa.key, priv->secy->key_len);
}
flow->assoc_num = ctx->sa.assoc_num; flow->assoc_num = ctx->sa.assoc_num;
flow->rx_sa = ctx->sa.rx_sa; flow->rx_sa = ctx->sa.rx_sa;
...@@ -730,24 +722,13 @@ static int __vsc8584_macsec_add_rxsa(struct macsec_context *ctx, ...@@ -730,24 +722,13 @@ static int __vsc8584_macsec_add_rxsa(struct macsec_context *ctx,
static int __vsc8584_macsec_add_txsa(struct macsec_context *ctx, static int __vsc8584_macsec_add_txsa(struct macsec_context *ctx,
struct macsec_flow *flow, bool update) struct macsec_flow *flow, bool update)
{ {
struct phy_device *phydev = ctx->phydev;
struct vsc8531_private *priv = phydev->priv;
if (!flow) {
flow = vsc8584_macsec_alloc_flow(priv, MACSEC_EGR);
if (IS_ERR(flow))
return PTR_ERR(flow);
memcpy(flow->key, ctx->sa.key, priv->secy->key_len);
}
flow->assoc_num = ctx->sa.assoc_num; flow->assoc_num = ctx->sa.assoc_num;
flow->tx_sa = ctx->sa.tx_sa; flow->tx_sa = ctx->sa.tx_sa;
/* Always match untagged packets on egress */ /* Always match untagged packets on egress */
flow->match.untagged = 1; flow->match.untagged = 1;
return vsc8584_macsec_add_flow(phydev, flow, update); return vsc8584_macsec_add_flow(ctx->phydev, flow, update);
} }
static int vsc8584_macsec_dev_open(struct macsec_context *ctx) static int vsc8584_macsec_dev_open(struct macsec_context *ctx)
...@@ -785,13 +766,12 @@ static int vsc8584_macsec_add_secy(struct macsec_context *ctx) ...@@ -785,13 +766,12 @@ static int vsc8584_macsec_add_secy(struct macsec_context *ctx)
struct vsc8531_private *priv = ctx->phydev->priv; struct vsc8531_private *priv = ctx->phydev->priv;
struct macsec_secy *secy = ctx->secy; struct macsec_secy *secy = ctx->secy;
if (ctx->prepare) { if (ctx->prepare)
return 0;
if (priv->secy) if (priv->secy)
return -EEXIST; return -EEXIST;
return 0;
}
priv->secy = secy; priv->secy = secy;
vsc8584_macsec_flow_default_action(ctx->phydev, MACSEC_EGR, vsc8584_macsec_flow_default_action(ctx->phydev, MACSEC_EGR,
...@@ -862,33 +842,46 @@ static int vsc8584_macsec_del_rxsc(struct macsec_context *ctx) ...@@ -862,33 +842,46 @@ static int vsc8584_macsec_del_rxsc(struct macsec_context *ctx)
static int vsc8584_macsec_add_rxsa(struct macsec_context *ctx) static int vsc8584_macsec_add_rxsa(struct macsec_context *ctx)
{ {
struct macsec_flow *flow = NULL; struct phy_device *phydev = ctx->phydev;
struct vsc8531_private *priv = phydev->priv;
struct macsec_flow *flow;
int ret;
if (ctx->prepare) if (ctx->prepare)
return __vsc8584_macsec_add_rxsa(ctx, flow, false); return 0;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_INGR); flow = vsc8584_macsec_alloc_flow(priv, MACSEC_INGR);
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
vsc8584_macsec_flow_enable(ctx->phydev, flow); memcpy(flow->key, ctx->sa.key, priv->secy->key_len);
ret = __vsc8584_macsec_add_rxsa(ctx, flow, false);
if (ret)
return ret;
vsc8584_macsec_flow_enable(phydev, flow);
return 0; return 0;
} }
static int vsc8584_macsec_upd_rxsa(struct macsec_context *ctx) static int vsc8584_macsec_upd_rxsa(struct macsec_context *ctx)
{ {
struct macsec_flow *flow; struct macsec_flow *flow;
int ret;
if (ctx->prepare)
return 0;
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);
if (ctx->prepare) {
/* Make sure the flow is disabled before updating it */ /* Make sure the flow is disabled before updating it */
vsc8584_macsec_flow_disable(ctx->phydev, flow); vsc8584_macsec_flow_disable(ctx->phydev, flow);
return __vsc8584_macsec_add_rxsa(ctx, flow, true); ret = __vsc8584_macsec_add_rxsa(ctx, flow, true);
} if (ret)
return ret;
vsc8584_macsec_flow_enable(ctx->phydev, flow); vsc8584_macsec_flow_enable(ctx->phydev, flow);
return 0; return 0;
...@@ -898,12 +891,12 @@ static int vsc8584_macsec_del_rxsa(struct macsec_context *ctx) ...@@ -898,12 +891,12 @@ static int vsc8584_macsec_del_rxsa(struct macsec_context *ctx)
{ {
struct macsec_flow *flow; struct macsec_flow *flow;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_INGR); if (ctx->prepare)
return 0;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_INGR);
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
if (ctx->prepare)
return 0;
vsc8584_macsec_del_flow(ctx->phydev, flow); vsc8584_macsec_del_flow(ctx->phydev, flow);
return 0; return 0;
...@@ -911,33 +904,46 @@ static int vsc8584_macsec_del_rxsa(struct macsec_context *ctx) ...@@ -911,33 +904,46 @@ static int vsc8584_macsec_del_rxsa(struct macsec_context *ctx)
static int vsc8584_macsec_add_txsa(struct macsec_context *ctx) static int vsc8584_macsec_add_txsa(struct macsec_context *ctx)
{ {
struct macsec_flow *flow = NULL; struct phy_device *phydev = ctx->phydev;
struct vsc8531_private *priv = phydev->priv;
struct macsec_flow *flow;
int ret;
if (ctx->prepare) if (ctx->prepare)
return __vsc8584_macsec_add_txsa(ctx, flow, false); return 0;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_EGR); flow = vsc8584_macsec_alloc_flow(priv, MACSEC_EGR);
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
vsc8584_macsec_flow_enable(ctx->phydev, flow); memcpy(flow->key, ctx->sa.key, priv->secy->key_len);
ret = __vsc8584_macsec_add_txsa(ctx, flow, false);
if (ret)
return ret;
vsc8584_macsec_flow_enable(phydev, flow);
return 0; return 0;
} }
static int vsc8584_macsec_upd_txsa(struct macsec_context *ctx) static int vsc8584_macsec_upd_txsa(struct macsec_context *ctx)
{ {
struct macsec_flow *flow; struct macsec_flow *flow;
int ret;
if (ctx->prepare)
return 0;
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);
if (ctx->prepare) {
/* Make sure the flow is disabled before updating it */ /* Make sure the flow is disabled before updating it */
vsc8584_macsec_flow_disable(ctx->phydev, flow); vsc8584_macsec_flow_disable(ctx->phydev, flow);
return __vsc8584_macsec_add_txsa(ctx, flow, true); ret = __vsc8584_macsec_add_txsa(ctx, flow, true);
} if (ret)
return ret;
vsc8584_macsec_flow_enable(ctx->phydev, flow); vsc8584_macsec_flow_enable(ctx->phydev, flow);
return 0; return 0;
...@@ -947,12 +953,12 @@ static int vsc8584_macsec_del_txsa(struct macsec_context *ctx) ...@@ -947,12 +953,12 @@ static int vsc8584_macsec_del_txsa(struct macsec_context *ctx)
{ {
struct macsec_flow *flow; struct macsec_flow *flow;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_EGR); if (ctx->prepare)
return 0;
flow = vsc8584_macsec_find_flow(ctx, MACSEC_EGR);
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
if (ctx->prepare)
return 0;
vsc8584_macsec_del_flow(ctx->phydev, flow); vsc8584_macsec_del_flow(ctx->phydev, flow);
return 0; return 0;
......
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