diff mbox series

[net-next,07/12] ethtool: rss: move the device op invocation out of rss_prepare_data()

Message ID 20240802001801.565176-8-kuba@kernel.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ethtool: rss: driver tweaks and netlink context dumps | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; GEN HAS DIFF 2 files changed, 119 insertions(+);
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 fail Errors and warnings before: 25 this patch: 22
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: ahmed.zaki@intel.com
netdev/build_clang fail Errors and warnings before: 37 this patch: 25
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: 207 this patch: 51
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 62 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski Aug. 2, 2024, 12:17 a.m. UTC
Factor calling device ops out of rss_prepare_data().
Next patch will add alternative path using xarray.
No functional changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/ethtool/rss.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

Comments

Joe Damato Aug. 2, 2024, 1:15 p.m. UTC | #1
On Thu, Aug 01, 2024 at 05:17:56PM -0700, Jakub Kicinski wrote:
> Factor calling device ops out of rss_prepare_data().
> Next patch will add alternative path using xarray.
> No functional changes.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  net/ethtool/rss.c | 43 +++++++++++++++++++++++++++----------------
>  1 file changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
> index cd8100d81919..5c477cc36251 100644
> --- a/net/ethtool/rss.c
> +++ b/net/ethtool/rss.c
> @@ -43,13 +43,9 @@ rss_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb,
>  }
>  
>  static int
> -rss_prepare_data(const struct ethnl_req_info *req_base,
> -		 struct ethnl_reply_data *reply_base,
> -		 const struct genl_info *info)
> +rss_prepare_get(const struct rss_req_info *request, struct net_device *dev,
> +		struct rss_reply_data *data, const struct genl_info *info)
>  {
> -	struct rss_reply_data *data = RSS_REPDATA(reply_base);
> -	struct rss_req_info *request = RSS_REQINFO(req_base);
> -	struct net_device *dev = reply_base->dev;
>  	struct ethtool_rxfh_param rxfh = {};
>  	const struct ethtool_ops *ops;
>  	u32 total_size, indir_bytes;
> @@ -57,16 +53,6 @@ rss_prepare_data(const struct ethnl_req_info *req_base,
>  	int ret;
>  
>  	ops = dev->ethtool_ops;
> -	if (!ops->get_rxfh)
> -		return -EOPNOTSUPP;
> -
> -	/* Some drivers don't handle rss_context */
> -	if (request->rss_context) {
> -		if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context)
> -			return -EOPNOTSUPP;
> -
> -		data->no_key_fields = !ops->rxfh_per_ctx_key;
> -	}
>  
>  	ret = ethnl_ops_begin(dev);
>  	if (ret < 0)
> @@ -109,6 +95,31 @@ rss_prepare_data(const struct ethnl_req_info *req_base,
>  	return ret;
>  }
>  
> +static int
> +rss_prepare_data(const struct ethnl_req_info *req_base,
> +		 struct ethnl_reply_data *reply_base,
> +		 const struct genl_info *info)
> +{
> +	struct rss_reply_data *data = RSS_REPDATA(reply_base);
> +	struct rss_req_info *request = RSS_REQINFO(req_base);
> +	struct net_device *dev = reply_base->dev;
> +	const struct ethtool_ops *ops;
> +
> +	ops = dev->ethtool_ops;
> +	if (!ops->get_rxfh)
> +		return -EOPNOTSUPP;
> +
> +	/* Some drivers don't handle rss_context */
> +	if (request->rss_context) {
> +		if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context)
> +			return -EOPNOTSUPP;
> +
> +		data->no_key_fields = !ops->rxfh_per_ctx_key;
> +	}
> +
> +	return rss_prepare_get(request, dev, data, info);
> +}
> +
>  static int
>  rss_reply_size(const struct ethnl_req_info *req_base,
>  	       const struct ethnl_reply_data *reply_base)
> -- 
> 2.45.2
> 
> 

Reviewed-by: Joe Damato <jdamato@fastly.com>
diff mbox series

Patch

diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
index cd8100d81919..5c477cc36251 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ -43,13 +43,9 @@  rss_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb,
 }
 
 static int
-rss_prepare_data(const struct ethnl_req_info *req_base,
-		 struct ethnl_reply_data *reply_base,
-		 const struct genl_info *info)
+rss_prepare_get(const struct rss_req_info *request, struct net_device *dev,
+		struct rss_reply_data *data, const struct genl_info *info)
 {
-	struct rss_reply_data *data = RSS_REPDATA(reply_base);
-	struct rss_req_info *request = RSS_REQINFO(req_base);
-	struct net_device *dev = reply_base->dev;
 	struct ethtool_rxfh_param rxfh = {};
 	const struct ethtool_ops *ops;
 	u32 total_size, indir_bytes;
@@ -57,16 +53,6 @@  rss_prepare_data(const struct ethnl_req_info *req_base,
 	int ret;
 
 	ops = dev->ethtool_ops;
-	if (!ops->get_rxfh)
-		return -EOPNOTSUPP;
-
-	/* Some drivers don't handle rss_context */
-	if (request->rss_context) {
-		if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context)
-			return -EOPNOTSUPP;
-
-		data->no_key_fields = !ops->rxfh_per_ctx_key;
-	}
 
 	ret = ethnl_ops_begin(dev);
 	if (ret < 0)
@@ -109,6 +95,31 @@  rss_prepare_data(const struct ethnl_req_info *req_base,
 	return ret;
 }
 
+static int
+rss_prepare_data(const struct ethnl_req_info *req_base,
+		 struct ethnl_reply_data *reply_base,
+		 const struct genl_info *info)
+{
+	struct rss_reply_data *data = RSS_REPDATA(reply_base);
+	struct rss_req_info *request = RSS_REQINFO(req_base);
+	struct net_device *dev = reply_base->dev;
+	const struct ethtool_ops *ops;
+
+	ops = dev->ethtool_ops;
+	if (!ops->get_rxfh)
+		return -EOPNOTSUPP;
+
+	/* Some drivers don't handle rss_context */
+	if (request->rss_context) {
+		if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context)
+			return -EOPNOTSUPP;
+
+		data->no_key_fields = !ops->rxfh_per_ctx_key;
+	}
+
+	return rss_prepare_get(request, dev, data, info);
+}
+
 static int
 rss_reply_size(const struct ethnl_req_info *req_base,
 	       const struct ethnl_reply_data *reply_base)