From: Shahar Shitrit <shshitrit@nvidia.com>
To: netdev@vger.kernel.org, mst@redhat.com, jasowang@redhat.com,
pabeni@redhat.com
Cc: virtualization@lists.linux.dev, parav@nvidia.com,
shshitrit@nvidia.com, yohadt@nvidia.com,
xuanzhuo@linux.alibaba.com, eperezma@redhat.com, jgg@ziepe.ca,
kevin.tian@intel.com, kuba@kernel.org, andrew+netdev@lunn.ch,
edumazet@google.com, danielj@nvidia.com
Subject: [PATCH net-next v22 08/14] ethtool: Introduce ethtool_flow_type_mask()
Date: Mon, 31 Aug 2026 10:58:01 +0300 [thread overview]
Message-ID: <20260831075807.2891426-9-shshitrit@nvidia.com> (raw)
In-Reply-To: <20260831075807.2891426-1-shshitrit@nvidia.com>
Add a common ethtool_flow_type_mask() helper to mask extension bits
from an ethtool flow type.
Move the helper to include/linux/ethtool.h and convert mlx5e and
mlx5i to use it, removing duplicate implementations.
Signed-off-by: Shahar Shitrit <shshitrit@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/en_fs_ethtool.c | 17 ++++++-----------
.../ethernet/mellanox/mlx5/core/ipoib/ethtool.c | 7 +------
include/linux/ethtool.h | 6 ++++++
3 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index aecfba7deeb0..7247f6cbdb32 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -53,11 +53,6 @@ struct mlx5e_ethtool_steering {
static int flow_type_to_traffic_type(u32 flow_type);
-static u32 flow_type_mask(u32 flow_type)
-{
- return flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
-}
-
struct mlx5e_ethtool_rule {
struct list_head list;
struct ethtool_rx_flow_spec flow_spec;
@@ -91,7 +86,7 @@ static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv,
int table_size;
int prio;
- switch (flow_type_mask(fs->flow_type)) {
+ switch (ethtool_flow_type_mask(fs->flow_type)) {
case TCP_V4_FLOW:
case UDP_V4_FLOW:
case TCP_V6_FLOW:
@@ -350,7 +345,7 @@ static int set_flow_attrs(u32 *match_c, u32 *match_v,
outer_headers);
void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v,
outer_headers);
- u32 flow_type = flow_type_mask(fs->flow_type);
+ u32 flow_type = ethtool_flow_type_mask(fs->flow_type);
switch (flow_type) {
case TCP_V4_FLOW:
@@ -435,7 +430,7 @@ static int flow_get_tirn(struct mlx5e_priv *priv,
if (!rss)
return -ENOENT;
- flow_type = flow_type_mask(fs->flow_type);
+ flow_type = ethtool_flow_type_mask(fs->flow_type);
tt = flow_type_to_traffic_type(flow_type);
if (tt < 0)
return -EINVAL;
@@ -673,7 +668,7 @@ static int validate_flow(struct mlx5e_priv *priv,
if (fs->ring_cookie >= priv->channels.params.num_channels)
return -EINVAL;
- switch (flow_type_mask(fs->flow_type)) {
+ switch (ethtool_flow_type_mask(fs->flow_type)) {
case ETHER_FLOW:
num_tuples += validate_ethter(fs);
break;
@@ -906,7 +901,7 @@ int mlx5e_ethtool_set_rxfh_fields(struct mlx5e_priv *priv,
rss_idx = nfc->rss_context;
- flow_type = flow_type_mask(nfc->flow_type);
+ flow_type = ethtool_flow_type_mask(nfc->flow_type);
tt = flow_type_to_traffic_type(flow_type);
if (tt < 0)
return tt;
@@ -951,7 +946,7 @@ int mlx5e_ethtool_get_rxfh_fields(struct mlx5e_priv *priv,
rss_idx = nfc->rss_context;
- flow_type = flow_type_mask(nfc->flow_type);
+ flow_type = ethtool_flow_type_mask(nfc->flow_type);
tt = flow_type_to_traffic_type(flow_type);
if (tt < 0)
return tt;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
index 01ddc3def9ac..83eaceddc437 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
@@ -233,11 +233,6 @@ static int mlx5i_get_link_ksettings(struct net_device *netdev,
return 0;
}
-static u32 mlx5i_flow_type_mask(u32 flow_type)
-{
- return flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
-}
-
static int mlx5i_set_rxfh_fields(struct net_device *dev,
const struct ethtool_rxfh_fields *cmd,
struct netlink_ext_ack *extack)
@@ -260,7 +255,7 @@ static int mlx5i_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
struct mlx5e_priv *priv = mlx5i_epriv(dev);
struct ethtool_rx_flow_spec *fs = &cmd->fs;
- if (mlx5i_flow_type_mask(fs->flow_type) == ETHER_FLOW)
+ if (ethtool_flow_type_mask(fs->flow_type) == ETHER_FLOW)
return -EINVAL;
return mlx5e_ethtool_set_rxnfc(priv, cmd);
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 12683b5d125e..adecb9225ee3 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -1567,4 +1567,10 @@ struct ethtool_forced_speed_map {
void
ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size);
+
+static inline u32 ethtool_flow_type_mask(u32 flow_type)
+{
+ return flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
+}
+
#endif /* _LINUX_ETHTOOL_H */
--
2.49.0
next prev parent reply other threads:[~2026-08-31 7:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 7:57 [PATCH net-next v22 00/14] virtio_net: Add ethtool flow rules support Shahar Shitrit
2026-08-31 7:57 ` [PATCH net-next v22 01/14] virtio_pci: Remove supported_caps cache and build assert Shahar Shitrit
2026-08-31 7:57 ` [PATCH net-next v22 02/14] virtio_pci: Fix sleeping under spinlock in admin command path Shahar Shitrit
2026-08-31 7:57 ` [PATCH net-next v22 03/14] virtio: Add config_op for admin commands Shahar Shitrit
2026-08-31 7:57 ` [PATCH net-next v22 04/14] virtio: Expose generic device capability operations Shahar Shitrit
2026-08-31 7:57 ` [PATCH net-next v22 05/14] virtio: Expose object create and destroy API Shahar Shitrit
2026-08-31 8:47 ` Michael S. Tsirkin
2026-08-31 7:57 ` [PATCH net-next v22 06/14] virtio_net: Query and set flow filter caps Shahar Shitrit
2026-08-31 7:58 ` [PATCH net-next v22 07/14] virtio_net: Create a FF group for ethtool steering Shahar Shitrit
2026-08-31 7:58 ` Shahar Shitrit [this message]
2026-08-31 7:58 ` [PATCH net-next v22 09/14] virtio_net: Implement layer 2 ethtool flow rules Shahar Shitrit
2026-08-31 7:58 ` [PATCH net-next v22 10/14] virtio_net: Use existing classifier if possible Shahar Shitrit
2026-08-31 7:58 ` [PATCH net-next v22 11/14] virtio_net: Implement IPv4 ethtool flow rules Shahar Shitrit
2026-08-31 7:58 ` [PATCH net-next v22 12/14] virtio_net: Add support for IPv6 ethtool steering Shahar Shitrit
2026-08-31 7:58 ` [PATCH net-next v22 13/14] virtio_net: Add support for TCP and UDP ethtool rules Shahar Shitrit
2026-08-31 7:58 ` [PATCH net-next v22 14/14] virtio_net: Add get ethtool flow rules ops Shahar Shitrit
2026-08-31 8:48 ` [PATCH net-next v22 00/14] virtio_net: Add ethtool flow rules support Michael S. Tsirkin
-- strict thread matches above, loose matches on Subject: below --
2026-08-16 12:20 Shahar Shitrit
2026-08-16 12:21 ` [PATCH net-next v22 08/14] ethtool: Introduce ethtool_flow_type_mask() Shahar Shitrit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260831075807.2891426-9-shshitrit@nvidia.com \
--to=shshitrit@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=danielj@nvidia.com \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yohadt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.