]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: enetc: relocate SR-IOV configuration helper for common PF support
authorWei Fang <wei.fang@nxp.com>
Fri, 22 May 2026 09:24:29 +0000 (17:24 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 26 May 2026 11:20:13 +0000 (13:20 +0200)
Move enetc_sriov_configure() from enetc_pf.c to enetc_msg.c to prepare
for integrating enetc_msg.c into the enetc-pf-common driver, where it
will be shared between ENETC v1 and v4 PF drivers.

Since enetc_msg_psi_init() and enetc_msg_psi_free() are now only called
from enetc_sriov_configure() within the same file, make them static.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Link: https://patch.msgid.link/20260522092438.1264020-4-wei.fang@nxp.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/freescale/enetc/enetc_msg.c
drivers/net/ethernet/freescale/enetc/enetc_pf.c
drivers/net/ethernet/freescale/enetc/enetc_pf.h
drivers/net/ethernet/freescale/enetc/enetc_pf_common.h

index 73da2018034e1f78b152ecd325d07c9de8132b11..fd1a42bbdcb1856395da1fed3149b9c94a3498fb 100644 (file)
@@ -189,7 +189,7 @@ static void enetc_msg_free_mbx(struct enetc_si *si, int idx)
        memset(msg, 0, sizeof(*msg));
 }
 
-int enetc_msg_psi_init(struct enetc_pf *pf)
+static int enetc_msg_psi_init(struct enetc_pf *pf)
 {
        struct enetc_si *si = pf->si;
        int vector, i, err;
@@ -229,7 +229,7 @@ free_mbx:
        return err;
 }
 
-void enetc_msg_psi_free(struct enetc_pf *pf)
+static void enetc_msg_psi_free(struct enetc_pf *pf)
 {
        struct enetc_si *si = pf->si;
        int i;
@@ -248,3 +248,39 @@ void enetc_msg_psi_free(struct enetc_pf *pf)
        for (i = 0; i < pf->num_vfs; i++)
                enetc_msg_free_mbx(si, i);
 }
+
+int enetc_sriov_configure(struct pci_dev *pdev, int num_vfs)
+{
+       struct enetc_si *si = pci_get_drvdata(pdev);
+       struct enetc_pf *pf = enetc_si_priv(si);
+       int err;
+
+       if (!num_vfs) {
+               pci_disable_sriov(pdev);
+               enetc_msg_psi_free(pf);
+               pf->num_vfs = 0;
+       } else {
+               pf->num_vfs = num_vfs;
+
+               err = enetc_msg_psi_init(pf);
+               if (err) {
+                       dev_err(&pdev->dev, "enetc_msg_psi_init (%d)\n", err);
+                       goto err_msg_psi;
+               }
+
+               err = pci_enable_sriov(pdev, num_vfs);
+               if (err) {
+                       dev_err(&pdev->dev, "pci_enable_sriov err %d\n", err);
+                       goto err_en_sriov;
+               }
+       }
+
+       return num_vfs;
+
+err_en_sriov:
+       enetc_msg_psi_free(pf);
+err_msg_psi:
+       pf->num_vfs = 0;
+
+       return err;
+}
index 67cc80adec72d4fb7e34b69ca3cd46e290d36723..fbe2c126082e92d0ee849b80b30dd62ed14d10b7 100644 (file)
@@ -480,46 +480,6 @@ static void enetc_configure_port(struct enetc_pf *pf)
        enetc_port_wr(hw, ENETC_PMR, ENETC_PMR_EN);
 }
 
-#ifdef CONFIG_PCI_IOV
-static int enetc_sriov_configure(struct pci_dev *pdev, int num_vfs)
-{
-       struct enetc_si *si = pci_get_drvdata(pdev);
-       struct enetc_pf *pf = enetc_si_priv(si);
-       int err;
-
-       if (!num_vfs) {
-               pci_disable_sriov(pdev);
-               enetc_msg_psi_free(pf);
-               pf->num_vfs = 0;
-       } else {
-               pf->num_vfs = num_vfs;
-
-               err = enetc_msg_psi_init(pf);
-               if (err) {
-                       dev_err(&pdev->dev, "enetc_msg_psi_init (%d)\n", err);
-                       goto err_msg_psi;
-               }
-
-               err = pci_enable_sriov(pdev, num_vfs);
-               if (err) {
-                       dev_err(&pdev->dev, "pci_enable_sriov err %d\n", err);
-                       goto err_en_sriov;
-               }
-       }
-
-       return num_vfs;
-
-err_en_sriov:
-       enetc_msg_psi_free(pf);
-err_msg_psi:
-       pf->num_vfs = 0;
-
-       return err;
-}
-#else
-#define enetc_sriov_configure(pdev, num_vfs)   (void)0
-#endif
-
 static int enetc_pf_set_features(struct net_device *ndev,
                                 netdev_features_t features)
 {
index 3b265ad8d845bef3b6e5e8c20ff4b3d572d4fd40..5b4094f8d5d4db88806f48ab8fbda29f2ff9af3b 100644 (file)
@@ -68,6 +68,3 @@ struct enetc_pf {
 
 #define phylink_to_enetc_pf(config) \
        container_of((config), struct enetc_pf, phylink_config)
-
-int enetc_msg_psi_init(struct enetc_pf *pf);
-void enetc_msg_psi_free(struct enetc_pf *pf);
index cef9fcc58e2f692087a75cd312ce2f1fa58faf6c..c9b3512d4e2fe2cfef7288b11963cc8ed9652d0f 100644 (file)
@@ -21,3 +21,12 @@ static inline u16 enetc_get_ip_revision(struct enetc_hw *hw)
 {
        return enetc_global_rd(hw, ENETC_G_EIPBRR0) & EIPBRR0_REVISION;
 }
+
+#if IS_ENABLED(CONFIG_PCI_IOV)
+int enetc_sriov_configure(struct pci_dev *pdev, int num_vfs);
+#else
+static inline int enetc_sriov_configure(struct pci_dev *pdev, int num_vfs)
+{
+       return 0;
+}
+#endif