Skip to contentSkip to conversation

net: enetc: add more checks to enetc_set_rxfh()

PATCH Superseded Wei Fang 2 participants 6 messages Mar 25

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Fang

author maintainer
#0 lore raw

cover net: enetc: add more checks to enetc_set_rxfh()

ENETC only supports Toeplitz algorithm, and VFs do not support setting the RSS key, but enetc_set_rxfh() does not check these constraints and silently accepts unsupported configurations. This may mislead users or tools into believing that the requested RSS settings have been successfully applied. So add checks to reject unsupported hash functions and RSS key updates on VFs, and return "-EOPNOTSUPP" to user space.

Wei Fang (2):
net: enetc: check whether the RSS algorithm is Toeplitz
net: enetc: do not allow VF to configure the RSS key

 drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/2 net: enetc: check whether the RSS algorithm is Toeplitz

Both ENETC v1 and v4 only provide Toeplitz RSS support. This patch adds a validation check to reject attempts to configure other RSS algorithms, avoiding misleading configuration options for users.

Fixes d382563f541b ("enetc: Add RFS and RSS support")
---
 drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +4 -0
index 2fe140ddebb2..a393647e6062 100644
@@ -795,6 +795,10 @@ static int enetc_set_rxfh(struct net_device *ndev,
 	struct enetc_si *si = priv->si;
 	int err = 0;
 
+	if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
+	    rxfh->hfunc != ETH_RSS_HASH_TOP)
+		return -EOPNOTSUPP;
+
 	/* set hash key, if PF */
 	if (rxfh->key && enetc_si_is_pf(si))
 		enetc_set_rss_key(si, rxfh->key);
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH 2/2 net: enetc: do not allow VF to configure the RSS key

In reply to Wei Fang

VFs do not have privilege to configure the RSS key because the registers are owned by the PF. Currently, if a VF attempts to onfigure the RSS key, enetc_set_rxfh() simply skips the configuration and does not generate a warning, which may mislead users into thinking the feature is supported. To improve this situation, add a check to reject RSS key configuration on VFs.

Fixes d382563f541b ("enetc: Add RFS and RSS support")
---
 drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +5 -1
index a393647e6062..7c17acaf7a38 100644
@@ -800,8 +800,12 @@ static int enetc_set_rxfh(struct net_device *ndev,
 		return -EOPNOTSUPP;
 
 	/* set hash key, if PF */
-	if (rxfh->key && enetc_si_is_pf(si))
+	if (rxfh->key) {
+		if (!enetc_si_is_pf(si))
+			return -EOPNOTSUPP;
+
 		enetc_set_rss_key(si, rxfh->key);
+	}
 
 	/* set RSS table */
 	if (rxfh->indir)
Signature · 1 line
2.34.1
maintainer
#4 lore raw

RE: [PATCH net 2/2] net: enetc: do not allow VF to configure the RSS key

Quoted 3 lines

VFs do not have privilege to configure the RSS key because the registers are owned by the PF. Currently, if a VF attempts to onfigure the RSS key,

Typo here: onfigure -> configure

Quoted 7 lines

enetc_set_rxfh() simply skips the configuration and does not generate a warning, which may mislead users into thinking the feature is supported. To improve this situation, add a check to reject RSS key configuration on VFs.

Fixes d382563f541b ("enetc: Add RFS and RSS support")

With the typo fixed, Reviewed-by: Clark Wang <[email protected]>

maintainer Reviewed-by on v1 1/2
#2 lore raw

RE: [PATCH net 1/2] net: enetc: check whether the RSS algorithm is Toeplitz

In reply to Wei Fang
Quoted 6 lines

Both ENETC v1 and v4 only provide Toeplitz RSS support. This patch adds a validation check to reject attempts to configure other RSS algorithms, avoiding misleading configuration options for users.

Fixes d382563f541b ("enetc: Add RFS and RSS support")
author maintainer
#5 lore raw

RE: [PATCH net 2/2] net: enetc: do not allow VF to configure the RSS key

In reply to Clark Wang
Quoted 10 lines
Quoted 3 lines

VFs do not have privilege to configure the RSS key because the registers are owned by the PF. Currently, if a VF attempts to onfigure the RSS key,

Typo here: onfigure -> configure

Quoted 5 lines

enetc_set_rxfh() simply skips the configuration and does not generate a warning, which may mislead users into thinking the feature is supported. To improve this situation, add a check to reject RSS key configuration on VFs.

Quoted 4 lines
Quoted 2 lines
Fixes d382563f541b ("enetc: Add RFS and RSS support")

With the typo fixed, Reviewed-by: Clark Wang <[email protected]>

Thanks for catching this.