git: b1020d33404d - main - bnxt: don't fail init when out of VLAN L2 filters
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Nov 2026 15:49:52 UTC
The branch main has been updated by bnovkov:
URL: https://cgit.FreeBSD.org/src/commit/?id=b1020d33404dc7a6f44bb84339fcdb9eafa683da
commit b1020d33404dc7a6f44bb84339fcdb9eafa683da
Author: Greg Becker <becker.greg@att.net>
AuthorDate: 2026-11-25 15:39:46 +0000
Commit: Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2026-11-25 15:48:32 +0000
bnxt: don't fail init when out of VLAN L2 filters
bnxt_hwrm_set_filter() allocates an L2 filter for every configured
VLAN and fails the init if any allocation fails. A port has a fixed
number of L2 filters (509 on a BCM57416), so with enough VLANs every
init fails with RESOURCE_ALLOC_ERROR and the port stays down until
VLANs are removed.
The port's MAC filter does not match on VLAN, so the per-VLAN filters
are not needed to receive tagged traffic ( VLANs added while the port
is running already work without one until the next init). Treat
ENOMEM from the VLAN filter allocations as non-fatal (leave the
remaining tags without a filter and log their count, once per init).
Any other error still fails the init.
Append new tags in bnxt_vlan_register() instead of prepending them, so
the oldest VLANs keep their filters and the most recently added ones
beyond the ports capabilities do not get a filter.
Fixes: 91fcacc35597 ("if_bnxt: Add support for VLAN on Thor")
MFC after: 2 weeks
Sponsored by: E-CARD LTD.
Sponsored by: Klara, Inc.
Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D61948
---
sys/dev/bnxt/bnxt_en/bnxt_hwrm.c | 24 ++++++++++++++++++++++++
sys/dev/bnxt/bnxt_en/if_bnxt.c | 10 +++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c
index 2d9983393995..d278d1a87ee2 100644
--- a/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c
+++ b/sys/dev/bnxt/bnxt_en/bnxt_hwrm.c
@@ -2531,17 +2531,41 @@ bnxt_hwrm_set_filter(struct bnxt_softc *softc)
{
struct bnxt_vnic_info *vnic = &softc->vnic_info;
struct bnxt_vlan_tag *tag;
+ int nfilters = 0;
int rc = 0;
rc = bnxt_hwrm_l2_filter_alloc(softc, 0xffff, &vnic->filter_id);
if (rc)
goto end;
+ /*
+ * The filter above matches our MAC on any VLAN, so per-VLAN
+ * filters are not needed to receive tagged traffic. Running out
+ * of VLAN filters (ENOMEM) must not fail the init and take the
+ * port down. The VLAN tag list is ordered from oldest to newest
+ * by bnxt_vlan_register(), so the VLANs that do not get a filter
+ * are the ones most recently added. Any other error is fatal.
+ */
SLIST_FOREACH(tag, &vnic->vlan_tags, next) {
rc = bnxt_hwrm_l2_filter_alloc(softc, tag->tag,
&tag->filter_id);
+ if (rc == ENOMEM)
+ break;
if (rc)
goto end;
+ nfilters++;
+ }
+
+ if (tag != NULL) {
+ struct bnxt_vlan_tag *full = tag;
+ int ntags = nfilters;
+
+ SLIST_FOREACH_FROM(tag, &vnic->vlan_tags, next)
+ ntags++;
+ device_printf(softc->dev, "out of L2 filters: %d of %d VLANs "
+ "have none (VLAN %d and newer)\n", ntags - nfilters,
+ ntags, full->tag);
+ rc = 0;
}
end:
diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c
index 032d3a4368ee..a1126755345c 100644
--- a/sys/dev/bnxt/bnxt_en/if_bnxt.c
+++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c
@@ -4749,13 +4749,21 @@ bnxt_vlan_register(if_ctx_t ctx, uint16_t vtag)
{
struct bnxt_softc *softc = iflib_get_softc(ctx);
struct bnxt_vlan_tag *new_tag;
+ struct vlan_head tail;
new_tag = malloc(sizeof(struct bnxt_vlan_tag), M_DEVBUF, M_NOWAIT);
if (new_tag == NULL)
return;
new_tag->tag = vtag;
new_tag->filter_id = -1;
- SLIST_INSERT_HEAD(&softc->vnic_info.vlan_tags, new_tag, next);
+
+ /*
+ * Append new tags to the list so that the oldest VLANs (re)acquire
+ * L2 filters if bnxt_hwrm_set_filter() runs out.
+ */
+ SLIST_INIT(&tail);
+ SLIST_INSERT_HEAD(&tail, new_tag, next);
+ SLIST_CONCAT(&softc->vnic_info.vlan_tags, &tail, bnxt_vlan_tag, next);
};
static void