From patchwork Sat Aug 10 05:37:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759414 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB6E73C488 for ; Sat, 10 Aug 2024 05:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268484; cv=none; b=tVNU1BEnDV5anHHXBCW05jDHl9R4bkp8LGw9o1SAw9dvjhtXbxhAm31xLQ7AvVB9k5TZ/AF1/p+cBkSGBJQE+m15PgRpbGy4+VYWTFNi5yFrgMKl3ckFpVk68+VjgRfD9z/JqF+OWXcXp9q/S0nxJcf5JB2Phgz4Q7SH71Xy4rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268484; c=relaxed/simple; bh=h7m3rBOCSELPXgRkrDIeZOBFnuVvnQIIL3oW3PCTAiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JjJoMhcJuJip5hL/NsG+7HKaGxQ+WWW0+ezpg5Ucy1cVbU+KK8mNM+Wf+dy95Hga+/nVe0hyTFA3svDDl83p5qUiTFuG13mdJQF9i6X4hkM9wVG+iRRMHSxwEHul1Kg6n7HIsZtdMa2UVY0bcu9PbaWnuBBI4qFyntsgh7hLKTQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L1ptB/7V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L1ptB/7V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F327C4AF0F; Sat, 10 Aug 2024 05:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268484; bh=h7m3rBOCSELPXgRkrDIeZOBFnuVvnQIIL3oW3PCTAiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L1ptB/7VhoZmxaSYJNOtnrC0R8PL6Vhh8DOrr7tTtPl3FgIyJADCYmI8UUOVSTUxR KhhqN+hD8zpI9h4KxlZgDAy1EpMJR23Pb89FUw3H1VU9ZXLGYrXmSiFurhw+53prsN gshE1P40ctav3tzbLly70ZxPYG9pXhT+T2XVGMWmuFeqYVKk8FxIJD7YKenlecjjZm 1fJiMjBy90TWIfKkFqvO7aVbxjXgWtyaEy5wNnIZNDVCusbsmHHhWoSRDcEJMqf/SR X/hbL14VyRSzFAs67ZYQtTxzVylSFrFldMfhK9jlxZOvYsPcYnc3VqygQfbE4xwzSF d7Mxe680DQS/w== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 01/12] selftests: drv-net: rss_ctx: add identifier to traffic comments Date: Fri, 9 Aug 2024 22:37:17 -0700 Message-ID: <20240810053728.2757709-2-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Include the "name" of the context in the comment for traffic checks. Makes it easier to reason about which context failed when we loop over 32 contexts (it may matter if we failed in first vs last, for example). Reviewed-by: Gal Pressman Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/hw/rss_ctx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index 011508ca604b..1da6b214f4fe 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -90,10 +90,10 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_ge(directed, 20000, f"traffic on {name}: " + str(cnts)) if params.get('noise'): ksft_lt(sum(cnts[i] for i in params['noise']), directed / 2, - "traffic on other queues:" + str(cnts)) + f"traffic on other queues ({name})':" + str(cnts)) if params.get('empty'): ksft_eq(sum(cnts[i] for i in params['empty']), 0, - "traffic on inactive queues: " + str(cnts)) + f"traffic on inactive queues ({name}): " + str(cnts)) def test_rss_key_indir(cfg): From patchwork Sat Aug 10 05:37:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759416 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD2E9481B3 for ; Sat, 10 Aug 2024 05:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268485; cv=none; b=jQZC5iARVv4g31LoANeKuLZkc385MgkLNjompuSv36bshHTvXnxHI7yDhn7wimlFknNI7AJM9KKgMFkQwkkEP1sojzUXfA7vF0kYH3noXUsnK0pBXDjBiDiK/NOIUQrpy7/Dexwzc/hqRLjt2Gngf3KRX3Rz5JXblgGxChwZwF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268485; c=relaxed/simple; bh=FsfpG7JXoocRYiEDQ/sFE4STzyjoW6JiTirbvC06X3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cHk/M7OEVqMUxUeL0yQeP80fq0wIx+lyk+A43qy3VTWUZHoTu4lPSlrqKHcKrFb1OlYdmw8hJUkQhlbgOw9Tgx0bBY8IQbHGjH9bj0WZ1XVm494Rex6+6Y9NLi3G1UnJH/u6pQaJE61IixSLXleY0uWr81kkDgc9nMFLZWfObHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tRkQTWxn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tRkQTWxn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73D70C4AF0C; Sat, 10 Aug 2024 05:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268485; bh=FsfpG7JXoocRYiEDQ/sFE4STzyjoW6JiTirbvC06X3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tRkQTWxnKs1V8YB3jGCo0UWtlU+x2GhMnVHeGm+CqlS81YpTScRKHWb1Gfz7BvuKQ kBy5jV4vJQBQ/B9QuDzX/sQKQ/fAC/vByVUClebUhDNLBxHmirwsB3acg0gbJXyJxD 9dLpAgMK9GDeNDa3QyL/yQ6a1wZUOuOviA9O5b/n1ohRKePq6NHQYAGwHjgufEEypD kvpyGhWEwjqDyB5aKCfe/j0Kb56q82zcKwt4bxjjWRqYu9hXQoJNUiiPq+97QsKXC4 ltwCg0AKIPmvHwavK8pcO+Eehm9jKS4cAMNgIH5jKZfDAwTB+KHCORCTgdPvkZNUIW DT3+hSRnCx5Iw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski , marcin.s.wojtas@gmail.com, linux@armlinux.org.uk Subject: [PATCH net-next v5 02/12] eth: mvpp2: implement new RSS context API Date: Fri, 9 Aug 2024 22:37:18 -0700 Message-ID: <20240810053728.2757709-3-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: 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. Note that there is no key at all, so we don't have to be concerned with reporting the wrong one (which is addressed by a patch later in the series). Compile-tested only. Reviewed-by: Edward Cree Signed-off-by: Jakub Kicinski --- v5: - fix build v4: - adjust to meaning of max_context_id from net v3: - fix max_context_id to be inclusive - extend commit message with why this is different than patch 6 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..1d472316e7a7 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_num_contexts = 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 From patchwork Sat Aug 10 05:37:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759417 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B07BD4D108; Sat, 10 Aug 2024 05:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268486; cv=none; b=p7tyPshAHVC3Wh6evgPwoyBrm/FA4rqG9my6mVBUL2wBZkdD72LFBcPJZIYyjSibhcdi5CyJy8fCtUZdxK/QAXY+3kdxVqNMKFxgHD2m407oIzXCogXIwwbM03VUfuZF6e4N6mtrOSUXAPpIiPZduBWiUE9/P5Ezhf5BNMldya8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268486; c=relaxed/simple; bh=v4PFyZZsLSqb2a67c3LKpA2NBtGrrBo+DJt1Ah+0Dxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvLnJTVf8DqG38LMvg9LU+hxOkKBKIlRFVzM5eYGwwNtXLtajJrZ9m/2Sa0VzLv2wHfMYOGYC78s41Ded0CMjAGz8BpXqx9K3uPBTsJ1VjaodhGjjSbnP/u2MRnfu5o7mqu5teUkDEZPuF52ys7tCmhQgaAHGIm85ir/DCSo6I8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mkGvaFnS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mkGvaFnS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62425C4AF10; Sat, 10 Aug 2024 05:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268486; bh=v4PFyZZsLSqb2a67c3LKpA2NBtGrrBo+DJt1Ah+0Dxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mkGvaFnSdup4KcCCjCUNlEkZ4wbZ1nHk3xTrkul5om5XgTcvDBZEXR5MiU9E9Jown AyUwEkBnF2+vIsQ0n/FZ4MPyMY6QY5JqmooUy/Zi42+fYJ9z2B/zCa5vgFjXqi4Yuy vxLgu2KerqD42CsJXD3OxKTUzHXxNe2KAYMByFCBwaxUh3EkmIOzE1sOWK2h8YRCEJ LIUFMennLyJGr2SPw+TOhOe71/IJQJA05HBGAeiBdyOjsI48fqusEC8MdcSuT1fU+P yE8Qsj6tsb5kSAidVhsWBh6p2hayyHNpB4RHqMED7vraiv5mZA/AZbuxE/9KGeP3F9 ys2itO9hcDpkA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski , saeedm@nvidia.com, tariqt@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH net-next v5 03/12] eth: mlx5: allow disabling queues when RSS contexts exist Date: Fri, 9 Aug 2024 22:37:19 -0700 Message-ID: <20240810053728.2757709-4-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Since commit 24ac7e544081 ("ethtool: use the rss context XArray in ring deactivation safety-check") core will prevent queues from being disabled while being used by additional RSS contexts. The safety check is no longer necessary, and core will do a more accurate job of only rejecting changes which can actually break things. Reviewed-by: Gal Pressman Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- CC: saeedm@nvidia.com CC: tariqt@nvidia.com CC: leon@kernel.org CC: linux-rdma@vger.kernel.org --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 56bdb4d07b7a..8af509397f63 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -433,7 +433,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, unsigned int count = ch->combined_count; struct mlx5e_params new_params; bool arfs_enabled; - int rss_cnt; bool opened; int err = 0; @@ -487,17 +486,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, goto out; } - /* Don't allow changing the number of channels if non-default RSS contexts exist, - * the kernel doesn't protect against set_channels operations that break them. - */ - rss_cnt = mlx5e_rx_res_rss_cnt(priv->rx_res) - 1; - if (rss_cnt) { - err = -EINVAL; - netdev_err(priv->netdev, "%s: Non-default RSS contexts exist (%d), cannot change the number of channels\n", - __func__, rss_cnt); - goto out; - } - /* Don't allow changing the number of channels if MQPRIO mode channel offload is active, * because it defines a partition over the channels queues. */ From patchwork Sat Aug 10 05:37:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759418 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A34A13A253 for ; Sat, 10 Aug 2024 05:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268487; cv=none; b=u0CsfheNkIp4YL4J48STx0u/DTTdE5oT4rOweB0IjAqDunwm8W8B+F23SdIvPv3iG6ZD6X7vhBP3s+rkYidMHJ4Ai1Lygcur93IhyT5JquBPWcpwr9zQ67amHH8izdYtrZlRs1tvctxkKF6oVVoF0uJ/+xu1Xjj89RDTJl1PM9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268487; c=relaxed/simple; bh=ZnBtdeyp11brBkiQM7OLPU1kLJToVDZ0f/Vv2YsCG84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o9tzLeb8rsupeSGBPP85zOmYPS1sSwiLMCE2F9wDngb/zFCZ2Nr0O48+x3nnZk8Ddak3wf90QRZwra6w9SpaQ9qYT1lhJrlxFx6EOyGYWM8MRTwuQBX0X6n24Pw/RZi37rijK2Xpxi7Ltu5bB3HysdEwFaLbifusRK40tpofXrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BtsTtNRZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BtsTtNRZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B728C32786; Sat, 10 Aug 2024 05:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268487; bh=ZnBtdeyp11brBkiQM7OLPU1kLJToVDZ0f/Vv2YsCG84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BtsTtNRZnbyvWbhg76UqLlbIcyCiIZHlDASnJ/Qr0ZV9A/hkQqLMh/ssC1Bax/QZa 7kFBcm3DyJ6Qu+nr1dfXfp/eyTCrn99GItpyQXGktUJ0d+dl7iKpl0zBR30q/Fk1Zc 3wbrWj7JC+0hsKyt+PXhpFQrwvdRDKR4qmzbP1ceZaPLXYYICK2M2tXG5jfGQzZ3Aw jwmu0oB/zKf0w0BJRGD9vY2yp0jCXq2u/kZsB+0ZlMNVasMKDvS0vTZfGlAlMU0cG1 LpKIbO0OiJ3H6y9YQx4oCPCtFu8lgTFXbCiEXssA0Re071GdVmIB7ai0WY6ScfW6DK hgNDhmJdMGIsA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 04/12] ethtool: make ethtool_ops::cap_rss_ctx_supported optional Date: Fri, 9 Aug 2024 22:37:20 -0700 Message-ID: <20240810053728.2757709-5-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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. Reviewed-by: Gal Pressman Reviewed-by: Edward Cree Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- 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 989c94eddb2b..a149485904d8 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 ba8630eb02ef..1698b73812ce 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); From patchwork Sat Aug 10 05:37:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759419 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D4F913BC0B for ; Sat, 10 Aug 2024 05:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268488; cv=none; b=L4BxNNMRjeW9xMpS3iV3pL6E7NR3J5As3GKQvvj5XWBz8+mz9RauI5bGmbONEd2/UZq50gCsbJ4gRonXWYEg8rj0Zl65xEa+vx2owoajfHDpizxod6c81RJqyqQMd2UKkCSIcYwTtIH08pxXUp5+6VtFTVdPT9gLDe3/Uay3sw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268488; c=relaxed/simple; bh=PavcYLDEPFVndeodLW/ZVWWbX5SVKLZCKmjP6iibtak=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EluRySSgZBhNbZkTlUtcFqR0NQM193Gw9r8Zvour9so+i8yz5A+hELPQ0oAPv5/BKjwpY7CZHZ15dSj5JjFyezG3muRT3TNIkHaVqAtSMzXabXShYmqKHlcR63/9VP/uR9WtI16bmIUcWh/MXfp7SXBgQsdY1ZAB4dky+xNLFGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CUeSwqQ3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CUeSwqQ3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 346AAC4AF0E; Sat, 10 Aug 2024 05:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268487; bh=PavcYLDEPFVndeodLW/ZVWWbX5SVKLZCKmjP6iibtak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CUeSwqQ3xOEOi6g82UFYOK8YT8ibJ4GI51QRmk9tCPCBrm8zIY2ZpkWoh+RI6TZ80 40sJ1aZv/wAWD0TtbEuhc+pheAfYjnsy3obTm/gOIgVjvktml5cmF2bPyfD8cSiJbF Kk4ASCdzjl0FS2q6vfSPWquhO5wbmM4Qh7IjSUiRM/g3jwnfh06DWv6auTacczOgxG 9MDdH1Tmtd6LWGRfQi1jzErbT8EPzsTvYhl5m74ccrsQnYFiR6c96ZM/vohdQINzEf qt5femz60HDPyUDy15k93VbeEan9DLmK9auTogXBDxpPmmTbGi7FW7N9uuGK/XG9FJ tCUiP4zHX11Xw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 05/12] eth: remove .cap_rss_ctx_supported from updated drivers Date: Fri, 9 Aug 2024 22:37:21 -0700 Message-ID: <20240810053728.2757709-6-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Remove .cap_rss_ctx_supported from drivers which moved to the new API. This makes it easy to grep for drivers which still need to be converted. Reviewed-by: Gal Pressman Reviewed-by: Edward Cree Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 - drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 - drivers/net/ethernet/sfc/ef100_ethtool.c | 1 - drivers/net/ethernet/sfc/ethtool.c | 1 - 4 files changed, 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 9dadc89378f0..44076e4ebf1a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -5289,7 +5289,6 @@ void bnxt_ethtool_free(struct bnxt *bp) const struct ethtool_ops bnxt_ethtool_ops = { .cap_link_lanes_supported = 1, - .cap_rss_ctx_supported = 1, .rxfh_max_num_contexts = BNXT_MAX_ETH_RSS_CTX + 1, .rxfh_indir_space = BNXT_MAX_RSS_TABLE_ENTRIES_P5, .rxfh_priv_size = sizeof(struct bnxt_rss_ctx), diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 1d472316e7a7..303427599c1c 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -5791,7 +5791,6 @@ 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_num_contexts = MVPP22_N_RSS_TABLES, .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES, diff --git a/drivers/net/ethernet/sfc/ef100_ethtool.c b/drivers/net/ethernet/sfc/ef100_ethtool.c index 896ffca4aee2..746b5314acb5 100644 --- a/drivers/net/ethernet/sfc/ef100_ethtool.c +++ b/drivers/net/ethernet/sfc/ef100_ethtool.c @@ -37,7 +37,6 @@ ef100_ethtool_get_ringparam(struct net_device *net_dev, /* Ethtool options available */ const struct ethtool_ops ef100_ethtool_ops = { - .cap_rss_ctx_supported = true, .get_drvinfo = efx_ethtool_get_drvinfo, .get_msglevel = efx_ethtool_get_msglevel, .set_msglevel = efx_ethtool_set_msglevel, diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 7c887160e2ef..15245720c949 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -240,7 +240,6 @@ static int efx_ethtool_get_ts_info(struct net_device *net_dev, } const struct ethtool_ops efx_ethtool_ops = { - .cap_rss_ctx_supported = true, .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_USECS_IRQ | ETHTOOL_COALESCE_USE_ADAPTIVE_RX, From patchwork Sat Aug 10 05:37:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759420 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C96B213C8FB for ; Sat, 10 Aug 2024 05:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268488; cv=none; b=QU7A7jqwf3PJjQflEUpjPsOFyA7PYfWyZroSxjqd6u9uAiIKZME5SqnN7cbAnfKCbs7/XraWemEtMYKKJpEAfdNM5tIRmpdv0htOLODLIf/NKuh6QjXzSeIEDaIuW81CcNNg8Zj0u4Uz3r+A0fzNslVRzpLwfHrYuvX+8tQ6qtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268488; c=relaxed/simple; bh=QFmRygjPeQw/o3a0yMddm2bIMkLIhjwR2W04FTcoMws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AkW/zVTgxNSjZHrtPamt68Mac48K7beyeJSj1VimfrwCN4N0/g6fty9RpCM5pN+3ujAKI+u314SSWqGCQatd4ms/uLsVfNS5nvLThrST/MLivl2ZtpCn81pDtayn7Ty5mrM1gdQoBHWVUOgDuntc4WJWlx9954e1JA5hdKBz9ks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UvOQQBkA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UvOQQBkA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A67DC4AF10; Sat, 10 Aug 2024 05:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268488; bh=QFmRygjPeQw/o3a0yMddm2bIMkLIhjwR2W04FTcoMws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UvOQQBkAEhuK0WAxU5gEMQfm3Ue2UzY6BW8PBs0YnEJ+aCvU1NwuljOkufKmYQILh 4qh7E2ZAjbWMyhcCLDqzgaJPRv6olwSY+Ji9UCEYsgvkp4bbwoK6Ob1CUkViGXRdGo N385kneKwjSZw+GnKHgNViu3u+2qZFIAEQ+Gl53tzPAWepudEuNHNjvidtfnSzxq7D K2FRkX57eBLpU+ldQXtoQmZklWV0+9nRXNa/6JMLFpmGcWshjmgtW55H0hW9jDjgkt wgoBS8Z+jlcGc9ujiPpGQFU2yLUde/erfkqCl7jCLrADtFd60xPw1HTKYHkwEn+h1J W4AFYBfSAyJxw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 06/12] ethtool: rss: don't report key if device doesn't support it Date: Fri, 9 Aug 2024 22:37:22 -0700 Message-ID: <20240810053728.2757709-7-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org marvell/otx2 and mvpp2 do not support setting different keys for different RSS contexts. Contexts have separate indirection tables but key is shared with all other contexts. This is likely fine, indirection table is the most important piece. Don't report the key-related parameters from such drivers. This prevents driver-errors, e.g. otx2 always writes the main key, even when user asks to change per-context key. The second reason is that without this change tracking the keys by the core gets complicated. Even if the driver correctly reject setting key with rss_context != 0, change of the main key would have to be reflected in the XArray for all additional contexts. Since the additional contexts don't have their own keys not including the attributes (in Netlink speak) seems intuitive. ethtool CLI seems to deal with it just fine. Having to set the flag in majority of the drivers is a bit tedious but not reporting the key is a safer default. Reviewed-by: Edward Cree Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- v3: - add safety note to the commit message - use true in sfc, drop sienna - extend kdoc of @rxfh_per_ctx_key --- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 1 + .../ethernet/mellanox/mlx5/core/en_ethtool.c | 1 + drivers/net/ethernet/sfc/ef100_ethtool.c | 1 + drivers/net/ethernet/sfc/ethtool.c | 1 + include/linux/ethtool.h | 4 +++ net/ethtool/ioctl.c | 25 ++++++++++++++++--- net/ethtool/rss.c | 21 +++++++++++----- 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 44076e4ebf1a..61d6afc3cacb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -5289,6 +5289,7 @@ void bnxt_ethtool_free(struct bnxt *bp) const struct ethtool_ops bnxt_ethtool_ops = { .cap_link_lanes_supported = 1, + .rxfh_per_ctx_key = 1, .rxfh_max_num_contexts = BNXT_MAX_ETH_RSS_CTX + 1, .rxfh_indir_space = BNXT_MAX_RSS_TABLE_ENTRIES_P5, .rxfh_priv_size = sizeof(struct bnxt_rss_ctx), diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index bc79ba974e49..c7641d326ba5 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -4725,6 +4725,7 @@ static const struct ethtool_ops ice_ethtool_ops = { ETHTOOL_COALESCE_USE_ADAPTIVE | ETHTOOL_COALESCE_RX_USECS_HIGH, .cap_rss_sym_xor_supported = true, + .rxfh_per_ctx_key = true, .get_link_ksettings = ice_get_link_ksettings, .set_link_ksettings = ice_set_link_ksettings, .get_fec_stats = ice_get_fec_stats, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 8af509397f63..4d123dae912c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -2595,6 +2595,7 @@ static void mlx5e_get_ts_stats(struct net_device *netdev, const struct ethtool_ops mlx5e_ethtool_ops = { .cap_rss_ctx_supported = true, + .rxfh_per_ctx_key = true, .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USE_ADAPTIVE | diff --git a/drivers/net/ethernet/sfc/ef100_ethtool.c b/drivers/net/ethernet/sfc/ef100_ethtool.c index 746b5314acb5..5c2551369812 100644 --- a/drivers/net/ethernet/sfc/ef100_ethtool.c +++ b/drivers/net/ethernet/sfc/ef100_ethtool.c @@ -58,6 +58,7 @@ const struct ethtool_ops ef100_ethtool_ops = { .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size, .get_rxfh_key_size = efx_ethtool_get_rxfh_key_size, + .rxfh_per_ctx_key = true, .rxfh_priv_size = sizeof(struct efx_rss_context_priv), .get_rxfh = efx_ethtool_get_rxfh, .set_rxfh = efx_ethtool_set_rxfh, diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 15245720c949..848b1923133a 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c @@ -267,6 +267,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_key = true, .rxfh_priv_size = sizeof(struct efx_rss_context_priv), .get_rxfh = efx_ethtool_get_rxfh, .set_rxfh = efx_ethtool_set_rxfh, diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index a149485904d8..12f6dc567598 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -731,6 +731,9 @@ struct kernel_ethtool_ts_info { * do not have to set this bit. * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor * RSS. + * @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. * @rxfh_indir_space: max size of RSS indirection tables, if indirection table * size as returned by @get_rxfh_indir_size may change during lifetime * of the device. Leave as 0 if the table size is constant. @@ -952,6 +955,7 @@ struct ethtool_ops { u32 cap_link_lanes_supported:1; u32 cap_rss_ctx_supported:1; u32 cap_rss_sym_xor_supported:1; + u32 rxfh_per_ctx_key:1; u32 rxfh_indir_space; u16 rxfh_key_space; u16 rxfh_priv_size; diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 1698b73812ce..18cf9fa32ae3 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1261,10 +1261,15 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, if (rxfh_dev.indir) memcpy(rxfh_dev.indir, ethtool_rxfh_context_indir(ctx), indir_bytes); - if (rxfh_dev.key) - memcpy(rxfh_dev.key, ethtool_rxfh_context_key(ctx), - user_key_size); - rxfh_dev.hfunc = ctx->hfunc; + if (!ops->rxfh_per_ctx_key) { + rxfh_dev.key_size = 0; + } else { + if (rxfh_dev.key) + memcpy(rxfh_dev.key, + ethtool_rxfh_context_key(ctx), + user_key_size); + rxfh_dev.hfunc = ctx->hfunc; + } rxfh_dev.input_xfrm = ctx->input_xfrm; ret = 0; } else { @@ -1281,6 +1286,11 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, &rxfh_dev.input_xfrm, sizeof(rxfh.input_xfrm))) { ret = -EFAULT; + } else if (copy_to_user(useraddr + + offsetof(struct ethtool_rxfh, key_size), + &rxfh_dev.key_size, + sizeof(rxfh.key_size))) { + ret = -EFAULT; } else if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, rss_config[0]), rss_config, total_size)) { @@ -1389,6 +1399,13 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, indir_bytes = dev_indir_size * sizeof(rxfh_dev.indir[0]); + /* Check settings which may be global rather than per RSS-context */ + if (rxfh.rss_context && !ops->rxfh_per_ctx_key) + if (rxfh.key_size || + (rxfh.hfunc && rxfh.hfunc != ETH_RSS_HASH_NO_CHANGE) || + (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)) + return -EOPNOTSUPP; + rss_config = kzalloc(indir_bytes + dev_key_size, GFP_USER); if (!rss_config) return -ENOMEM; diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c index a06bdac8b8a2..cd8100d81919 100644 --- a/net/ethtool/rss.c +++ b/net/ethtool/rss.c @@ -10,6 +10,7 @@ struct rss_req_info { struct rss_reply_data { struct ethnl_reply_data base; + bool no_key_fields; u32 indir_size; u32 hkey_size; u32 hfunc; @@ -60,9 +61,12 @@ 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 || - ops->create_rxfh_context)) - return -EOPNOTSUPP; + 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) @@ -132,13 +136,18 @@ rss_fill_reply(struct sk_buff *skb, const struct ethnl_req_info *req_base, nla_put_u32(skb, ETHTOOL_A_RSS_CONTEXT, request->rss_context)) return -EMSGSIZE; + if ((data->indir_size && + nla_put(skb, ETHTOOL_A_RSS_INDIR, + sizeof(u32) * data->indir_size, data->indir_table))) + return -EMSGSIZE; + + if (data->no_key_fields) + return 0; + if ((data->hfunc && nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc)) || (data->input_xfrm && nla_put_u32(skb, ETHTOOL_A_RSS_INPUT_XFRM, data->input_xfrm)) || - (data->indir_size && - nla_put(skb, ETHTOOL_A_RSS_INDIR, - sizeof(u32) * data->indir_size, data->indir_table)) || (data->hkey_size && nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey))) return -EMSGSIZE; From patchwork Sat Aug 10 05:37:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759421 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF9E343AB3 for ; Sat, 10 Aug 2024 05:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268490; cv=none; b=an/e3/36bEm3qnpqspXkP86Aa2ltunG4PxlON6nxO32SfYTcgIrzCmELI5EkmLer+1LsGKG8PjAU4gTmFMzfMudMW9k3BJ2uWLUqtY7HB07Z8Wb5XCezwsRG5kP9xwSlgyY22JWYfJJBsqOjvjmovPF145/nay7bfNV52DhPfyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268490; c=relaxed/simple; bh=lIno4aI++2TXO7b+efn8pUHCnDi/i1cC62eqDjVwWuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qRQNVlMHn+wfiijQoEAO84MCzsaw723czVGIJTSZLB2ZXAjT6BBhB9WYpRtbuNqe/ukiQwSxg/3WwFuxHtFxF0yARqCBelA2+T3AIRcQapjef23devQt25v+ecZisHbaCXRIxeghlCDPvz+NeA5Yo+y/rQMC536t21/fatOYjCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NXGzoG6/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NXGzoG6/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3958C4AF0C; Sat, 10 Aug 2024 05:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268489; bh=lIno4aI++2TXO7b+efn8pUHCnDi/i1cC62eqDjVwWuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NXGzoG6/dr3eVQT4rkOiOOy+IX11hZyyS8Ixnjn/By4Xve1fM+xJ8pBsul2Jtr+7r SLX7U4BxWGlpvhzJ6wXpB71oCCCWYQnSxk2+yPnWEz89cM7ZYDhAm5h+yVN1g4RqkM Y/P1D2d/ma21WcHZVtkCv23azHgPcgfMqb2GZVbvEerNVWXTwQoaZqY71wE8+RYcD8 Z8/H5zBYc55zppSwDX+uJ0QMCS7Gd7+9G7Us9hgojAcwb8x/ReoumzP9zSshssgx4q 9PYYJ+C8zBIinFpGmKm8xTiW4KjHI/bjDiqkY1U6xyE6uhxquKjphJKuxzqQeNp0Xe YoMGH0raW7tpA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 07/12] ethtool: rss: move the device op invocation out of rss_prepare_data() Date: Fri, 9 Aug 2024 22:37:23 -0700 Message-ID: <20240810053728.2757709-8-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Factor calling device ops out of rss_prepare_data(). Next patch will add alternative path using xarray. No functional changes. Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- 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) From patchwork Sat Aug 10 05:37:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759422 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97A9713D240 for ; Sat, 10 Aug 2024 05:41:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268491; cv=none; b=EFaoraFkB8MjPvqkUWSLL3jYloJyctk2QY1bF+BnAdZ5cxPDdVz98DYh+cNoijuoBLbPEBkzEo9UjR7dCmjA4TG3bFprAb0F+FCNpwpLG+rG3ZzGYKA4+6jja489kZhGe5iRoYOLXZCKMzf1lWuoaoTZy0NE+Na7Kbg6vfbMQ8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268491; c=relaxed/simple; bh=KZwwQbfypZM7en4HuZQB6/5ollICWQL/7o7f7k1O1XY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MOLUxjbqyWzHhuw3sD2wx1My8ju/U9HyQ65c5AyBVLD5Wc1eE1BqdSJC8fKSn2XExoieLc/A45RPzOfwDcEZTYWWQzly1pgdNIyiPLdsM+Ey6/DYSK2GT9UQfYecwQIcZ5U0AyTGuqRPTMz5EfVwhy8ThkS5GLkAVcvFNsqH9DA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vsb4ki70; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vsb4ki70" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0F1EC4AF49; Sat, 10 Aug 2024 05:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268490; bh=KZwwQbfypZM7en4HuZQB6/5ollICWQL/7o7f7k1O1XY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vsb4ki70gutmzPn48kYkTZWFef63EOrBYNEEozADBUj9SrxIWMnu67GCEcL/6YRhg zHnzhN0s2WyBFuOR4IvW2kafKCheCIJhJ0SOCGO75v5esOfgyJTND9JMBXjKuUt7ox FOMLCiFYgNngE6XclHSV758cnJEgdyu3xpeBfg8IyxK2NtUgIESBT07HIU7oZn1o6P zDqEqkuOkSWpoDVukyyYtJVEJziUE4LFPE5FHbbswdpBJd+0Hw+Mc1rKp4stN0Mfus 1hT8dgkftt6gb/qVUqZnqvFrqqdqU9efD9VWUmiZtpkEKqnz9kjGG+G5j14mSLaC66 CbYclbtWCBRjA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 08/12] ethtool: rss: report info about additional contexts from XArray Date: Fri, 9 Aug 2024 22:37:24 -0700 Message-ID: <20240810053728.2757709-9-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org IOCTL already uses the XArray when reporting info about additional contexts. Do the same thing in netlink code. Reviewed-by: Edward Cree Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- net/ethtool/rss.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c index 5c477cc36251..023782ca1230 100644 --- a/net/ethtool/rss.c +++ b/net/ethtool/rss.c @@ -82,7 +82,6 @@ rss_prepare_get(const struct rss_req_info *request, struct net_device *dev, rxfh.indir = data->indir_table; rxfh.key_size = data->hkey_size; rxfh.key = data->hkey; - rxfh.rss_context = request->rss_context; ret = ops->get_rxfh(dev, &rxfh); if (ret) @@ -95,6 +94,41 @@ rss_prepare_get(const struct rss_req_info *request, struct net_device *dev, return ret; } +static int +rss_prepare_ctx(const struct rss_req_info *request, struct net_device *dev, + struct rss_reply_data *data, const struct genl_info *info) +{ + struct ethtool_rxfh_context *ctx; + u32 total_size, indir_bytes; + u8 *rss_config; + + ctx = xa_load(&dev->ethtool->rss_ctx, request->rss_context); + if (!ctx) + return -ENOENT; + + data->indir_size = ctx->indir_size; + data->hkey_size = ctx->key_size; + data->hfunc = ctx->hfunc; + data->input_xfrm = ctx->input_xfrm; + + indir_bytes = data->indir_size * sizeof(u32); + total_size = indir_bytes + data->hkey_size; + rss_config = kzalloc(total_size, GFP_KERNEL); + if (!rss_config) + return -ENOMEM; + + data->indir_table = (u32 *)rss_config; + memcpy(data->indir_table, ethtool_rxfh_context_indir(ctx), indir_bytes); + + if (data->hkey_size) { + data->hkey = rss_config + indir_bytes; + memcpy(data->hkey, ethtool_rxfh_context_key(ctx), + data->hkey_size); + } + + return 0; +} + static int rss_prepare_data(const struct ethnl_req_info *req_base, struct ethnl_reply_data *reply_base, @@ -115,6 +149,7 @@ rss_prepare_data(const struct ethnl_req_info *req_base, return -EOPNOTSUPP; data->no_key_fields = !ops->rxfh_per_ctx_key; + return rss_prepare_ctx(request, dev, data, info); } return rss_prepare_get(request, dev, data, info); From patchwork Sat Aug 10 05:37:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759423 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E539C13D282 for ; Sat, 10 Aug 2024 05:41:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268492; cv=none; b=OHrYotRUkg9A9C1MfewVP5RsZy6c48rg9wtyQ9fuYF5Y3p5liALwxFZho0r1lC59rE+ljoIP1rGVrHL90Pq5rbc9zdeuAk5XtnCWFxoT26/Ne7tfUmsmuCwWPqJHSLscBIR8hMboOX+TWulpvcSjKx0/Cd9hm0v7uUE/+DpUTFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268492; c=relaxed/simple; bh=t0LN1etwkxjzhhvFuxdtxi820G2qk6LMBOmz4fghzLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qj5Mp4DyLFTepOBtu0blAGL9pVN8YTGeyywx3N0i1XM/R2Ql3xLcJoATvCt9/O1Jm21aWT/c3xTM989o3PcQgXMjsRiqYg9G+ZRsqUU586glPTZnv6WKHjD7nj8Zy+KjuY7UEFAPsTkFCI5tWkUPOwEUPlvYO8GnXK+LH26F+WQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JHeHC2NF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JHeHC2NF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E53FC4AF0F; Sat, 10 Aug 2024 05:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268491; bh=t0LN1etwkxjzhhvFuxdtxi820G2qk6LMBOmz4fghzLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHeHC2NFIPwtGD/eJ8WTnHNAOW5HvIRGqJ0K+Ej1yW9UZOLhXuBXSa3yT2QnEbR0r ZhcVbTfFFj7wBEErshTgOZ1iFMogO3cmTWVO7h05+0b3JXUwc30Plb+g2qaRowgqKY ZkZXmO8FCHofmDS4moDLRvkxGL4P2SV44zhVN7bVoZf3KWv1P5Pimqi0TTE+TqK8oO IizsfBHGK7nYkUX4wzCouBYTDpS9OsqrP7PKb13CXZAzk9zypRo9kftOTiLsm3DeJV fBmkncnJSQGTPm9UMH81oUqAxgPbbsEMJ3sFw5YpkXBQagFw6HId5IhebgSMLnZguN cwZcJP6j6ydqg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 09/12] ethtool: rss: support dumping RSS contexts Date: Fri, 9 Aug 2024 22:37:25 -0700 Message-ID: <20240810053728.2757709-10-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Now that we track RSS contexts in the core we can easily dump them. This is a major introspection improvement, as previously the only way to find all contexts would be to try all ids (of which there may be 2^32 - 1). Don't use the XArray iterators (like xa_for_each_start()) as they do not move the index past the end of the array once done, which caused multiple bugs in Netlink dumps in the past. Reviewed-by: Edward Cree Reviewed-by: Joe Damato Signed-off-by: Jakub Kicinski --- v3: - one_ifindex -> match_ifindex, add a comment - add comment about context 0 not being in XArray - extend commit message (XArray iterators) --- Documentation/netlink/specs/ethtool.yaml | 9 +- net/ethtool/netlink.c | 2 + net/ethtool/netlink.h | 2 + net/ethtool/rss.c | 135 +++++++++++++++++++++++ 4 files changed, 146 insertions(+), 2 deletions(-) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index ea21fe135b97..cf69eedae51d 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -1749,12 +1749,12 @@ doc: Partial family for Ethtool Netlink. attribute-set: rss - do: &rss-get-op + do: request: attributes: - header - context - reply: + reply: &rss-reply attributes: - header - context @@ -1762,6 +1762,11 @@ doc: Partial family for Ethtool Netlink. - indir - hkey - input_xfrm + dump: + request: + attributes: + - header + reply: *rss-reply - name: plca-get-cfg doc: Get PLCA params. diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index cb1eea00e349..041548e5f5e6 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -1128,6 +1128,8 @@ static const struct genl_ops ethtool_genl_ops[] = { { .cmd = ETHTOOL_MSG_RSS_GET, .doit = ethnl_default_doit, + .start = ethnl_rss_dump_start, + .dumpit = ethnl_rss_dumpit, .policy = ethnl_rss_get_policy, .maxattr = ARRAY_SIZE(ethnl_rss_get_policy) - 1, }, diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 46ec273a87c5..919371383b23 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -464,6 +464,8 @@ int ethnl_tunnel_info_doit(struct sk_buff *skb, struct genl_info *info); int ethnl_tunnel_info_start(struct netlink_callback *cb); int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int ethnl_act_module_fw_flash(struct sk_buff *skb, struct genl_info *info); +int ethnl_rss_dump_start(struct netlink_callback *cb); +int ethnl_rss_dumpit(struct sk_buff *skb, struct netlink_callback *cb); extern const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN]; extern const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN]; diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c index 023782ca1230..2865720ff583 100644 --- a/net/ethtool/rss.c +++ b/net/ethtool/rss.c @@ -208,6 +208,141 @@ static void rss_cleanup_data(struct ethnl_reply_data *reply_base) kfree(data->indir_table); } +struct rss_nl_dump_ctx { + unsigned long ifindex; + unsigned long ctx_idx; + + /* User wants to only dump contexts from given ifindex */ + unsigned int match_ifindex; +}; + +static struct rss_nl_dump_ctx *rss_dump_ctx(struct netlink_callback *cb) +{ + NL_ASSERT_DUMP_CTX_FITS(struct rss_nl_dump_ctx); + + return (struct rss_nl_dump_ctx *)cb->ctx; +} + +int ethnl_rss_dump_start(struct netlink_callback *cb) +{ + const struct genl_info *info = genl_info_dump(cb); + struct rss_nl_dump_ctx *ctx = rss_dump_ctx(cb); + struct ethnl_req_info req_info = {}; + struct nlattr **tb = info->attrs; + int ret; + + /* Filtering by context not supported */ + if (tb[ETHTOOL_A_RSS_CONTEXT]) { + NL_SET_BAD_ATTR(info->extack, tb[ETHTOOL_A_RSS_CONTEXT]); + return -EINVAL; + } + + ret = ethnl_parse_header_dev_get(&req_info, + tb[ETHTOOL_A_RSS_HEADER], + sock_net(cb->skb->sk), cb->extack, + false); + if (req_info.dev) { + ctx->match_ifindex = req_info.dev->ifindex; + ctx->ifindex = ctx->match_ifindex; + ethnl_parse_header_dev_put(&req_info); + req_info.dev = NULL; + } + + return ret; +} + +static int +rss_dump_one_ctx(struct sk_buff *skb, struct netlink_callback *cb, + struct net_device *dev, u32 rss_context) +{ + const struct genl_info *info = genl_info_dump(cb); + struct rss_reply_data data = {}; + struct rss_req_info req = {}; + void *ehdr; + int ret; + + req.rss_context = rss_context; + + ehdr = ethnl_dump_put(skb, cb, ETHTOOL_MSG_RSS_GET_REPLY); + if (!ehdr) + return -EMSGSIZE; + + ret = ethnl_fill_reply_header(skb, dev, ETHTOOL_A_RSS_HEADER); + if (ret < 0) + goto err_cancel; + + /* Context 0 is not currently storred or cached in the XArray */ + if (!rss_context) + ret = rss_prepare_get(&req, dev, &data, info); + else + ret = rss_prepare_ctx(&req, dev, &data, info); + if (ret) + goto err_cancel; + + ret = rss_fill_reply(skb, &req.base, &data.base); + if (ret) + goto err_cleanup; + genlmsg_end(skb, ehdr); + + rss_cleanup_data(&data.base); + return 0; + +err_cleanup: + rss_cleanup_data(&data.base); +err_cancel: + genlmsg_cancel(skb, ehdr); + return ret; +} + +static int +rss_dump_one_dev(struct sk_buff *skb, struct netlink_callback *cb, + struct net_device *dev) +{ + struct rss_nl_dump_ctx *ctx = rss_dump_ctx(cb); + int ret; + + if (!dev->ethtool_ops->get_rxfh) + return 0; + + if (!ctx->ctx_idx) { + ret = rss_dump_one_ctx(skb, cb, dev, 0); + if (ret) + return ret; + ctx->ctx_idx++; + } + + for (; xa_find(&dev->ethtool->rss_ctx, &ctx->ctx_idx, + ULONG_MAX, XA_PRESENT); ctx->ctx_idx++) { + ret = rss_dump_one_ctx(skb, cb, dev, ctx->ctx_idx); + if (ret) + return ret; + } + ctx->ctx_idx = 0; + + return 0; +} + +int ethnl_rss_dumpit(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct rss_nl_dump_ctx *ctx = rss_dump_ctx(cb); + struct net *net = sock_net(skb->sk); + struct net_device *dev; + int ret = 0; + + rtnl_lock(); + for_each_netdev_dump(net, dev, ctx->ifindex) { + if (ctx->match_ifindex && ctx->match_ifindex != ctx->ifindex) + break; + + ret = rss_dump_one_dev(skb, cb, dev); + if (ret) + break; + } + rtnl_unlock(); + + return ret; +} + const struct ethnl_request_ops ethnl_rss_request_ops = { .request_cmd = ETHTOOL_MSG_RSS_GET, .reply_cmd = ETHTOOL_MSG_RSS_GET_REPLY, From patchwork Sat Aug 10 05:37:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759424 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 325B313D2BC for ; Sat, 10 Aug 2024 05:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268492; cv=none; b=ZUI2DjKpSFR7GNRCYOf9HRAIE+a983pF9o7QYyEhUsljff8k1c3g06fdTswhnKN9+AquupEMxOyTLa/2YytINX49tyBax3iUNy1bV1ebxr8YyI9StKI7cdAdogeG9DkJSehdEa7/UPF/UVxK+Ii3A5w51oIb5ajBA6hbcGyE6H4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268492; c=relaxed/simple; bh=/PiUOW0PTU2RAGAXxarF0bTMgVa8BPy+8uYTYEjCk0w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KkWwR/kReim+bhvqZlDEEo0C1m+68yLmvbs0w+sgeogS8HMbqLiBRISb9n28pj/G+gf1RFE7NMjAbDpz1BDQRJIZWjqALryzurSIZ05biMzUSFn4dS3EyBrUXTwA6cdGJ7/JQhHeTgSZqEUd15laiIYMmzlI5ks10uFucrq2BdQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MOL2XVwR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MOL2XVwR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67308C32786; Sat, 10 Aug 2024 05:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268492; bh=/PiUOW0PTU2RAGAXxarF0bTMgVa8BPy+8uYTYEjCk0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MOL2XVwRVoVHTmW9laRwnQl4tb4S1k//9shpeMeyncf91cbX6x6wKTVhg4ZNr/nW/ 3MvMiZvlaIT6BNtAbbmqyBHRaLUs63dx66kk7H0hl5ypONsaZLBOwB2QYrC3dIeDkS S6fD6kvLaxu6cLouMV4dhHhReu0pwSE3hteSHq4LZ8kJmv1kja0/aauny3+8aBzxK+ VKJkvOiEQrb3OHES3jb/nolOF3XK+oE5O8N1C8nqzodAPCv1mSH1meERVXPu7GJf24 qPP1EatOFnVvq+fSHLAYI4l/dDyfrxwxwq+DVDaExTAHa3ME+mFwuevbjETtqFtPsZ iAI56/KLBTfmQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 10/12] ethtool: rss: support skipping contexts during dump Date: Fri, 9 Aug 2024 22:37:26 -0700 Message-ID: <20240810053728.2757709-11-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Applications may want to deal with dynamic RSS contexts only. So dumping context 0 will be counter-productive for them. Support starting the dump from a given context ID. Alternative would be to implement a dump flag to skip just context 0, not sure which is better... Reviewed-by: Edward Cree Signed-off-by: Jakub Kicinski --- Documentation/netlink/specs/ethtool.yaml | 4 ++++ Documentation/networking/ethtool-netlink.rst | 12 ++++++++++-- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/netlink.h | 2 +- net/ethtool/rss.c | 12 +++++++++++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index cf69eedae51d..4c2334c213b0 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -1028,6 +1028,9 @@ doc: Partial family for Ethtool Netlink. - name: input_xfrm type: u32 + - + name: start-context + type: u32 - name: plca attributes: @@ -1766,6 +1769,7 @@ doc: Partial family for Ethtool Netlink. request: attributes: - header + - start-context reply: *rss-reply - name: plca-get-cfg diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index d5f246aceb9f..82c5542c80ce 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -1866,10 +1866,18 @@ RSS context of an interface similar to ``ETHTOOL_GRSSH`` ioctl request. Request contents: -===================================== ====== ========================== +===================================== ====== ============================ ``ETHTOOL_A_RSS_HEADER`` nested request header ``ETHTOOL_A_RSS_CONTEXT`` u32 context number -===================================== ====== ========================== + ``ETHTOOL_A_RSS_START_CONTEXT`` u32 start context number (dumps) +===================================== ====== ============================ + +``ETHTOOL_A_RSS_CONTEXT`` specifies which RSS context number to query, +if not set context 0 (the main context) is queried. Dumps can be filtered +by device (only listing contexts of a given netdev). Filtering single +context number is not supported but ``ETHTOOL_A_RSS_START_CONTEXT`` +can be used to start dumping context from the given number (primarily +used to ignore context 0s and only dump additional contexts). Kernel response contents: diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 6d5bdcc67631..93c57525a975 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -965,6 +965,7 @@ enum { ETHTOOL_A_RSS_INDIR, /* binary */ ETHTOOL_A_RSS_HKEY, /* binary */ ETHTOOL_A_RSS_INPUT_XFRM, /* u32 */ + ETHTOOL_A_RSS_START_CONTEXT, /* u32 */ __ETHTOOL_A_RSS_CNT, ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1), diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 919371383b23..236c189fc968 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -449,7 +449,7 @@ extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER + extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY + 1]; extern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER + 1]; extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1]; -extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_CONTEXT + 1]; +extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_START_CONTEXT + 1]; extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER + 1]; extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1]; extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1]; diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c index 2865720ff583..e07386275e14 100644 --- a/net/ethtool/rss.c +++ b/net/ethtool/rss.c @@ -28,6 +28,7 @@ struct rss_reply_data { const struct nla_policy ethnl_rss_get_policy[] = { [ETHTOOL_A_RSS_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), [ETHTOOL_A_RSS_CONTEXT] = { .type = NLA_U32 }, + [ETHTOOL_A_RSS_START_CONTEXT] = { .type = NLA_U32 }, }; static int @@ -38,6 +39,10 @@ rss_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb, if (tb[ETHTOOL_A_RSS_CONTEXT]) request->rss_context = nla_get_u32(tb[ETHTOOL_A_RSS_CONTEXT]); + if (tb[ETHTOOL_A_RSS_START_CONTEXT]) { + NL_SET_BAD_ATTR(extack, tb[ETHTOOL_A_RSS_START_CONTEXT]); + return -EINVAL; + } return 0; } @@ -214,6 +219,7 @@ struct rss_nl_dump_ctx { /* User wants to only dump contexts from given ifindex */ unsigned int match_ifindex; + unsigned int start_ctx; }; static struct rss_nl_dump_ctx *rss_dump_ctx(struct netlink_callback *cb) @@ -236,6 +242,10 @@ int ethnl_rss_dump_start(struct netlink_callback *cb) NL_SET_BAD_ATTR(info->extack, tb[ETHTOOL_A_RSS_CONTEXT]); return -EINVAL; } + if (tb[ETHTOOL_A_RSS_START_CONTEXT]) { + ctx->start_ctx = nla_get_u32(tb[ETHTOOL_A_RSS_START_CONTEXT]); + ctx->ctx_idx = ctx->start_ctx; + } ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_RSS_HEADER], @@ -317,7 +327,7 @@ rss_dump_one_dev(struct sk_buff *skb, struct netlink_callback *cb, if (ret) return ret; } - ctx->ctx_idx = 0; + ctx->ctx_idx = ctx->start_ctx; return 0; } From patchwork Sat Aug 10 05:37:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759425 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D92813D619 for ; Sat, 10 Aug 2024 05:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268493; cv=none; b=gKfEnK5N934c8iZiKDzhXQ9RvVMNBSP/ZN/QfpGFp9vB4hYR1XDYQp4vsulPojDiiqXVsAuakiHoNtHM+0t9OX9aGjldnBD7IyCOsyyFP6SsSDErSWzyP9mkV5gliQCJUWYnScqAgP6Yq1C4ICw+rSVFtxj8psUsaZhiYXUsXRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268493; c=relaxed/simple; bh=pSOWwb/NcdhwdHCZvWze8Cm/jHPpakBJe+i9qVQm+qw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NKYvAal3XW/DRbGPMwsS7QEJgWv3Egdytnj5AAsQz7buXvvnO2njocW6IqczAC+v6QYI3ksSpHOWzwrbQGhCmQtM4hKVIc0CB4Z7tVTQ03tkXrpjaoF/24vIs+VDnDy9clWZYtdm9X8yU2LVg4Xqm0RVXehESqn9jU2BZ5A/xMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fKexde97; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fKexde97" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C4B6C4AF13; Sat, 10 Aug 2024 05:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268492; bh=pSOWwb/NcdhwdHCZvWze8Cm/jHPpakBJe+i9qVQm+qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fKexde97Ia3eXlYv78UJmIdvMgeC3jsbpgbOQJFq17ZJyDVsPz1upvsUn2A8AiABQ p85i07aIu/v3GIs6t4uxPn1NY+B4ureJItr8cVhkpbahl2msZcZKrNPrWBlr2707vM DvXc+i+Tt1cgnk7TuWtYvHSRwxD1g3NeND0Zu/wOORwEeOIQwk952v5GmtIiCNbME/ aggFykP32sz1pzTV/dz1vg6WPjpNfMg8QnmM9M0avJVyaW7nzVhljIf1eWK9SxKqzB 4k+KSU+N8gEV2S/NgJX1Au42963Y/IFtcXMVj4n+bvrwvMY+geneGHcBWnjVHBr0Px NoBXzQcVNrErA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 11/12] netlink: specs: decode indirection table as u32 array Date: Fri, 9 Aug 2024 22:37:27 -0700 Message-ID: <20240810053728.2757709-12-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Indirection table is dumped as a raw u32 array, decode it. It's tempting to decode hash key, too, but it is an actual bitstream, so leave it be for now. Signed-off-by: Jakub Kicinski Reviewed-by: Donald Hunter --- Documentation/netlink/specs/ethtool.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml index 4c2334c213b0..1bbeaba5c644 100644 --- a/Documentation/netlink/specs/ethtool.yaml +++ b/Documentation/netlink/specs/ethtool.yaml @@ -1022,6 +1022,7 @@ doc: Partial family for Ethtool Netlink. - name: indir type: binary + sub-type: u32 - name: hkey type: binary From patchwork Sat Aug 10 05:37:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13759426 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E050213D626 for ; Sat, 10 Aug 2024 05:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268494; cv=none; b=uAvL1s3/Y8srZZkQtylY93peKLMnQBC6DHtBbGdka10LJtA6QJvqD7Z2d/BKEfkDjxnSA3C1tPVwPfPKjtqu3od+9YbmNrHiHFWq/XXFaPrzBPfQwDEC88l8ItVVJKFJL2fdeZtbRpqkl5TSPzhZvmeyyncg9/6i3PMm+AshDic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723268494; c=relaxed/simple; bh=Cr63pKk4pkX6lUs023whrYDKXYv3dwHcYT7lbXO34Zo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m33+FctLNyj47/joClsK89r2j8+86HbcgboSFe5A/+dMSAHGHMu6Uy1Yhj4FbreliSqI3NbvIiPKSUOBYHUcXnku318vJcmj/qJqrGNOOQjMd5B+BAmyN7b51eNDXZ9iK/Fi40owvlnaxEOSJrtnDvnnaR7vKv5cNomuo8bRSAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dCzUrVFN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dCzUrVFN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20044C4AF0E; Sat, 10 Aug 2024 05:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723268493; bh=Cr63pKk4pkX6lUs023whrYDKXYv3dwHcYT7lbXO34Zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dCzUrVFNvFx3/6OajmeE9Of1JbqWmz8jGC+CoSawNiMqFRzO7yXE1p6EB21439JKW sk/rT5nKMHN+yjeGs2qBiBAset3aJsENUYUHeOsR/8XojtFdKUWNojXYDZ+RJ0nxQ5 UM1LP0KQW3xUOsJG+yKpP/my50zrrQWGEKKv9JqCRi3ak3e1/iUGwWQUTyg05kVFOL QTDQqgGoHKCm7WxRY3ugchuToONwAd1ZxEm6TeOrDBuOz6il8X62fxx8KReequw3zA GvA0p/9rPhnVXEd+kYq/DS+3sT7bQl6PwRsDiqWaRABBnKMJgxBVNOs1toKIzISEoM DRn591pFcwQxg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, michael.chan@broadcom.com, shuah@kernel.org, ecree.xilinx@gmail.com, przemyslaw.kitszel@intel.com, ahmed.zaki@intel.com, andrew@lunn.ch, willemb@google.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, gal@nvidia.com, jdamato@fastly.com, donald.hunter@gmail.com, Jakub Kicinski Subject: [PATCH net-next v5 12/12] selftests: drv-net: rss_ctx: test dumping RSS contexts Date: Fri, 9 Aug 2024 22:37:28 -0700 Message-ID: <20240810053728.2757709-13-kuba@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240810053728.2757709-1-kuba@kernel.org> References: <20240810053728.2757709-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add a test for dumping RSS contexts. Make sure indir table and key are sane when contexts are created with various combination of inputs. Test the dump filtering by ifname and start-context. Reviewed-by: Petr Machata Reviewed-by: Edward Cree Signed-off-by: Jakub Kicinski --- v3: - filter results by ifindex - check for duplicates --- .../selftests/drivers/net/hw/rss_ctx.py | 76 ++++++++++++++++++- tools/testing/selftests/net/lib/py/ksft.py | 6 ++ 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/rss_ctx.py b/tools/testing/selftests/drivers/net/hw/rss_ctx.py index 1da6b214f4fe..9d7adb3cf33b 100755 --- a/tools/testing/selftests/drivers/net/hw/rss_ctx.py +++ b/tools/testing/selftests/drivers/net/hw/rss_ctx.py @@ -3,7 +3,7 @@ import datetime import random -from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ge, ksft_lt +from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ne, ksft_ge, ksft_lt from lib.py import NetDrvEpEnv from lib.py import EthtoolFamily, NetdevFamily from lib.py import KsftSkipEx @@ -302,6 +302,78 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_eq(carrier1 - carrier0, 0) +def test_rss_context_dump(cfg): + """ + Test dumping RSS contexts. This tests mostly exercises the kernel APIs. + """ + + # Get a random key of the right size + data = get_rss(cfg) + if 'rss-hash-key' in data: + key_data = _rss_key_rand(len(data['rss-hash-key'])) + key = _rss_key_str(key_data) + else: + key_data = [] + key = "ba:ad" + + ids = [] + try: + ids.append(ethtool_create(cfg, "-X", f"context new")) + defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete") + + ids.append(ethtool_create(cfg, "-X", f"context new weight 1 1")) + defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete") + + ids.append(ethtool_create(cfg, "-X", f"context new hkey {key}")) + defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete") + except CmdExitFailure: + if not ids: + raise KsftSkipEx("Unable to add any contexts") + ksft_pr(f"Added only {len(ids)} out of 3 contexts") + + expect_tuples = set([(cfg.ifname, -1)] + [(cfg.ifname, ctx_id) for ctx_id in ids]) + + # Dump all + ctxs = cfg.ethnl.rss_get({}, dump=True) + tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs] + ksft_eq(len(tuples), len(set(tuples)), "duplicates in context dump") + ctx_tuples = set([ctx for ctx in tuples if ctx[0] == cfg.ifname]) + ksft_eq(expect_tuples, ctx_tuples) + + # Sanity-check the results + for data in ctxs: + ksft_ne(set(data['indir']), {0}, "indir table is all zero") + ksft_ne(set(data.get('hkey', [1])), {0}, "key is all zero") + + # More specific checks + if len(ids) > 1 and data.get('context') == ids[1]: + ksft_eq(set(data['indir']), {0, 1}, + "ctx1 - indir table mismatch") + if len(ids) > 2 and data.get('context') == ids[2]: + ksft_eq(data['hkey'], bytes(key_data), "ctx2 - key mismatch") + + # Ifindex filter + ctxs = cfg.ethnl.rss_get({'header': {'dev-name': cfg.ifname}}, dump=True) + tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs] + ctx_tuples = set(tuples) + ksft_eq(len(tuples), len(ctx_tuples), "duplicates in context dump") + ksft_eq(expect_tuples, ctx_tuples) + + # Skip ctx 0 + expect_tuples.remove((cfg.ifname, -1)) + + ctxs = cfg.ethnl.rss_get({'start-context': 1}, dump=True) + tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs] + ksft_eq(len(tuples), len(set(tuples)), "duplicates in context dump") + ctx_tuples = set([ctx for ctx in tuples if ctx[0] == cfg.ifname]) + ksft_eq(expect_tuples, ctx_tuples) + + # And finally both with ifindex and skip main + ctxs = cfg.ethnl.rss_get({'header': {'dev-name': cfg.ifname}, 'start-context': 1}, dump=True) + ctx_tuples = set([(c['header']['dev-name'], c.get('context', -1)) for c in ctxs]) + ksft_eq(expect_tuples, ctx_tuples) + + def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None): """ Test separating traffic into RSS contexts. @@ -542,7 +614,7 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_run([test_rss_key_indir, test_rss_queue_reconfigure, test_rss_resize, test_hitless_key_update, test_rss_context, test_rss_context4, test_rss_context32, - test_rss_context_queue_reconfigure, + test_rss_context_dump, test_rss_context_queue_reconfigure, test_rss_context_overlap, test_rss_context_overlap2, test_rss_context_out_of_order, test_rss_context4_create_with_cfg], args=(cfg, )) diff --git a/tools/testing/selftests/net/lib/py/ksft.py b/tools/testing/selftests/net/lib/py/ksft.py index f663e0daec0d..477ae76de93d 100644 --- a/tools/testing/selftests/net/lib/py/ksft.py +++ b/tools/testing/selftests/net/lib/py/ksft.py @@ -55,6 +55,12 @@ KSFT_DISRUPTIVE = True _fail("Check failed", a, "!=", b, comment) +def ksft_ne(a, b, comment=""): + global KSFT_RESULT + if a == b: + _fail("Check failed", a, "==", b, comment) + + def ksft_true(a, comment=""): if not a: _fail("Check failed", a, "does not eval to True", comment)