From patchwork Thu Jul 11 22:07:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13731124 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 1E68F16D4E8 for ; Thu, 11 Jul 2024 22:07:20 +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=1720735641; cv=none; b=FnTH5+PSz32rW333NwncPWMpCtA5YWIis6ewHnfaEqa1NwW0DIVJiEysQmsshTBNBGz2++3WpkxbIOOs72LfekLPL8DUbHfQ3TYXSUonx5FCrGGcWnJz80sDj4Ql+snOp4ILy2i3JVjneZkV0sPbd5TUaSDNSxrdne422tky+mg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735641; c=relaxed/simple; bh=rFN3QtDXK3m8eiud+YpEXtD0npPICxW3GRAEhZhDVzY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SLjBmRtb+F8quDu+G46AWmMkevKnajdSNRS7AltI5cIhcXRCSPMpXZgyf9Pp3o02mvSpXderGs04KtCbEema/AJlM7W44pouCHAoHSUMj7ZgHpFba035/fzuHw62gIdNYgBVLEbIEKark1kB+ufD395PobmA9m0RREbJ5g+Lrj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uzhMC9Ja; 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="uzhMC9Ja" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63EABC32782; Thu, 11 Jul 2024 22:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735640; bh=rFN3QtDXK3m8eiud+YpEXtD0npPICxW3GRAEhZhDVzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uzhMC9JaOiewIIqCCWDiDPVNr9AcpiBm5rIZlloS5RukkJiFi1cgtlCGrxETd7Kw6 pNApFoQLwyrW75DkCJHkqB40/AG99hxAWGoHAJlDJFjnrloJTaiUjV81ccqpKx7TRJ +xOeLt6rFLbRCcgJOIQwtjnB2sqGM93dqc5hY7NAkn2bECRhlbGecG4Bn1yLzNnb5B yhh7nVxDTQSrEnhxYHr/QiFkCPhtkLE9cGUu5OUYUVBw83qYLmrT8F1rq7XnKGQ/Gu jTnQnWy4ROZeE0xZ+6fXuiXN3iMtAxogdL65LdYAPYa7Z6hXnLJkooLyzQm2S/cY6t ZV7sfbq0V7msQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 01/11] net: ethtool: let drivers remove lost RSS contexts Date: Thu, 11 Jul 2024 15:07:03 -0700 Message-ID: <20240711220713.283778-2-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 RSS contexts may get lost from a device, in various extreme circumstances. Specifically if the firmware leaks resources and resets, or crashes and either recovers in partially working state or the crash causes a different FW version to run - creating the context again may fail. Drivers should do their absolute best to prevent this from happening. When it does, however, telling user that a context exists, when it can't possibly be used any more is counter productive. Add a helper for drivers to discard contexts. Print an error, in the future netlink notification will also be sent. More robust approaches were proposed, like keeping the contexts but marking them as "dead" (but possibly resurrected by next reset). That may be better but it's unclear at this stage whether the effort is worth the benefits. Signed-off-by: Jakub Kicinski --- I'm keeping this patch as is, since this is the simplest solution, and nobody has strong opinions. v2: - move to common.c to avoid build problems when ethtool-nl isn't enabled - add a note about the counter proposal in the commit message --- include/linux/ethtool.h | 2 ++ net/ethtool/common.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index e213b5508da6..89da0254ccd4 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -210,6 +210,8 @@ static inline size_t ethtool_rxfh_context_size(u32 indir_size, u32 key_size, return struct_size_t(struct ethtool_rxfh_context, data, flex_len); } +void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id); + /* declare a link mode bitmap */ #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 7bda9600efcf..67d06cd002a5 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -741,3 +741,17 @@ ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size) } } EXPORT_SYMBOL_GPL(ethtool_forced_speed_maps_init); + +void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id) +{ + struct ethtool_rxfh_context *ctx; + + WARN_ONCE(!rtnl_is_locked() && + !lockdep_is_held_type(&dev->ethtool->rss_lock, -1), + "RSS context lock assertion failed\n"); + + netdev_err(dev, "device error, RSS context %d lost\n", context_id); + ctx = xa_erase(&dev->ethtool->rss_ctx, context_id); + kfree(ctx); +} +EXPORT_SYMBOL(ethtool_rxfh_context_lost); From patchwork Thu Jul 11 22:07:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13731125 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 7BBF11A00DF for ; Thu, 11 Jul 2024 22:07:21 +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=1720735641; cv=none; b=ZBizuLipgDTNFMnR64cSMxC84ldCCHguN24GtnjbqxKvFEImhHgL0HH4Fpma4ZG61BVr3Hdb5qHvGWgeT8u7w7P6PHsUk8EoCfwzO9O00aYOWsGeIJ/nHVnTd4WdPnk50LCn+AWew4lDMXZAncpkvDU7yRNAYSWZF9x6oGfiwcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735641; c=relaxed/simple; bh=LnRzQSNxhKhZop4m9SC1mc7SXZX2f7qSaUKClO/ijpw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JV7HQ8FQBef4aVrSH/2ZLfUKmrALsctfMbYqERRPM4ah9+wf7DObYcNQqcCZwv9XoFPY3pRkDa2/klgGLJ82YYhf+R7WY79RQXjbCQP4Ry7oXR8E7UFgVArHvtTVFhgvemMwiL4zFkR+zm39TnupHG76x2aqzr0Ik2uFmXaXS/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tW8lDLGV; 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="tW8lDLGV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7BEBC4AF0D; Thu, 11 Jul 2024 22:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735641; bh=LnRzQSNxhKhZop4m9SC1mc7SXZX2f7qSaUKClO/ijpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tW8lDLGViUahmkcWvCiRjj+3u0cPC6WVMF7dla2tkmFrUQkolFYI1STT3YFIRQkLx 5CUnTqzH1D8X9PAz3kAY76Ew4hPTYFmomUGk2KX14Bh9+jharzK9qvO67RfIIT3/0y Hivi9Rski9YDiaFGNy8Tk0pj/p5lyX5RdFrPjLdOrHXsZ+T4UJpsX9Qdat7wohTD9O I6ghv5ukkwOJIY/Pb52V9P5XQWMDMbyiFTeyGjehtA6wIos4zttowKDt2MJHwcqmIq 1udgb0sUt0smu2go8XtcvhYGBGJXVgCliIqOo/V3XxooazyerVkgugruxanNlO3NBy IJBHZB8M4HelA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 02/11] net: ethtool: let drivers declare max size of RSS indir table and key Date: Thu, 11 Jul 2024 15:07:04 -0700 Message-ID: <20240711220713.283778-3-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Some drivers (bnxt but I think also mlx5 from ML discussions) change the size of the indirection table depending on the number of Rx rings. Decouple the max table size from the size of the currently used table, so that we can reserve space in the context for table growth. Static members in ethtool_ops are good enough for now, we can add callbacks to read the max size more dynamically if someone needs that. Signed-off-by: Jakub Kicinski --- v2: - move key_off to the end, under the private label (hiding from kdoc) --- include/linux/ethtool.h | 20 +++++++----------- net/ethtool/ioctl.c | 46 ++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 89da0254ccd4..a1ee76936f53 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -181,6 +181,7 @@ struct ethtool_rxfh_context { /* private: driver private data, indirection table, and hash key are * stored sequentially in @data area. Use below helpers to access. */ + u32 key_off; u8 data[] __aligned(sizeof(void *)); }; @@ -196,18 +197,7 @@ static inline u32 *ethtool_rxfh_context_indir(struct ethtool_rxfh_context *ctx) static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx) { - return (u8 *)(ethtool_rxfh_context_indir(ctx) + ctx->indir_size); -} - -static inline size_t ethtool_rxfh_context_size(u32 indir_size, u32 key_size, - u16 priv_size) -{ - size_t indir_bytes = array_size(indir_size, sizeof(u32)); - size_t flex_len; - - flex_len = size_add(size_add(indir_bytes, key_size), - ALIGN(priv_size, sizeof(u32))); - return struct_size_t(struct ethtool_rxfh_context, data, flex_len); + return &ctx->data[ctx->key_off]; } void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id); @@ -723,6 +713,10 @@ struct ethtool_rxfh_param { * contexts. * @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 + * size as returned by @get_rxfh_indir_size may change during lifetime + * of the device. Leave as 0 if the table size is constant. + * @rxfh_key_space: same as @rxfh_indir_space, but for the key. * @rxfh_priv_size: size of the driver private data area the core should * allocate for an RSS context (in &struct ethtool_rxfh_context). * @rxfh_max_context_id: maximum (exclusive) supported RSS context ID. If this @@ -940,6 +934,8 @@ struct ethtool_ops { u32 cap_link_lanes_supported:1; u32 cap_rss_ctx_supported:1; u32 cap_rss_sym_xor_supported:1; + u32 rxfh_indir_space; + u16 rxfh_key_space; u16 rxfh_priv_size; u32 rxfh_max_context_id; u32 supported_coalesce_params; diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 615812ff8974..0732710a4836 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1290,6 +1290,40 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, return ret; } +static struct ethtool_rxfh_context * +ethtool_rxfh_ctx_alloc(const struct ethtool_ops *ops, + u32 indir_size, u32 key_size) +{ + size_t indir_bytes, flex_len, key_off, size; + struct ethtool_rxfh_context *ctx; + u32 priv_bytes, indir_max; + u16 key_max; + + key_max = max(key_size, ops->rxfh_key_space); + indir_max = max(indir_size, ops->rxfh_indir_space); + + priv_bytes = ALIGN(ops->rxfh_priv_size, sizeof(u32)); + indir_bytes = array_size(indir_max, sizeof(u32)); + + key_off = size_add(priv_bytes, indir_bytes); + flex_len = size_add(key_off, key_max); + size = struct_size_t(struct ethtool_rxfh_context, data, flex_len); + + ctx = kzalloc(size, GFP_KERNEL_ACCOUNT); + if (!ctx) + return NULL; + + ctx->indir_size = indir_size; + ctx->key_size = key_size; + ctx->key_off = key_off; + ctx->priv_size = ops->rxfh_priv_size; + + ctx->hfunc = ETH_RSS_HASH_NO_CHANGE; + ctx->input_xfrm = RXH_XFRM_NO_CHANGE; + + return ctx; +} + static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, void __user *useraddr) { @@ -1406,20 +1440,12 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, ret = -EINVAL; goto out; } - ctx = kzalloc(ethtool_rxfh_context_size(dev_indir_size, - dev_key_size, - ops->rxfh_priv_size), - GFP_KERNEL_ACCOUNT); + ctx = ethtool_rxfh_ctx_alloc(ops, dev_indir_size, dev_key_size); if (!ctx) { ret = -ENOMEM; goto out; } - ctx->indir_size = dev_indir_size; - ctx->key_size = dev_key_size; - ctx->priv_size = ops->rxfh_priv_size; - /* Initialise to an empty context */ - ctx->hfunc = ETH_RSS_HASH_NO_CHANGE; - ctx->input_xfrm = RXH_XFRM_NO_CHANGE; + if (ops->create_rxfh_context) { u32 limit = ops->rxfh_max_context_id ?: U32_MAX; u32 ctx_id; From patchwork Thu Jul 11 22:07:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13731126 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 6DF5E1A0705 for ; Thu, 11 Jul 2024 22:07:21 +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=1720735642; cv=none; b=WY0BX6R0nKFeOPco87Z979kCIlf0gFK6a1lcRaJxk5FF+d0nBqTH8uUNqvYo0o7HbzZF/sQh5Z9bXErHT6fP+dAcQB0w/FssGOcssd7+AmN9T6d9kA88kSjlqVArn+vHZdqbmnlBFJHGKI7p3ZvLjsRuhdDP3kgWIY4Db/zDu4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735642; c=relaxed/simple; bh=/AklftYlH6FhBGa2+/Pb9Rcw6KCYCSX5u56H2ND8n1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LCDwLDitgQv60UVUifyW4u23Fi4zNajKcFfxFs20yENW6T1yhAbUTZwMV0X8wkFKaiH16KugS4lMR6eWqvMU+mkHiB7AZAr75FIPFvxSc2Dx0nJ4p7fSykxYosMdDBBnUrgCKKpiZnDw5seDl5QFE7lPt0R/qmPD7zOnv3eSYvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hk3LSVJU; 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="hk3LSVJU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A2B2C4AF14; Thu, 11 Jul 2024 22:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735641; bh=/AklftYlH6FhBGa2+/Pb9Rcw6KCYCSX5u56H2ND8n1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hk3LSVJUJUdZO6zsjwaUiAdbbfHrYRxcGaXsALtqPJQcQvNME2SDgnrtPMMQGYjd6 fCFZFhRzBIAZbDYm+RHFISm2K++HUSy+faJ2lYXwLaXqlUS7nb037YuhzjFkrebEt6 9kyXrr8ciWsB1Xpv/8jwu3muYer+ShOM9V8SEUm7zkSOxqtjD1jtaKIk0gx5pSOs8e LkDwbInRMFQbEx8rUrONBH4vSbCTf5y2OG4/KR7U3ZNSAL1tG77iMTppyNnuZUoubj c4r3VIF0tXEvExDLwqQyVO9uQoNRC3JDcr0JPzz50Avkp+iYv0fD/PLstk9HyGuYqi ygjGUjiiv3q3Q== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 03/11] eth: bnxt: allow deleting RSS contexts when the device is down Date: Thu, 11 Jul 2024 15:07:05 -0700 Message-ID: <20240711220713.283778-4-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Contexts get deleted from FW when the device is down, but they are kept in SW and re-added back on open. bnxt_set_rxfh_context() apparently does not want to deal with complexity of dealing with both the device down and device up cases. This is perhaps acceptable for creating new contexts, but not being able to delete contexts makes core-driven cleanups messy. Specifically with the new RSS API core will try to delete contexts automatically after bringing the device down. Support the delete-while-down case. Skip the FW logic and delete just the driver state. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 80fce0aaad66..e8965cf743fc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10210,10 +10210,12 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, struct bnxt_ntuple_filter *ntp_fltr; int i; - bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic); - for (i = 0; i < BNXT_MAX_CTX_PER_VNIC; i++) { - if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID) - bnxt_hwrm_vnic_ctx_free_one(bp, vnic, i); + if (netif_running(bp->dev)) { + bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic); + for (i = 0; i < BNXT_MAX_CTX_PER_VNIC; i++) { + if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID) + bnxt_hwrm_vnic_ctx_free_one(bp, vnic, i); + } } if (!all) return; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 4d53ec7adc61..846a19b5f58d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1874,6 +1874,7 @@ static int bnxt_set_rxfh_context(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx; struct bnxt_vnic_info *vnic; bool modify = false; + bool delete; int bit_id; int rc; @@ -1882,7 +1883,8 @@ static int bnxt_set_rxfh_context(struct bnxt *bp, return -EOPNOTSUPP; } - if (!netif_running(bp->dev)) { + delete = *rss_context != ETH_RXFH_CONTEXT_ALLOC && rxfh->rss_delete; + if (!netif_running(bp->dev) && !delete) { NL_SET_ERR_MSG_MOD(extack, "Unable to set RSS contexts when interface is down"); return -EAGAIN; } @@ -1894,7 +1896,7 @@ static int bnxt_set_rxfh_context(struct bnxt *bp, *rss_context); return -EINVAL; } - if (*rss_context && rxfh->rss_delete) { + if (delete) { bnxt_del_one_rss_ctx(bp, rss_ctx, true); return 0; } From patchwork Thu Jul 11 22:07: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: 13731127 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 CD9861A0715 for ; Thu, 11 Jul 2024 22:07:22 +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=1720735642; cv=none; b=nTbwyLTC1s263PjI23/keIGJPOWmowMyQE0F4+zdR9MH9ZEmfhwWeMi/nI0S2FwkEs8y+fXPQknA8p48RQXODG2pgtsDLaT3z8JmQJcI7eAeSS260DZ+4p1xTPASCuEy0VzICEX2DEZ3ji1d5hu7Ee2/vXSVpoOqrN5afHUrESA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735642; c=relaxed/simple; bh=+xiWiPMg1O1fB5qkJ5w8F50SzQ49sTuGFURMZaDWHzc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j4Mk0uyxKFddLafJayhi/zUveTS1yX3qTbe17JojFCMJONGdDGd0FIVOAey1jT66fqYhJ7NPZFR+9h2c9SwKNTrZ5gsn8xvF7h8B2KLwpd1hfzwS5DvdNWWBIRB8Ft2CSRK1GKJzIhnvugWBn4FEyY0flpLLi223Nf+Nrdgaq3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fDT6rp4X; 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="fDT6rp4X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08309C4AF0A; Thu, 11 Jul 2024 22:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735642; bh=+xiWiPMg1O1fB5qkJ5w8F50SzQ49sTuGFURMZaDWHzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fDT6rp4XtGIt3iLgRXPzuVy/vA6gt/1AlFZQ794+7gsohllvtk5v9pn96sdIhyzw/ x+lART7pIV3YB0vi3yIEv29hRPIvMVLgzhwl/TgoC4ykjWZMxDSZasTENUZOJH9j+Q 3lamGBVtCtgeEWOThJ+izhhjgOgP8buyZgFy5O1x2rOcTSY22e7LkngYV1eANePlvk PdrriTHJfBo7Uylsdop+7ZAgZigQxArHzoX7QDODey5fz8WJQjKOEYZjngLNa13hCJ +8LScFifAJSIzr7NByBRHs1J2rnY1vSs7imVY+yzQQynlTjjgCyFeSiI8oWe1XoE2b amr3mbawQhlvQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 04/11] eth: bnxt: move from .set_rxfh to .create_rxfh_context and friends Date: Thu, 11 Jul 2024 15:07:06 -0700 Message-ID: <20240711220713.283778-5-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Use the new ethtool ops for RSS context management. The conversion is pretty straightforward cut / paste of the right chunks of the combined handler. Main change is that we let the core pick the IDs (bitmap will be removed separately for ease of review), so we need to tell the core when we lose a context. Since the new API passes rxfh as const, change bnxt_modify_rss() to also take const. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 119 +++++++++++------- 2 files changed, 75 insertions(+), 45 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e8965cf743fc..bd087c85af5c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10257,6 +10257,7 @@ static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp) netdev_err(bp->dev, "Failed to restore RSS ctx %d\n", rss_ctx->index); bnxt_del_one_rss_ctx(bp, rss_ctx, true); + ethtool_rxfh_context_lost(bp->dev, rss_ctx->index); } } } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 846a19b5f58d..afbb7546ee14 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1841,7 +1841,7 @@ static int bnxt_get_rxfh(struct net_device *dev, } static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, - struct ethtool_rxfh_param *rxfh) + const struct ethtool_rxfh_param *rxfh) { if (rxfh->key) { if (rss_ctx) { @@ -1866,44 +1866,35 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, } } -static int bnxt_set_rxfh_context(struct bnxt *bp, - struct ethtool_rxfh_param *rxfh, - struct netlink_ext_ack *extack) +static int bnxt_rxfh_context_check(struct bnxt *bp, + struct netlink_ext_ack *extack) { - u32 *rss_context = &rxfh->rss_context; - struct bnxt_rss_ctx *rss_ctx; - struct bnxt_vnic_info *vnic; - bool modify = false; - bool delete; - int bit_id; - int rc; - if (!BNXT_SUPPORTS_MULTI_RSS_CTX(bp)) { NL_SET_ERR_MSG_MOD(extack, "RSS contexts not supported"); return -EOPNOTSUPP; } - delete = *rss_context != ETH_RXFH_CONTEXT_ALLOC && rxfh->rss_delete; - if (!netif_running(bp->dev) && !delete) { + if (!netif_running(bp->dev)) { NL_SET_ERR_MSG_MOD(extack, "Unable to set RSS contexts when interface is down"); return -EAGAIN; } - if (*rss_context != ETH_RXFH_CONTEXT_ALLOC) { - rss_ctx = bnxt_get_rss_ctx_from_index(bp, *rss_context); - if (!rss_ctx) { - NL_SET_ERR_MSG_FMT_MOD(extack, "RSS context %u not found", - *rss_context); - return -EINVAL; - } - if (delete) { - bnxt_del_one_rss_ctx(bp, rss_ctx, true); - return 0; - } - modify = true; - vnic = &rss_ctx->vnic; - goto modify_context; - } + return 0; +} + +static int bnxt_create_rxfh_context(struct net_device *dev, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack) +{ + struct bnxt *bp = netdev_priv(dev); + struct bnxt_rss_ctx *rss_ctx; + struct bnxt_vnic_info *vnic; + int rc; + + rc = bnxt_rxfh_context_check(bp, extack); + if (rc) + return rc; if (bp->num_rss_ctx >= BNXT_MAX_ETH_RSS_CTX) { NL_SET_ERR_MSG_FMT_MOD(extack, "Out of RSS contexts, maximum %u", @@ -1911,6 +1902,11 @@ static int bnxt_set_rxfh_context(struct bnxt *bp, return -EINVAL; } + if (test_and_set_bit(rxfh->rss_context, bp->rss_ctx_bmap)) { + NL_SET_ERR_MSG_MOD(extack, "Context ID conflict"); + return -EINVAL; + } + if (!bnxt_rfs_capable(bp, true)) { NL_SET_ERR_MSG_MOD(extack, "Out hardware resources"); return -ENOMEM; @@ -1945,33 +1941,65 @@ static int bnxt_set_rxfh_context(struct bnxt *bp, NL_SET_ERR_MSG_MOD(extack, "Unable to setup TPA"); goto out; } -modify_context: bnxt_modify_rss(bp, rss_ctx, rxfh); - if (modify) - return bnxt_hwrm_vnic_rss_cfg_p5(bp, vnic); - rc = __bnxt_setup_vnic_p5(bp, vnic); if (rc) { NL_SET_ERR_MSG_MOD(extack, "Unable to setup TPA"); goto out; } - bit_id = bitmap_find_free_region(bp->rss_ctx_bmap, - BNXT_RSS_CTX_BMAP_LEN, 0); - if (bit_id < 0) { - rc = -ENOMEM; - goto out; - } - rss_ctx->index = (u16)bit_id; - *rss_context = rss_ctx->index; - + rss_ctx->index = rxfh->rss_context; return 0; out: bnxt_del_one_rss_ctx(bp, rss_ctx, true); return rc; } +static int bnxt_modify_rxfh_context(struct net_device *dev, + struct ethtool_rxfh_context *ctx, + const struct ethtool_rxfh_param *rxfh, + struct netlink_ext_ack *extack) +{ + struct bnxt *bp = netdev_priv(dev); + struct bnxt_rss_ctx *rss_ctx; + int rc; + + rc = bnxt_rxfh_context_check(bp, extack); + if (rc) + return rc; + + rss_ctx = bnxt_get_rss_ctx_from_index(bp, rxfh->rss_context); + if (!rss_ctx) { + NL_SET_ERR_MSG_FMT_MOD(extack, "RSS context %u not found", + rxfh->rss_context); + return -EINVAL; + } + + bnxt_modify_rss(bp, rss_ctx, rxfh); + + return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic); +} + +static int bnxt_remove_rxfh_context(struct net_device *dev, + struct ethtool_rxfh_context *ctx, + u32 rss_context, + struct netlink_ext_ack *extack) +{ + struct bnxt *bp = netdev_priv(dev); + struct bnxt_rss_ctx *rss_ctx; + + rss_ctx = bnxt_get_rss_ctx_from_index(bp, rss_context); + if (!rss_ctx) { + NL_SET_ERR_MSG_FMT_MOD(extack, "RSS context %u not found", + rss_context); + return -EINVAL; + } + + bnxt_del_one_rss_ctx(bp, rss_ctx, true); + return 0; +} + static int bnxt_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh, struct netlink_ext_ack *extack) @@ -1982,9 +2010,6 @@ static int bnxt_set_rxfh(struct net_device *dev, if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; - if (rxfh->rss_context) - return bnxt_set_rxfh_context(bp, rxfh, extack); - bnxt_modify_rss(bp, NULL, rxfh); bnxt_clear_usr_fltrs(bp, false); @@ -5277,6 +5302,7 @@ 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, .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USECS_IRQ | @@ -5314,6 +5340,9 @@ const struct ethtool_ops bnxt_ethtool_ops = { .get_rxfh_key_size = bnxt_get_rxfh_key_size, .get_rxfh = bnxt_get_rxfh, .set_rxfh = bnxt_set_rxfh, + .create_rxfh_context = bnxt_create_rxfh_context, + .modify_rxfh_context = bnxt_modify_rxfh_context, + .remove_rxfh_context = bnxt_remove_rxfh_context, .flash_device = bnxt_flash_device, .get_eeprom_len = bnxt_get_eeprom_len, .get_eeprom = bnxt_get_eeprom, From patchwork Thu Jul 11 22:07: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: 13731128 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 4FEAA1A0734 for ; Thu, 11 Jul 2024 22:07:23 +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=1720735643; cv=none; b=sgCrZ9ANXvZv0gBFRQaMGS1MeGFhR6TGyHWVNlqZExtJVxCYXdOQ+SlXyVWCsU6LgdmQ72iooK9gujOEej4ZBJg1GZ8NzCBbP34dJdRE6+8S6MN/dAaambTIFcX8yZAZbYomdpCGT5ZsRUWZc2dX6S9fj18wkmrpWPW0qFRKmw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735643; c=relaxed/simple; bh=UIuVffc927VdQxejsKwsvnznN1vtwo8nBC75VMqH35E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jtllmXIkFQc5EYnDhAuXWpLmTUCrBiKLaGHJO+N113fcMmXvbVhITYIUkXlSCDSVj1aYzF9pQuvmnTl2hun5rFFZKYbkph/Wy0GYd2bzxhJbNafZrkvNP8TTnXq8qYqwHxb2f/TPgGxMsoZ0ib9LJlge4tZtBPsijGi8uAP3Rus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k0QhqwlH; 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="k0QhqwlH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D111C4AF0C; Thu, 11 Jul 2024 22:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735643; bh=UIuVffc927VdQxejsKwsvnznN1vtwo8nBC75VMqH35E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k0QhqwlHmZuQAvgXlExf3rz7hFzdWtZS7tqMKohGd7UxBDzYqwWAhsnTmgywPnS8R FNhWTSFuTBhUGdSptOGvt3Hrxx+2XWvd3toAEdNCz+y+6FxZy8WTLsXlX4ViJavbXq UYG7IQtZ0GajJTlO6T5ExDFPUypmPKgRpejTN4DtOwsKig4zoiHhZuAIY1AorUG3J2 tNCJBiRui0wK52X0fyZuZq6+uCJkdwEwxk/KuP4z6D3pQazm/U1AaqBOSwhPXGIjo0 FiUNyvJ05FlVyMBQMcjVaNC3yw3moFHD/ChjMTAFTDy+B8LNYTGmaJFJVI0CQQ4K5R hbaeFrcROvHqg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 05/11] eth: bnxt: remove rss_ctx_bmap Date: Thu, 11 Jul 2024 15:07:07 -0700 Message-ID: <20240711220713.283778-6-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Core will allocate IDs for the driver, from the range [1, BNXT_MAX_ETH_RSS_CTX], no need to track the allocations. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 ++----------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 -- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 ----- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index bd087c85af5c..026ceaa0b329 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10239,7 +10239,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, kfree(rss_ctx->rss_indir_tbl); list_del(&rss_ctx->list); bp->num_rss_ctx--; - clear_bit(rss_ctx->index, bp->rss_ctx_bmap); kfree(rss_ctx); } @@ -10281,20 +10280,12 @@ void bnxt_clear_rss_ctxs(struct bnxt *bp, bool all) list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) bnxt_del_one_rss_ctx(bp, rss_ctx, all); - - if (all) - bitmap_free(bp->rss_ctx_bmap); } static void bnxt_init_multi_rss_ctx(struct bnxt *bp) { - bp->rss_ctx_bmap = bitmap_zalloc(BNXT_RSS_CTX_BMAP_LEN, GFP_KERNEL); - if (bp->rss_ctx_bmap) { - /* burn index 0 since we cannot have context 0 */ - __set_bit(0, bp->rss_ctx_bmap); - INIT_LIST_HEAD(&bp->rss_ctx_list); - bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; - } + INIT_LIST_HEAD(&bp->rss_ctx_list); + bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; } /* Allow PF, trusted VFs and VFs with default VLAN to be in promiscuous mode */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 3c8826875ceb..9b0c6656ce27 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1298,7 +1298,6 @@ struct bnxt_rss_ctx { }; #define BNXT_MAX_ETH_RSS_CTX 32 -#define BNXT_RSS_CTX_BMAP_LEN (BNXT_MAX_ETH_RSS_CTX + 1) #define BNXT_VNIC_ID_INVALID 0xffffffff struct bnxt_hw_rings { @@ -2332,7 +2331,6 @@ struct bnxt { struct bnxt_ring_grp_info *grp_info; struct bnxt_vnic_info *vnic_info; struct list_head rss_ctx_list; - unsigned long *rss_ctx_bmap; u32 num_rss_ctx; int nr_vnics; u16 *rss_indir_tbl; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index afbb7546ee14..04855846b5f6 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1902,11 +1902,6 @@ static int bnxt_create_rxfh_context(struct net_device *dev, return -EINVAL; } - if (test_and_set_bit(rxfh->rss_context, bp->rss_ctx_bmap)) { - NL_SET_ERR_MSG_MOD(extack, "Context ID conflict"); - return -EINVAL; - } - if (!bnxt_rfs_capable(bp, true)) { NL_SET_ERR_MSG_MOD(extack, "Out hardware resources"); return -ENOMEM; From patchwork Thu Jul 11 22:07: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: 13731129 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 D501B1A0705 for ; Thu, 11 Jul 2024 22:07:23 +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=1720735643; cv=none; b=MmC2E7bLezzvJ2Cj6fwu9mjD+++o2GhVxgMITbcvkUNz2m90tTkaMS/abAEXEPOmI53VdwSV7uEicYiWs2nj96Ksyp8UZysqpbapg1rrjrmtwdZA129EVRF7uCoUvdbVr9NQay37rAaedOcakcDK4lrbwGIEjEczSPsGlcPH4zI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735643; c=relaxed/simple; bh=PzAeenRjo5OdxcNqBQZYS5U0OjJsATYXdam/0EC34gk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OOsYiF/GfKqtCkEydWWidHm8GtbXZgKX6tK1bHjoJFItQq8MMYD3/LoMhjXhFyStZbdZnMxviUE9BY4KB99sHDHXp/hqpWPfElBU8CCCoCPrl4X6jHjnwqUEezwbPrVyMT/x7hpm41EOeVpQojPwF1Jk1Aq2v8cR9wPkywwarDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gWV3FpY7; 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="gWV3FpY7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25348C116B1; Thu, 11 Jul 2024 22:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735643; bh=PzAeenRjo5OdxcNqBQZYS5U0OjJsATYXdam/0EC34gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gWV3FpY7oLHGZGogTKo9KG6442ZWlCdOkXFoK/+Q99uIathFI2PJsTcTniou1FE5B GVEMrIvN1pTZL3LXDmF3+86J+dcil8Lunm31LbPdWTAJjcXHugR5Mxijg0x3E9OQzZ S1jnPJmInwEKD+QyVT8ogYdXDqnFg4qUf0o5s8haEIDCKk9T6KuvSExWIjzXGjUAYX WzmjW4jEi9aK/TtOs2MdJQrpglfC37JnPouvO40H/ZmyG8fRmVfZHFHu7ECtb7fB59 TLws4gfDDcK9TlapK6oVcERCyRnEYSfaUbDWv/JhnDbg4E/4yOI/ub5SBGeSFgSuxp IUcvCA1bMQGaw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 06/11] eth: bnxt: depend on core cleaning up RSS contexts Date: Thu, 11 Jul 2024 15:07:08 -0700 Message-ID: <20240711220713.283778-7-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 New RSS context API removes old contexts on netdev unregister. No need to wipe them manually. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 026ceaa0b329..d6a4ce5066c6 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10274,12 +10274,12 @@ struct bnxt_rss_ctx *bnxt_alloc_rss_ctx(struct bnxt *bp) return rss_ctx; } -void bnxt_clear_rss_ctxs(struct bnxt *bp, bool all) +void bnxt_clear_rss_ctxs(struct bnxt *bp) { struct bnxt_rss_ctx *rss_ctx, *tmp; list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) - bnxt_del_one_rss_ctx(bp, rss_ctx, all); + bnxt_del_one_rss_ctx(bp, rss_ctx, false); } static void bnxt_init_multi_rss_ctx(struct bnxt *bp) @@ -12331,7 +12331,7 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init, msleep(20); if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp)) - bnxt_clear_rss_ctxs(bp, false); + bnxt_clear_rss_ctxs(bp); /* Flush rings and disable interrupts */ bnxt_shutdown_nic(bp, irq_re_init); @@ -15246,8 +15246,7 @@ static void bnxt_remove_one(struct pci_dev *pdev) bnxt_free_l2_filters(bp, true); bnxt_free_ntp_fltrs(bp, true); - if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp)) - bnxt_clear_rss_ctxs(bp, true); + WARN_ON(bp->num_rss_ctx); clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); /* Flush any pending tasks */ cancel_work_sync(&bp->sp_task); @@ -15898,8 +15897,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bnxt_clear_int_mode(bp); init_err_pci_clean: - if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp)) - bnxt_clear_rss_ctxs(bp, true); bnxt_hwrm_func_drv_unrgtr(bp); bnxt_free_hwrm_resources(bp); bnxt_hwmon_uninit(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 9b0c6656ce27..df96524a8b8b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2847,7 +2847,7 @@ int __bnxt_setup_vnic_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic); void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, bool all); struct bnxt_rss_ctx *bnxt_alloc_rss_ctx(struct bnxt *bp); -void bnxt_clear_rss_ctxs(struct bnxt *bp, bool all); +void bnxt_clear_rss_ctxs(struct bnxt *bp); int bnxt_open_nic(struct bnxt *, bool, bool); int bnxt_half_open_nic(struct bnxt *bp); void bnxt_half_close_nic(struct bnxt *bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 04855846b5f6..5a64c0ea56c0 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -976,7 +976,7 @@ static int bnxt_set_channels(struct net_device *dev, bnxt_clear_usr_fltrs(bp, true); if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp)) - bnxt_clear_rss_ctxs(bp, false); + bnxt_clear_rss_ctxs(bp); if (netif_running(dev)) { if (BNXT_PF(bp)) { /* TODO CHIMP_FW: Send message to all VF's From patchwork Thu Jul 11 22:07: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: 13731130 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 4228B1A08C7 for ; Thu, 11 Jul 2024 22:07: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=1720735644; cv=none; b=OsUbfZqfTVgGYqo6UBf295JRpXFCaT1ou4IdETWZKrzVvDaVGXz0pR4AdoiMXf/hPgEYhnla2eCUv8WYWW94g8F6AKT8dkSBHkZif5SIHt41xss5WsJaX7Xo4pxn2UXnwK2E2SRvuxeCSfJCKunLEW6y6PsVeh93427Bav3BXAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735644; c=relaxed/simple; bh=/zOI9wSF+QS62FI3V5COHzO08xptmcDxzpkAb4zMKjs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F1nqFiMBn6D7C3JHHWte516dI+VuoFzs/pIwOdqzZ/CmDf/wg5L7NaZp2fPQ6e6raSB6DAxzXXz+iUf2josotKmy461NP8noaH1XQhQ0dSPKuhbEOIM58PCZaTAYn4wRZGLjANbRrDdzG9WecouuQpk1hpkuD+cFJ8uP8QdlNuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jpmD2PaN; 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="jpmD2PaN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0D0EC4AF10; Thu, 11 Jul 2024 22:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735644; bh=/zOI9wSF+QS62FI3V5COHzO08xptmcDxzpkAb4zMKjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jpmD2PaNAzaKqd+JJyKqxgEpZV2bb1k76f9PhvCltaazlUPFisVuUpQE6Y15/lb9V 9pkAQcnRH7mvWAUymBAPPdj8mW2jvL+LIEL72B8ZXVL4FMQrGD/8BZ9+cp2RmqerFU rkb9i9TckgDwOiu6UjwWnJ9qCXnd/mwdBfHOF7cTez2IfSDJ4Vd4GpE6FuZRr6D/BX YKWGb73T+8sP6VtNDYoRv8E1ILhJF1wEP6B62f75Ekutw5QfTTkXYUBwIdIqLu88RT CCXTNyTu5B3rF8dNlWiP73wr8xGu1x0C34Vw+MJ3d7oGXbE/l8c4UGIbIyZuA1FT9H ZxTnBGz+upmRA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 07/11] eth: bnxt: use context priv for struct bnxt_rss_ctx Date: Thu, 11 Jul 2024 15:07:09 -0700 Message-ID: <20240711220713.283778-8-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Core can allocate space for per-context driver-private data, use it for struct bnxt_rss_ctx. Inline bnxt_alloc_rss_ctx() at this point, most of the init (as in the actions bnxt_del_one_rss_ctx() will undo) is open coded in bnxt_create_rxfh_context(), anyway. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 14 ----------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 24 +++++++------------ 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index d6a4ce5066c6..e3cc34712f33 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10239,7 +10239,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, kfree(rss_ctx->rss_indir_tbl); list_del(&rss_ctx->list); bp->num_rss_ctx--; - kfree(rss_ctx); } static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp) @@ -10261,19 +10260,6 @@ static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp) } } -struct bnxt_rss_ctx *bnxt_alloc_rss_ctx(struct bnxt *bp) -{ - struct bnxt_rss_ctx *rss_ctx = NULL; - - rss_ctx = kzalloc(sizeof(*rss_ctx), GFP_KERNEL); - if (rss_ctx) { - rss_ctx->vnic.rss_ctx = rss_ctx; - list_add_tail(&rss_ctx->list, &bp->rss_ctx_list); - bp->num_rss_ctx++; - } - return rss_ctx; -} - void bnxt_clear_rss_ctxs(struct bnxt *bp) { struct bnxt_rss_ctx *rss_ctx, *tmp; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index df96524a8b8b..c5fd7a4e6681 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2846,7 +2846,6 @@ int bnxt_hwrm_vnic_rss_cfg_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic); int __bnxt_setup_vnic_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic); void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, bool all); -struct bnxt_rss_ctx *bnxt_alloc_rss_ctx(struct bnxt *bp); void bnxt_clear_rss_ctxs(struct bnxt *bp); int bnxt_open_nic(struct bnxt *, bool, bool); int bnxt_half_open_nic(struct bnxt *bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 5a64c0ea56c0..de8e13412151 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1907,11 +1907,13 @@ static int bnxt_create_rxfh_context(struct net_device *dev, return -ENOMEM; } - rss_ctx = bnxt_alloc_rss_ctx(bp); - if (!rss_ctx) - return -ENOMEM; + rss_ctx = ethtool_rxfh_context_priv(ctx); + + list_add_tail(&rss_ctx->list, &bp->rss_ctx_list); + bp->num_rss_ctx++; vnic = &rss_ctx->vnic; + vnic->rss_ctx = rss_ctx; vnic->flags |= BNXT_VNIC_RSSCTX_FLAG; vnic->vnic_id = BNXT_VNIC_ID_INVALID; rc = bnxt_alloc_rss_ctx_rss_table(bp, rss_ctx); @@ -1964,12 +1966,7 @@ static int bnxt_modify_rxfh_context(struct net_device *dev, if (rc) return rc; - rss_ctx = bnxt_get_rss_ctx_from_index(bp, rxfh->rss_context); - if (!rss_ctx) { - NL_SET_ERR_MSG_FMT_MOD(extack, "RSS context %u not found", - rxfh->rss_context); - return -EINVAL; - } + rss_ctx = ethtool_rxfh_context_priv(ctx); bnxt_modify_rss(bp, rss_ctx, rxfh); @@ -1984,12 +1981,7 @@ static int bnxt_remove_rxfh_context(struct net_device *dev, struct bnxt *bp = netdev_priv(dev); struct bnxt_rss_ctx *rss_ctx; - rss_ctx = bnxt_get_rss_ctx_from_index(bp, rss_context); - if (!rss_ctx) { - NL_SET_ERR_MSG_FMT_MOD(extack, "RSS context %u not found", - rss_context); - return -EINVAL; - } + rss_ctx = ethtool_rxfh_context_priv(ctx); bnxt_del_one_rss_ctx(bp, rss_ctx, true); return 0; @@ -5298,6 +5290,8 @@ 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), .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USECS_IRQ | From patchwork Thu Jul 11 22:07: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: 13731132 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 9D9E41A0AFB for ; Thu, 11 Jul 2024 22:07: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=1720735645; cv=none; b=CP/BQVuyXFXhm5q1SmCw2DRdDUoK/K4m30bcLi7j4kExVGwUKReCnJEo+p+BKuDJRz3MLo23DDe71AQNOxiesH4k57CV1+ke2gR5XyvMsSJ6uyC9CaVD3SmQHxwiIYiIoiOR8YBE6X4Da7STeRqTdAcyilRGLo18wLPfnaDeO5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735645; c=relaxed/simple; bh=EkKHKenCFlkVEpqsKtn/fEIYDNNFa0ZanGKXul4zgZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SRNsnAUIBIQWsgRSjqOFtU7BlCDVFYAywr1jbcSbDkljJBZ9jilj70iUoWlq9UsVIv6xNn9d9fIkQjOgFcXwqL0nXRe+5/uTg6Vj+ErKIv4VrIFsOeqxV3jnKjaENEZbZk7SzUVOKaCMuNYVqq/KVWtxuwR6ZOBRu6BVR7PxO4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KGIguAaY; 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="KGIguAaY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 504EAC4AF0B; Thu, 11 Jul 2024 22:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735644; bh=EkKHKenCFlkVEpqsKtn/fEIYDNNFa0ZanGKXul4zgZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGIguAaY1xjtoxTU+xxw1LO3jttEjsw6qhYMpTOFHBB1+O3KDcVGkjDMjzPt7lzO9 JAi/0ghSbSBittNv2TOfTA/LGb8NDgolY8NS9qz6FCaYqmb1oWbSvg/BoqvJupXkn/ kO4g/3ZG+DeHipN4dCRH84PtCEYnPT9LDZZJewbZ4UmmqDxiCteqIz8A9rtF6ZEN0r VRCi7ZKL49DKEoWi/X35mmFfyXIIdZrAIx2czCdkMqGJpKP9s5NiLvxqmQWo7Rnk7k t4CGzpLcUYTzQRvTKH+emu/9Soww8VNI6QOFlEHQDX8ZB5L55Nq1HVuUOVrx+LcoEx PJeCFe3j6+2kA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 08/11] eth: bnxt: use the RSS context XArray instead of the local list Date: Thu, 11 Jul 2024 15:07:10 -0700 Message-ID: <20240711220713.283778-9-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Core already maintains all RSS contexts in an XArray, no need to keep a second list in the driver. Remove bnxt_get_max_rss_ctx_ring() completely since core performs the same check already. Signed-off-by: Jakub Kicinski --- v2: - remove bnxt_get_max_rss_ctx_ring() --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 56 +++++++------------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 - .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 17 ++---- 3 files changed, 26 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e3cc34712f33..f9554f512314 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5970,17 +5970,20 @@ bnxt_cfg_rfs_ring_tbl_idx(struct bnxt *bp, struct hwrm_cfa_ntuple_filter_alloc_input *req, struct bnxt_ntuple_filter *fltr) { - struct bnxt_rss_ctx *rss_ctx, *tmp; u16 rxq = fltr->base.rxq; if (fltr->base.flags & BNXT_ACT_RSS_CTX) { - list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) { - if (rss_ctx->index == fltr->base.fw_vnic_id) { - struct bnxt_vnic_info *vnic = &rss_ctx->vnic; + struct ethtool_rxfh_context *ctx; + struct bnxt_rss_ctx *rss_ctx; + struct bnxt_vnic_info *vnic; - req->dst_id = cpu_to_le16(vnic->fw_vnic_id); - break; - } + ctx = xa_load(&bp->dev->ethtool->rss_ctx, + fltr->base.fw_vnic_id); + if (ctx) { + rss_ctx = ethtool_rxfh_context_priv(ctx); + vnic = &rss_ctx->vnic; + + req->dst_id = cpu_to_le16(vnic->fw_vnic_id); } return; } @@ -6282,21 +6285,6 @@ static u16 bnxt_get_max_rss_ring(struct bnxt *bp) return max_ring; } -u16 bnxt_get_max_rss_ctx_ring(struct bnxt *bp) -{ - u16 i, tbl_size, max_ring = 0; - struct bnxt_rss_ctx *rss_ctx; - - tbl_size = bnxt_get_rxfh_indir_size(bp->dev); - - list_for_each_entry(rss_ctx, &bp->rss_ctx_list, list) { - for (i = 0; i < tbl_size; i++) - max_ring = max(max_ring, rss_ctx->rss_indir_tbl[i]); - } - - return max_ring; -} - int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings) { if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { @@ -10237,16 +10225,17 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, vnic->rss_table, vnic->rss_table_dma_addr); kfree(rss_ctx->rss_indir_tbl); - list_del(&rss_ctx->list); bp->num_rss_ctx--; } static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp) { bool set_tpa = !!(bp->flags & BNXT_FLAG_TPA); - struct bnxt_rss_ctx *rss_ctx, *tmp; + struct ethtool_rxfh_context *ctx; + unsigned long context; - list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) { + xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { + struct bnxt_rss_ctx *rss_ctx = ethtool_rxfh_context_priv(ctx); struct bnxt_vnic_info *vnic = &rss_ctx->vnic; if (bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings) || @@ -10262,16 +10251,14 @@ static void bnxt_hwrm_realloc_rss_ctx_vnic(struct bnxt *bp) void bnxt_clear_rss_ctxs(struct bnxt *bp) { - struct bnxt_rss_ctx *rss_ctx, *tmp; + struct ethtool_rxfh_context *ctx; + unsigned long context; + + xa_for_each(&bp->dev->ethtool->rss_ctx, context, ctx) { + struct bnxt_rss_ctx *rss_ctx = ethtool_rxfh_context_priv(ctx); - list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) bnxt_del_one_rss_ctx(bp, rss_ctx, false); -} - -static void bnxt_init_multi_rss_ctx(struct bnxt *bp) -{ - INIT_LIST_HEAD(&bp->rss_ctx_list); - bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; + } } /* Allow PF, trusted VFs and VFs with default VLAN to be in promiscuous mode */ @@ -15859,8 +15846,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) INIT_LIST_HEAD(&bp->usr_fltr_list); if (BNXT_SUPPORTS_NTUPLE_VNIC(bp)) - bnxt_init_multi_rss_ctx(bp); - + bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX; rc = register_netdev(dev); if (rc) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index c5fd7a4e6681..be40e0513777 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1291,7 +1291,6 @@ struct bnxt_vnic_info { }; struct bnxt_rss_ctx { - struct list_head list; struct bnxt_vnic_info vnic; u16 *rss_indir_tbl; u8 index; @@ -2330,7 +2329,6 @@ struct bnxt { /* grp_info indexed by completion ring index */ struct bnxt_ring_grp_info *grp_info; struct bnxt_vnic_info *vnic_info; - struct list_head rss_ctx_list; u32 num_rss_ctx; int nr_vnics; u16 *rss_indir_tbl; @@ -2812,7 +2810,6 @@ int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic, void bnxt_fill_ipv6_mask(__be32 mask[4]); int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx); void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx); -u16 bnxt_get_max_rss_ctx_ring(struct bnxt *bp); int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index de8e13412151..74765583405b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -961,12 +961,6 @@ static int bnxt_set_channels(struct net_device *dev, return rc; } - if (req_rx_rings < bp->rx_nr_rings && - req_rx_rings <= bnxt_get_max_rss_ctx_ring(bp)) { - netdev_warn(dev, "Can't deactivate rings used by RSS contexts\n"); - return -EINVAL; - } - if (bnxt_get_nr_rss_ctxs(bp, req_rx_rings) != bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) && netif_is_rxfh_configured(dev)) { @@ -1216,12 +1210,12 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd) static struct bnxt_rss_ctx *bnxt_get_rss_ctx_from_index(struct bnxt *bp, u32 index) { - struct bnxt_rss_ctx *rss_ctx, *tmp; + struct ethtool_rxfh_context *ctx; - list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) - if (rss_ctx->index == index) - return rss_ctx; - return NULL; + ctx = xa_load(&bp->dev->ethtool->rss_ctx, index); + if (!ctx) + return NULL; + return ethtool_rxfh_context_priv(ctx); } static int bnxt_alloc_rss_ctx_rss_table(struct bnxt *bp, @@ -1909,7 +1903,6 @@ static int bnxt_create_rxfh_context(struct net_device *dev, rss_ctx = ethtool_rxfh_context_priv(ctx); - list_add_tail(&rss_ctx->list, &bp->rss_ctx_list); bp->num_rss_ctx++; vnic = &rss_ctx->vnic; From patchwork Thu Jul 11 22:07: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: 13731131 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 9D98F1A08C7 for ; Thu, 11 Jul 2024 22:07: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=1720735645; cv=none; b=b0z8/f0HRtASVKyzFbMpbF3L4jqKyc40pTaQ8dkVjDky8F04U5XR7UlUhqMhhfZy0uzYvk4WJo0lI5P/B0K5nI8uMnHT/W/odkDxjPQL6Mnc51rKf2l3J9ZTy1GpXQarYOvwiXSq86gtT8VeqPvZME9RLO1zGsrtwmadXR33G3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735645; c=relaxed/simple; bh=BA/4/lrYg+wmWQ4tVUW2kOuW7U1qId5Lb3PiH0KAVL8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=clhCWqutDvrbM9zD7MPXcfCJcPexMXxk8NyODYv/XJHSONdtkfdm629F7WrDWELgF8+mSOEaqr3duDDDb49cjDMDCOJUv9YEL9dgo9tvgi6sLMQbCVqpEoz+6ip5fzkk4i+s2KZr6H5dS4zBOq4CLm6qnxhSzXjIlvdp+FfOXVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sFdW4uxi; 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="sFdW4uxi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEBC2C4AF09; Thu, 11 Jul 2024 22:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735645; bh=BA/4/lrYg+wmWQ4tVUW2kOuW7U1qId5Lb3PiH0KAVL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sFdW4uxik8R5POIbb/rbdCFcnVDqVjiPvHWS3pOyVUtLlV+yJ48dbX5G5ss7w0lOF H7k2KC/tg6pZwqWjHtdnxgPzBRstrgqAtrvKE0SXLsjpw3d5HUmRD4yslI3uMRb6Mu LrOM4q/UQtpvLVom4mRdWQ0Ck0MXEFZMajSc4QX6bE91sqJV0B1/D9rTc8bJ8tq7z7 AerltfOib0AA/TORNq5SXNjphncLehigaMe7Dsom1NrxNCOlUfRUmsLTy56VhSJCv3 ZJuOHNqAimodK5BkKN6bKqiktorMaUdO9p1P0g8aSKeVFuQ7JFWSsiB9phGh08r5Bs vKT7IiGt48RJQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 09/11] eth: bnxt: pad out the correct indirection table Date: Thu, 11 Jul 2024 15:07:11 -0700 Message-ID: <20240711220713.283778-10-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 bnxt allocates tables of max size, and changes the used size based on number of active rings. The unused entries get padded out with zeros. bnxt_modify_rss() seems to always pad out the table of the main / default RSS context, instead of the table of the modified context. I haven't observed any behavior change due to this patch, so I don't think it's a fix. Not entirely sure what role the padding plays, 0 is a valid queue ID. Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 74765583405b..8c30f740a9c5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1856,7 +1856,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, indir_tbl[i] = rxfh->indir[i]; pad = bp->rss_indir_tbl_entries - tbl_size; if (pad) - memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); + memset(&indir_tbl[i], 0, pad * sizeof(u16)); } } From patchwork Thu Jul 11 22:07: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: 13731133 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 0235C19F485 for ; Thu, 11 Jul 2024 22:07: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=1720735646; cv=none; b=OBa6BoKliS7NO2p4Ozyw0QnYpdPKSsZLrxtOClfh8Auz6NvlSO7EhPagSrBkWyTWE2YQuzAi8uOvCUPOaihnwXMl7qGRdJjcd22FGzFDvGvJrLAN1oDVYX07aeo7Jn5D13brU/dwiHVCQT6BQXXm2ChTQ8RPZpKH6OJhi+5dARg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735646; c=relaxed/simple; bh=OB4v2rdbXorCKz4rp2P4CdP/ZdfXdVzh0kuoR5cD5ds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m0RoCwK+itv0BOtVWtxqQriVvn2eKAf4m7eOa+D7zIl+FnSKXqsngGDJ8JHoUMRHdL7Jf48yZfQWnsOivWSET5QDv4VgtbGkP6N4CxXHogPoq9Kol34mkYzSx3LDeYg8miTRScRLOEpuKzYccqtMdCF9VTPomxSOxyb/xOyx118= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sJCokyYT; 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="sJCokyYT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73540C4AF0A; Thu, 11 Jul 2024 22:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735645; bh=OB4v2rdbXorCKz4rp2P4CdP/ZdfXdVzh0kuoR5cD5ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJCokyYTYzJat1FuURHhskZrqdC2o1gp8Uc+PYPi9q6i5g5VvFCF/SxWW3brSk0zl mdvMZheZEFGDrjsCtCWVWOe8WEtd/5dRxvZ9+jQFU71x7/7/pdNM+V8AL9zDvMw+5c 9Q60UBXDoA80ceh/Veq1izsj98FfV4RupZCXTrk2YmHNiS4IMRTA8/WgkYD93rgFyq FsRsSnnSppMUvcXaey9NQieN2mzHS0/G6LkIDIZ3dOTxpZ47vKqQbhEWYeDg7qMyxk jtrsN89t5ZGjuDFqwuKT+kd072yeDsR6Ajmj33HbeBDTFPA3ScLzfPtGG7MK5kyQT0 WYCtFMBm5j86Q== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 10/11] eth: bnxt: bump the entry size in indir tables to u32 Date: Thu, 11 Jul 2024 15:07:12 -0700 Message-ID: <20240711220713.283778-11-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Ethtool core stores indirection table with u32 entries, "just to be safe". Switch the type in the driver, so that it's easier to swap local tables for the core ones. Memory allocations already use sizeof(*entry), switch the memset()s as well. Signed-off-by: Jakub Kicinski --- v2: - switch from sizeof(u32) to sizeof(*indir_tbl) - add a sentence to the commit msg --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index f9554f512314..ed46d74533ed 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6225,7 +6225,7 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr) int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) { int entries; - u16 *tbl; + u32 *tbl; if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5; @@ -6248,7 +6248,7 @@ int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) { u16 max_rings, max_entries, pad, i; - u16 *rss_indir_tbl; + u32 *rss_indir_tbl; if (!bp->rx_nr_rings) return; @@ -6269,12 +6269,12 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) pad = bp->rss_indir_tbl_entries - max_entries; if (pad) - memset(&rss_indir_tbl[i], 0, pad * sizeof(u16)); + memset(&rss_indir_tbl[i], 0, pad * sizeof(*rss_indir_tbl)); } static u16 bnxt_get_max_rss_ring(struct bnxt *bp) { - u16 i, tbl_size, max_ring = 0; + u32 i, tbl_size, max_ring = 0; if (!bp->rss_indir_tbl) return 0; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index be40e0513777..1a33824a32a8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1292,7 +1292,7 @@ struct bnxt_vnic_info { struct bnxt_rss_ctx { struct bnxt_vnic_info vnic; - u16 *rss_indir_tbl; + u32 *rss_indir_tbl; u8 index; }; @@ -2331,7 +2331,7 @@ struct bnxt { struct bnxt_vnic_info *vnic_info; u32 num_rss_ctx; int nr_vnics; - u16 *rss_indir_tbl; + u32 *rss_indir_tbl; u16 rss_indir_tbl_entries; u32 rss_hash_cfg; u32 rss_hash_delta; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 8c30f740a9c5..edcbb1a4f6c8 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1804,7 +1804,7 @@ static int bnxt_get_rxfh(struct net_device *dev, u32 rss_context = rxfh->rss_context; struct bnxt_rss_ctx *rss_ctx = NULL; struct bnxt *bp = netdev_priv(dev); - u16 *indir_tbl = bp->rss_indir_tbl; + u32 *indir_tbl = bp->rss_indir_tbl; struct bnxt_vnic_info *vnic; u32 i, tbl_size; @@ -1848,7 +1848,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, } if (rxfh->indir) { u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(bp->dev); - u16 *indir_tbl = bp->rss_indir_tbl; + u32 *indir_tbl = bp->rss_indir_tbl; if (rss_ctx) indir_tbl = rss_ctx->rss_indir_tbl; @@ -1856,7 +1856,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, indir_tbl[i] = rxfh->indir[i]; pad = bp->rss_indir_tbl_entries - tbl_size; if (pad) - memset(&indir_tbl[i], 0, pad * sizeof(u16)); + memset(&indir_tbl[i], 0, pad * sizeof(*indir_tbl)); } } From patchwork Thu Jul 11 22:07: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: 13731134 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 C8B931A2556 for ; Thu, 11 Jul 2024 22:07: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=1720735646; cv=none; b=W7QvuKSucvdszr1cNyirPKNtF3OgUBaGvj6JvaV9/Ki2/H7otde2rUyZIRZDCSXPtVIwS+X4XJcGsqbHnUhiI8XzCc8G+I4VEvspnvQY0zV39erlXahagFnioyD2GBJxMVs5+IfOeud+L2P4q3z949BFvusIH1KqCF9p/5P90qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720735646; c=relaxed/simple; bh=sxTgz6tXDQe3pImKfV6ApXG/Aax4/z33k2zqszCETcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cl1dT/kWb4Tf/VjTEKNmSy5vtXm4K/Z7sAC/fGevpFdXcVzQwhIYcezPUgQeJeZu6v8D2hjNkCS4saBHQajx4/Ob5vBLnkrkiKhj31+Q9Wz0eDb/Be1vut2wZNcceplbwiZYeZOBI4v7aWiZfqb3HiDrpeYJ62Prer+k2h0ooHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RGwsgR0k; 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="RGwsgR0k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CDE0C116B1; Thu, 11 Jul 2024 22:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720735646; bh=sxTgz6tXDQe3pImKfV6ApXG/Aax4/z33k2zqszCETcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGwsgR0knUN5H8Kv6Fk9gKaMixoB9a+IJRmBAD/OXERswsXDA6Ngv/c5gimUloiqs z1T47ZfcNbCX+lh0tUSnBZrZEWFxmRTzN+vOIurIByN3m1gpm7q1Ds27UTSDTFw/3V Y+ABmR6V7D3bzqPKzaN8D55Km4MDda/v32a2AeXteWua94V2waEKB4A3a+Mer3JJtH r2G8etpRIvQ0jGGEPpK7UyZPvwycQKN0duceqUBP4Xj5NHq9m6s4wJzAPkenXhFDC2 uTjTpbkPa4B/pvY1zwN7PDyz6081J6emLtxO4MJNCFOdPTQyQJxPJlrB4IWQFPw2aC 8RP8hbKrhw9ow== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, ecree.xilinx@gmail.com, michael.chan@broadcom.com, horms@kernel.org, pavan.chebbi@broadcom.com, przemyslaw.kitszel@intel.com, Jakub Kicinski Subject: [PATCH net-next 11/11] eth: bnxt: use the indir table from ethtool context Date: Thu, 11 Jul 2024 15:07:13 -0700 Message-ID: <20240711220713.283778-12-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240711220713.283778-1-kuba@kernel.org> References: <20240711220713.283778-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 Instead of allocating a separate indir table in the vnic use the one already present in the RSS context allocated by the core. This saves some LoC and also we won't have to worry about syncing the local version back to the core, once core learns how to dump contexts. Signed-off-by: Jakub Kicinski --- v2: - store a pointer to struct ethtool_rxfh_param instead of adding the ethtool_rxfh_priv_context() helper --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 23 +++++------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 7 ++-- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 36 +++++++++---------- 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index ed46d74533ed..bb3be33c1bbd 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6222,10 +6222,9 @@ static u16 bnxt_cp_ring_for_tx(struct bnxt *bp, struct bnxt_tx_ring_info *txr) return bnxt_cp_ring_from_grp(bp, &txr->tx_ring_struct); } -int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) +static int bnxt_alloc_rss_indir_tbl(struct bnxt *bp) { int entries; - u32 *tbl; if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) entries = BNXT_MAX_RSS_TABLE_ENTRIES_P5; @@ -6233,19 +6232,16 @@ int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) entries = HW_HASH_INDEX_SIZE; bp->rss_indir_tbl_entries = entries; - tbl = kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL); - if (!tbl) + bp->rss_indir_tbl = + kmalloc_array(entries, sizeof(*bp->rss_indir_tbl), GFP_KERNEL); + if (!bp->rss_indir_tbl) return -ENOMEM; - if (rss_ctx) - rss_ctx->rss_indir_tbl = tbl; - else - bp->rss_indir_tbl = tbl; - return 0; } -void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) +void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, + struct ethtool_rxfh_context *rss_ctx) { u16 max_rings, max_entries, pad, i; u32 *rss_indir_tbl; @@ -6260,7 +6256,7 @@ void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx) max_entries = bnxt_get_rxfh_indir_size(bp->dev); if (rss_ctx) - rss_indir_tbl = &rss_ctx->rss_indir_tbl[0]; + rss_indir_tbl = ethtool_rxfh_context_indir(rss_ctx); else rss_indir_tbl = &bp->rss_indir_tbl[0]; @@ -6326,7 +6322,7 @@ static void bnxt_fill_hw_rss_tbl_p5(struct bnxt *bp, if (vnic->flags & BNXT_VNIC_NTUPLE_FLAG) j = ethtool_rxfh_indir_default(i, bp->rx_nr_rings); else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG) - j = vnic->rss_ctx->rss_indir_tbl[i]; + j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i]; else j = bp->rss_indir_tbl[i]; rxr = &bp->rx_ring[j]; @@ -10224,7 +10220,6 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size, vnic->rss_table, vnic->rss_table_dma_addr); - kfree(rss_ctx->rss_indir_tbl); bp->num_rss_ctx--; } @@ -15689,7 +15684,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bp->flags |= BNXT_FLAG_CHIP_P7; } - rc = bnxt_alloc_rss_indir_tbl(bp, NULL); + rc = bnxt_alloc_rss_indir_tbl(bp); if (rc) goto init_err_pci_clean; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 1a33824a32a8..6bbdc718c3a7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1286,13 +1286,12 @@ struct bnxt_vnic_info { #define BNXT_VNIC_RFS_NEW_RSS_FLAG 0x10 #define BNXT_VNIC_NTUPLE_FLAG 0x20 #define BNXT_VNIC_RSSCTX_FLAG 0x40 - struct bnxt_rss_ctx *rss_ctx; + struct ethtool_rxfh_context *rss_ctx; u32 vnic_id; }; struct bnxt_rss_ctx { struct bnxt_vnic_info vnic; - u32 *rss_indir_tbl; u8 index; }; @@ -2808,8 +2807,8 @@ int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp, int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, struct bnxt_vnic_info *vnic, u32 tpa_flags); void bnxt_fill_ipv6_mask(__be32 mask[4]); -int bnxt_alloc_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx); -void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx); +void bnxt_set_dflt_rss_indir_tbl(struct bnxt *bp, + struct ethtool_rxfh_context *rss_ctx); int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index edcbb1a4f6c8..f121a5e9691f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1218,11 +1218,10 @@ static struct bnxt_rss_ctx *bnxt_get_rss_ctx_from_index(struct bnxt *bp, return ethtool_rxfh_context_priv(ctx); } -static int bnxt_alloc_rss_ctx_rss_table(struct bnxt *bp, - struct bnxt_rss_ctx *rss_ctx) +static int bnxt_alloc_vnic_rss_table(struct bnxt *bp, + struct bnxt_vnic_info *vnic) { int size = L1_CACHE_ALIGN(BNXT_MAX_RSS_TABLE_SIZE_P5); - struct bnxt_vnic_info *vnic = &rss_ctx->vnic; vnic->rss_table_size = size + HW_HASH_KEY_SIZE; vnic->rss_table = dma_alloc_coherent(&bp->pdev->dev, @@ -1801,7 +1800,6 @@ static u32 bnxt_get_rxfh_key_size(struct net_device *dev) static int bnxt_get_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh) { - u32 rss_context = rxfh->rss_context; struct bnxt_rss_ctx *rss_ctx = NULL; struct bnxt *bp = netdev_priv(dev); u32 *indir_tbl = bp->rss_indir_tbl; @@ -1815,10 +1813,13 @@ static int bnxt_get_rxfh(struct net_device *dev, vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; if (rxfh->rss_context) { - rss_ctx = bnxt_get_rss_ctx_from_index(bp, rss_context); - if (!rss_ctx) + struct ethtool_rxfh_context *ctx; + + ctx = xa_load(&bp->dev->ethtool->rss_ctx, rxfh->rss_context); + if (!ctx) return -EINVAL; - indir_tbl = rss_ctx->rss_indir_tbl; + indir_tbl = ethtool_rxfh_context_indir(ctx); + rss_ctx = ethtool_rxfh_context_priv(ctx); vnic = &rss_ctx->vnic; } @@ -1834,7 +1835,8 @@ static int bnxt_get_rxfh(struct net_device *dev, return 0; } -static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, +static void bnxt_modify_rss(struct bnxt *bp, struct ethtool_rxfh_context *ctx, + struct bnxt_rss_ctx *rss_ctx, const struct ethtool_rxfh_param *rxfh) { if (rxfh->key) { @@ -1851,7 +1853,7 @@ static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, u32 *indir_tbl = bp->rss_indir_tbl; if (rss_ctx) - indir_tbl = rss_ctx->rss_indir_tbl; + indir_tbl = ethtool_rxfh_context_indir(ctx); for (i = 0; i < tbl_size; i++) indir_tbl[i] = rxfh->indir[i]; pad = bp->rss_indir_tbl_entries - tbl_size; @@ -1906,18 +1908,14 @@ static int bnxt_create_rxfh_context(struct net_device *dev, bp->num_rss_ctx++; vnic = &rss_ctx->vnic; - vnic->rss_ctx = rss_ctx; + vnic->rss_ctx = ctx; vnic->flags |= BNXT_VNIC_RSSCTX_FLAG; vnic->vnic_id = BNXT_VNIC_ID_INVALID; - rc = bnxt_alloc_rss_ctx_rss_table(bp, rss_ctx); + rc = bnxt_alloc_vnic_rss_table(bp, vnic); if (rc) goto out; - rc = bnxt_alloc_rss_indir_tbl(bp, rss_ctx); - if (rc) - goto out; - - bnxt_set_dflt_rss_indir_tbl(bp, rss_ctx); + bnxt_set_dflt_rss_indir_tbl(bp, ctx); memcpy(vnic->rss_hash_key, bp->rss_hash_key, HW_HASH_KEY_SIZE); rc = bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings); @@ -1931,7 +1929,7 @@ static int bnxt_create_rxfh_context(struct net_device *dev, NL_SET_ERR_MSG_MOD(extack, "Unable to setup TPA"); goto out; } - bnxt_modify_rss(bp, rss_ctx, rxfh); + bnxt_modify_rss(bp, ctx, rss_ctx, rxfh); rc = __bnxt_setup_vnic_p5(bp, vnic); if (rc) { @@ -1961,7 +1959,7 @@ static int bnxt_modify_rxfh_context(struct net_device *dev, rss_ctx = ethtool_rxfh_context_priv(ctx); - bnxt_modify_rss(bp, rss_ctx, rxfh); + bnxt_modify_rss(bp, ctx, rss_ctx, rxfh); return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic); } @@ -1990,7 +1988,7 @@ static int bnxt_set_rxfh(struct net_device *dev, if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; - bnxt_modify_rss(bp, NULL, rxfh); + bnxt_modify_rss(bp, NULL, NULL, rxfh); bnxt_clear_usr_fltrs(bp, false); if (netif_running(bp->dev)) {