mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
net: enetc: relocate SR-IOV configuration helper for common PF support
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>
This commit is contained in:
parent
9ba01f8770
commit
bb69b9fd1c
|
|
@ -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 @@ int enetc_msg_psi_init(struct enetc_pf *pf)
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user