From patchwork Tue Aug 6 19:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755261 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 788D6143C46 for ; Tue, 6 Aug 2024 19:33:37 +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=1722972817; cv=none; b=Z8du0Rp/rLK3zyq1qRJlD97unfqcxH6MbxAVUG8Oete4tAgAmxpw1CyBuVplULhDQxVKeM7OdLK+i9ukp8gO4Ft2UuE1gfjc6sFsd0pYpejXMqUfux0OOLqqQdw/j97s623y3Sk+XGiYmTU+io2jQ5VJ1HiKjl/IADXC4PfLtfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972817; c=relaxed/simple; bh=KisNNNCfQT3YqpWIenhbN16DNRy6W+U6stCIScrNpco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CwveLSXtNKrB9vkMXCbAN28H6n8VwEQXOlgso4iIFbWoiREFCl4+tSUtth1cg1r0sd7eC9QoccEtYtD9I9ofP+lQQrnmKyd8+5znohVy+GL8z/EndsLkGg8bJf2AqKYMVVrR5HCFgYkxCLvdNgOwJlzH51Fps4tl0Mz5PW128Gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q0OV04/5; 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="Q0OV04/5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E79C4AF0C; Tue, 6 Aug 2024 19:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972817; bh=KisNNNCfQT3YqpWIenhbN16DNRy6W+U6stCIScrNpco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q0OV04/5oNAFn8SxZNolocYJv/ZVglvvjAvvrZgNiUhim/wLQ5SwtNpgyIoa6OAXw 0i1nzEwNatb185OLQws7nHuaeh7iCethmPjDoLgSQWDxekYK5S9ImNnAW9RvtZaPiI yrZv2wGDb/vfx4e4q+X2LhAsR5yrXBRI7wSdp8wf54MKR+izdcBoZSTv2ehr6ke/6t Qik4UGEmFG8lNqWMpvg9Xfd33KBKexTf56c7MG2I9zxcAVX0CFwLhoPFJ6KkzN1e7r VsDZXwW6nbPKk+H0mC+H9aT8K5x1y732KR1F+YRJxGSvfjGfX/v02LfGVACE+864iW VAMyu5rnP4bgg== 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 v3 01/12] selftests: drv-net: rss_ctx: add identifier to traffic comments Date: Tue, 6 Aug 2024 12:33:06 -0700 Message-ID: <20240806193317.1491822-2-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 Tue Aug 6 19:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755262 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 B8D11146D49 for ; Tue, 6 Aug 2024 19:33:38 +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=1722972818; cv=none; b=V0UwbLZ5aEephkNhgGsObzhMSANp/q/PRGUuu+7ZaPXPzPBmbZAkl6of9QKEQMwSaIJE8CAGc/qsaxmH/TacsjpkVEDJRwtBE7lWuMXNMe3Ux8lHSs5CmKsUDpugCb7Tm8Ie5wC8Z8ExlPxdqug0wVgCgKycINaUI0wDBeBJ+rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972818; c=relaxed/simple; bh=LQcW5lZJ/9P8WMyjGCfS1M6CZwnMNL6hR6fMW47+xbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gAeCzkceGijGTrAPazuKv/FvRTGWnVCq5Lb180MoWA8o5KMOuRvS0ZPdyH2SPFmoDa45t9j8p4tYpBeu8tB5V4MFIW/E5Yl/t8e41r4ofLzH2zMn1Sc08coxRMIlYV5ph8/8TsHXiAcsQEGUq7KZUnBkVP4h0V3yqfx/YKQyzRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LYzFjrd8; 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="LYzFjrd8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A99EC4AF0D; Tue, 6 Aug 2024 19:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972818; bh=LQcW5lZJ/9P8WMyjGCfS1M6CZwnMNL6hR6fMW47+xbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYzFjrd8f+qEaFy1BLo1XjRVXV4OvDUoJ+tktS/q2lajKh0q1GXwuGgJTyvP0w5xF cpQYiirnmmV5SA4f9slcOjTyz7xgCl6Kn7MDApQ5axSQ3tPj5sleaFwCG9W7W2LDz3 0v9Tq8BJcyPYnL5DJl3HD5IIyalN74Ey5nuKGriMM2eq8GUcqs4kZV3BsmbJsRnBJC Pp9IjOEybVBQuGzMdcjYTVsVt+kNXIdeHvgtiH40+H7/vjHiFQ05cqV5HaieUtNr26 fs8l9I2jEgXrlQs41JIsxqb6WsYW1TvuMZcJdwmKOL2bcRXy89GxembNB46KAha+b+ WATB7L8Qz05Rw== 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 v3 02/12] eth: mvpp2: implement new RSS context API Date: Tue, 6 Aug 2024 12:33:07 -0700 Message-ID: <20240806193317.1491822-3-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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. Signed-off-by: Jakub Kicinski Reviewed-by: Edward Cree --- 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..b70aca33b928 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 - 1, .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 Tue Aug 6 19:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755263 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 3BAC614901A; Tue, 6 Aug 2024 19:33:39 +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=1722972819; cv=none; b=N5qygm+/EUHGlDypJD8pUl/cQx8/y2ZRgqjoYu4cnahYfov+Q/KYNshWjm6v62fsDV4DIsMLnaIo16tADZm9Jkay+6OI9ROKyVhHZapw4B79CApxgmdSfACLg3Hm3jYh3Gd3d0XKYLgZ7tZiZoHy1Rh+xYfQYoLpeSUhVKeDYNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972819; c=relaxed/simple; bh=Ksaiilzzj7YrsLDz/h9N0t7bhMsZ6HG9XzjE586OUy8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3j5usLKGCfv4HexhvRk96/Cau0/qIiUTZZh+NMZ51ugk5yZC/NQwXZpHb/K5LCwaKRUQnnKUpbA+dCjGnS/i7dl3KOrJ5kI7cWJdOCIHdMm2wNpArpZknBQd/oytHfYap/csxISR5MkFK2YOaRHox6pj+lUQHofYK83rpD3u+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LCnhfoLY; 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="LCnhfoLY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FD9BC4AF0E; Tue, 6 Aug 2024 19:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972819; bh=Ksaiilzzj7YrsLDz/h9N0t7bhMsZ6HG9XzjE586OUy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCnhfoLYUJjzUbriyA5wG7FYi/WGT7h9GmY6gJY4/J5FrHEENnl3pEWMaX2RAr0KA SORZ2PaRYBtX2uMNjfBdahsXzncZ8vXxEw66hD2R8SUNqQYr/+BDL+uSVL9tAvudi+ Ya0/COw/Sl/5DLAOLKSagw3JCyrw2lh7V637gQfz3xeiSXT0i/5RNrSrmfVFUuPmV0 TGpWif+nZ0blQU17ihC5k0kMCUY7k9g8N9Nv++ObitCBPS0C7zqCCe05rtIgLMDY1j JMlbe+lfeB9CsfLI0RlN6BFkbUinaGgN471J1a6tvpcavP8c1Ap7ehXl2pKFGf3vB8 iJ9JVQrBldolw== 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 v3 03/12] eth: mlx5: allow disabling queues when RSS contexts exist Date: Tue, 6 Aug 2024 12:33:08 -0700 Message-ID: <20240806193317.1491822-4-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 36845872ae94..0b941482db30 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -445,7 +445,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; @@ -499,17 +498,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 Tue Aug 6 19:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755264 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 23A92150990 for ; Tue, 6 Aug 2024 19:33:40 +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=1722972820; cv=none; b=qOk+IkWrm1imwDpJ3IYzaKp+fZEf22skSXzhirPJ617ze1C7QzRobIWH9RHu49E/omuUu9NtJhl4eeY1sArMnRulZMRCn76XpiCok7ick32Ii+bDdg3pVwXTmJ+UHvdbUDZBfVmO3puHZIQsRWPsP9LGx1ef6SjtPGKkCKh0B7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972820; c=relaxed/simple; bh=zuGG0Bgj9l5xKD+PHF+G/QrgAraol3r0Zlqzr4Zap7E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kwZfIxeuSW6APjqRzN0nY/YC4K8G/1UV1RldcEDdBmvWJ+cf3iwNYnFn9QF4qJU2XO1AwStHPjpsdowuTJv3w/Kudb5L3CG3ROL7GgLdATP7K2ZjUDuRnOfZc75CHI2M0a2Nj472SIA6E88P0T+HJ25EA77nwBLXUmrS47zgIUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zt+h6TTU; 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="Zt+h6TTU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AE9EC4AF0D; Tue, 6 Aug 2024 19:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972820; bh=zuGG0Bgj9l5xKD+PHF+G/QrgAraol3r0Zlqzr4Zap7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zt+h6TTUkATAb01jHMXpq/1xX0espaTHSszEe3Mt5DbRMbQm3McBw0T3KHa1VYJGu 8ZLGjCfJgfdxaQXczYeI7iBT3KpIDWNULNnOZ4DRkQCyTB4FiWs1SUfNET0TFoN8xE PxqxDNH6zbJfVQn5sNS9vow6vpfUbFXRZgvY0N6n8qY8Ultrl5MSFosWD3QtpqcFq7 KwKhbIMT5KwXpJODOhJBjSygKzWntLtSM70jrTX5rG5vk3d1wUDgFEiaCDPrDwAwuR n3L4IfjQJrUjyGxCEJBkttVkoZa4JSUqf8p1v0RrE85OI+/roXXofEd34QrNQQZXT6 3ydHovTa6Wgiw== 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 v3 04/12] ethtool: make ethtool_ops::cap_rss_ctx_supported optional Date: Tue, 6 Aug 2024 12:33:09 -0700 Message-ID: <20240806193317.1491822-5-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 303fda54ef17..55c9f613ab64 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -727,7 +727,8 @@ struct kernel_ethtool_ts_info { * @cap_link_lanes_supported: indicates if the driver supports lanes * parameter. * @cap_rss_ctx_supported: indicates if the driver supports RSS - * contexts. + * contexts via legacy API, drivers implementing @create_rxfh_context + * do not have to set this bit. * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor * RSS. * @rxfh_indir_space: max size of RSS indirection tables, if indirection table diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 8ca13208d240..52dfb07393a6 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1227,7 +1227,8 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32) return -EINVAL; /* Most drivers don't handle rss_context, check it's 0 as well */ - if (rxfh.rss_context && !ops->cap_rss_ctx_supported) + if (rxfh.rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context)) return -EOPNOTSUPP; rxfh.indir_size = rxfh_dev.indir_size; @@ -1357,7 +1358,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32) return -EINVAL; /* Most drivers don't handle rss_context, check it's 0 as well */ - if (rxfh.rss_context && !ops->cap_rss_ctx_supported) + if (rxfh.rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context)) return -EOPNOTSUPP; /* Check input data transformation capabilities */ if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR && diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c index 5c4c4505ab9a..a06bdac8b8a2 100644 --- a/net/ethtool/rss.c +++ b/net/ethtool/rss.c @@ -60,7 +60,8 @@ rss_prepare_data(const struct ethnl_req_info *req_base, return -EOPNOTSUPP; /* Some drivers don't handle rss_context */ - if (request->rss_context && !ops->cap_rss_ctx_supported) + if (request->rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context)) return -EOPNOTSUPP; ret = ethnl_ops_begin(dev); From patchwork Tue Aug 6 19:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755265 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 4E9A6154C03 for ; Tue, 6 Aug 2024 19:33:41 +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=1722972821; cv=none; b=AOZHwnOzsMtHPOZT41yD6akEsCH27GF+XF/zKYjHTTi0hur/i1yuwW3l9IyW6o3s2C9R4Tv14QhKB0BaB2JYlMlPrd7c/hZRtZBbFBK+c3PFtXdlYJCSC9MDnc+xLefacMB8y6nJRPj58iSP2rSi8bc8EZLvnFK7rR6X7DXjOX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972821; c=relaxed/simple; bh=ySWkduIsUYX42MGHqm/WphfoDV9ovzfyI6PB3ZCriwc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FzEalGeYWFHaMRQyYBoYrbdQLiS3LFKqc96Tsq19ppGbO32BjuKbz4jHdY4TOPrkkQ8TI2XNoxcJX0T+4Krtw+0S6dZZ/OdkcdM5vrxqC2t7Qn2F/gAN50OH7PYOgNxRIDc4OlN37d+O5bJj/ZZSrVGjGJ7mTveRNf6XQyF3EZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DPJ257ha; 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="DPJ257ha" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30383C4AF0C; Tue, 6 Aug 2024 19:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972820; bh=ySWkduIsUYX42MGHqm/WphfoDV9ovzfyI6PB3ZCriwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DPJ257haghXpVvSt/dBGWRnKdvPTO52rRM3nD1pKcHZlj56jVfUzw5Hi05iZkLquO J6RWOzEGX+Wh+7HwFcnDbf7XKIFvPVeQt9QIPmXA9SXEsS1M59Henb96i//EIu4eHR +d/jASaGq3f0M2i60aDTP6INRZDbKDH/6anOBc8DbIsAg6X/oTubJT8IU6xJPEXRnQ 1bser4XZjZ//9pL/0neintOwsEOhKXbKdVGsQcWP7wt5dqMf8ZY+PnwZ3Zpp3vIo+K d5rJiUFpRGzi/6Dorm3VZYjjDp/wqTeJjJL89UywoQ9Wr+foqBnsOBmmQi6+vZSyAd 2OakkEy7+EWXw== 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 v3 05/12] eth: remove .cap_rss_ctx_supported from updated drivers Date: Tue, 6 Aug 2024 12:33:10 -0700 Message-ID: <20240806193317.1491822-6-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 ab8e3f197e7b..33e8cf0a3764 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_context_id = BNXT_MAX_ETH_RSS_CTX, .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 b70aca33b928..98500b70f994 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_context_id = MVPP22_N_RSS_TABLES - 1, .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 Tue Aug 6 19:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755266 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 25BBD155307 for ; Tue, 6 Aug 2024 19:33:41 +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=1722972822; cv=none; b=gJMODNUSLB6JPVyukmp/zRAqhfM5UEV6Ek6NNRP4/zXt/386cZ/5k2yDmmLhEwb1nmgA8DMfezhU7tLTnSCK1vzA2qhL8w+7bJTdfKXMX4YhN9c+f9izuopvQpCq8HFLUdzElvAmdiJDIJIHcF2ARj3wljNSkbDVkkdg7Z6ys5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972822; c=relaxed/simple; bh=LqQJIT7AUEdDqYLilu2yynPsoirZlCFYGE2I3wcBUzg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AiAAO/OFISmC63c/g+8ywauWXPT1MpsHbwQ2ycKs7+y3bgX8hFItWlZWyGkSR2m44xiWtnokd2elLbfeVkF7pVUxIZ7STMc0V+C67l1QsM0rRS1EKIJD87chx2dzGzWaovjxyQfw3O2Alm8bAeXf3DM/dRKV3yjZYTv1ntcgbfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ctty8EQX; 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="Ctty8EQX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14E74C32786; Tue, 6 Aug 2024 19:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972821; bh=LqQJIT7AUEdDqYLilu2yynPsoirZlCFYGE2I3wcBUzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ctty8EQXKsS8dv/V9MG7tZ/Mz/3qpx+Av0rgbjipSB+toG/oIh3u2z+JTlBDz9D// TaHhHs4attP3Mp4SPGzW/16AAKqmxFEhfnWPNuhdk9yvLR43tKDAtHWuXX0jInwFP7 LjzBrPf3otw1AiCmEQubgAvp0NJqPqccO7lPkciY1Apwmj0SdSls+piL+/yyvUhWs5 qmaN35QrwpPwMEmKKnTFCG6EPyfVEF4fkfxo+G9KgGjnZhDSK+6OLEsmVR3mXGExAA KmQe94K1p0Qjj14/ECHsFGhV+jG8C+H9mvgGtIqWqRseFzWA9NVjE8YCUP+pNt2hQG bxqu6XIOYpGrA== 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 v3 06/12] ethtool: rss: don't report key if device doesn't support it Date: Tue, 6 Aug 2024 12:33:11 -0700 Message-ID: <20240806193317.1491822-7-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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: Joe Damato Signed-off-by: Jakub Kicinski Reviewed-by: Edward Cree --- 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 33e8cf0a3764..77621ccfff5e 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_context_id = BNXT_MAX_ETH_RSS_CTX, .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 8c990c976132..b5b57926cdc0 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 0b941482db30..2d514210aaec 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -2593,6 +2593,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 55c9f613ab64..8c89dc33d51c 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 52dfb07393a6..e32b791f8d1c 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)) { @@ -1386,6 +1396,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 Tue Aug 6 19:33:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755267 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 C5DDB13C677 for ; Tue, 6 Aug 2024 19:33:42 +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=1722972822; cv=none; b=bgWMbix22TQ11ikw57qa1hGAYs/Yh1zNMPNg5YyxLr5hDFIB3wZoysia2TOCnxq1UUXVUjHg8jKc3jhCH8fmRMscLzk7gNdoL/f2g0putug+p0S6U9Ba0ZdT7nTN2FjYnzRq2kfSvKiFtO7PPlXcL8qMZdWUjGc7PIlr8Blhr30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972822; c=relaxed/simple; bh=mern0oxMBhMjRajxmnvl090135JBDOuY+VtdAgYTjBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QhXEuKOoBolSFb0f/MmKpisWZwTGM0ye7NydpVbaNmmYyGF8yJB0pFMsD/tEbIxdCQnfZoaATJAAHPBctA3oQ6Nc+dfYixNHVZStXhWQl4RjRwJ9ZevgbpChYERF+/Comdd+Hwsk7fvkJWVXyLWURG1R5PHMcLSXoFoSdeUJsTA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zm4ZXoHf; 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="Zm4ZXoHf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAC41C4AF0D; Tue, 6 Aug 2024 19:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972822; bh=mern0oxMBhMjRajxmnvl090135JBDOuY+VtdAgYTjBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zm4ZXoHf0n3q4c36GQ1SNNyLItE8rHmRI44mI4k7SdukLbqUJF6r0HjCNwBIseyq8 pA9A0ZcGYa2GJ/GHRIT8C9SH+roGIVDTPDMTr1u/R40ob4HNbHxULsSrvTYCsVZnJa HQQadFsSMAz8H9lsR1tWlkL5U++P2fgnLcDUYwL9IJ/YFYEslVge6x6n7YDsFGgO9x TcAYQfpwB87i9zYnFv9nfOa6E2RAid+PHdLyxwu8CeBNLJJKJwyWNqhOV6O7niwFBX T/KACQV3QZW1BrSyJWSkUzlCS+HUM0loG7vAEvtkUVunXbRXUEzd1flQql/F2CkpaG ef5Vug0bGuWTA== 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 v3 07/12] ethtool: rss: move the device op invocation out of rss_prepare_data() Date: Tue, 6 Aug 2024 12:33:12 -0700 Message-ID: <20240806193317.1491822-8-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 Tue Aug 6 19:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755268 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 040EA156993 for ; Tue, 6 Aug 2024 19:33:43 +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=1722972824; cv=none; b=GHm9EpknhRBdanBTDYqCrx0oDOmaNAejicfv26xYrRX1QI68xWx7v0YFovZoY9N8Ea7+O3xxZImqYlA1ECgXCYwHEc+GSjSu6akyFZtEejrkVkkAf7MKQzLXtnZoWQVd4hTJJGXNS5Vo0IqZws26kPVsD5t+N1kjDyL4uEas6iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972824; c=relaxed/simple; bh=bnfTCYzUhpzmWELdNE82oxRe3hAgG2+lrD0ewcA4yOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cAGp67wTsOzwVKbNqyAF+4s8ClpYKnzZzTfIkhJ8m1Tdpsmfsj/LwKwVGURV0mUTs1ICZMZbLnxmigl3lQkNKyw+JLobustU9ttdfIHu96c5Yo8QjFrW22ZLHvOkBmRMnXEMFi8y5IweUpSIMDnXi4C/jRpM+DNSkftTxY0x5aE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b+nQTlN0; 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="b+nQTlN0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F3BC4AF11; Tue, 6 Aug 2024 19:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972823; bh=bnfTCYzUhpzmWELdNE82oxRe3hAgG2+lrD0ewcA4yOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+nQTlN0jW5VSHRU2Iaq42zg/pJ1PzCES3cT11gFVGsC/NYTUf9nj0IghCe2gDHE6 hZlCcUr2wefuWg7SJmh7U4pIWbY0j833tDaLhgO7Q/7ls6akvHu5i3TyY/FQm5GuO3 xbjDSA53Gh8OGWH8HOtt+sRT+QFBh9WVvvNrwtYTxGVjFVxMimlsvklh5MSkfCugUf 4VraMgGKBGDW8X+8zcj7rQWQyViwB4mPWA41NrFihCbXOGGfN9C4y2BGr1lb1Xb/04 PZHOfXNvaS/l8YjkGhzT/PhGS4rSn5NqD3jPhnW1QfoJSXhgqLFM1ntdggDe5ludJh xPbvQ4jKaLhrw== 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 v3 08/12] ethtool: rss: report info about additional contexts from XArray Date: Tue, 6 Aug 2024 12:33:13 -0700 Message-ID: <20240806193317.1491822-9-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 Tue Aug 6 19:33:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755269 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 9ED19158DBF for ; Tue, 6 Aug 2024 19:33:44 +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=1722972824; cv=none; b=FbPUPFO1f5dj7BuJ7LtLq07MySbq+m89UsumQiKvrsytndaJu9vty8rOC7rAgA/YgHHxfWV3aqwjcvhpF1bIx/XmFsxL1qgdWhZnR0uW4MPyfgCL8sxN+LXcq6TbbgQagQCGC65eC0mTXLUlFqXe2lyJpbJOnEkjzoM/GRrEB8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972824; c=relaxed/simple; bh=6F7camCDIKKK2sxB2S5wzNjfhMOUeLbsxlYULACcv/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ekXzyS/33cptD3BpFjjamZj+BmSxwwAVAKtqIdoVMtR7vpeMzFqsIW+z1hRuX00EpQKksPHct5n/v6y5oKriQvDy34d6h6JY97gkMEVkbEM8tCqEqqzKmpOShlyO3LEk8DKGIbw2yE4H/hjWYEvVCSLPBV1eEC/fSeYlGnZ/0IM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JxvJWM2K; 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="JxvJWM2K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C17C5C4AF0E; Tue, 6 Aug 2024 19:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972824; bh=6F7camCDIKKK2sxB2S5wzNjfhMOUeLbsxlYULACcv/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxvJWM2KhwggoiWJvPsamuVd6sxIAd9N7aO4TWgUTNfXCa4PE6ALHHUcaINZVUA0W HzHONvceBessMb4+I2ZciWKAbvWuQxTUB7umyld+2zyxzsWcXWAxaK9ZNbDo2XSK2h I/eLwfzP/TlHkI9/eu3jyJnBpzpYyOxP+knk5J9jFnebwqLLUsFTLcMSGvIzWNNOCV M66il5nSUgjAAqCMr2iMrB4MGy8Mih1o9/vuEQsKqBAf6RWYFBOuwJGLEgzDRlhsuh 5hDB/JvmsIoIOvM+8vTTz+qvQiAFjDvo+vGQFWj/sgSeIncOQBjI4hwKHmDnoJp8la m1aSubHm7+FWA== 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 v3 09/12] ethtool: rss: support dumping RSS contexts Date: Tue, 6 Aug 2024 12:33:14 -0700 Message-ID: <20240806193317.1491822-10-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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: Joe Damato Signed-off-by: Jakub Kicinski Reviewed-by: Edward Cree --- 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 Tue Aug 6 19:33:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755270 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 88838145A10 for ; Tue, 6 Aug 2024 19:33:45 +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=1722972825; cv=none; b=Gnb/s7g/02XlYKzuYeAxDJRXhNlgkZ5KvD/FcVySTYjE9FWJaQrMOayViYvQqzRN7IRjxlG8Qs4/NoeVfACDbXHIdsJptxlqszEtOC20VwsLrmRjBkAvI+yduhKLn2PxYxOVSN0I9HMyX7RZT1/E/R+V0Xmr8ws2l1VYzmVxME8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972825; c=relaxed/simple; bh=QWhjmLj5JNMKL1NEAhEU1S9UW1D6357Ar+yUE4H9RUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=midfejZzxm00gHJvBgpL62D44/Tk41NChUSjFRIRY/AExG89upwkIVd0Re95NaKIrq+bROxrgC2xUO43Ar8QUmMQNTUkayXITWbP8p9NEYt5GU0T7Z7FxEcfN9P1xJBI2rgsBb2yVqDg4tw2XRwR8sWlsN0mD+STwvE/3qzT82U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=krnDIQkS; 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="krnDIQkS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB0B6C4AF0C; Tue, 6 Aug 2024 19:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972825; bh=QWhjmLj5JNMKL1NEAhEU1S9UW1D6357Ar+yUE4H9RUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=krnDIQkS18OsZ4PHxkpDrCdCSE/p4/Y1zj3LRX+e6WqlYmaFvnPPvKXZn3zBu2iWe mJJtBERA9eUoAbBscJXt+kKcSHwEZ1HwaBoVxSIxj7D+1abO0PZExc9u/RMsPWL7do Q7Sd+pJFhTwZCQ6i6N1ceZ5ODbK/i+8zMZ4QVUVDrdtZABR/Dc25HL5w9XS7wxPO1A bU4rmqWwyyr3wB5GG1XhdXA40k7G3vGEujLZa0L8Rb1LH36VbVcVCHYW2J4Tc20Q9g 70hSuqZUbEE5mjs2o5m59ripXC3vBhSVQdtB7jZIiVkDwm4ON6nWrSXnBVfEuFCmpZ YDYqj9qOXJsOw== 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 v3 10/12] ethtool: rss: support skipping contexts during dump Date: Tue, 6 Aug 2024 12:33:15 -0700 Message-ID: <20240806193317.1491822-11-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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 Tue Aug 6 19:33:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13755271 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 CA00A15B12B for ; Tue, 6 Aug 2024 19:33:46 +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=1722972826; cv=none; b=XTV9OiV1ZdnhBMN0gAUVzfbAO3O2Y97EKdJ04TrYgMvyE692bZgWZ7WIGBxVKAMSjItsvup7LISm72ezmfGom7bzANkqY0T08gzsOcworH/RxgjjRfM2p7B7eXjLqXvlDpATUwwlM3mJK/8K3AoKcETDUCkN7JwYDumbbHeMBmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972826; c=relaxed/simple; bh=dI7gId/L8B6nMeZZXK6onHZD2A995y4+iTbvKlETJAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q9SOhK4x0wdrc+s66djjiOSR6vkew4WS9RGbkVH/OJcbAGAv2fMXJD4h5dGUHF0KWdex4rNZKqxvmaQ6AtVjiOyz9qJGdeiMh5NHaGlDnJMwBCdfIInhM3/MZDn/zrKoj2sasFRxS47y0PwAZGJx+7AHUMhUNgaN/2nd9EzZJKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TBzOYIb4; 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="TBzOYIb4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94925C4AF10; Tue, 6 Aug 2024 19:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972826; bh=dI7gId/L8B6nMeZZXK6onHZD2A995y4+iTbvKlETJAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TBzOYIb4FPzcmKhm/wM1Ht1gO6lltrmH8Ltj4Jq4HPXNel9RMxEEUh3k3QXVOkQCR xEXDQCLUMHti601Lwy/icvafoa1hyvPT6hPsB/mNOogUeznTLdeXyhjQOWt48dXuJd W8stZpJM/bWKOg2ssfxfiaPaiA0vqZiX9svHV6UzxF4lpx3S8xCgKyKKa3rIM0Ar1u BSWwqnBqZ0c/Bw2lZ895Q9FceBUsP4dGK6il/HpX6089a6fUTnX4hhgsqQek03gYHD A2hzqNHqyVZI4zRtpyJDY6reu6YVJaCkRnXTJ9MBZVcYecFWv/UiS0NNB5soOKXVzg ubdQ/bOuXxaCg== 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 v3 11/12] netlink: specs: decode indirection table as u32 array Date: Tue, 6 Aug 2024 12:33:16 -0700 Message-ID: <20240806193317.1491822-12-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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: Joe Damato --- 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 Tue Aug 6 19:33: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: 13755272 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 4D0CA15B54A for ; Tue, 6 Aug 2024 19:33:47 +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=1722972827; cv=none; b=cv/AQwmkxV1f7kmuPKsGShQUOTtnEEI9HiBrUpSkQ0W/bQTCTF31/W/vmdmzHRXHjAbIj0X2lr/OAiAD0JFeDPcrYJpJM9obUf8pwpvP0SraIgUiJGyGw48Myin6vBqgfA8y7TZTeGoSu4TxpYPDgxttidGuLle3rRxB0Vp0v/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722972827; c=relaxed/simple; bh=1piwLmiDV1hbG+SdM4h8lBoO6Bybq+NPapFUgzBVwA8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eI5mUA3Q3CAuDv6WnPXzXIdur/JEakmfnintXzs+BZ9CbY2/yFP4xV29OX2M0rg6tdMUJ37EtikRLmhlxqFkOWqD+XboJEsdEfYQDWIyeP7glcJ3nq5DTCtIEn5pZQMf1pgm7jCH121GXQhYVLM8o/a+JuWUIC8YcNF3MUjvBhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cw+rX6ay; 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="Cw+rX6ay" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77976C32786; Tue, 6 Aug 2024 19:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722972827; bh=1piwLmiDV1hbG+SdM4h8lBoO6Bybq+NPapFUgzBVwA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cw+rX6ayHimbcYiTqQK/h6AW8Kjjqf/LPYFXZBoiUseqpZNjUX9aCrke+HLMJ7wNZ 0REey8L1vpMHF8kBqAbK9iJl/TLI6+AlIJlZQB/0LOEgUl7BTbf3w1X1OU9hBO0/2T nNAQrAhDsKSc+9dxK5AXdEq+4Hx89DYvxGImwAU8sCl8vN2HW+NVsRP/P75Fq8g+SA 3Hx9a7/j1fjoym1o/BLap0bFIgM3Ob45vL+6ij9BGA1QFw8e79psKKHSTuIPCtOPp8 4xk0x/W2qFFJ9xu9GjwyN1jD0tnoTkyhRT1nys1nB26rQp67RSYq08BMnlmlZHWbPM 6NQ+N18w9D07w== 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 v3 12/12] selftests: drv-net: rss_ctx: test dumping RSS contexts Date: Tue, 6 Aug 2024 12:33:17 -0700 Message-ID: <20240806193317.1491822-13-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806193317.1491822-1-kuba@kernel.org> References: <20240806193317.1491822-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. Signed-off-by: Jakub Kicinski Reviewed-by: Petr Machata Reviewed-by: Edward Cree --- 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)