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=1796107185; b=uHFKqBC9qHiOOdIwrfPlrim1qnmjB1vexRYVS+5KtlPjOhTafPO+ty0PNgbtvSHdSBte Avbk4LyuGXzDKihTxuTWIu3dRvDSaEGsogdRiYGFi/g4qyN0fwqL63PrUxG3U8EatLSEn Td4DnDaNielCgY/81MJWcB1DulZYY+7b8G+ctlz3QFZJwDD9x4GGILQ+rdF+hEnarUU/G 1X/UFbCDlnmFqyDtwudRorPEo+mRIVxjk7IElHL++JQOMcaRX2yX0JDhNCy6cC8H03nKa XaebD1+vxUyeqqUJAY9LNTrXyL0N44p2IYNn1FxTDK3lxa2wcgytm5GsQVFwKQYz2FA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107185; 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=4XpmUKvCbielDbnyP5RPqsjjtjhHn3djelFC/TW9jjE=; b=Oq9Kh0Be6NYqUs9p1B4uB8589Gc5OY8kmx5o06Up0pL1bFNaiwEcheGHdhcATr1bwBdZ DHKaCR2EIJSBwkT5DQf5fmolq+ryrbdXbnBNe9uMhZnD+QMOySF5FNwy0avzYxGi/7pnb 0GIivOteZoUUl1LiK5NT5dLKrTV1rb/pi6NqZMiayXn1yZzJNiCMqh48yMjeaJpDfmb4N Zs+cADRWJPIzA2G1gpPMJdIFD1xUbwBUZmEhbt/19W0mJCDwPki3GFyd7KCdxLtcZaVVP T7l2rgwAGmOhqMbnw9aDi0FpegqgnlIVuiIxwQMEwJtLCCYBZOQZbsCqE5utw/+LX0A== 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=k+vP8Q29; 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 88232606A682; Tue, 1 Dec 2026 06:39:45 +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=k+vP8Q29 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61BCE1F00899; Tue, 1 Dec 2026 06:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796107185; bh=4XpmUKvCbielDbnyP5RPqsjjtjhHn3djelFC/TW9jjE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=k+vP8Q29cvzyUKBKhglowQKQ7qZsN12fH0Qh58AwXRztQ0O8wCiEpW/rApGdLiKho oXxhj8j2BP95byGcgGiQ075xxEp8f6QNjnQKGWjmDELkatewVBOEMywVS/wcsXPi4N //O3wFMUO2bU6D4V2IKPxtUTKY5be9EMlVm8cmIpQ+WwTXDiRzTtF43y9QW/aUZPsU H14iBTWfJLjYOo6z0M1SWZMVxG8yKqox1o4KsNvaKavyosxqanc86xth2KeVcVW8m7 Q964dBFQzJM0G1oVEwq3DN4xuIM1+GzoZiqhBF4HS2NYk3XlNa77jJ31v2x8atm1vZ AqSsDzIiW3pjg== Subject: Re: [PATCH net-next v11 08/10] bnge: add NTUPLE filter support in ethtool 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:43 +0000 Message-ID: <179610718394.3146.6986934605932201051@kernel.org> In-Reply-To: <20261130055736.2306367-9-vikas.gupta@broadcom.com> References: <20261130055736.2306367-9-vikas.gupta@broadcom.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@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 more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] A user rule that cannot be restored on open is deleted for good, and the commit message does not say so. - [Low] After this patch, the comment and the L2 branch of the loop in bnge_close_core() (drivers/net/ethernet/broadcom/bnge/bnge_netdev.c)… - [Low] bnge_srxclsrldel() (drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c) ignores the return… -- bnge: add NTUPLE filter support in ethtool This adds ethtool rxnfc get/set operations to the bnge driver for managing ntuple and ETHER_FLOW filters. User filters are kept in software across close/open, and bnge_cfg_usr_fltrs() programs them again on open. NETIF_F_NTUPLE is enabled by default, and the unicast L2 filter limit is raised to BNGE_MAX_L2_FLTRS. > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c > index 99a69f16a0a62..77edcd564b619 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c [ ... ] > @@ -1242,6 +1256,611 @@ static int bnge_remove_rxfh_context(struct net_device *dev, [ ... ] > +static int bnge_srxclsrldel(struct bnge_net *bn, struct ethtool_rxnfc *cmd) > +{ > + struct ethtool_rx_flow_spec *fs = &cmd->fs; > + struct bnge_filter_base *fltr_base; > + struct bnge_ntuple_filter *fltr; > + u32 id = fs->location; > + > + rcu_read_lock(); > + fltr_base = bnge_get_one_fltr_rcu(bn, bn->l2_fltr_hash_tbl, > + BNGE_L2_FLTR_HASH_SIZE, id, 0); > + if (fltr_base) { > + struct bnge_l2_filter *l2_fltr; > + > + l2_fltr = container_of(fltr_base, struct bnge_l2_filter, base); > + rcu_read_unlock(); > + /* The firmware filter is gone once the interface is closed. */ > + if (test_bit(BNGE_FLTR_VALID, &l2_fltr->base.state)) > + bnge_hwrm_l2_filter_free(bn->bd, l2_fltr); > + bnge_del_usr_l2_filter(bn, l2_fltr); > + return 0; > + } [ ... ] > + rcu_read_unlock(); > + bnge_hwrm_cfa_ntuple_filter_free(bn->bd, fltr); > + bnge_del_ntp_filter_rcu(bn, fltr); > + return 0; > +} [Severity: Low] What happens here if the firmware free fails? bnge_hwrm_l2_filter_free() returns the HWRM send result. bnge_hwrm_cfa_ntuple_filter_free() resets filter_id only on success. bnge_srxclsrldel() ignores both return values, always deletes the software entry and returns 0. Suppose HWRM rejects or times out the free, for example with -EAGAIN while the firmware is busy. Wouldn't the CFA filter stay programmed in the NIC while the driver loses its filter_id through kfree_rcu()? Until the next close, the NIC would still steer or drop matching traffic for a rule that ethtool -n no longer lists and that the user cannot delete. The sw_id is also released, so a new rule can reuse the same location. In the L2 case, bnge_del_usr_l2_filter() then calls bnge_hwrm_set_vnic_filter(). That programs the same MAC towards the default VNIC while the stale NTUPLE VNIC filter for that MAC may still exist in firmware. The l2_free count in bnge_cfg_rx_mode() is based on l2_fltr_bmap, so it would also undercount what the firmware holds. Would it make sense to return the error and keep the software entry when the firmware free fails? > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c > index 3ebb3cae4829b..639c36d571f24 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c > @@ -584,3 +584,135 @@ int bnge_hwrm_set_vnic_filter(struct bnge_net *bn, u16 vnic_id, u16 idx, [ ... ] > +static bool bnge_usr_fltr_ring_lost(struct bnge_net *bn, > + struct bnge_filter_base *fltr) > +{ > + if (fltr->flags & (BNGE_ACT_DROP | BNGE_ACT_RSS_CTX) || > + fltr->rxq < bn->bd->rx_nr_rings) > + return false; > + > + netdev_warn(bn->netdev, "filter id %d: rx ring %u no longer exists\n", > + fltr->type == BNGE_FLTR_TYPE_NTUPLE ? > + BNGE_MAX_L2_FLTRS + fltr->sw_id : fltr->sw_id, fltr->rxq); > + return true; > +} > + > +static void bnge_cfg_one_usr_fltr(struct bnge_net *bn, > + struct bnge_filter_base *fltr) > +{ > + struct bnge_ntuple_filter *ntp_fltr; > + struct bnge_l2_filter *l2_fltr; > + > + if (list_empty(&fltr->list_node)) > + return; > + > + if (fltr->type == BNGE_FLTR_TYPE_NTUPLE) { > + ntp_fltr = container_of(fltr, struct bnge_ntuple_filter, base); > + l2_fltr = bn->vnic_info[BNGE_VNIC_DEFAULT].l2_filters[0]; > + ntp_fltr->l2_filter_id = l2_fltr->base.filter_id; > + if (bnge_usr_fltr_ring_lost(bn, fltr) || > + bnge_hwrm_cfa_ntuple_filter_alloc(bn->bd, ntp_fltr)) { > + netdev_err(bn->netdev, > + "restoring previously configured ntuple filter id %d failed\n", > + BNGE_MAX_L2_FLTRS + fltr->sw_id); > + bnge_del_ntp_filter_rcu(bn, ntp_fltr); > + } > + } else if (fltr->type == BNGE_FLTR_TYPE_L2) { > + l2_fltr = container_of(fltr, struct bnge_l2_filter, base); > + fltr->fw_vnic_id = bn->vnic_info[BNGE_VNIC_NTUPLE].fw_vnic_id; > + if (bnge_usr_fltr_ring_lost(bn, fltr) || > + bnge_hwrm_l2_filter_alloc(bn->bd, l2_fltr)) { > + netdev_err(bn->netdev, > + "restoring previously configured l2 filter id %d failed\n", > + fltr->sw_id); > + bnge_del_usr_l2_filter(bn, l2_fltr); > + } > + } > +} [Severity: Low] This isn't a bug, but the commit message says: User filters stay in software while the interface is down. bnge_cfg_usr_fltrs() programs them in firmware again on open, ... bnge_cfg_one_usr_fltr() deletes a rule permanently in two cases: - bnge_usr_fltr_ring_lost() finds fltr->rxq >= rx_nr_rings for a rule that is neither a drop rule nor an RSS context rule. - bnge_hwrm_cfa_ntuple_filter_alloc() or bnge_hwrm_l2_filter_alloc() fails. The rule is then removed with bnge_del_ntp_filter_rcu() or bnge_del_usr_l2_filter(). After a down/up cycle it no longer shows up in ethtool -n, and the only trace is a netdev_warn() or netdev_err() in dmesg. bnxt_cfg_one_usr_fltr() behaves the same way, so this is only about the commit message. Could it say that the restore is best effort, and that rules which cannot be restored are dropped, including those caught by the new ring-lost check? > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c > index 58039e6d610ed..44637152b075c 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c [ ... ] > @@ -2344,8 +2364,29 @@ static void bnge_hwrm_clear_vnic_filter(struct bnge_net *bn) > vnic->uc_filter_count = 0; > } > > +/* User ETHER_FLOW rules are L2 filters whose destination is the NTUPLE VNIC. > + * Free them in firmware before that VNIC goes away, as is done for the > + * default VNIC filters. The rules stay in usr_fltr_list and are programmed > + * again by bnge_cfg_usr_fltrs() on the next open. > + */ > +static void bnge_hwrm_clear_usr_l2_fltrs(struct bnge_net *bn) > +{ > + struct bnge_filter_base *fltr; > + > + list_for_each_entry(fltr, &bn->usr_fltr_list, list_node) { > + if (fltr->type != BNGE_FLTR_TYPE_L2 || > + !test_and_clear_bit(BNGE_FLTR_VALID, &fltr->state)) > + continue; > + bnge_hwrm_l2_filter_free(bn->bd, > + container_of(fltr, > + struct bnge_l2_filter, > + base)); > + } > +} > + > static void bnge_clear_vnic(struct bnge_net *bn) > { > + bnge_hwrm_clear_usr_l2_fltrs(bn); > bnge_hwrm_clear_vnic_filter(bn); > bnge_hwrm_vnic_free(bn); > bnge_hwrm_vnic_ctx_free(bn); [Severity: Low] With this change, does the L2 branch of the loop in bnge_close_core() still do anything, and is its comment still accurate? bnge_close_core() { ... bnge_shutdown_nic(bn); bnge_nq0_napi_to_wq(bn); /* Invalidate user L2 filters now that NAPI is disabled so that * subsequent re-enabling during open cannot read a stale or torn * filter_id before bnge_cfg_usr_fltrs() completes reallocation. */ /* Only the driver's tracking is reset here. The user filters are * programmed again by bnge_cfg_usr_fltrs() on the next open. */ list_for_each_entry(fltr, &bn->usr_fltr_list, list_node) { if (fltr->type == BNGE_FLTR_TYPE_L2) clear_bit(BNGE_FLTR_VALID, &fltr->state); ... } The new bnge_hwrm_clear_usr_l2_fltrs() already calls test_and_clear_bit(BNGE_FLTR_VALID) and frees the firmware filter for every user L2 filter. It does this earlier in the same close sequence: bnge_close_core()->bnge_shutdown_nic()->bnge_hwrm_resource_free()-> bnge_clear_vnic()->bnge_hwrm_clear_usr_l2_fltrs() That runs before bnge_nq0_napi_to_wq(). So the later clear_bit() for L2 entries is always a no-op, and the comment points to the wrong place for the invalidation. Could the comment and the L2 branch be updated to match? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130055736.2306367-1-vikas.gupta%40broadcom.com