diff mbox series

[net-next,04/12] ethtool: make ethtool_ops::cap_rss_ctx_supported optional

Message ID 20240802001801.565176-5-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: 28 this patch: 25
netdev/build_tools success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 1 maintainers not CCed: ahmed.zaki@intel.com
netdev/build_clang fail Errors and warnings before: 70 this patch: 70
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: 1417 this patch: 1514
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 5 this patch: 5
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski Aug. 2, 2024, 12:17 a.m. UTC
cap_rss_ctx_supported was created because the API for creating
and configuring additional contexts is mux'ed with the normal
RSS API. Presence of ops does not imply driver can actually
support rss_context != 0 (in fact drivers mostly ignore that
field). cap_rss_ctx_supported lets core check that the driver
is context-aware before calling it.

Now that we have .create_rxfh_context, there is no such
ambiguity. We can depend on presence of the op.
Make setting the bit optional.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 include/linux/ethtool.h | 3 ++-
 net/ethtool/ioctl.c     | 6 ++++--
 net/ethtool/rss.c       | 3 ++-
 3 files changed, 8 insertions(+), 4 deletions(-)

Comments

Joe Damato Aug. 2, 2024, 11:35 a.m. UTC | #1
On Thu, Aug 01, 2024 at 05:17:53PM -0700, Jakub Kicinski wrote:
> cap_rss_ctx_supported was created because the API for creating
> and configuring additional contexts is mux'ed with the normal
> RSS API. Presence of ops does not imply driver can actually
> support rss_context != 0 (in fact drivers mostly ignore that
> field). cap_rss_ctx_supported lets core check that the driver
> is context-aware before calling it.
> 
> Now that we have .create_rxfh_context, there is no such
> ambiguity. We can depend on presence of the op.
> Make setting the bit optional.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  include/linux/ethtool.h | 3 ++-
>  net/ethtool/ioctl.c     | 6 ++++--
>  net/ethtool/rss.c       | 3 ++-
>  3 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
> index 303fda54ef17..55c9f613ab64 100644
> --- a/include/linux/ethtool.h
> +++ b/include/linux/ethtool.h
> @@ -727,7 +727,8 @@ struct kernel_ethtool_ts_info {
>   * @cap_link_lanes_supported: indicates if the driver supports lanes
>   *	parameter.
>   * @cap_rss_ctx_supported: indicates if the driver supports RSS
> - *	contexts.
> + *	contexts via legacy API, drivers implementing @create_rxfh_context
> + *	do not have to set this bit.
>   * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor
>   *	RSS.
>   * @rxfh_indir_space: max size of RSS indirection tables, if indirection table
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 8ca13208d240..52dfb07393a6 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -1227,7 +1227,8 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
>  	if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
>  		return -EINVAL;
>  	/* Most drivers don't handle rss_context, check it's 0 as well */
> -	if (rxfh.rss_context && !ops->cap_rss_ctx_supported)
> +	if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
> +				  ops->create_rxfh_context))
>  		return -EOPNOTSUPP;
>  
>  	rxfh.indir_size = rxfh_dev.indir_size;
> @@ -1357,7 +1358,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
>  	if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
>  		return -EINVAL;
>  	/* Most drivers don't handle rss_context, check it's 0 as well */
> -	if (rxfh.rss_context && !ops->cap_rss_ctx_supported)
> +	if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
> +				  ops->create_rxfh_context))
>  		return -EOPNOTSUPP;
>  	/* Check input data transformation capabilities */
>  	if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
> diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
> index 5c4c4505ab9a..a06bdac8b8a2 100644
> --- a/net/ethtool/rss.c
> +++ b/net/ethtool/rss.c
> @@ -60,7 +60,8 @@ rss_prepare_data(const struct ethnl_req_info *req_base,
>  		return -EOPNOTSUPP;
>  
>  	/* Some drivers don't handle rss_context */
> -	if (request->rss_context && !ops->cap_rss_ctx_supported)
> +	if (request->rss_context && !(ops->cap_rss_ctx_supported ||
> +				      ops->create_rxfh_context))
>  		return -EOPNOTSUPP;
>  
>  	ret = ethnl_ops_begin(dev);
> -- 
> 2.45.2

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

Patch

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 303fda54ef17..55c9f613ab64 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -727,7 +727,8 @@  struct kernel_ethtool_ts_info {
  * @cap_link_lanes_supported: indicates if the driver supports lanes
  *	parameter.
  * @cap_rss_ctx_supported: indicates if the driver supports RSS
- *	contexts.
+ *	contexts via legacy API, drivers implementing @create_rxfh_context
+ *	do not have to set this bit.
  * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor
  *	RSS.
  * @rxfh_indir_space: max size of RSS indirection tables, if indirection table
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 8ca13208d240..52dfb07393a6 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1227,7 +1227,8 @@  static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
 	if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
 		return -EINVAL;
 	/* Most drivers don't handle rss_context, check it's 0 as well */
-	if (rxfh.rss_context && !ops->cap_rss_ctx_supported)
+	if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
+				  ops->create_rxfh_context))
 		return -EOPNOTSUPP;
 
 	rxfh.indir_size = rxfh_dev.indir_size;
@@ -1357,7 +1358,8 @@  static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
 		return -EINVAL;
 	/* Most drivers don't handle rss_context, check it's 0 as well */
-	if (rxfh.rss_context && !ops->cap_rss_ctx_supported)
+	if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
+				  ops->create_rxfh_context))
 		return -EOPNOTSUPP;
 	/* Check input data transformation capabilities */
 	if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
index 5c4c4505ab9a..a06bdac8b8a2 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ -60,7 +60,8 @@  rss_prepare_data(const struct ethnl_req_info *req_base,
 		return -EOPNOTSUPP;
 
 	/* Some drivers don't handle rss_context */
-	if (request->rss_context && !ops->cap_rss_ctx_supported)
+	if (request->rss_context && !(ops->cap_rss_ctx_supported ||
+				      ops->create_rxfh_context))
 		return -EOPNOTSUPP;
 
 	ret = ethnl_ops_begin(dev);