Skip to content

Commit

Permalink
ice: Remove and readd netdev during devlink reload
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/2091107

Recent changes to the devlink reload (commit 9b2348e
("devlink: warn about existing entities during reload-reinit"))
force the drivers to destroy devlink ports during reinit.
Adjust ice driver to this requirement, unregister netdvice, destroy
devlink port. ice_init_eth() was removed and all the common code
between probe and reload was moved to ice_load().

During devlink reload we can't take devl_lock (it's already taken)
and in ice_probe() we have to lock it. Use devl_* variant of the API
which does not acquire and release devl_lock. Guard ice_load()
with devl_lock only in case of probe.

Suggested-by: Jiri Pirko <[email protected]>
Reviewed-by: Przemek Kitszel <[email protected]>
Reviewed-by: Vadim Fedorenko <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Reviewed-by: Brett Creeley <[email protected]>
Signed-off-by: Wojciech Drewek <[email protected]>
Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <[email protected]>
(cherry picked from commit 41cc4e5)
Signed-off-by: Jacob Martin <[email protected]>
  • Loading branch information
WojDrew authored and jacobmartin0 committed Dec 5, 2024
1 parent 902e24c commit c42e6dc
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 131 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/ice/ice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,8 @@ void ice_service_task_schedule(struct ice_pf *pf);
int ice_load(struct ice_pf *pf);
void ice_unload(struct ice_pf *pf);
void ice_adv_lnk_speed_maps_init(void);
int ice_init_dev(struct ice_pf *pf);
void ice_deinit_dev(struct ice_pf *pf);

/**
* ice_set_rdma_cap - enable RDMA support
Expand Down
68 changes: 62 additions & 6 deletions drivers/net/ethernet/intel/ice/ice_devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,20 @@ ice_devlink_reload_empr_start(struct ice_pf *pf,
return 0;
}

/**
* ice_devlink_reinit_down - unload given PF
* @pf: pointer to the PF struct
*/
static void ice_devlink_reinit_down(struct ice_pf *pf)
{
/* No need to take devl_lock, it's already taken by devlink API */
ice_unload(pf);
rtnl_lock();
ice_vsi_decfg(ice_get_main_vsi(pf));
rtnl_unlock();
ice_deinit_dev(pf);
}

/**
* ice_devlink_reload_down - prepare for reload
* @devlink: pointer to the devlink instance to reload
Expand Down Expand Up @@ -477,7 +491,7 @@ ice_devlink_reload_down(struct devlink *devlink, bool netns_change,
"Remove all VFs before doing reinit\n");
return -EOPNOTSUPP;
}
ice_unload(pf);
ice_devlink_reinit_down(pf);
return 0;
case DEVLINK_RELOAD_ACTION_FW_ACTIVATE:
return ice_devlink_reload_empr_start(pf, extack);
Expand Down Expand Up @@ -1269,6 +1283,45 @@ static int ice_devlink_set_parent(struct devlink_rate *devlink_rate,
return status;
}

/**
* ice_devlink_reinit_up - do reinit of the given PF
* @pf: pointer to the PF struct
*/
static int ice_devlink_reinit_up(struct ice_pf *pf)
{
struct ice_vsi *vsi = ice_get_main_vsi(pf);
struct ice_vsi_cfg_params params;
int err;

err = ice_init_dev(pf);
if (err)
return err;

params = ice_vsi_to_params(vsi);
params.flags = ICE_VSI_FLAG_INIT;

rtnl_lock();
err = ice_vsi_cfg(vsi, &params);
rtnl_unlock();
if (err)
goto err_vsi_cfg;

/* No need to take devl_lock, it's already taken by devlink API */
err = ice_load(pf);
if (err)
goto err_load;

return 0;

err_load:
rtnl_lock();
ice_vsi_decfg(vsi);
rtnl_unlock();
err_vsi_cfg:
ice_deinit_dev(pf);
return err;
}

/**
* ice_devlink_reload_up - do reload up after reinit
* @devlink: pointer to the devlink instance reloading
Expand All @@ -1289,7 +1342,7 @@ ice_devlink_reload_up(struct devlink *devlink,
switch (action) {
case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
*actions_performed = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT);
return ice_load(pf);
return ice_devlink_reinit_up(pf);
case DEVLINK_RELOAD_ACTION_FW_ACTIVATE:
*actions_performed = BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE);
return ice_devlink_reload_empr_finish(pf, extack);
Expand Down Expand Up @@ -1569,6 +1622,7 @@ static const struct devlink_port_ops ice_devlink_port_ops = {
* @pf: the PF to create a devlink port for
*
* Create and register a devlink_port for this PF.
* This function has to be called under devl_lock.
*
* Return: zero on success or an error code on failure.
*/
Expand All @@ -1581,6 +1635,8 @@ int ice_devlink_create_pf_port(struct ice_pf *pf)
struct device *dev;
int err;

devlink = priv_to_devlink(pf);

dev = ice_pf_to_dev(pf);

devlink_port = &pf->devlink_port;
Expand All @@ -1601,10 +1657,9 @@ int ice_devlink_create_pf_port(struct ice_pf *pf)
ice_devlink_set_switch_id(pf, &attrs.switch_id);

devlink_port_attrs_set(devlink_port, &attrs);
devlink = priv_to_devlink(pf);

err = devlink_port_register_with_ops(devlink, devlink_port, vsi->idx,
&ice_devlink_port_ops);
err = devl_port_register_with_ops(devlink, devlink_port, vsi->idx,
&ice_devlink_port_ops);
if (err) {
dev_err(dev, "Failed to create devlink port for PF %d, error %d\n",
pf->hw.pf_id, err);
Expand All @@ -1619,10 +1674,11 @@ int ice_devlink_create_pf_port(struct ice_pf *pf)
* @pf: the PF to cleanup
*
* Unregisters the devlink_port structure associated with this PF.
* This function has to be called under devl_lock.
*/
void ice_devlink_destroy_pf_port(struct ice_pf *pf)
{
devlink_port_unregister(&pf->devlink_port);
devl_port_unregister(&pf->devlink_port);
}

/**
Expand Down
Loading

0 comments on commit c42e6dc

Please sign in to comment.