diff mbox series

[RFC,net-next,4/6] net: ethtool: pass ctx_priv and create into .set_rxfh_context

Message ID 2b0bb0b96c09cc79d39ef79ce6733fc0244c5548.1680538846.git.ecree.xilinx@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ethtool: track custom RSS contexts in the core | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1896 this patch: 1896
netdev/cc_maintainers warning 3 maintainers not CCed: vladimir.oltean@nxp.com d-tatianin@yandex-team.ru andrew@lunn.ch
netdev/build_clang fail Errors and warnings before: 576 this patch: 576
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 1605 this patch: 1887
netdev/checkpatch warning WARNING: function definition argument 'struct net_device *' should also have an identifier name
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

edward.cree@amd.com April 3, 2023, 4:33 p.m. UTC
From: Edward Cree <ecree.xilinx@gmail.com>

Allows drivers to easily use the private data area in the ctx to store
 their hardware-specific state.
The create flag is needed to inform them that in this case ctx_priv
 has not already been populated.

Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
---
 include/linux/ethtool.h | 12 ++++++++----
 net/core/dev.c          |  5 +++--
 net/ethtool/ioctl.c     |  6 ++++--
 3 files changed, 15 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 0c7df2e043b2..141b020a8855 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -750,11 +750,13 @@  struct ethtool_mm_stats {
  *	the contents of the RX flow hash indirection table, hash key, and/or
  *	hash function associated to the given context. Arguments which are set
  *	to %NULL or zero will remain unchanged.
+ *	The &struct ethtool_rxfh_context for this context is passed in @ctx;
+ *	note that it will still contain the *old* settings.  The driver does
+ *	not need to update these; the core will do so if this op succeeds.
  *	Returns a negative error code or zero. An error code must be returned
  *	if at least one unsupported change was requested.
  * @set_rxfh_context_old: Legacy version of @set_rxfh_context, where driver
  *	chooses the new context ID in the %ETH_RXFH_CONTEXT_ALLOC case.
- *	Arguments and return otherwise the same.
  * @get_channels: Get number of channels.
  * @set_channels: Set number of channels.  Returns a negative error code or
  *	zero.
@@ -902,9 +904,11 @@  struct ethtool_ops {
 	u16	(*get_rxfh_priv_size)(struct net_device *);
 	int	(*get_rxfh_context)(struct net_device *, u32 *indir, u8 *key,
 				    u8 *hfunc, u32 rss_context);
-	int	(*set_rxfh_context)(struct net_device *, const u32 *indir,
-				    const u8 *key, const u8 hfunc,
-				    u32 rss_context, bool delete);
+	int	(*set_rxfh_context)(struct net_device *,
+				    struct ethtool_rxfh_context *ctx,
+				    const u32 *indir, const u8 *key,
+				    const u8 hfunc, u32 rss_context,
+				    bool create, bool delete);
 	int	(*set_rxfh_context_old)(struct net_device *, const u32 *indir,
 					const u8 *key, const u8 hfunc,
 					u32 *rss_context, bool delete);
diff --git a/net/core/dev.c b/net/core/dev.c
index 0600945a6810..b2cfc631761d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10794,8 +10794,9 @@  static void netdev_rss_contexts_free(struct net_device *dev)
 
 		idr_remove(&dev->rss_ctx, context);
 		if (dev->ethtool_ops->set_rxfh_context)
-			dev->ethtool_ops->set_rxfh_context(dev, indir, key,
-							   ctx->hfunc, context,
+			dev->ethtool_ops->set_rxfh_context(dev, ctx, indir,
+							   key, ctx->hfunc,
+							   context, false,
 							   true);
 		else
 			dev->ethtool_ops->set_rxfh_context_old(dev, indir, key,
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 9e41dc9151d2..fa0a3de1e9fb 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1382,8 +1382,10 @@  static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 
 	if (rxfh.rss_context) {
 		if (ops->set_rxfh_context)
-			ret = ops->set_rxfh_context(dev, indir, hkey, rxfh.hfunc,
-						    rxfh.rss_context, delete);
+			ret = ops->set_rxfh_context(dev, ctx, indir, hkey,
+						    rxfh.hfunc,
+						    rxfh.rss_context, create,
+						    delete);
 		else
 			ret = ops->set_rxfh_context_old(dev, indir, hkey,
 							rxfh.hfunc,