From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796107179; b=dIvqgqdjEnUBJF6ZlYW+mHFpLrGMDAauAdTTUJ+NaE/D4q7Taq45XcLOdEWrF8ICoZ/w ipSn5eJ0hplpK9dOXNdeprpm5kiBk0KQiTby7UyE0IyH2H3KzkbuACb7DVHtKBqLpRbNB vPZ+eYcjUyIlpNpkKZSjC61wIP8wmmpfROWS38Fm5YsOkkh1LhYNF4Gkxg1VDnhBwQb1h eabZHt/XZ2dQ1DU7++aix1vZ9i/9IX9j0Ur0IcGXjA8IbIOgHGlS4X7oLYEflTMTw+YJz L6rS5MrYSJ9X7mE2kDLq/nU0rdjLLSy53kCbyVzy8HIKpGgf+lqHT8NaNdc47zXcq6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107179; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=dBj9LUYey0lizNOVuQhbxNcCQ/QMdJ8WgAgj5UNxBRc=; b=HM+WjVGSYn8MENx96qqE3iaT3ZHg/5o3xKTejjWEwwriBYmoBjTO9O2UYNRH8GYYfo/h LFUP8BgiHuJBhGLs29i7uM3OlEkgj5q2VB8InQGjEbromhUzrVQKck7l6Pi2yoXdM3RYH BKJblqw3zQNyIslT30zKfQmpbMFBsKw55Ihv8EQOgXZZE09jikhJG7pivSR+iuA0YQrxa mRUGRsGVwXWXYW9kYhGu3hiO5A7UBTASCbqpVhi0G9RniJr5MUJ4g02yjWb61ousllZrl T55VaAC4+AAPVF4Ug5W933FY8FHxvWeUIQo7/3P0NAEJgk5ywV9bawnnJiV6cIbrjig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="oi/3Ig/P"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905E1606A33C; Tue, 1 Dec 2026 06:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oi/3Ig/P Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5207A1F00893; Tue, 1 Dec 2026 06:39:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796107179; bh=dBj9LUYey0lizNOVuQhbxNcCQ/QMdJ8WgAgj5UNxBRc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=oi/3Ig/PoIFh0X+8ZJ3p3sD0AGC1mUSVdwiqvd94KXMw2DYkLCIATefBsEpiHxpv4 BOMXyN4RYsaFGRSst2XW89usvs5ohKhkFunJhl7olIbK+iFSjPYrNxY2J5KrUoJjAn /DvZbPKIKkoL0PxOQBqIvifhSAJyZ0g4+tZIQB63ekJiUOF97V6brnVz6qpFhoimyS AOhpn9vQBCxjh/PfCecU67vEle2vBWVOJmhKtdx1+anQyth/Jv57Qr3jDFpoXQKxMQ OqQw5zSl+HPAQmw8d1pTDhU178ebsQv7orikH+EosEIKvv73Ht7MU/zzifOivDJIs2 5gy/mK7aZyxFQ== Subject: Re: [PATCH net-next v11 03/10] bnge: add helper functions for multi RSS contexts From: netdev-bot+sashiko@kernel.org To: vikas.gupta@broadcom.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bhargava.marreddy@broadcom.com, rahul-rg.gupta@broadcom.com, vsrama-krishna.nemani@broadcom.com, rajashekar.hudumula@broadcom.com, dharmender.garg@broadcom.com, ajit.khaparde@broadcom.com Date: Tue, 01 Dec 2026 06:39:37 +0000 Message-ID: <179610717784.3146.16757179548099097860@kernel.org> In-Reply-To: <20261130055736.2306367-4-vikas.gupta@broadcom.com> References: <20261130055736.2306367-4-vikas.gupta@broadcom.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · Low: 3 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] At this commit, bnge_modify_rss() stores a user RSS context's indirection table in ethtool_rxfh_context_indir(ctx). - [Medium] At this commit, bnge_modify_rss() zero-pads a user context's indirection table out to bd->rss_indir_tbl_entries (512) with… - [Medium] This patch adds bn->num_rss_ctx but nothing reads it, and only bnge_del_one_rss_ctx() decrements it. - [Medium] struct bnge_rss_ctx sits in the ethtool core's kzalloc'ed private area, so the embedded bnge_vnic_info starts with vnic_id == 0… - [Low] At this commit, bnge_hwrm_realloc_rss_ctx_vnic() walks netdev->ethtool->rss_ctx and calls ethtool_rxfh_context_lost()… - [Low] bnge_hwrm_realloc_rss_ctx_vnic() prints the u32 field rss_ctx->index with a signed %d: netdev_err(bn->netdev, "Failed to… - [Low] With all=true, bnge_del_one_rss_ctx() calls dma_free_coherent() on vnic->rss_table but does not set vnic->rss_table or… -- bnge: add helper functions for multi RSS contexts This commit moves the per-VNIC RSS table allocation into a new helper, bnge_alloc_vnic_rss_table(). It also adds helpers to modify, restore, clear and delete user-defined RSS contexts, and each context gets its own VNIC. Finally, it adds struct bnge_rss_ctx and a num_rss_ctx counter to struct bnge_net. [ ... ] > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h > index 13871d3d8286d..e0462a0f4f2c9 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h > @@ -376,6 +376,8 @@ struct bnge_net { > > u8 pri2cos_idx[8]; > bool pri2cos_valid; > + > + u16 num_rss_ctx; > }; [Severity: Medium] In this patch nothing reads or increments num_rss_ctx. The only access is the decrement in bnge_del_one_rss_ctx(). Also, bnge_get_total_vnics() still returns a constant: drivers/net/ethernet/broadcom/bnge/bnge_resc.c:bnge_get_total_vnics() { return BNGE_BASE_VNICS; } Would the firmware VNIC and RSS context reservation then miss the VNICs that bnge_hwrm_realloc_rss_ctx_vnic() allocates for user contexts? The helpers have no callers yet. The follow-up commit "bnge: add ethtool support to manage RSS contexts" adds bn->num_rss_ctx to bnge_get_total_vnics(), increments the counter in bnge_create_rxfh_context() and checks bnge_rss_ctx_capable(). Could the counter be added in the same patch as its users? > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c > index d98a6196c859c..a44971a7c74d3 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c > @@ -129,3 +129,116 @@ int bnge_alloc_rfs_vnic(struct bnge_net *bn) > vnic = &bn->vnic_info[BNGE_VNIC_NTUPLE]; > return bnge_alloc_and_setup_vnic(bn, vnic, bn->bd->rx_nr_rings); > } > + > +void bnge_modify_rss(struct bnge_net *bn, struct ethtool_rxfh_context *ctx, > + struct bnge_rss_ctx *rss_ctx, > + const struct ethtool_rxfh_param *rxfh) > +{ > + struct bnge_dev *bd = bn->bd; > + [ ... ] > + if (rxfh->indir) { > + u32 i, pad, tbl_size = bnge_get_rxfh_indir_size(bd); > + u32 *indir_tbl = bd->rss_indir_tbl; > + > + if (rss_ctx) > + indir_tbl = ethtool_rxfh_context_indir(ctx); [Severity: Medium] For a user context, the indirection table goes into ethtool_rxfh_context_indir(ctx). Is that table ever read when the hardware is programmed? The context VNIC is set up through this chain: bnge_hwrm_realloc_rss_ctx_vnic() bnge_setup_vnic() bnge_hwrm_vnic_rss_cfg() bnge_hwrm_vnic_set_rss() bnge_fill_hw_rss_tbl() bnge_fill_hw_rss_tbl() only handles the ntuple VNIC and the default table: if (vnic->flags & BNGE_VNIC_NTUPLE_FLAG) j = ethtool_rxfh_indir_default(i, bd->rx_nr_rings); else j = bd->rss_indir_tbl[i]; struct bnge_vnic_info has no back-pointer to the ethtool context, and there is no RSS context VNIC flag. Would a context VNIC then be programmed with the default context's queue spread? These helpers have no callers at this commit. Later in the series, "bnge: add ethtool support to manage RSS contexts" adds BNGE_VNIC_RSSCTX_FLAG and vnic->rss_ctx, and makes bnge_fill_hw_rss_tbl() read the per-context table. > + for (i = 0; i < tbl_size; i++) > + indir_tbl[i] = rxfh->indir[i]; > + pad = bd->rss_indir_tbl_entries - tbl_size; > + if (pad) > + memset(&indir_tbl[i], 0, pad * sizeof(*indir_tbl)); [Severity: Medium] When rss_ctx is set, indir_tbl points into the context, and the ethtool core sizes that area in ethtool_rxfh_ctx_alloc() as: indir_max = max(indir_size, ops->rxfh_indir_space) bnge does not set rxfh_indir_space at this commit. If a context were created with a 64-entry table, could this memset() pad out to bd->rss_indir_tbl_entries and write past the end of that area? Nothing calls this with a non-NULL ctx yet. Later in the series, "bnge: add RXFH ethtool support" sets .rxfh_indir_space to BNGE_MAX_RSS_TABLE_ENTRIES. Then "bnge: add ethtool support to manage RSS contexts" changes the condition to if (pad && !rss_ctx), so context tables are never padded. > + } > +} > + > +void bnge_del_one_rss_ctx(struct bnge_net *bn, struct bnge_rss_ctx *rss_ctx, > + bool all) > +{ > + struct bnge_vnic_info *vnic = &rss_ctx->vnic; > + int i; > + > + bnge_hwrm_vnic_free_one(bn->bd, &rss_ctx->vnic); > + for (i = 0; i < BNGE_MAX_CTX_PER_VNIC; i++) { > + if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID) > + bnge_hwrm_vnic_ctx_free_one(bn->bd, vnic, i); > + } [Severity: Medium] struct bnge_rss_ctx lives in the ethtool core's kzalloc'ed private area. So the embedded vnic starts with vnic_id, fw_vnic_id and fw_rss_cos_lb_ctx[] all set to 0, and none of the helpers here initialize them. bnge_hwrm_vnic_free_one() only skips the free when fw_vnic_id is INVALID_HW_RING_ID. For a context that never got a firmware VNIC, would this send HWRM_VNIC_FREE for VNIC ID 0? The fw_rss_cos_lb_ctx[] loop above has the same problem. The same issue shows up in bnge_hwrm_vnic_alloc(): if (vnic->vnic_id == BNGE_VNIC_DEFAULT) req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT); If bnge_hwrm_realloc_rss_ctx_vnic() passes a context VNIC that still has vnic_id 0, is it requested as a default VNIC? There are no callers at this commit. Later, "bnge: add ethtool support to manage RSS contexts" adds bnge_init_vnic_mem(), and bnge_create_rxfh_context() calls it and sets a non-default vnic_id before any firmware call. > + > + if (!all) > + return; > + > + if (vnic->rss_table) > + dma_free_coherent(bn->bd->dev, vnic->rss_table_size, > + vnic->rss_table, > + vnic->rss_table_dma_addr); > + bn->num_rss_ctx--; [Severity: Low] This isn't a bug, but vnic->rss_table and vnic->rss_hash_key still point at the freed DMA buffer after dma_free_coherent(). A second all=true call on the same context would free it twice. As far as I can tell, no path does that. Every all=true caller in the series is followed by the ethtool core or ethtool_rxfh_context_lost() erasing and freeing the context. bnxt_del_one_rss_ctx() works the same way. Would it still be worth setting the pointers to NULL here? > +} > + > +void bnge_hwrm_realloc_rss_ctx_vnic(struct bnge_net *bn) > +{ > + u32 tpa_flags = bn->priv_flags & BNGE_NET_EN_TPA; > + struct ethtool_rxfh_context *ctx; > + unsigned long context; > + > + xa_for_each(&bn->netdev->ethtool->rss_ctx, context, ctx) { > + struct bnge_rss_ctx *rss_ctx = ethtool_rxfh_context_priv(ctx); > + struct bnge_vnic_info *vnic = &rss_ctx->vnic; > + > + if (bnge_hwrm_vnic_alloc(bn->bd, vnic, bn->bd->rx_nr_rings) || > + bnge_hwrm_vnic_set_tpa(bn->bd, vnic, tpa_flags) || > + bnge_setup_vnic(bn, vnic)) { > + netdev_err(bn->netdev, "Failed to restore RSS ctx %d\n", > + rss_ctx->index); [Severity: Low] This isn't a bug, but rss_ctx->index is a u32 and is printed with %d. The vnic_id prints in bnge_vnic.c use %u, and bnge_modify_rxfh_context() later in the series prints this same field with %u. Should this be %u too? > + bnge_del_one_rss_ctx(bn, rss_ctx, true); > + ethtool_rxfh_context_lost(bn->netdev, rss_ctx->index); [Severity: Low] This loop walks netdev->ethtool->rss_ctx and calls ethtool_rxfh_context_lost(), which does xa_erase() and kfree(), without holding netdev->ethtool->rss_lock. bnge uses request_ops_lock, so rtnl is not guaranteed to be held either. ethtool_rxfh_context_lost() checks: WARN_ONCE(!rtnl_is_locked() && !lockdep_is_held_type(&dev->ethtool->rss_lock, -1), "RSS context lock assertion failed\n"); Would a caller of this function hit that warning? Nothing calls this yet, and "bnge: add ethtool support to manage RSS contexts" wraps the loop in rss_lock. bnge_clear_rss_ctxs() is still unlocked at the end of the series. However, it only runs from bnge_close_core() under the netdev instance lock, that lock also serializes context create and delete in net/ethtool/rss.c, and the function does not change the xarray. > + } > + } > +} [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130055736.2306367-1-vikas.gupta%40broadcom.com