Commit 21b6b8e8 authored by Kalesh AP's avatar Kalesh AP Committed by Paolo Abeni
Browse files

bnxt_en: Optimize bnxt_sriov_disable()



bnxt_sriov_disable() is invoked from 2 places:

1. When the user deletes the VFs.
2. During the unload of the PF driver instance.

Inside bnxt_sriov_disable(), driver invokes
bnxt_restore_pf_fw_resources() which in turn causes a close/open_nic().
There is no harm doing this in the unload path, although it is inefficient
and unnecessary.

Optimize the function to make it more efficient.

Reviewed-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: default avatarKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250917040839.1924698-4-michael.chan@broadcom.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent e23c40d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16156,7 +16156,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
	struct bnxt *bp = netdev_priv(dev);

	if (BNXT_PF(bp))
		bnxt_sriov_disable(bp);
		__bnxt_sriov_disable(bp);

	bnxt_rdma_aux_device_del(bp);

+10 −2
Original line number Diff line number Diff line
@@ -919,7 +919,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
	return rc;
}

void bnxt_sriov_disable(struct bnxt *bp)
void __bnxt_sriov_disable(struct bnxt *bp)
{
	u16 num_vfs = pci_num_vf(bp->pdev);

@@ -943,6 +943,14 @@ void bnxt_sriov_disable(struct bnxt *bp)
	devl_unlock(bp->dl);

	bnxt_free_vf_resources(bp);
}

static void bnxt_sriov_disable(struct bnxt *bp)
{
	if (!pci_num_vf(bp->pdev))
		return;

	__bnxt_sriov_disable(bp);

	/* Reclaim all resources for the PF. */
	rtnl_lock();
@@ -1321,7 +1329,7 @@ int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)
	return 0;
}

void bnxt_sriov_disable(struct bnxt *bp)
void __bnxt_sriov_disable(struct bnxt *bp)
{
}

+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ bool bnxt_is_trusted_vf(struct bnxt *bp, struct bnxt_vf_info *vf);
int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trust);
int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs);
int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset);
void bnxt_sriov_disable(struct bnxt *);
void __bnxt_sriov_disable(struct bnxt *bp);
void bnxt_hwrm_exec_fwd_req(struct bnxt *);
void bnxt_update_vf_mac(struct bnxt *);
int bnxt_approve_mac(struct bnxt *, const u8 *, bool);