* [PATCH net-next 1/9] net: ethtool: copy the rxfh flow handling
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-12 21:02 ` Joe Damato
2025-06-11 14:59 ` [PATCH net-next 2/9] net: ethtool: remove the duplicated handling from rxfh and rxnfc Jakub Kicinski
` (9 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, andrew
RX Flow Hash configuration uses the same argument structure
as flow filters. This is probably why ethtool IOCTL handles
them together. The more checks we add the more convoluted
this code is getting (as some of the checks apply only
to flow filters and others only to the hashing).
Copy the code to separate the handling. This is an exact
copy, the next change will remove unnecessary handling.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andrew@lunn.ch
CC: ecree.xilinx@gmail.com
---
net/ethtool/ioctl.c | 93 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 92 insertions(+), 1 deletion(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 39ec920f5de7..5c15eff53c80 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1060,6 +1060,93 @@ static int ethtool_check_flow_types(struct net_device *dev, u32 input_xfrm)
return 0;
}
+static noinline_for_stack int
+ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
+{
+ const struct ethtool_ops *ops = dev->ethtool_ops;
+ struct ethtool_rxnfc info;
+ size_t info_size = sizeof(info);
+ int rc;
+
+ if (!ops->set_rxnfc)
+ return -EOPNOTSUPP;
+
+ rc = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
+ if (rc)
+ return rc;
+
+ if (cmd == ETHTOOL_SRXCLSRLINS && info.fs.flow_type & FLOW_RSS) {
+ /* Nonzero ring with RSS only makes sense
+ * if NIC adds them together
+ */
+ if (!ops->cap_rss_rxnfc_adds &&
+ ethtool_get_flow_spec_ring(info.fs.ring_cookie))
+ return -EINVAL;
+
+ if (!xa_load(&dev->ethtool->rss_ctx, info.rss_context))
+ return -EINVAL;
+ }
+
+ if (cmd == ETHTOOL_SRXFH && ops->get_rxfh) {
+ struct ethtool_rxfh_param rxfh = {};
+
+ rc = ops->get_rxfh(dev, &rxfh);
+ if (rc)
+ return rc;
+
+ rc = ethtool_check_xfrm_rxfh(rxfh.input_xfrm, info.data);
+ if (rc)
+ return rc;
+ }
+
+ rc = ops->set_rxnfc(dev, &info);
+ if (rc)
+ return rc;
+
+ if (cmd == ETHTOOL_SRXCLSRLINS &&
+ ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL))
+ return -EFAULT;
+
+ return 0;
+}
+
+static noinline_for_stack int
+ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
+{
+ struct ethtool_rxnfc info;
+ size_t info_size = sizeof(info);
+ const struct ethtool_ops *ops = dev->ethtool_ops;
+ int ret;
+ void *rule_buf = NULL;
+
+ if (!ops->get_rxnfc)
+ return -EOPNOTSUPP;
+
+ ret = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
+ if (ret)
+ return ret;
+
+ if (info.cmd == ETHTOOL_GRXCLSRLALL) {
+ if (info.rule_cnt > 0) {
+ if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
+ rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
+ GFP_USER);
+ if (!rule_buf)
+ return -ENOMEM;
+ }
+ }
+
+ ret = ops->get_rxnfc(dev, &info, rule_buf);
+ if (ret < 0)
+ goto err_out;
+
+ ret = ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, rule_buf);
+err_out:
+ kfree(rule_buf);
+
+ return ret;
+}
+
static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
u32 cmd, void __user *useraddr)
{
@@ -3338,13 +3425,17 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
dev->ethtool_ops->set_priv_flags);
break;
case ETHTOOL_GRXFH:
+ rc = ethtool_get_rxfh_fields(dev, ethcmd, useraddr);
+ break;
+ case ETHTOOL_SRXFH:
+ rc = ethtool_set_rxfh_fields(dev, ethcmd, useraddr);
+ break;
case ETHTOOL_GRXRINGS:
case ETHTOOL_GRXCLSRLCNT:
case ETHTOOL_GRXCLSRULE:
case ETHTOOL_GRXCLSRLALL:
rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
break;
- case ETHTOOL_SRXFH:
case ETHTOOL_SRXCLSRLDEL:
case ETHTOOL_SRXCLSRLINS:
rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 1/9] net: ethtool: copy the rxfh flow handling
2025-06-11 14:59 ` [PATCH net-next 1/9] net: ethtool: copy the rxfh flow handling Jakub Kicinski
@ 2025-06-12 21:02 ` Joe Damato
0 siblings, 0 replies; 23+ messages in thread
From: Joe Damato @ 2025-06-12 21:02 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, andrew
On Wed, Jun 11, 2025 at 07:59:41AM -0700, Jakub Kicinski wrote:
> RX Flow Hash configuration uses the same argument structure
> as flow filters. This is probably why ethtool IOCTL handles
> them together. The more checks we add the more convoluted
> this code is getting (as some of the checks apply only
> to flow filters and others only to the hashing).
>
> Copy the code to separate the handling. This is an exact
> copy, the next change will remove unnecessary handling.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: andrew@lunn.ch
> CC: ecree.xilinx@gmail.com
> ---
> net/ethtool/ioctl.c | 93 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 92 insertions(+), 1 deletion(-)
>
Reviewed-by: Joe Damato <joe@dama.to>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 2/9] net: ethtool: remove the duplicated handling from rxfh and rxnfc
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
2025-06-11 14:59 ` [PATCH net-next 1/9] net: ethtool: copy the rxfh flow handling Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-12 21:34 ` Joe Damato
2025-06-11 14:59 ` [PATCH net-next 3/9] net: ethtool: require drivers to opt into the per-RSS ctx RXFH Jakub Kicinski
` (8 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, andrew
Now that the handles have been separated - remove the RX Flow Hash
handling from rxnfc functions and vice versa.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andrew@lunn.ch
CC: ecree.xilinx@gmail.com
---
net/ethtool/ioctl.c | 57 ++++-----------------------------------------
1 file changed, 5 insertions(+), 52 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 5c15eff53c80..330ca99800ce 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1075,19 +1075,7 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
if (rc)
return rc;
- if (cmd == ETHTOOL_SRXCLSRLINS && info.fs.flow_type & FLOW_RSS) {
- /* Nonzero ring with RSS only makes sense
- * if NIC adds them together
- */
- if (!ops->cap_rss_rxnfc_adds &&
- ethtool_get_flow_spec_ring(info.fs.ring_cookie))
- return -EINVAL;
-
- if (!xa_load(&dev->ethtool->rss_ctx, info.rss_context))
- return -EINVAL;
- }
-
- if (cmd == ETHTOOL_SRXFH && ops->get_rxfh) {
+ if (ops->get_rxfh) {
struct ethtool_rxfh_param rxfh = {};
rc = ops->get_rxfh(dev, &rxfh);
@@ -1099,15 +1087,7 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
return rc;
}
- rc = ops->set_rxnfc(dev, &info);
- if (rc)
- return rc;
-
- if (cmd == ETHTOOL_SRXCLSRLINS &&
- ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL))
- return -EFAULT;
-
- return 0;
+ return ops->set_rxnfc(dev, &info);
}
static noinline_for_stack int
@@ -1117,7 +1097,6 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
size_t info_size = sizeof(info);
const struct ethtool_ops *ops = dev->ethtool_ops;
int ret;
- void *rule_buf = NULL;
if (!ops->get_rxnfc)
return -EOPNOTSUPP;
@@ -1126,25 +1105,11 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
if (ret)
return ret;
- if (info.cmd == ETHTOOL_GRXCLSRLALL) {
- if (info.rule_cnt > 0) {
- if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
- rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
- GFP_USER);
- if (!rule_buf)
- return -ENOMEM;
- }
- }
-
- ret = ops->get_rxnfc(dev, &info, rule_buf);
+ ret = ops->get_rxnfc(dev, &info, NULL);
if (ret < 0)
- goto err_out;
+ return ret;
- ret = ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, rule_buf);
-err_out:
- kfree(rule_buf);
-
- return ret;
+ return ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL);
}
static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
@@ -1174,18 +1139,6 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
return -EINVAL;
}
- if (cmd == ETHTOOL_SRXFH && ops->get_rxfh) {
- struct ethtool_rxfh_param rxfh = {};
-
- rc = ops->get_rxfh(dev, &rxfh);
- if (rc)
- return rc;
-
- rc = ethtool_check_xfrm_rxfh(rxfh.input_xfrm, info.data);
- if (rc)
- return rc;
- }
-
rc = ops->set_rxnfc(dev, &info);
if (rc)
return rc;
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 2/9] net: ethtool: remove the duplicated handling from rxfh and rxnfc
2025-06-11 14:59 ` [PATCH net-next 2/9] net: ethtool: remove the duplicated handling from rxfh and rxnfc Jakub Kicinski
@ 2025-06-12 21:34 ` Joe Damato
0 siblings, 0 replies; 23+ messages in thread
From: Joe Damato @ 2025-06-12 21:34 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, andrew
On Wed, Jun 11, 2025 at 07:59:42AM -0700, Jakub Kicinski wrote:
> Now that the handles have been separated - remove the RX Flow Hash
> handling from rxnfc functions and vice versa.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: andrew@lunn.ch
> CC: ecree.xilinx@gmail.com
> ---
> net/ethtool/ioctl.c | 57 ++++-----------------------------------------
> 1 file changed, 5 insertions(+), 52 deletions(-)
Reviewed-by: Joe Damato <joe@dama.to>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 3/9] net: ethtool: require drivers to opt into the per-RSS ctx RXFH
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
2025-06-11 14:59 ` [PATCH net-next 1/9] net: ethtool: copy the rxfh flow handling Jakub Kicinski
2025-06-11 14:59 ` [PATCH net-next 2/9] net: ethtool: remove the duplicated handling from rxfh and rxnfc Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-12 21:09 ` Joe Damato
2025-06-11 14:59 ` [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields Jakub Kicinski
` (7 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, saeedm, tariqt, leon, linux-rdma,
linux-net-drivers
RX Flow Hashing supports using different configuration for different
RSS contexts. Only two drivers seem to support it. Make sure we
uniformly error out for drivers which don't.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: saeedm@nvidia.com
CC: tariqt@nvidia.com
CC: leon@kernel.org
CC: ecree.xilinx@gmail.com
CC: linux-rdma@vger.kernel.org
CC: linux-net-drivers@amd.com
---
include/linux/ethtool.h | 3 +++
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 1 +
drivers/net/ethernet/sfc/ethtool.c | 1 +
net/ethtool/ioctl.c | 8 ++++++++
4 files changed, 13 insertions(+)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 5e0dd333ad1f..fc1c2379e7ff 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -855,6 +855,8 @@ struct kernel_ethtool_ts_info {
* @cap_rss_ctx_supported: indicates if the driver supports RSS
* contexts via legacy API, drivers implementing @create_rxfh_context
* do not have to set this bit.
+ * @rxfh_per_ctx_fields: device supports selecting different header fields
+ * for Rx hash calculation and RSS for each additional context.
* @rxfh_per_ctx_key: device supports setting different RSS key for each
* additional context. Netlink API should report hfunc, key, and input_xfrm
* for every context, not just context 0.
@@ -1084,6 +1086,7 @@ struct ethtool_ops {
u32 supported_input_xfrm:8;
u32 cap_link_lanes_supported:1;
u32 cap_rss_ctx_supported:1;
+ u32 rxfh_per_ctx_fields:1;
u32 rxfh_per_ctx_key:1;
u32 cap_rss_rxnfc_adds:1;
u32 rxfh_indir_space;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index ea078c9f5d15..90c760057bb6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -2619,6 +2619,7 @@ static void mlx5e_get_ts_stats(struct net_device *netdev,
const struct ethtool_ops mlx5e_ethtool_ops = {
.cap_link_lanes_supported = true,
.cap_rss_ctx_supported = true,
+ .rxfh_per_ctx_fields = true,
.rxfh_per_ctx_key = true,
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES |
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 83d715544f7f..afbedca63b29 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -262,6 +262,7 @@ const struct ethtool_ops efx_ethtool_ops = {
.set_rxnfc = efx_ethtool_set_rxnfc,
.get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
.get_rxfh_key_size = efx_ethtool_get_rxfh_key_size,
+ .rxfh_per_ctx_fields = true,
.rxfh_per_ctx_key = true,
.cap_rss_rxnfc_adds = true,
.rxfh_priv_size = sizeof(struct efx_rss_context_priv),
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 330ca99800ce..bd9fd95bb82f 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1075,6 +1075,10 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
if (rc)
return rc;
+ if (info.flow_type & FLOW_RSS && info.rss_context &&
+ !ops->rxfh_per_ctx_fields)
+ return -EINVAL;
+
if (ops->get_rxfh) {
struct ethtool_rxfh_param rxfh = {};
@@ -1105,6 +1109,10 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
if (ret)
return ret;
+ if (info.flow_type & FLOW_RSS && info.rss_context &&
+ !ops->rxfh_per_ctx_fields)
+ return -EINVAL;
+
ret = ops->get_rxnfc(dev, &info, NULL);
if (ret < 0)
return ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 3/9] net: ethtool: require drivers to opt into the per-RSS ctx RXFH
2025-06-11 14:59 ` [PATCH net-next 3/9] net: ethtool: require drivers to opt into the per-RSS ctx RXFH Jakub Kicinski
@ 2025-06-12 21:09 ` Joe Damato
0 siblings, 0 replies; 23+ messages in thread
From: Joe Damato @ 2025-06-12 21:09 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, saeedm, tariqt, leon, linux-rdma, linux-net-drivers
On Wed, Jun 11, 2025 at 07:59:43AM -0700, Jakub Kicinski wrote:
> RX Flow Hashing supports using different configuration for different
> RSS contexts. Only two drivers seem to support it. Make sure we
> uniformly error out for drivers which don't.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: saeedm@nvidia.com
> CC: tariqt@nvidia.com
> CC: leon@kernel.org
> CC: ecree.xilinx@gmail.com
> CC: linux-rdma@vger.kernel.org
> CC: linux-net-drivers@amd.com
> ---
> include/linux/ethtool.h | 3 +++
> drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 1 +
> drivers/net/ethernet/sfc/ethtool.c | 1 +
> net/ethtool/ioctl.c | 8 ++++++++
> 4 files changed, 13 insertions(+)
Reviewed-by: Joe Damato <joe@dama.to>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (2 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 3/9] net: ethtool: require drivers to opt into the per-RSS ctx RXFH Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-13 5:36 ` Joe Damato
2025-06-18 17:25 ` Dan Carpenter
2025-06-11 14:59 ` [PATCH net-next 5/9] eth: remove empty RXFH handling from drivers Jakub Kicinski
` (6 subsequent siblings)
10 siblings, 2 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, andrew
We mux multiple calls to the drivers via the .get_nfc and .set_nfc
callbacks. This is slightly inconvenient to the drivers as they
have to de-mux them back. It will also be awkward for netlink code
to construct struct ethtool_rxnfc when it wants to get info about
RX Flow Hash, from the RSS module.
Add dedicated driver callbacks. Create struct ethtool_rxfh_fields
which contains only data relevant to RXFH. Maintain the names of
the fields to avoid having to heavily modify the drivers.
For now support both callbacks, once all drivers are converted
ethtool_*et_rxfh_fields() will stop using the rxnfc callbacks.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andrew@lunn.ch
CC: ecree.xilinx@gmail.com
---
include/linux/ethtool.h | 20 +++++++++++++++
net/ethtool/ioctl.c | 55 +++++++++++++++++++++++++++++++++--------
2 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index fc1c2379e7ff..b2e71e641f62 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -825,6 +825,19 @@ struct ethtool_rxfh_param {
u8 input_xfrm;
};
+/**
+ * struct ethtool_rxfh_fields - Rx Flow Hashing (RXFH) header field config
+ * @data: which header fields are used for hashing, bitmask of RXH_* defines
+ * @flow_type: L2-L4 network traffic flow type
+ * @rss_context: RSS context, will only be used if rxfh_per_ctx_fields is
+ * set in struct ethtool_ops
+ */
+struct ethtool_rxfh_fields {
+ u32 data;
+ u32 flow_type;
+ u32 rss_context;
+};
+
/**
* struct kernel_ethtool_ts_info - kernel copy of struct ethtool_ts_info
* @cmd: command number = %ETHTOOL_GET_TS_INFO
@@ -970,6 +983,8 @@ struct kernel_ethtool_ts_info {
* will remain unchanged.
* Returns a negative error code or zero. An error code must be returned
* if at least one unsupported change was requested.
+ * @get_rxfh_fields: Get header fields used for flow hashing.
+ * @set_rxfh_fields: Set header fields used for flow hashing.
* @create_rxfh_context: Create a new RSS context with the specified RX flow
* hash indirection table, hash key, and hash function.
* The &struct ethtool_rxfh_context for this context is passed in @ctx;
@@ -1156,6 +1171,11 @@ struct ethtool_ops {
int (*get_rxfh)(struct net_device *, struct ethtool_rxfh_param *);
int (*set_rxfh)(struct net_device *, struct ethtool_rxfh_param *,
struct netlink_ext_ack *extack);
+ int (*get_rxfh_fields)(struct net_device *,
+ struct ethtool_rxfh_fields *);
+ int (*set_rxfh_fields)(struct net_device *,
+ const struct ethtool_rxfh_fields *,
+ struct netlink_ext_ack *extack);
int (*create_rxfh_context)(struct net_device *,
struct ethtool_rxfh_context *ctx,
const struct ethtool_rxfh_param *rxfh,
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index bd9fd95bb82f..f4d4d60275f8 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1048,9 +1048,20 @@ static int ethtool_check_flow_types(struct net_device *dev, u32 input_xfrm)
continue;
info.flow_type = i;
- err = ops->get_rxnfc(dev, &info, NULL);
- if (err)
- continue;
+
+ if (ops->get_rxfh_fields) {
+ struct ethtool_rxfh_fields fields = {
+ .flow_type = info.flow_type,
+ };
+
+ if (ops->get_rxfh_fields(dev, &fields))
+ continue;
+
+ info.data = fields.data;
+ } else {
+ if (ops->get_rxnfc(dev, &info, NULL))
+ continue;
+ }
err = ethtool_check_xfrm_rxfh(input_xfrm, info.data);
if (err)
@@ -1064,11 +1075,12 @@ static noinline_for_stack int
ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
+ struct ethtool_rxfh_fields fields = {};
struct ethtool_rxnfc info;
size_t info_size = sizeof(info);
int rc;
- if (!ops->set_rxnfc)
+ if (!ops->set_rxnfc && !ops->set_rxfh_fields)
return -EOPNOTSUPP;
rc = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
@@ -1091,7 +1103,15 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
return rc;
}
- return ops->set_rxnfc(dev, &info);
+ if (!ops->set_rxfh_fields)
+ return ops->set_rxnfc(dev, &info);
+
+ fields.data = info.data;
+ fields.flow_type = info.flow_type & ~FLOW_RSS;
+ if (info.flow_type & FLOW_RSS)
+ fields.rss_context = info.rss_context;
+
+ return ops->set_rxfh_fields(dev, &fields, NULL);
}
static noinline_for_stack int
@@ -1102,7 +1122,7 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
const struct ethtool_ops *ops = dev->ethtool_ops;
int ret;
- if (!ops->get_rxnfc)
+ if (!ops->get_rxnfc && !ops->get_rxfh_fields)
return -EOPNOTSUPP;
ret = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
@@ -1113,9 +1133,24 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
!ops->rxfh_per_ctx_fields)
return -EINVAL;
- ret = ops->get_rxnfc(dev, &info, NULL);
- if (ret < 0)
- return ret;
+ if (ops->get_rxfh_fields) {
+ struct ethtool_rxfh_fields fields = {
+ .flow_type = info.flow_type & ~FLOW_RSS,
+ };
+
+ if (info.flow_type & FLOW_RSS)
+ fields.rss_context = info.rss_context;
+
+ ret = ops->get_rxfh_fields(dev, &fields);
+ if (ret < 0)
+ return ret;
+
+ info.data = fields.data;
+ } else {
+ ret = ops->get_rxnfc(dev, &info, NULL);
+ if (ret < 0)
+ return ret;
+ }
return ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL);
}
@@ -1492,7 +1527,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
u8 *rss_config;
int ret;
- if (!ops->get_rxnfc || !ops->set_rxfh)
+ if ((!ops->get_rxnfc && !ops->get_rxfh_fields) || !ops->set_rxfh)
return -EOPNOTSUPP;
if (ops->get_rxfh_indir_size)
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
2025-06-11 14:59 ` [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields Jakub Kicinski
@ 2025-06-13 5:36 ` Joe Damato
2025-06-13 14:39 ` Jakub Kicinski
2025-06-18 17:25 ` Dan Carpenter
1 sibling, 1 reply; 23+ messages in thread
From: Joe Damato @ 2025-06-13 5:36 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, andrew
On Wed, Jun 11, 2025 at 07:59:44AM -0700, Jakub Kicinski wrote:
> We mux multiple calls to the drivers via the .get_nfc and .set_nfc
> callbacks. This is slightly inconvenient to the drivers as they
> have to de-mux them back. It will also be awkward for netlink code
> to construct struct ethtool_rxnfc when it wants to get info about
> RX Flow Hash, from the RSS module.
>
> Add dedicated driver callbacks. Create struct ethtool_rxfh_fields
> which contains only data relevant to RXFH. Maintain the names of
> the fields to avoid having to heavily modify the drivers.
>
> For now support both callbacks, once all drivers are converted
> ethtool_*et_rxfh_fields() will stop using the rxnfc callbacks.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: andrew@lunn.ch
> CC: ecree.xilinx@gmail.com
> ---
[...]
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index bd9fd95bb82f..f4d4d60275f8 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
[...]
> @@ -1492,7 +1527,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
> u8 *rss_config;
> int ret;
>
> - if (!ops->get_rxnfc || !ops->set_rxfh)
> + if ((!ops->get_rxnfc && !ops->get_rxfh_fields) || !ops->set_rxfh)
> return -EOPNOTSUPP;
I realize I am late to the thread, but is this part above correct? It seems
like ethtool_set_rxfh calls ops->get_rxnfc but not ops->get_rxfh_fields,
unless I missed something in an earlier patch?
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
2025-06-13 5:36 ` Joe Damato
@ 2025-06-13 14:39 ` Jakub Kicinski
0 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-13 14:39 UTC (permalink / raw)
To: Joe Damato
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, andrew
On Fri, 13 Jun 2025 08:36:15 +0300 Joe Damato wrote:
> > @@ -1492,7 +1527,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
> > u8 *rss_config;
> > int ret;
> >
> > - if (!ops->get_rxnfc || !ops->set_rxfh)
> > + if ((!ops->get_rxnfc && !ops->get_rxfh_fields) || !ops->set_rxfh)
> > return -EOPNOTSUPP;
>
> I realize I am late to the thread, but is this part above correct? It seems
> like ethtool_set_rxfh calls ops->get_rxnfc but not ops->get_rxfh_fields,
> unless I missed something in an earlier patch?
It calls ethtool_check_flow_types(), but you're right it also calls
->get_rxnfc, so it should have been an ||. I'll correct in the "closing
patch" that removes the calls to get_rxnfc once all drivers are done.
Thanks!
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
2025-06-11 14:59 ` [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields Jakub Kicinski
2025-06-13 5:36 ` Joe Damato
@ 2025-06-18 17:25 ` Dan Carpenter
2025-06-18 18:35 ` Jakub Kicinski
1 sibling, 1 reply; 23+ messages in thread
From: Dan Carpenter @ 2025-06-18 17:25 UTC (permalink / raw)
To: oe-kbuild, Jakub Kicinski; +Cc: lkp, oe-kbuild-all
Hi Jakub,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Jakub-Kicinski/net-ethtool-copy-the-rxfh-flow-handling/20250611-231716
base: net-next/main
patch link: https://lore.kernel.org/r/20250611145949.2674086-5-kuba%40kernel.org
patch subject: [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
config: i386-randconfig-r071-20250612 (https://download.01.org/0day-ci/archive/20250613/202506131104.4D5TmGvi-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202506131104.4D5TmGvi-lkp@intel.com/
smatch warnings:
net/ethtool/ioctl.c:1592 ethtool_set_rxfh() error: we previously assumed 'ops->get_rxnfc' could be null (see line 1530)
vim +1592 net/ethtool/ioctl.c
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1513 static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1514 void __user *useraddr)
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1515 {
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1516 u32 rss_cfg_offset = offsetof(struct ethtool_rxfh, rss_config[0]);
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1517 const struct ethtool_ops *ops = dev->ethtool_ops;
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1518 u32 dev_indir_size = 0, dev_key_size = 0, i;
7195f0ef7f5b8c6 net/ethtool/ioctl.c Jakub Kicinski 2024-07-25 1519 u32 user_indir_len = 0, indir_bytes = 0;
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1520 struct ethtool_rxfh_param rxfh_dev = {};
eac9122f0c41b83 net/ethtool/ioctl.c Edward Cree 2024-06-27 1521 struct ethtool_rxfh_context *ctx = NULL;
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1522 struct netlink_ext_ack *extack = NULL;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1523 struct ethtool_rxnfc rx_rings;
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1524 struct ethtool_rxfh rxfh;
87925151191b64d net/ethtool/ioctl.c Edward Cree 2024-06-27 1525 bool locked = false; /* dev->ethtool->rss_lock taken */
eac9122f0c41b83 net/ethtool/ioctl.c Edward Cree 2024-06-27 1526 bool create = false;
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1527 u8 *rss_config;
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1528 int ret;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1529
65107e14ebb8971 net/ethtool/ioctl.c Jakub Kicinski 2025-06-11 @1530 if ((!ops->get_rxnfc && !ops->get_rxfh_fields) || !ops->set_rxfh)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Imagine ops->get_rxnfc is NULL but ops->get_rxfh_fields is not
and also ops->set_rxfh is not. Seems unlikely...
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1531 return -EOPNOTSUPP;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1532
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1533 if (ops->get_rxfh_indir_size)
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1534 dev_indir_size = ops->get_rxfh_indir_size(dev);
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1535 if (ops->get_rxfh_key_size)
d340c862e760815 net/core/ethtool.c Dan Carpenter 2015-02-20 1536 dev_key_size = ops->get_rxfh_key_size(dev);
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1537
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1538 if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1539 return -EFAULT;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1540
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1541 /* Check that reserved fields are 0 for now */
13e59344fb9d3c9 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1542 if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1543 return -EINVAL;
84a1d9c4820080b net/core/ethtool.c Edward Cree 2018-03-08 1544 /* Most drivers don't handle rss_context, check it's 0 as well */
ce056504e2e53b2 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1545 if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
ce056504e2e53b2 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1546 ops->create_rxfh_context))
84a1d9c4820080b net/core/ethtool.c Edward Cree 2018-03-08 1547 return -EOPNOTSUPP;
13e59344fb9d3c9 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1548 /* Check input data transformation capabilities */
948f97f9d8d2aa3 net/ethtool/ioctl.c Ahmed Zaki 2024-01-04 1549 if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
ecdff893384cf16 net/ethtool/ioctl.c Gal Pressman 2025-02-24 1550 rxfh.input_xfrm != RXH_XFRM_SYM_OR_XOR &&
948f97f9d8d2aa3 net/ethtool/ioctl.c Ahmed Zaki 2024-01-04 1551 rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)
948f97f9d8d2aa3 net/ethtool/ioctl.c Ahmed Zaki 2024-01-04 1552 return -EINVAL;
503757c809281a2 net/ethtool/ioctl.c Saeed Mahameed 2024-07-10 1553 if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&
ecdff893384cf16 net/ethtool/ioctl.c Gal Pressman 2025-02-24 1554 rxfh.input_xfrm & ~ops->supported_input_xfrm)
13e59344fb9d3c9 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1555 return -EOPNOTSUPP;
eac9122f0c41b83 net/ethtool/ioctl.c Edward Cree 2024-06-27 1556 create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1557
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1558 if ((rxfh.indir_size &&
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1559 rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1560 rxfh.indir_size != dev_indir_size) ||
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1561 (rxfh.key_size && rxfh.key_size != dev_key_size))
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1562 return -EINVAL;
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1563
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1564 /* Must request at least one change: indir size, hash key, function
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1565 * or input transformation.
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1566 * There's no need for any of it in case of context creation.
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1567 */
4d7c3c1aba3ca12 net/ethtool/ioctl.c Gal Pressman 2024-08-07 1568 if (!create &&
f062a3844845d26 net/core/ethtool.c Ben Hutchings 2014-05-15 1569 (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
0dd415d155050f5 net/ethtool/ioctl.c Ahmed Zaki 2023-12-21 1570 rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE &&
0dd415d155050f5 net/ethtool/ioctl.c Ahmed Zaki 2023-12-21 1571 rxfh.input_xfrm == RXH_XFRM_NO_CHANGE))
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1572 return -EINVAL;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1573
1b2900db0119c02 net/ethtool/ioctl.c Gal Pressman 2025-05-08 1574 ret = ethtool_check_flow_types(dev, rxfh.input_xfrm);
1b2900db0119c02 net/ethtool/ioctl.c Gal Pressman 2025-05-08 1575 if (ret)
1b2900db0119c02 net/ethtool/ioctl.c Gal Pressman 2025-05-08 1576 return ret;
1b2900db0119c02 net/ethtool/ioctl.c Gal Pressman 2025-05-08 1577
fb6e30a72539ce2 net/ethtool/ioctl.c Ahmed Zaki 2023-12-12 1578 indir_bytes = dev_indir_size * sizeof(rxfh_dev.indir[0]);
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1579
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1580 /* Check settings which may be global rather than per RSS-context */
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1581 if (rxfh.rss_context && !ops->rxfh_per_ctx_key)
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1582 if (rxfh.key_size ||
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1583 (rxfh.hfunc && rxfh.hfunc != ETH_RSS_HASH_NO_CHANGE) ||
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1584 (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_NO_CHANGE))
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1585 return -EOPNOTSUPP;
ec6e57beaf8bc64 net/ethtool/ioctl.c Jakub Kicinski 2024-08-09 1586
dc9755370e1c596 net/ethtool/ioctl.c Jakub Kicinski 2024-07-25 1587 rss_config = kzalloc(indir_bytes + dev_key_size, GFP_USER);
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1588 if (!rss_config)
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1589 return -ENOMEM;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1590
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1591 rx_rings.cmd = ETHTOOL_GRXRINGS;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 @1592 ret = ops->get_rxnfc(dev, &rx_rings, NULL);
Then this would be a NULL dereference. There is no way we succeed
when ops->get_rxnfc is NULL.
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1593 if (ret)
7850f63f1620512 net/core/ethtool.c Ben Hutchings 2011-12-15 1594 goto out;
3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1595
84a1d9c4820080b net/core/ethtool.c Edward Cree 2018-03-08 1596 /* rxfh.indir_size == 0 means reset the indir table to default (master
84a1d9c4820080b net/core/ethtool.c Edward Cree 2018-03-08 1597 * context) or delete the context (other RSS contexts).
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
2025-06-18 17:25 ` Dan Carpenter
@ 2025-06-18 18:35 ` Jakub Kicinski
0 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-18 18:35 UTC (permalink / raw)
To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all
On Wed, 18 Jun 2025 20:25:24 +0300 Dan Carpenter wrote:
> 65107e14ebb8971 net/ethtool/ioctl.c Jakub Kicinski 2025-06-11 @1530 if ((!ops->get_rxnfc && !ops->get_rxfh_fields) || !ops->set_rxfh)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Imagine ops->get_rxnfc is NULL but ops->get_rxfh_fields is not
> and also ops->set_rxfh is not. Seems unlikely...
> 3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 1591 rx_rings.cmd = ETHTOOL_GRXRINGS;
> 3de0b592394d17b net/core/ethtool.c Venkata Duvvuru 2014-04-21 @1592 ret = ops->get_rxnfc(dev, &rx_rings, NULL);
>
> Then this would be a NULL dereference. There is no way we succeed
> when ops->get_rxnfc is NULL.
Ack, thanks! There is some compat code here that will be gone once
I convert all the drivers (hopefully by Friday). I'll fix it when
removing the compat.
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 5/9] eth: remove empty RXFH handling from drivers
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (3 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-12 3:21 ` Ziwei Xiao
2025-06-11 14:59 ` [PATCH net-next 6/9] eth: fbnic: migrate to new RXFH callbacks Jakub Kicinski
` (5 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, jeroendb, hramamurthy, marcin.s.wojtas, willemb,
pkaligineedi, joshwash, ziweixiao
We're migrating RXFH config to new callbacks.
Remove RXFH handling from drivers where it does nothing.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jeroendb@google.com
CC: hramamurthy@google.com
CC: marcin.s.wojtas@gmail.com
CC: willemb@google.com
CC: pkaligineedi@google.com
CC: joshwash@google.com
CC: ziweixiao@google.com
---
drivers/net/ethernet/google/gve/gve_ethtool.c | 6 ------
drivers/net/ethernet/marvell/mvneta.c | 2 --
2 files changed, 8 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c
index 3c1da0cf3f61..a6d0089ecd7b 100644
--- a/drivers/net/ethernet/google/gve/gve_ethtool.c
+++ b/drivers/net/ethernet/google/gve/gve_ethtool.c
@@ -798,9 +798,6 @@ static int gve_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
case ETHTOOL_SRXCLSRLDEL:
err = gve_del_flow_rule(priv, cmd);
break;
- case ETHTOOL_SRXFH:
- err = -EOPNOTSUPP;
- break;
default:
err = -EOPNOTSUPP;
break;
@@ -835,9 +832,6 @@ static int gve_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, u
case ETHTOOL_GRXCLSRLALL:
err = gve_get_flow_rule_ids(priv, cmd, (u32 *)rule_locs);
break;
- case ETHTOOL_GRXFH:
- err = -EOPNOTSUPP;
- break;
default:
err = -EOPNOTSUPP;
break;
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 147571fdada3..feab392ab2ee 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -5014,8 +5014,6 @@ static int mvneta_ethtool_get_rxnfc(struct net_device *dev,
case ETHTOOL_GRXRINGS:
info->data = rxq_number;
return 0;
- case ETHTOOL_GRXFH:
- return -EOPNOTSUPP;
default:
return -EOPNOTSUPP;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 5/9] eth: remove empty RXFH handling from drivers
2025-06-11 14:59 ` [PATCH net-next 5/9] eth: remove empty RXFH handling from drivers Jakub Kicinski
@ 2025-06-12 3:21 ` Ziwei Xiao
0 siblings, 0 replies; 23+ messages in thread
From: Ziwei Xiao @ 2025-06-12 3:21 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, jeroendb, hramamurthy, marcin.s.wojtas, willemb,
pkaligineedi, joshwash
On Wed, Jun 11, 2025 at 7:59 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> We're migrating RXFH config to new callbacks.
> Remove RXFH handling from drivers where it does nothing.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: jeroendb@google.com
> CC: hramamurthy@google.com
> CC: marcin.s.wojtas@gmail.com
> CC: willemb@google.com
> CC: pkaligineedi@google.com
> CC: joshwash@google.com
> CC: ziweixiao@google.com
> ---
Reviewed-by: Ziwei Xiao <ziweixiao@google.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 6/9] eth: fbnic: migrate to new RXFH callbacks
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (4 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 5/9] eth: remove empty RXFH handling from drivers Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-11 14:59 ` [PATCH net-next 7/9] net: drv: vmxnet3: " Jakub Kicinski
` (4 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, alexanderduyck, kernel-team, mohsin.bashr
Add support for the new rxfh_fields callbacks, instead of de-muxing
the rxnfc calls. The code is moved as we try to declare the functions
in the order ing which they appear in the ops struct.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: alexanderduyck@fb.com
CC: kernel-team@meta.com
CC: mohsin.bashr@gmail.com
---
.../net/ethernet/meta/fbnic/fbnic_ethtool.c | 111 +++++++++---------
1 file changed, 56 insertions(+), 55 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index 5c7556c8c4c5..1439d0c88fa6 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -531,20 +531,6 @@ static int fbnic_get_rss_hash_idx(u32 flow_type)
return -1;
}
-static int
-fbnic_get_rss_hash_opts(struct fbnic_net *fbn, struct ethtool_rxnfc *cmd)
-{
- int hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type);
-
- if (hash_opt_idx < 0)
- return -EINVAL;
-
- /* Report options from rss_en table in fbn */
- cmd->data = fbn->rss_flow_hash[hash_opt_idx];
-
- return 0;
-}
-
static int fbnic_get_cls_rule_all(struct fbnic_net *fbn,
struct ethtool_rxnfc *cmd,
u32 *rule_locs)
@@ -779,9 +765,6 @@ static int fbnic_get_rxnfc(struct net_device *netdev,
cmd->data = fbn->num_rx_queues;
ret = 0;
break;
- case ETHTOOL_GRXFH:
- ret = fbnic_get_rss_hash_opts(fbn, cmd);
- break;
case ETHTOOL_GRXCLSRULE:
ret = fbnic_get_cls_rule(fbn, cmd);
break;
@@ -803,41 +786,6 @@ static int fbnic_get_rxnfc(struct net_device *netdev,
return ret;
}
-#define FBNIC_L2_HASH_OPTIONS \
- (RXH_L2DA | RXH_DISCARD)
-#define FBNIC_L3_HASH_OPTIONS \
- (FBNIC_L2_HASH_OPTIONS | RXH_IP_SRC | RXH_IP_DST)
-#define FBNIC_L4_HASH_OPTIONS \
- (FBNIC_L3_HASH_OPTIONS | RXH_L4_B_0_1 | RXH_L4_B_2_3)
-
-static int
-fbnic_set_rss_hash_opts(struct fbnic_net *fbn, const struct ethtool_rxnfc *cmd)
-{
- int hash_opt_idx;
-
- /* Verify the type requested is correct */
- hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type);
- if (hash_opt_idx < 0)
- return -EINVAL;
-
- /* Verify the fields asked for can actually be assigned based on type */
- if (cmd->data & ~FBNIC_L4_HASH_OPTIONS ||
- (hash_opt_idx > FBNIC_L4_HASH_OPT &&
- cmd->data & ~FBNIC_L3_HASH_OPTIONS) ||
- (hash_opt_idx > FBNIC_IP_HASH_OPT &&
- cmd->data & ~FBNIC_L2_HASH_OPTIONS))
- return -EINVAL;
-
- fbn->rss_flow_hash[hash_opt_idx] = cmd->data;
-
- if (netif_running(fbn->netdev)) {
- fbnic_rss_reinit(fbn->fbd, fbn);
- fbnic_write_rules(fbn->fbd);
- }
-
- return 0;
-}
-
static int fbnic_cls_rule_any_loc(struct fbnic_dev *fbd)
{
int i;
@@ -1244,9 +1192,6 @@ static int fbnic_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
int ret = -EOPNOTSUPP;
switch (cmd->cmd) {
- case ETHTOOL_SRXFH:
- ret = fbnic_set_rss_hash_opts(fbn, cmd);
- break;
case ETHTOOL_SRXCLSRLINS:
ret = fbnic_set_cls_rule_ins(fbn, cmd);
break;
@@ -1346,6 +1291,60 @@ fbnic_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
return 0;
}
+static int
+fbnic_get_rss_hash_opts(struct net_device *netdev,
+ struct ethtool_rxfh_fields *cmd)
+{
+ int hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type);
+ struct fbnic_net *fbn = netdev_priv(netdev);
+
+ if (hash_opt_idx < 0)
+ return -EINVAL;
+
+ /* Report options from rss_en table in fbn */
+ cmd->data = fbn->rss_flow_hash[hash_opt_idx];
+
+ return 0;
+}
+
+#define FBNIC_L2_HASH_OPTIONS \
+ (RXH_L2DA | RXH_DISCARD)
+#define FBNIC_L3_HASH_OPTIONS \
+ (FBNIC_L2_HASH_OPTIONS | RXH_IP_SRC | RXH_IP_DST)
+#define FBNIC_L4_HASH_OPTIONS \
+ (FBNIC_L3_HASH_OPTIONS | RXH_L4_B_0_1 | RXH_L4_B_2_3)
+
+static int
+fbnic_set_rss_hash_opts(struct net_device *netdev,
+ const struct ethtool_rxfh_fields *cmd,
+ struct netlink_ext_ack *extack)
+{
+ struct fbnic_net *fbn = netdev_priv(netdev);
+ int hash_opt_idx;
+
+ /* Verify the type requested is correct */
+ hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type);
+ if (hash_opt_idx < 0)
+ return -EINVAL;
+
+ /* Verify the fields asked for can actually be assigned based on type */
+ if (cmd->data & ~FBNIC_L4_HASH_OPTIONS ||
+ (hash_opt_idx > FBNIC_L4_HASH_OPT &&
+ cmd->data & ~FBNIC_L3_HASH_OPTIONS) ||
+ (hash_opt_idx > FBNIC_IP_HASH_OPT &&
+ cmd->data & ~FBNIC_L2_HASH_OPTIONS))
+ return -EINVAL;
+
+ fbn->rss_flow_hash[hash_opt_idx] = cmd->data;
+
+ if (netif_running(fbn->netdev)) {
+ fbnic_rss_reinit(fbn->fbd, fbn);
+ fbnic_write_rules(fbn->fbd);
+ }
+
+ return 0;
+}
+
static int
fbnic_modify_rxfh_context(struct net_device *netdev,
struct ethtool_rxfh_context *ctx,
@@ -1633,6 +1632,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
.get_rxfh_indir_size = fbnic_get_rxfh_indir_size,
.get_rxfh = fbnic_get_rxfh,
.set_rxfh = fbnic_set_rxfh,
+ .get_rxfh_fields = fbnic_get_rss_hash_opts,
+ .set_rxfh_fields = fbnic_set_rss_hash_opts,
.create_rxfh_context = fbnic_create_rxfh_context,
.modify_rxfh_context = fbnic_modify_rxfh_context,
.remove_rxfh_context = fbnic_remove_rxfh_context,
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH net-next 7/9] net: drv: vmxnet3: migrate to new RXFH callbacks
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (5 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 6/9] eth: fbnic: migrate to new RXFH callbacks Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-11 14:59 ` [PATCH net-next 8/9] net: drv: virtio: " Jakub Kicinski
` (3 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, ronak.doshi, bcm-kernel-feedback-list
Add support for the new rxfh_fields callbacks, instead of de-muxing
the rxnfc calls. This driver does not support flow filtering so
the set_rxnfc callback is completely removed.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: ronak.doshi@broadcom.com
CC: bcm-kernel-feedback-list@broadcom.com
---
drivers/net/vmxnet3/vmxnet3_ethtool.c | 74 +++++++++------------------
1 file changed, 25 insertions(+), 49 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 471f91c4204a..cc4d7573839d 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -833,11 +833,19 @@ vmxnet3_set_ringparam(struct net_device *netdev,
}
static int
-vmxnet3_get_rss_hash_opts(struct vmxnet3_adapter *adapter,
- struct ethtool_rxnfc *info)
+vmxnet3_get_rss_hash_opts(struct net_device *netdev,
+ struct ethtool_rxfh_fields *info)
{
+ struct vmxnet3_adapter *adapter = netdev_priv(netdev);
enum Vmxnet3_RSSField rss_fields;
+ if (!VMXNET3_VERSION_GE_4(adapter))
+ return -EOPNOTSUPP;
+#ifdef VMXNET3_RSS
+ if (!adapter->rss)
+ return -EOPNOTSUPP;
+#endif
+
if (netif_running(adapter->netdev)) {
unsigned long flags;
@@ -900,10 +908,20 @@ vmxnet3_get_rss_hash_opts(struct vmxnet3_adapter *adapter,
static int
vmxnet3_set_rss_hash_opt(struct net_device *netdev,
- struct vmxnet3_adapter *adapter,
- struct ethtool_rxnfc *nfc)
+ const struct ethtool_rxfh_fields *nfc,
+ struct netlink_ext_ack *extack)
{
- enum Vmxnet3_RSSField rss_fields = adapter->rss_fields;
+ struct vmxnet3_adapter *adapter = netdev_priv(netdev);
+ enum Vmxnet3_RSSField rss_fields;
+
+ if (!VMXNET3_VERSION_GE_4(adapter))
+ return -EOPNOTSUPP;
+#ifdef VMXNET3_RSS
+ if (!adapter->rss)
+ return -EOPNOTSUPP;
+#endif
+
+ rss_fields = adapter->rss_fields;
/* RSS does not support anything other than hashing
* to queues on src and dst IPs and ports
@@ -1074,19 +1092,6 @@ vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info,
case ETHTOOL_GRXRINGS:
info->data = adapter->num_rx_queues;
break;
- case ETHTOOL_GRXFH:
- if (!VMXNET3_VERSION_GE_4(adapter)) {
- err = -EOPNOTSUPP;
- break;
- }
-#ifdef VMXNET3_RSS
- if (!adapter->rss) {
- err = -EOPNOTSUPP;
- break;
- }
-#endif
- err = vmxnet3_get_rss_hash_opts(adapter, info);
- break;
default:
err = -EOPNOTSUPP;
break;
@@ -1095,36 +1100,6 @@ vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info,
return err;
}
-static int
-vmxnet3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info)
-{
- struct vmxnet3_adapter *adapter = netdev_priv(netdev);
- int err = 0;
-
- if (!VMXNET3_VERSION_GE_4(adapter)) {
- err = -EOPNOTSUPP;
- goto done;
- }
-#ifdef VMXNET3_RSS
- if (!adapter->rss) {
- err = -EOPNOTSUPP;
- goto done;
- }
-#endif
-
- switch (info->cmd) {
- case ETHTOOL_SRXFH:
- err = vmxnet3_set_rss_hash_opt(netdev, adapter, info);
- break;
- default:
- err = -EOPNOTSUPP;
- break;
- }
-
-done:
- return err;
-}
-
#ifdef VMXNET3_RSS
static u32
vmxnet3_get_rss_indir_size(struct net_device *netdev)
@@ -1361,12 +1336,13 @@ static const struct ethtool_ops vmxnet3_ethtool_ops = {
.get_ringparam = vmxnet3_get_ringparam,
.set_ringparam = vmxnet3_set_ringparam,
.get_rxnfc = vmxnet3_get_rxnfc,
- .set_rxnfc = vmxnet3_set_rxnfc,
#ifdef VMXNET3_RSS
.get_rxfh_indir_size = vmxnet3_get_rss_indir_size,
.get_rxfh = vmxnet3_get_rss,
.set_rxfh = vmxnet3_set_rss,
#endif
+ .get_rxfh_fields = vmxnet3_get_rss_hash_opts,
+ .set_rxfh_fields = vmxnet3_set_rss_hash_opt,
.get_link_ksettings = vmxnet3_get_link_ksettings,
.get_channels = vmxnet3_get_channels,
};
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH net-next 8/9] net: drv: virtio: migrate to new RXFH callbacks
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (6 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 7/9] net: drv: vmxnet3: " Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-13 0:42 ` Jason Wang
2025-06-11 14:59 ` [PATCH net-next 9/9] net: drv: hyperv: " Jakub Kicinski
` (2 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, mst, jasowang, xuanzhuo, eperezma, virtualization
Add support for the new rxfh_fields callbacks, instead of de-muxing
the rxnfc calls. This driver does not support flow filtering so
the set_rxnfc callback is completely removed.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: mst@redhat.com
CC: jasowang@redhat.com
CC: xuanzhuo@linux.alibaba.com
CC: eperezma@redhat.com
CC: virtualization@lists.linux.dev
---
drivers/net/virtio_net.c | 47 +++++++++++++++-------------------------
1 file changed, 18 insertions(+), 29 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index e53ba600605a..07e41dce4203 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -4193,8 +4193,11 @@ static void virtnet_init_default_rss(struct virtnet_info *vi)
netdev_rss_key_fill(vi->rss_hash_key_data, vi->rss_key_size);
}
-static void virtnet_get_hashflow(const struct virtnet_info *vi, struct ethtool_rxnfc *info)
+static int virtnet_get_hashflow(struct net_device *dev,
+ struct ethtool_rxfh_fields *info)
{
+ struct virtnet_info *vi = netdev_priv(dev);
+
info->data = 0;
switch (info->flow_type) {
case TCP_V4_FLOW:
@@ -4243,17 +4246,22 @@ static void virtnet_get_hashflow(const struct virtnet_info *vi, struct ethtool_r
info->data = 0;
break;
}
+
+ return 0;
}
-static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc *info)
+static int virtnet_set_hashflow(struct net_device *dev,
+ const struct ethtool_rxfh_fields *info,
+ struct netlink_ext_ack *extack)
{
+ struct virtnet_info *vi = netdev_priv(dev);
u32 new_hashtypes = vi->rss_hash_types_saved;
bool is_disable = info->data & RXH_DISCARD;
bool is_l4 = info->data == (RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3);
/* supports only 'sd', 'sdfn' and 'r' */
if (!((info->data == (RXH_IP_SRC | RXH_IP_DST)) | is_l4 | is_disable))
- return false;
+ return -EINVAL;
switch (info->flow_type) {
case TCP_V4_FLOW:
@@ -4292,21 +4300,22 @@ static bool virtnet_set_hashflow(struct virtnet_info *vi, struct ethtool_rxnfc *
break;
default:
/* unsupported flow */
- return false;
+ return -EINVAL;
}
/* if unsupported hashtype was set */
if (new_hashtypes != (new_hashtypes & vi->rss_hash_types_supported))
- return false;
+ return -EINVAL;
if (new_hashtypes != vi->rss_hash_types_saved) {
vi->rss_hash_types_saved = new_hashtypes;
vi->rss_hdr->hash_types = cpu_to_le32(vi->rss_hash_types_saved);
if (vi->dev->features & NETIF_F_RXHASH)
- return virtnet_commit_rss_command(vi);
+ if (!virtnet_commit_rss_command(vi))
+ return -EINVAL;
}
- return true;
+ return 0;
}
static void virtnet_get_drvinfo(struct net_device *dev,
@@ -5539,27 +5548,6 @@ static int virtnet_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
switch (info->cmd) {
case ETHTOOL_GRXRINGS:
info->data = vi->curr_queue_pairs;
- break;
- case ETHTOOL_GRXFH:
- virtnet_get_hashflow(vi, info);
- break;
- default:
- rc = -EOPNOTSUPP;
- }
-
- return rc;
-}
-
-static int virtnet_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
-{
- struct virtnet_info *vi = netdev_priv(dev);
- int rc = 0;
-
- switch (info->cmd) {
- case ETHTOOL_SRXFH:
- if (!virtnet_set_hashflow(vi, info))
- rc = -EINVAL;
-
break;
default:
rc = -EOPNOTSUPP;
@@ -5591,8 +5579,9 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
.get_rxfh_indir_size = virtnet_get_rxfh_indir_size,
.get_rxfh = virtnet_get_rxfh,
.set_rxfh = virtnet_set_rxfh,
+ .get_rxfh_fields = virtnet_get_hashflow,
+ .set_rxfh_fields = virtnet_set_hashflow,
.get_rxnfc = virtnet_get_rxnfc,
- .set_rxnfc = virtnet_set_rxnfc,
};
static void virtnet_get_queue_stats_rx(struct net_device *dev, int i,
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 8/9] net: drv: virtio: migrate to new RXFH callbacks
2025-06-11 14:59 ` [PATCH net-next 8/9] net: drv: virtio: " Jakub Kicinski
@ 2025-06-13 0:42 ` Jason Wang
0 siblings, 0 replies; 23+ messages in thread
From: Jason Wang @ 2025-06-13 0:42 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx, mst, xuanzhuo, eperezma, virtualization
On Wed, Jun 11, 2025 at 11:00 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Add support for the new rxfh_fields callbacks, instead of de-muxing
> the rxnfc calls. This driver does not support flow filtering so
> the set_rxnfc callback is completely removed.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: mst@redhat.com
> CC: jasowang@redhat.com
> CC: xuanzhuo@linux.alibaba.com
> CC: eperezma@redhat.com
> CC: virtualization@lists.linux.dev
> ---
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH net-next 9/9] net: drv: hyperv: migrate to new RXFH callbacks
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (7 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 8/9] net: drv: virtio: " Jakub Kicinski
@ 2025-06-11 14:59 ` Jakub Kicinski
2025-06-13 0:50 ` [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks patchwork-bot+netdevbpf
2025-06-25 6:44 ` Gal Pressman
10 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-11 14:59 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx,
Jakub Kicinski, kys, haiyangz, wei.liu, decui, linux-hyperv
Add support for the new rxfh_fields callbacks, instead of de-muxing
the rxnfc calls. This driver does not support flow filtering so
the set_rxnfc callback is completely removed.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: kys@microsoft.com
CC: haiyangz@microsoft.com
CC: wei.liu@kernel.org
CC: decui@microsoft.com
CC: linux-hyperv@vger.kernel.org
---
drivers/net/hyperv/netvsc_drv.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c41a025c66f0..42d98e99566e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1580,9 +1580,10 @@ static void netvsc_get_strings(struct net_device *dev, u32 stringset, u8 *data)
}
static int
-netvsc_get_rss_hash_opts(struct net_device_context *ndc,
- struct ethtool_rxnfc *info)
+netvsc_get_rxfh_fields(struct net_device *ndev,
+ struct ethtool_rxfh_fields *info)
{
+ struct net_device_context *ndc = netdev_priv(ndev);
const u32 l4_flag = RXH_L4_B_0_1 | RXH_L4_B_2_3;
info->data = RXH_IP_SRC | RXH_IP_DST;
@@ -1637,16 +1638,17 @@ netvsc_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
case ETHTOOL_GRXRINGS:
info->data = nvdev->num_chn;
return 0;
-
- case ETHTOOL_GRXFH:
- return netvsc_get_rss_hash_opts(ndc, info);
}
return -EOPNOTSUPP;
}
-static int netvsc_set_rss_hash_opts(struct net_device_context *ndc,
- struct ethtool_rxnfc *info)
+static int
+netvsc_set_rxfh_fields(struct net_device *dev,
+ const struct ethtool_rxfh_fields *info,
+ struct netlink_ext_ack *extack)
{
+ struct net_device_context *ndc = netdev_priv(dev);
+
if (info->data == (RXH_IP_SRC | RXH_IP_DST |
RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
switch (info->flow_type) {
@@ -1701,17 +1703,6 @@ static int netvsc_set_rss_hash_opts(struct net_device_context *ndc,
return -EOPNOTSUPP;
}
-static int
-netvsc_set_rxnfc(struct net_device *ndev, struct ethtool_rxnfc *info)
-{
- struct net_device_context *ndc = netdev_priv(ndev);
-
- if (info->cmd == ETHTOOL_SRXFH)
- return netvsc_set_rss_hash_opts(ndc, info);
-
- return -EOPNOTSUPP;
-}
-
static u32 netvsc_get_rxfh_key_size(struct net_device *dev)
{
return NETVSC_HASH_KEYLEN;
@@ -1979,11 +1970,12 @@ static const struct ethtool_ops ethtool_ops = {
.set_channels = netvsc_set_channels,
.get_ts_info = ethtool_op_get_ts_info,
.get_rxnfc = netvsc_get_rxnfc,
- .set_rxnfc = netvsc_set_rxnfc,
.get_rxfh_key_size = netvsc_get_rxfh_key_size,
.get_rxfh_indir_size = netvsc_rss_indir_size,
.get_rxfh = netvsc_get_rxfh,
.set_rxfh = netvsc_set_rxfh,
+ .get_rxfh_fields = netvsc_get_rxfh_fields,
+ .set_rxfh_fields = netvsc_set_rxfh_fields,
.get_link_ksettings = netvsc_get_link_ksettings,
.set_link_ksettings = netvsc_set_link_ksettings,
.get_ringparam = netvsc_get_ringparam,
--
2.49.0
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (8 preceding siblings ...)
2025-06-11 14:59 ` [PATCH net-next 9/9] net: drv: hyperv: " Jakub Kicinski
@ 2025-06-13 0:50 ` patchwork-bot+netdevbpf
2025-06-25 6:44 ` Gal Pressman
10 siblings, 0 replies; 23+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-13 0:50 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 11 Jun 2025 07:59:40 -0700 you wrote:
> Andrew asked me to plumb the RXFH header fields configuration
> thru to netlink. Before we do that we need to clean up the driver
> facing API a little bit. Right now RXFH configuration shares the
> callbacks with n-tuple filters. The future of n-tuple filters
> is uncertain within netlink. Separate the two for clarity both
> of the core code and the driver facing API.
>
> [...]
Here is the summary with links:
- [net-next,1/9] net: ethtool: copy the rxfh flow handling
https://git.kernel.org/netdev/net-next/c/f4f126535546
- [net-next,2/9] net: ethtool: remove the duplicated handling from rxfh and rxnfc
https://git.kernel.org/netdev/net-next/c/2a644c5cecc0
- [net-next,3/9] net: ethtool: require drivers to opt into the per-RSS ctx RXFH
https://git.kernel.org/netdev/net-next/c/fac4b41741b5
- [net-next,4/9] net: ethtool: add dedicated callbacks for getting and setting rxfh fields
https://git.kernel.org/netdev/net-next/c/9bb00786fc61
- [net-next,5/9] eth: remove empty RXFH handling from drivers
https://git.kernel.org/netdev/net-next/c/86b2315e7041
- [net-next,6/9] eth: fbnic: migrate to new RXFH callbacks
https://git.kernel.org/netdev/net-next/c/2a34007ba977
- [net-next,7/9] net: drv: vmxnet3: migrate to new RXFH callbacks
https://git.kernel.org/netdev/net-next/c/2f14765d6397
- [net-next,8/9] net: drv: virtio: migrate to new RXFH callbacks
https://git.kernel.org/netdev/net-next/c/63d474cfb596
- [net-next,9/9] net: drv: hyperv: migrate to new RXFH callbacks
https://git.kernel.org/netdev/net-next/c/6867fbe3a9f4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks
2025-06-11 14:59 [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks Jakub Kicinski
` (9 preceding siblings ...)
2025-06-13 0:50 ` [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks patchwork-bot+netdevbpf
@ 2025-06-25 6:44 ` Gal Pressman
2025-06-25 20:17 ` Jakub Kicinski
10 siblings, 1 reply; 23+ messages in thread
From: Gal Pressman @ 2025-06-25 6:44 UTC (permalink / raw)
To: Jakub Kicinski, davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, ecree.xilinx
Hi Jakub,
On 11/06/2025 17:59, Jakub Kicinski wrote:
> The future of n-tuple filters is uncertain within netlink.
What does that mean exactly?
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH net-next 0/9] net: ethtool: add dedicated RXFH driver callbacks
2025-06-25 6:44 ` Gal Pressman
@ 2025-06-25 20:17 ` Jakub Kicinski
0 siblings, 0 replies; 23+ messages in thread
From: Jakub Kicinski @ 2025-06-25 20:17 UTC (permalink / raw)
To: Gal Pressman
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms,
ecree.xilinx
On Wed, 25 Jun 2025 09:44:04 +0300 Gal Pressman wrote:
> On 11/06/2025 17:59, Jakub Kicinski wrote:
> > The future of n-tuple filters is uncertain within netlink.
>
> What does that mean exactly?
Just that I don't have a clear idea of where it should go.
In this series I was refactoring rxnfc code - one could argue
I should also add dedicated callbacks for n-tuple ioctls
which are also muxed into the rxnfc driver op. But at some
point some people were pushing for n-tuple filters to be
deprecated in favor of cls_flower. Also Jamal's P4-ish
proposal could become n-tuple-next-gen. Or we could lift
existing ntuple filters into netlink.. 🤷️
IDK where we are on that, so I'm not refactoring the ntuple callbacks.
^ permalink raw reply [flat|nested] 23+ messages in thread