]> www.infradead.org Git - users/hch/misc.git/commitdiff
bnxt_en: Optimize bnxt_sriov_disable()
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Wed, 17 Sep 2025 04:08:32 +0000 (21:08 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 18 Sep 2025 11:09:42 +0000 (13:09 +0200)
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: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20250917040839.1924698-4-michael.chan@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h

index 5f4f4d99f1e796fcd1087a411358b4a37635ae09..a74b50130cc031b5caee225c6fec85619bdc4542 100644 (file)
@@ -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);
 
index 480e18a32caa3ecac825408f9e4594a71cbed72b..e7fbfeb1a387a21d6e6c51816709e037733317af 100644 (file)
@@ -919,7 +919,7 @@ err_out1:
        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)
 {
 }
 
index 9a4bacba477b14603cf3bf327a8ceb4c2d919da8..e4979d7293125585345420ebba4bacfd698929fb 100644 (file)
@@ -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);