lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2b0bb0b96c09cc79d39ef79ce6733fc0244c5548.1680538846.git.ecree.xilinx@gmail.com>
Date:   Mon, 3 Apr 2023 17:33:01 +0100
From:   <edward.cree@....com>
To:     <linux-net-drivers@....com>, <davem@...emloft.net>,
        <kuba@...nel.org>, <pabeni@...hat.com>, <edumazet@...gle.com>
CC:     Edward Cree <ecree.xilinx@...il.com>, <netdev@...r.kernel.org>,
        <habetsm.xilinx@...il.com>, <sudheer.mogilappagari@...el.com>
Subject: [RFC PATCH net-next 4/6] net: ethtool: pass ctx_priv and create into .set_rxfh_context

From: Edward Cree <ecree.xilinx@...il.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@...il.com>
---
 include/linux/ethtool.h | 12 ++++++++----
 net/core/dev.c          |  5 +++--
 net/ethtool/ioctl.c     |  6 ++++--
 3 files changed, 15 insertions(+), 8 deletions(-)

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,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ