net: enetc: add set/get_rss_table() hooks to enetc_si_ops

Since i.MX95 ENETC (v4) uses NTMP 2.0 to manage the RSS table, which is
different from LS1028A ENETC (v1). In order to reuse some functions
related to the RSS table, so add .get_rss_table() and .set_rss_table()
hooks to enetc_si_ops.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20250506080735.3444381-7-wei.fang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Wei Fang
2025-05-06 16:07:27 +08:00
committed by Jakub Kicinski
parent df6cb09580
commit 66b3fb0011
5 changed files with 32 additions and 7 deletions

View File

@@ -2415,7 +2415,7 @@ static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups)
for (i = 0; i < si->num_rss; i++)
rss_table[i] = i % num_groups;
enetc_set_rss_table(si, rss_table, si->num_rss);
si->ops->set_rss_table(si, rss_table, si->num_rss);
kfree(rss_table);

View File

@@ -279,6 +279,19 @@ struct enetc_platform_info {
const struct enetc_drvdata *data;
};
struct enetc_si;
/*
* This structure defines the some common hooks for ENETC PSI and VSI.
* In addition, since VSI only uses the struct enetc_si as its private
* driver data, so this structure also define some hooks specifically
* for VSI. For VSI-specific hooks, the format is vf_*().
*/
struct enetc_si_ops {
int (*get_rss_table)(struct enetc_si *si, u32 *table, int count);
int (*set_rss_table)(struct enetc_si *si, const u32 *table, int count);
};
/* PCI IEP device data */
struct enetc_si {
struct pci_dev *pdev;

View File

@@ -681,7 +681,8 @@ static int enetc_get_rxfh(struct net_device *ndev,
struct ethtool_rxfh_param *rxfh)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
struct enetc_hw *hw = &priv->si->hw;
struct enetc_si *si = priv->si;
struct enetc_hw *hw = &si->hw;
int err = 0, i;
/* return hash function */
@@ -695,8 +696,7 @@ static int enetc_get_rxfh(struct net_device *ndev,
/* return RSS table */
if (rxfh->indir)
err = enetc_get_rss_table(priv->si, rxfh->indir,
priv->si->num_rss);
err = si->ops->get_rss_table(si, rxfh->indir, si->num_rss);
return err;
}
@@ -715,7 +715,8 @@ static int enetc_set_rxfh(struct net_device *ndev,
struct netlink_ext_ack *extack)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
struct enetc_hw *hw = &priv->si->hw;
struct enetc_si *si = priv->si;
struct enetc_hw *hw = &si->hw;
int err = 0;
/* set hash key, if PF */
@@ -724,8 +725,7 @@ static int enetc_set_rxfh(struct net_device *ndev,
/* set RSS table */
if (rxfh->indir)
err = enetc_set_rss_table(priv->si, rxfh->indir,
priv->si->num_rss);
err = si->ops->set_rss_table(si, rxfh->indir, si->num_rss);
return err;
}

View File

@@ -905,6 +905,11 @@ static int enetc_pf_register_with_ierb(struct pci_dev *pdev)
return enetc_ierb_register_pf(ierb_pdev, pdev);
}
static const struct enetc_si_ops enetc_psi_ops = {
.get_rss_table = enetc_get_rss_table,
.set_rss_table = enetc_set_rss_table,
};
static struct enetc_si *enetc_psi_create(struct pci_dev *pdev)
{
struct enetc_si *si;
@@ -924,6 +929,7 @@ static struct enetc_si *enetc_psi_create(struct pci_dev *pdev)
}
si->revision = enetc_get_ip_revision(&si->hw);
si->ops = &enetc_psi_ops;
err = enetc_get_driver_data(si);
if (err) {
dev_err(&pdev->dev, "Could not get PF driver data\n");

View File

@@ -162,6 +162,11 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
enetc_load_primary_mac_addr(&si->hw, ndev);
}
static const struct enetc_si_ops enetc_vsi_ops = {
.get_rss_table = enetc_get_rss_table,
.set_rss_table = enetc_set_rss_table,
};
static int enetc_vf_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -176,6 +181,7 @@ static int enetc_vf_probe(struct pci_dev *pdev,
si = pci_get_drvdata(pdev);
si->revision = ENETC_REV_1_0;
si->ops = &enetc_vsi_ops;
err = enetc_get_driver_data(si);
if (err) {
dev_err_probe(&pdev->dev, err,