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=1796481983; b=rVMUrUq5GiLobcUOimyZ45G0Y2gmtvWiuvPCVw27GXikqiAUIqKiITAVvF5XW8mPKGW2 +29nTod929KXCQgdn+atZXLX0w6piOjwBkbsAq/YiHZUqkZIHTyhqyzmfP2YY1aMWCtBl drYfImrXMtT+o1GqVITckR0PbdDPrlU+DCbZNlyAwa+9S9/VnevKMLGC022IEipOk+0zU iBxaZuVcSx/Cil3G84SzsmQl4N9tJyHjbXwGzGbz37QwGykjFs4mnxKwUS9mUdLN7WBZH F87zgtruAibh76e6Uk/KvBdgvGtvVKYWBoIgv9VbXZYs8Ubn61/wKfDUvyKvHY+9EGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796481983; 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=6NuKmy9GPGqYX+mrEon2icEfI7hk4+4rAMC39UVMF5M=; b=w/6NdmenQwuaslK7ToPJ4n5LRpWa6xKBwV6sKdIZ74u1ogCcmSsuwaYeVtAZS75/k4tV uTr6pep9EyjTJk+dyrUwPhQ1ChPzEXhuFupw66kHUKXny3C7tvxOZysVv7cszc+s1bdAO JRzSn/gt2pQf0vJv4F4dEYOyR+9HOwwM5ubmznHk4cMpjT6i+hPfVQFSgoB4tLx/S9YxG elUAMU9xtM1xXTNlADVNh/WRK0fXAgvTdPq3X4jsyKttqsX42Z8o0MhbcwbqBY/moIUbT NiHCMuTBllKkK9WMPRty2PmhAcY9HWrNRJSNsKEALaT3fmh2Rvzi7Tbb78sJt0lvssg== 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=Q6cRTxlk; 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 8A8F4606A6BB; Sat, 5 Dec 2026 14:46:23 +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=Q6cRTxlk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 428891F00A1B; Sat, 5 Dec 2026 14:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796481983; bh=6NuKmy9GPGqYX+mrEon2icEfI7hk4+4rAMC39UVMF5M=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Q6cRTxlkJa1yGk/LV3X7jdUqBzM2dOo8mjTi6pik/STRUv8E5OaAn0hHgkj7vgVyG 9HdprwkWAYufNk8JMKcFUTrlaQ35NPmGOA6unJ4yklUtemjNXCgwNyP5r3YfSQeYBh 1xUvP5qIUTeo0kXmLQHNI1eDcBb53F6BH/cjh5i4Ra6OkUhhKkHMKMCmjggXtZz/ne PXypbJsxjjaU9cTOYyQHFzTxaQhwuJYWNMm9/m5pIzwUA65RHIlE4l4RXhPAe95U5j 3hHXfS/QA9vW8E32q2qzZsspEoDMWEckenY4yDawmw+w88XaCzbBq47DWq88yZ3pmw NKoqsqg7QSpWA== Subject: Re: [PATCH net-next v12 09/10] bnge: add aRFS flow steering ndo support 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: Sat, 05 Dec 2026 14:46:21 +0000 Message-ID: <179648198178.3146.7542356016116033536@kernel.org> In-Reply-To: <20261201132011.2705569-10-vikas.gupta@broadcom.com> References: <20261201132011.2705569-10-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 4 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 2 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] Installed aRFS rules are not revalidated when the L2 filter they were programmed against is recreated or deleted while the… - [Medium] In the expire loop of bnge_cfg_ntp_filters(), the return value of bnge_hwrm_cfa_ntuple_filter_free() is ignored and… - [Low] bnge_cfg_one_usr_fltr() now writes ntp_fltr->l2_key and l2_filter_id under ntp_fltr_lock. - [Low] The comment on bnge_net::ntp_fltr_lock still says it "Protects the aRFS/ntuple hash table add and delete". -- bnge: add aRFS flow steering ndo support This adds bnge_rx_flow_steer() as the ndo_rx_flow_steer callback. It creates aRFS ntuple filters, and bnge_cfg_ntp_filters(), run from sp_task, programs, retargets and expires them. The ntuple rule matching now compares the L2 filter key instead of the firmware L2 filter id. > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c > index 639c36d571f24..b7261018216bc 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c [ ... ] > @@ -643,7 +658,11 @@ static void bnge_cfg_one_usr_fltr(struct bnge_net *bn, > 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]; > + /* bnge_rx_flow_steer() can already run and match this rule */ > + spin_lock_bh(&bn->ntp_fltr_lock); > ntp_fltr->l2_filter_id = l2_fltr->base.filter_id; > + ntp_fltr->l2_key = l2_fltr->l2_key; > + spin_unlock_bh(&bn->ntp_fltr_lock); [Severity: Low] Does ntp_fltr_lock order this write against bnge_rx_flow_steer()? The first match in bnge_rx_flow_steer() runs under rcu_read_lock() only: bnge_rx_flow_steer() rcu_read_lock() bnge_lookup_ntp_filter_from_idx() bnge_fltr_match() ether_addr_equal(f1->l2_key.dst_mac_addr, f2->l2_key.dst_mac_addr) && f1->l2_key.vlan == f2->l2_key.vlan; Those are plain loads done without ntp_fltr_lock. The lock therefore only orders this write against the second match in bnge_insert_ntp_filter(). bnge_open_core() sets BNGE_STATE_OPEN and enables NAPI and interrupts before it calls bnge_cfg_usr_fltrs(). RX and aRFS can run while this struct copy updates a rule that is already in ntp_fltr_hash_tbl. If a torn read causes a false miss, bnge_insert_ntp_filter() catches it with -EEXIST. A false match returns the user rule's sw_id, and no aRFS rule gets installed for that flow. The impact looks small. Should the comment be corrected and the lockless accesses annotated? [ ... ] > @@ -716,3 +735,105 @@ void bnge_clear_usr_fltrs(struct bnge_net *bn) > } > } > } > + > +void bnge_cfg_ntp_filters(struct bnge_net *bn) > +{ [ ... ] > + list_for_each_entry_safe(fltr, tmp, &install_list, base.list_node) { > + list_del_init(&fltr->base.list_node); > + /* The firmware id of the L2 filter changes whenever the filter > + * is recreated, so look it up again from the key before > + * programming the rule. > + */ > + l2_id = bnge_lookup_l2_filter_from_key(bn, &fltr->l2_key); [Severity: Medium] The L2 id is looked up again only here, for rules on install_list. What happens to rules that are already BNGE_FLTR_VALID when their L2 filter is recreated or deleted while the interface is up? In the non-dev_addr branch of bnge_rx_flow_steer(), bnge_lookup_l2_filter_from_key() can return a secondary unicast filter (vnic->l2_filters[1..]) or a vlan 0 user ETHER_FLOW L2 filter. On a unicast list change, bnge_set_rx_mode()->bnge_cfg_rx_mode() frees all of them in firmware and recreates them with new ids: bnge_cfg_rx_mode() { ... for (i = 1; i < vnic->uc_filter_count; i++) { struct bnge_l2_filter *fltr = vnic->l2_filters[i]; if (!fltr) continue; bnge_hwrm_l2_filter_free(bd, fltr); bnge_del_l2_filter_rcu(bn, fltr); } ... } bnge_srxclsrldel() does the same to a user L2 filter, through bnge_hwrm_l2_filter_free() and bnge_del_usr_l2_filter(). Neither path touches the ntuple rules that depend on those filters. A BNGE_FLTR_VALID aRFS rule keeps a firmware entry built on the freed L2 context until the flow expires or moves to another queue. Depending on the firmware, that entry either keeps steering with a stale context, or it is removed silently. In the second case, later bnge_hwrm_cfa_ntuple_filter_free() calls fail, and the driver state no longer matches the hardware. The new comment on struct bnge_ntuple_filter also says l2_filter_id "is reassigned by firmware on every open". The commit message says the id also changes "after a unicast address list change". Should installed rules be revalidated when this happens, or should the comment at least describe the limitation? For reference, bnxt_cfg_rx_mode() also frees the firmware L2 filter while ntuple rules hold a refcount on it. That refcount only keeps the software struct alive, so the real effect depends on how the firmware treats ntuple entries whose L2 context is freed. [ ... ] > + hlist_del_init_rcu(&fltr->base.hlist); > + spin_unlock_bh(&bn->ntp_fltr_lock); > + > + bnge_hwrm_cfa_ntuple_filter_free(bn->bd, fltr); > + bnge_del_ntp_filter_rcu(bn, fltr); [Severity: Medium] Can this leak the firmware ntuple entry? bnge_hwrm_cfa_ntuple_filter_free() can fail in bnge_hwrm_req_init() or bnge_hwrm_req_send(). On failure it leaves filter_id valid: rc = bnge_hwrm_req_send(bd, req); if (!rc) fltr->base.filter_id = BNGE_FLTR_ID_INVALID; return rc; bnge_del_ntp_filter_rcu() then frees the only copy of base.filter_id and releases the sw_id. Nothing retries the free. The firmware entry keeps steering that 5-tuple to the old ring until the VNIC is torn down at close. A later aRFS rule for the same flow is either programmed next to it or refused as a duplicate. If it is refused, every later attempt repeats alloc -> sp_task -> firmware alloc failure -> delete. The update loop above checks the return value of the same call. Should the expire path handle a failed free as well? > + } > +#endif > +} [ ... ] > diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c > index 44637152b075c..de7320521a3e0 100644 > --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c > +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c [ ... ] > @@ -3433,6 +3442,146 @@ static int bnge_set_features(struct net_device *dev, netdev_features_t features) > return 0; > } > > +#ifdef CONFIG_RFS_ACCEL > +/* Called with ntp_fltr_lock held. Returns true if sp_task must be queued. */ > +static bool bnge_ntp_fltr_retarget(struct bnge_net *bn, > + struct bnge_ntuple_filter *fltr, > + u16 rxq_index, u32 flow_id) > +{ > + if ((fltr->base.flags & BNGE_ACT_NO_AGING) || > + READ_ONCE(fltr->base.rxq) == rxq_index) > + return false; > + > + WRITE_ONCE(fltr->base.rxq, rxq_index); > + WRITE_ONCE(fltr->flow_id, flow_id); [Severity: Low] This isn't a bug, but the comment on bnge_net::ntp_fltr_lock in bnge_netdev.h still says: /* Protects the aRFS/ntuple hash table add and delete. ... This patch also uses the lock for per-filter state: - rxq and flow_id here - the expire re-check and unlink in bnge_cfg_ntp_filters() - the hlist_unhashed() check in bnge_rx_flow_steer() - the l2_key and l2_filter_id writes in bnge_cfg_one_usr_fltr() Could the struct comment be updated, so a later change does not write rxq or flow_id without holding the lock? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201132011.2705569-1-vikas.gupta%40broadcom.com