Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 418e534

Browse files
pmstillwkuba-moo
authored andcommitted
ice: move devlink port creation/deletion
Commit a286ba7 ("ice: reorder PF/representor devlink port register/unregister flows") moved the code to create and destroy the devlink PF port. This was fine, but created a corner case issue in the case of ice_register_netdev() failing. In that case, the driver would end up calling ice_devlink_destroy_pf_port() twice. Additionally, it makes no sense to tie creation of the devlink PF port to the creation of the netdev so separate out the code to create/destroy the devlink PF port from the netdev code. This makes it a cleaner interface. Fixes: a286ba7 ("ice: reorder PF/representor devlink port register/unregister flows") Signed-off-by: Paul M Stillwell Jr <[email protected]> Tested-by: Gurucharan G <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 458e279 commit 418e534

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

drivers/net/ethernet/intel/ice/ice_lib.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,9 +3235,6 @@ int ice_vsi_release(struct ice_vsi *vsi)
32353235
}
32363236
}
32373237

3238-
if (vsi->type == ICE_VSI_PF)
3239-
ice_devlink_destroy_pf_port(pf);
3240-
32413238
if (vsi->type == ICE_VSI_VF &&
32423239
vsi->agg_node && vsi->agg_node->valid)
32433240
vsi->agg_node->num_vsis--;

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4590,7 +4590,7 @@ static void ice_print_wake_reason(struct ice_pf *pf)
45904590
}
45914591

45924592
/**
4593-
* ice_register_netdev - register netdev and devlink port
4593+
* ice_register_netdev - register netdev
45944594
* @pf: pointer to the PF struct
45954595
*/
45964596
static int ice_register_netdev(struct ice_pf *pf)
@@ -4602,11 +4602,6 @@ static int ice_register_netdev(struct ice_pf *pf)
46024602
if (!vsi || !vsi->netdev)
46034603
return -EIO;
46044604

4605-
err = ice_devlink_create_pf_port(pf);
4606-
if (err)
4607-
goto err_devlink_create;
4608-
4609-
SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port);
46104605
err = register_netdev(vsi->netdev);
46114606
if (err)
46124607
goto err_register_netdev;
@@ -4617,8 +4612,6 @@ static int ice_register_netdev(struct ice_pf *pf)
46174612

46184613
return 0;
46194614
err_register_netdev:
4620-
ice_devlink_destroy_pf_port(pf);
4621-
err_devlink_create:
46224615
free_netdev(vsi->netdev);
46234616
vsi->netdev = NULL;
46244617
clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
@@ -4636,6 +4629,7 @@ static int
46364629
ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
46374630
{
46384631
struct device *dev = &pdev->dev;
4632+
struct ice_vsi *vsi;
46394633
struct ice_pf *pf;
46404634
struct ice_hw *hw;
46414635
int i, err;
@@ -4918,6 +4912,18 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
49184912
pcie_print_link_status(pf->pdev);
49194913

49204914
probe_done:
4915+
err = ice_devlink_create_pf_port(pf);
4916+
if (err)
4917+
goto err_create_pf_port;
4918+
4919+
vsi = ice_get_main_vsi(pf);
4920+
if (!vsi || !vsi->netdev) {
4921+
err = -EINVAL;
4922+
goto err_netdev_reg;
4923+
}
4924+
4925+
SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port);
4926+
49214927
err = ice_register_netdev(pf);
49224928
if (err)
49234929
goto err_netdev_reg;
@@ -4955,6 +4961,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
49554961
err_devlink_reg_param:
49564962
ice_devlink_unregister_params(pf);
49574963
err_netdev_reg:
4964+
ice_devlink_destroy_pf_port(pf);
4965+
err_create_pf_port:
49584966
err_send_version_unroll:
49594967
ice_vsi_release_all(pf);
49604968
err_alloc_sw_unroll:
@@ -5083,6 +5091,7 @@ static void ice_remove(struct pci_dev *pdev)
50835091
ice_setup_mc_magic_wake(pf);
50845092
ice_vsi_release_all(pf);
50855093
mutex_destroy(&(&pf->hw)->fdir_fltr_lock);
5094+
ice_devlink_destroy_pf_port(pf);
50865095
ice_set_wake(pf);
50875096
ice_free_irq_msix_misc(pf);
50885097
ice_for_each_vsi(pf, i) {

0 commit comments

Comments
 (0)