From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
dxu@dxuuu.xyz, ecree.xilinx@gmail.com,
przemyslaw.kitszel@intel.com, donald.hunter@gmail.com,
gal.pressman@linux.dev, tariqt@nvidia.com,
willemdebruijn.kernel@gmail.com, jdamato@fastly.com,
Jakub Kicinski <kuba@kernel.org>,
marcin.s.wojtas@gmail.com, linux@armlinux.org.uk
Subject: [PATCH net-next v2 02/12] eth: mvpp2: implement new RSS context API
Date: Fri, 2 Aug 2024 21:26:14 -0700 [thread overview]
Message-ID: <20240803042624.970352-3-kuba@kernel.org> (raw)
In-Reply-To: <20240803042624.970352-1-kuba@kernel.org>
Implement the separate create/modify/delete ops for RSS.
No problems with IDs - even tho RSS tables are per device
the driver already seems to allocate IDs linearly per port.
There's a translation table from per-port context ID
to device context ID.
mvpp2 doesn't have a key for the hash, it defaults to
an empty/previous indir table.
Compile-tested only.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- copy the default indir table
- use ID from the core
- fix build issues
CC: marcin.s.wojtas@gmail.com
CC: linux@armlinux.org.uk
---
.../net/ethernet/marvell/mvpp2/mvpp2_cls.c | 18 +---
.../net/ethernet/marvell/mvpp2/mvpp2_cls.h | 2 +-
.../net/ethernet/marvell/mvpp2/mvpp2_main.c | 102 +++++++++++++-----
3 files changed, 79 insertions(+), 43 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
index 40aeaa7bd739..1641791a2d5b 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
@@ -1522,29 +1522,19 @@ static int mvpp22_rss_context_create(struct mvpp2_port *port, u32 *rss_ctx)
return 0;
}
-int mvpp22_port_rss_ctx_create(struct mvpp2_port *port, u32 *port_ctx)
+int mvpp22_port_rss_ctx_create(struct mvpp2_port *port, u32 port_ctx)
{
u32 rss_ctx;
- int ret, i;
+ int ret;
ret = mvpp22_rss_context_create(port, &rss_ctx);
if (ret)
return ret;
- /* Find the first available context number in the port, starting from 1.
- * Context 0 on each port is reserved for the default context.
- */
- for (i = 1; i < MVPP22_N_RSS_TABLES; i++) {
- if (port->rss_ctx[i] < 0)
- break;
- }
-
- if (i == MVPP22_N_RSS_TABLES)
+ if (WARN_ON_ONCE(port->rss_ctx[port_ctx] >= 0))
return -EINVAL;
- port->rss_ctx[i] = rss_ctx;
- *port_ctx = i;
-
+ port->rss_ctx[port_ctx] = rss_ctx;
return 0;
}
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.h
index 663157dc8062..85c9c6e80678 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.h
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.h
@@ -264,7 +264,7 @@ int mvpp22_port_rss_init(struct mvpp2_port *port);
int mvpp22_port_rss_enable(struct mvpp2_port *port);
int mvpp22_port_rss_disable(struct mvpp2_port *port);
-int mvpp22_port_rss_ctx_create(struct mvpp2_port *port, u32 *rss_ctx);
+int mvpp22_port_rss_ctx_create(struct mvpp2_port *port, u32 rss_ctx);
int mvpp22_port_rss_ctx_delete(struct mvpp2_port *port, u32 rss_ctx);
int mvpp22_port_rss_ctx_indir_set(struct mvpp2_port *port, u32 rss_ctx,
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 0d62a33afa80..90182f6fd9a1 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -5696,38 +5696,80 @@ static int mvpp2_ethtool_get_rxfh(struct net_device *dev,
return ret;
}
+static bool mvpp2_ethtool_rxfh_okay(struct mvpp2_port *port,
+ const struct ethtool_rxfh_param *rxfh)
+{
+ if (!mvpp22_rss_is_supported(port))
+ return false;
+
+ if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
+ rxfh->hfunc != ETH_RSS_HASH_CRC32)
+ return false;
+
+ if (rxfh->key)
+ return false;
+
+ return true;
+}
+
+static int mvpp2_create_rxfh_context(struct net_device *dev,
+ struct ethtool_rxfh_context *ctx,
+ const struct ethtool_rxfh_param *rxfh,
+ struct netlink_ext_ack *extack)
+{
+ struct mvpp2_port *port = netdev_priv(dev);
+ int ret = 0;
+
+ if (!mvpp2_ethtool_rxfh_okay(port, rxfh))
+ return -EOPNOTSUPP;
+
+ ctx->hfunc = ETH_RSS_HASH_CRC32;
+
+ ret = mvpp22_port_rss_ctx_create(port, rxfh->rss_context);
+ if (ret)
+ return ret;
+
+ if (!rxfh->indir)
+ ret = mvpp22_port_rss_ctx_indir_get(port, rxfh->rss_context,
+ ethtool_rxfh_context_indir(ctx));
+ else
+ ret = mvpp22_port_rss_ctx_indir_set(port, rxfh->rss_context,
+ rxfh->indir);
+ return ret;
+}
+
+static int mvpp2_modify_rxfh_context(struct net_device *dev,
+ struct ethtool_rxfh_context *ctx,
+ const struct ethtool_rxfh_param *rxfh,
+ struct netlink_ext_ack *extack)
+{
+ struct mvpp2_port *port = netdev_priv(dev);
+ int ret = 0;
+
+ if (!mvpp2_ethtool_rxfh_okay(port, rxfh))
+ return -EOPNOTSUPP;
+
+ if (rxfh->indir)
+ ret = mvpp22_port_rss_ctx_indir_set(port, rxfh->rss_context,
+ rxfh->indir);
+ return ret;
+}
+
+static int mvpp2_remove_rxfh_context(struct net_device *dev,
+ struct ethtool_rxfh_context *ctx,
+ u32 rss_context,
+ struct netlink_ext_ack *extack)
+{
+ struct mvpp2_port *port = netdev_priv(dev);
+
+ return mvpp22_port_rss_ctx_delete(port, rss_context);
+}
+
static int mvpp2_ethtool_set_rxfh(struct net_device *dev,
struct ethtool_rxfh_param *rxfh,
struct netlink_ext_ack *extack)
{
- struct mvpp2_port *port = netdev_priv(dev);
- u32 *rss_context = &rxfh->rss_context;
- int ret = 0;
-
- if (!mvpp22_rss_is_supported(port))
- return -EOPNOTSUPP;
-
- if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
- rxfh->hfunc != ETH_RSS_HASH_CRC32)
- return -EOPNOTSUPP;
-
- if (rxfh->key)
- return -EOPNOTSUPP;
-
- if (*rss_context && rxfh->rss_delete)
- return mvpp22_port_rss_ctx_delete(port, *rss_context);
-
- if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
- ret = mvpp22_port_rss_ctx_create(port, rss_context);
- if (ret)
- return ret;
- }
-
- if (rxfh->indir)
- ret = mvpp22_port_rss_ctx_indir_set(port, *rss_context,
- rxfh->indir);
-
- return ret;
+ return mvpp2_modify_rxfh_context(dev, NULL, rxfh, extack);
}
/* Device ops */
@@ -5750,6 +5792,7 @@ static const struct net_device_ops mvpp2_netdev_ops = {
static const struct ethtool_ops mvpp2_eth_tool_ops = {
.cap_rss_ctx_supported = true,
+ .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES,
.nway_reset = mvpp2_ethtool_nway_reset,
@@ -5772,6 +5815,9 @@ static const struct ethtool_ops mvpp2_eth_tool_ops = {
.get_rxfh_indir_size = mvpp2_ethtool_get_rxfh_indir_size,
.get_rxfh = mvpp2_ethtool_get_rxfh,
.set_rxfh = mvpp2_ethtool_set_rxfh,
+ .create_rxfh_context = mvpp2_create_rxfh_context,
+ .modify_rxfh_context = mvpp2_modify_rxfh_context,
+ .remove_rxfh_context = mvpp2_remove_rxfh_context,
};
/* Used for PPv2.1, or PPv2.2 with the old Device Tree binding that
--
2.45.2
next prev parent reply other threads:[~2024-08-03 4:26 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-03 4:26 [PATCH net-next v2 00/12] ethtool: rss: driver tweaks and netlink context dumps Jakub Kicinski
2024-08-03 4:26 ` [PATCH net-next v2 01/12] selftests: drv-net: rss_ctx: add identifier to traffic comments Jakub Kicinski
2024-08-04 6:40 ` Gal Pressman
2024-08-05 21:35 ` Jakub Kicinski
2024-08-03 4:26 ` Jakub Kicinski [this message]
2024-08-05 11:25 ` [PATCH net-next v2 02/12] eth: mvpp2: implement new RSS context API Edward Cree
2024-08-05 21:29 ` Jakub Kicinski
2024-08-06 13:28 ` Edward Cree
2024-08-06 14:11 ` Jakub Kicinski
2024-08-03 4:26 ` [PATCH net-next v2 03/12] eth: mlx5: allow disabling queues when RSS contexts exist Jakub Kicinski
2024-08-04 6:36 ` Gal Pressman
2024-08-03 4:26 ` [PATCH net-next v2 04/12] ethtool: make ethtool_ops::cap_rss_ctx_supported optional Jakub Kicinski
2024-08-04 6:46 ` Gal Pressman
2024-08-05 11:34 ` Edward Cree
2024-08-03 4:26 ` [PATCH net-next v2 05/12] eth: remove .cap_rss_ctx_supported from updated drivers Jakub Kicinski
2024-08-04 6:47 ` Gal Pressman
2024-08-05 11:34 ` Edward Cree
2024-08-03 4:26 ` [PATCH net-next v2 06/12] ethtool: rss: don't report key if device doesn't support it Jakub Kicinski
2024-08-05 14:36 ` Edward Cree
2024-08-06 14:07 ` Jakub Kicinski
2024-08-03 4:26 ` [PATCH net-next v2 07/12] ethtool: rss: move the device op invocation out of rss_prepare_data() Jakub Kicinski
2024-08-03 4:26 ` [PATCH net-next v2 08/12] ethtool: rss: report info about additional contexts from XArray Jakub Kicinski
2024-08-06 13:55 ` Edward Cree
2024-08-03 4:26 ` [PATCH net-next v2 09/12] ethtool: rss: support dumping RSS contexts Jakub Kicinski
2024-08-03 18:11 ` Joe Damato
2024-08-05 21:59 ` Jakub Kicinski
2024-08-06 10:09 ` Joe Damato
2024-08-06 10:44 ` Przemek Kitszel
2024-08-06 13:58 ` Edward Cree
2024-08-06 14:17 ` Jakub Kicinski
2024-08-06 14:24 ` Edward Cree
2024-08-06 15:23 ` Jakub Kicinski
2024-08-03 4:26 ` [PATCH net-next v2 10/12] ethtool: rss: support skipping contexts during dump Jakub Kicinski
2024-08-03 18:18 ` Joe Damato
2024-08-06 14:27 ` Edward Cree
2024-08-03 4:26 ` [PATCH net-next v2 11/12] netlink: specs: decode indirection table as u32 array Jakub Kicinski
2024-08-03 18:24 ` Joe Damato
2024-08-03 4:26 ` [PATCH net-next v2 12/12] selftests: drv-net: rss_ctx: test dumping RSS contexts Jakub Kicinski
2024-08-03 18:40 ` Joe Damato
2024-08-06 16:48 ` Edward Cree
2024-08-06 18:28 ` Jakub Kicinski
2024-08-04 6:08 ` [PATCH net-next v2 00/12] ethtool: rss: driver tweaks and netlink context dumps Gal Pressman
2024-08-05 22:13 ` Jakub Kicinski
2024-08-06 12:22 ` Gal Pressman
2024-08-06 14:20 ` Jakub Kicinski
2024-08-06 15:14 ` Gal Pressman
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=20240803042624.970352-3-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dxu@dxuuu.xyz \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=gal.pressman@linux.dev \
--cc=jdamato@fastly.com \
--cc=linux@armlinux.org.uk \
--cc=marcin.s.wojtas@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=tariqt@nvidia.com \
--cc=willemdebruijn.kernel@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).