Commit d6292ade authored by Vasundhara Volam's avatar Vasundhara Volam Committed by David S. Miller

bnxt_en: Refactor bnxt_dl_register()

Define bnxt_dl_params_register() and bnxt_dl_params_unregister()
functions and move params register/unregister code to these newly
defined functions. This patch is in preparation to register
devlink irrespective of firmware spec. version in the next patch.
Signed-off-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5313845f
...@@ -485,6 +485,38 @@ static const struct devlink_param bnxt_dl_params[] = { ...@@ -485,6 +485,38 @@ static const struct devlink_param bnxt_dl_params[] = {
static const struct devlink_param bnxt_dl_port_params[] = { static const struct devlink_param bnxt_dl_port_params[] = {
}; };
static int bnxt_dl_params_register(struct bnxt *bp)
{
int rc;
rc = devlink_params_register(bp->dl, bnxt_dl_params,
ARRAY_SIZE(bnxt_dl_params));
if (rc) {
netdev_warn(bp->dev, "devlink_params_register failed. rc=%d",
rc);
return rc;
}
rc = devlink_port_params_register(&bp->dl_port, bnxt_dl_port_params,
ARRAY_SIZE(bnxt_dl_port_params));
if (rc) {
netdev_err(bp->dev, "devlink_port_params_register failed");
devlink_params_unregister(bp->dl, bnxt_dl_params,
ARRAY_SIZE(bnxt_dl_params));
return rc;
}
devlink_params_publish(bp->dl);
return 0;
}
static void bnxt_dl_params_unregister(struct bnxt *bp)
{
devlink_params_unregister(bp->dl, bnxt_dl_params,
ARRAY_SIZE(bnxt_dl_params));
devlink_port_params_unregister(&bp->dl_port, bnxt_dl_port_params,
ARRAY_SIZE(bnxt_dl_port_params));
}
int bnxt_dl_register(struct bnxt *bp) int bnxt_dl_register(struct bnxt *bp)
{ {
struct devlink *dl; struct devlink *dl;
...@@ -520,40 +552,24 @@ int bnxt_dl_register(struct bnxt *bp) ...@@ -520,40 +552,24 @@ int bnxt_dl_register(struct bnxt *bp)
if (!BNXT_PF(bp)) if (!BNXT_PF(bp))
return 0; return 0;
rc = devlink_params_register(dl, bnxt_dl_params,
ARRAY_SIZE(bnxt_dl_params));
if (rc) {
netdev_warn(bp->dev, "devlink_params_register failed. rc=%d",
rc);
goto err_dl_unreg;
}
devlink_port_attrs_set(&bp->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL, devlink_port_attrs_set(&bp->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
bp->pf.port_id, false, 0, bp->pf.port_id, false, 0,
bp->switch_id, sizeof(bp->switch_id)); bp->switch_id, sizeof(bp->switch_id));
rc = devlink_port_register(dl, &bp->dl_port, bp->pf.port_id); rc = devlink_port_register(dl, &bp->dl_port, bp->pf.port_id);
if (rc) { if (rc) {
netdev_err(bp->dev, "devlink_port_register failed"); netdev_err(bp->dev, "devlink_port_register failed");
goto err_dl_param_unreg; goto err_dl_unreg;
} }
devlink_port_type_eth_set(&bp->dl_port, bp->dev); devlink_port_type_eth_set(&bp->dl_port, bp->dev);
rc = devlink_port_params_register(&bp->dl_port, bnxt_dl_port_params, rc = bnxt_dl_params_register(bp);
ARRAY_SIZE(bnxt_dl_port_params)); if (rc)
if (rc) {
netdev_err(bp->dev, "devlink_port_params_register failed");
goto err_dl_port_unreg; goto err_dl_port_unreg;
}
devlink_params_publish(dl);
return 0; return 0;
err_dl_port_unreg: err_dl_port_unreg:
devlink_port_unregister(&bp->dl_port); devlink_port_unregister(&bp->dl_port);
err_dl_param_unreg:
devlink_params_unregister(dl, bnxt_dl_params,
ARRAY_SIZE(bnxt_dl_params));
err_dl_unreg: err_dl_unreg:
devlink_unregister(dl); devlink_unregister(dl);
err_dl_free: err_dl_free:
...@@ -570,12 +586,8 @@ void bnxt_dl_unregister(struct bnxt *bp) ...@@ -570,12 +586,8 @@ void bnxt_dl_unregister(struct bnxt *bp)
return; return;
if (BNXT_PF(bp)) { if (BNXT_PF(bp)) {
devlink_port_params_unregister(&bp->dl_port, bnxt_dl_params_unregister(bp);
bnxt_dl_port_params,
ARRAY_SIZE(bnxt_dl_port_params));
devlink_port_unregister(&bp->dl_port); devlink_port_unregister(&bp->dl_port);
devlink_params_unregister(dl, bnxt_dl_params,
ARRAY_SIZE(bnxt_dl_params));
} }
devlink_unregister(dl); devlink_unregister(dl);
devlink_free(dl); devlink_free(dl);
......
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