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>
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;
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;
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;
+}
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)
{
#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);
{
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