Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Tue, 01 Dec 2026 06:39
Re: [PATCH net-next v11 08/10] bnge: add NTUPLE filter support in ethtool
Author: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 06:39
Date: Tue, 01 Dec 2026 06:39
244 lines
17236 bytes
17236 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads