Skip to contentSkip to conversation

ice: move devlink port creation/deletion

PATCH In review Paul M Stillwell Jr 3 participants 4 messages Jan 5, 2023 – Jan 16, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ice: move devlink port creation/deletion

Commit a286ba738714 ("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 a286ba738714 ("ice: reorder PF/representor devlink port register/unregister flows")
---
 drivers/net/ethernet/intel/ice/ice_lib.c  |  3 ---
 drivers/net/ethernet/intel/ice/ice_main.c | 25 +++++++++++++++--------
 2 files changed, 17 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
index 22bcb414546a..6e30c176e6f1 100644
@@ -3235,9 +3235,6 @@ int ice_vsi_release(struct ice_vsi *vsi)
 		}
 	}
 
-	if (vsi->type == ICE_VSI_PF)
-		ice_devlink_destroy_pf_port(pf);
-
 	if (vsi->type == ICE_VSI_VF &&
 	    vsi->agg_node && vsi->agg_node->valid)
 		vsi->agg_node->num_vsis--;
drivers/net/ethernet/intel/ice/ice_main.c +17 -8
index a9a7f8b52140..237ede2cffb0 100644
@@ -4590,7 +4590,7 @@ static void ice_print_wake_reason(struct ice_pf *pf)
 }
 
 /**
- * ice_register_netdev - register netdev and devlink port
+ * ice_register_netdev - register netdev
  * @pf: pointer to the PF struct
  */
 static int ice_register_netdev(struct ice_pf *pf)
@@ -4602,11 +4602,6 @@ static int ice_register_netdev(struct ice_pf *pf)
 	if (!vsi || !vsi->netdev)
 		return -EIO;
 
-	err = ice_devlink_create_pf_port(pf);
-	if (err)
-		goto err_devlink_create;
-
-	SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port);
 	err = register_netdev(vsi->netdev);
 	if (err)
 		goto err_register_netdev;
@@ -4617,8 +4612,6 @@ static int ice_register_netdev(struct ice_pf *pf)
 
 	return 0;
 err_register_netdev:
-	ice_devlink_destroy_pf_port(pf);
-err_devlink_create:
 	free_netdev(vsi->netdev);
 	vsi->netdev = NULL;
 	clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state);
@@ -4636,6 +4629,7 @@ static int
 ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 {
 	struct device *dev = &pdev->dev;
+	struct ice_vsi *vsi;
 	struct ice_pf *pf;
 	struct ice_hw *hw;
 	int i, err;
@@ -4918,6 +4912,18 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	pcie_print_link_status(pf->pdev);
 
 probe_done:
+	err = ice_devlink_create_pf_port(pf);
+	if (err)
+		goto err_create_pf_port;
+
+	vsi = ice_get_main_vsi(pf);
+	if (!vsi || !vsi->netdev) {
+		err = -EINVAL;
+		goto err_netdev_reg;
+	}
+
+	SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port);
+
 	err = ice_register_netdev(pf);
 	if (err)
 		goto err_netdev_reg;
@@ -4955,6 +4961,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 err_devlink_reg_param:
 	ice_devlink_unregister_params(pf);
 err_netdev_reg:
+	ice_devlink_destroy_pf_port(pf);
+err_create_pf_port:
 err_send_version_unroll:
 	ice_vsi_release_all(pf);
 err_alloc_sw_unroll:
@@ -5083,6 +5091,7 @@ static void ice_remove(struct pci_dev *pdev)
 	ice_setup_mc_magic_wake(pf);
 	ice_vsi_release_all(pf);
 	mutex_destroy(&(&pf->hw)->fdir_fltr_lock);
+	ice_devlink_destroy_pf_port(pf);
 	ice_set_wake(pf);
 	ice_free_irq_msix_misc(pf);
 	ice_for_each_vsi(pf, i) {
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw

Dear Paul,

Thank you for the patch.

Am 05.01.23 um 23:14 schrieb Paul M Stillwell Jr:

Quoted 6 lines

Commit a286ba738714 ("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.

Reading the summary, I though it’s just a refactoring, and not also a fix. Maybe use

Avoid calling ice_devlink_destroy_pf_port() twice

or something similar.

Quoted 4 lines

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.

It’d be great if you re-flowed the body for 72 characters per line. You seem to use less.

Quoted 6 lines
Fixes a286ba738714 ("ice: reorder PF/representor devlink port register/unregister flows")
---
  drivers/net/ethernet/intel/ice/ice_lib.c  |  3 ---
  drivers/net/ethernet/intel/ice/ice_main.c | 25 +++++++++++++++--------
  2 files changed, 17 insertions(+), 11 deletions(-)

[…]

Kind regards,

Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 30 lines

-----Original Message-----
From: Paul Menzel <[email protected]>
Sent: Friday, January 6, 2023 12:49 AM
To: Stillwell Jr, Paul M <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net v4] ice: move devlink port creation/deletion

Dear Paul,

Thank you for the patch.

Am 05.01.23 um 23:14 schrieb Paul M Stillwell Jr:

Quoted 6 lines

Commit a286ba738714 ("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.

Reading the summary, I though it’s just a refactoring, and not also a fix. Maybe use

Avoid calling ice_devlink_destroy_pf_port() twice

or something similar.

Quoted 8 lines
Quoted 4 lines

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.

It’d be great if you re-flowed the body for 72 characters per line. You seem to use less.

Thanks for your feedback. If there are changes that need to happen in the code that requires a respin of the patch then I'll make changes to the commit message. Otherwise I don't want to resend the patch for cosmetic changes.

Quoted 8 lines
Quoted 7 lines
Fixes a286ba738714 ("ice: reorder PF/representor devlink port

register/unregister flows")

---
  drivers/net/ethernet/intel/ice/ice_lib.c  |  3 ---
  drivers/net/ethernet/intel/ice/ice_main.c | 25 +++++++++++++++--------
  2 files changed, 17 insertions(+), 11 deletions(-)
Quoted 6 lines

[…]

Kind regards,

Paul

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v4 1/1
#3 lore raw
In reply to Paul M Stillwell Jr
Quoted 20 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Paul M Stillwell Jr
Sent: Friday, January 6, 2023 3:44 AM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH net v4] ice: move devlink port creation/deletion

Commit a286ba738714 ("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.

Quoted 8 lines
Fixes a286ba738714 ("ice: reorder PF/representor devlink port

register/unregister flows")

---
 drivers/net/ethernet/intel/ice/ice_lib.c  |  3 ---
drivers/net/ethernet/intel/ice/ice_main.c | 25 +++++++++++++++--------
 2 files changed, 17 insertions(+), 11 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan