From nobody Mon Aug 3 12:34:51 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hDGN11fvjz6nJZB for ; Mon, 03 Aug 2026 12:34:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hDGN06M96z3f6p for ; Mon, 03 Aug 2026 12:34:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785760496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Tz+8DI6znU8deNljJjB8p37Oh15XQ7n6FSBOMTg4VA=; b=gGdKizHfe/xuYBHKTs/9jGAdhOeZ4XQTxYLk8iSa+wwdeDVShRHkAteVSQ1jfFMNPBWjLa clKwvTWz2q++HtgVYGCCfA7lYpMZRuJw2znFSHrWV7EfLx9Fm2SuMEcE1npb1eJe6iYdvT DJH9JEr7ABVCwtydB/8xhGQLd1Xg+yzQCsIX/FBye8qrVZP78508lIOnVAa7KZcq2VwIGa iOKelfj6F/DUjCkdrhYG8RZzd+tEIscNPp6fMAHT5X5Rd38n2pOgx8ayMB9ItftrIM+C3H mOIF2bEPoOHRUErcc1WQPhc+EoeY41exHTPnfT5DAidOGOv7uCDwKoEyZJ0oSw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785760496; a=rsa-sha256; cv=none; b=Z6eEV5m1+XSxZwywCsFl2qQyakTFE3T0fZSyM+8nnUgvovfDfuP/cWnPWgJ5UuqvYQ4hVB 9ZdW99rk8FrM0UJmklwa1uTaRogjDRgqhdPauwUMZo6TFzOD9h50TbJ0D7dFdfvO8MJJjZ G1r3/bWTdeFrE9glfXzg8QStTMq0ExIDNwWsjt9dQNA2AlVH+l/cY4h1kegFPWWa7uCaw+ x0L5lh10ulNiBU/BKggoyPoCk0OsbwDsIE7TREZwvkueQw/4on/C/OWVIfUku2cJMwQSdd aKedNT9Ph6Ynp30r14P641R+yfDYuHc4Rydwrw3bAIuqU3FCqpvuGOcdeOocHw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785760496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Tz+8DI6znU8deNljJjB8p37Oh15XQ7n6FSBOMTg4VA=; b=VAl/xCMhMKLIWIXEY9b8h47lb/ZN5uiZt6UYrxhWwyIZJ2GvBClFl78VzJeCmKZHNr/pWP DKnkIy3CX9krxurKSVZ0VIa5VvDXqGtw0F1ZU8A3tDlLHYutfQAgE8SdIigN3i0UYHjgsC DCtsx8wMjxOdNL2h7dHqFoXgI+VMX0GBf0DinqlSsWbxeFElLBpGXWGI0bdRxK9uBBBbjw 1B4TofELmjc6v6FsiSvfo03i+C4Q0CL/yWvMAkHwYbiKji78iqZMQgWBHy0Oyd4qeEtkco os6Zl+S69ixRfhVNhpkGO573bG6GZ/CVhpzBr7jdumFnG/XoTAbD1+uXHB+8/w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hDGN05NMjz11Nk for ; Mon, 03 Aug 2026 12:34:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2221c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 03 Aug 2026 12:34:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 8f779f159e21 - main - igc: Add VLAN hardware filtering List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8f779f159e2198c85b4fcb8685989879a9330104 Auto-Submitted: auto-generated Date: Mon, 03 Aug 2026 12:34:51 +0000 Message-Id: <6a708aeb.2221c.31d75922@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=8f779f159e2198c85b4fcb8685989879a9330104 commit 8f779f159e2198c85b4fcb8685989879a9330104 Author: Kevin Bowling AuthorDate: 2026-08-03 10:57:39 +0000 Commit: Kevin Bowling CommitDate: 2026-08-03 12:34:09 +0000 igc: Add VLAN hardware filtering Borrow the e1000 VLAN filter table Ambiguous presence of the feature by Intel was settled by DPDK and emperical testing. MFC after: 2 weeks Relnotes: yes --- share/man/man4/igc.4 | 6 +-- sys/dev/igc/if_igc.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++---- sys/dev/igc/if_igc.h | 3 ++ 3 files changed, 113 insertions(+), 12 deletions(-) diff --git a/share/man/man4/igc.4 b/share/man/man4/igc.4 index 3b92472e8355..521a36531208 100644 --- a/share/man/man4/igc.4 +++ b/share/man/man4/igc.4 @@ -3,7 +3,7 @@ .\" Copyright 2021 Rubicon Communications, LLC (Netgate) .\" SPDX-License-Identifier: BSD-3-Clause .\" -.Dd March 9, 2026 +.Dd August 3, 2026 .Dt IGC 4 .Os .Sh NAME @@ -39,8 +39,8 @@ utility configures the adapter to receive and transmit Jumbo Frames. The maximum MTU size for Jumbo Frames is 9216 bytes. .Pp -This driver version supports VLAN hardware insertion / extraction, and -VLAN checksum offload. +This driver version supports VLAN hardware insertion / extraction, +VLAN checksum offload, and VLAN hardware filtering. For information on enabling VLANs, see .Xr ifconfig 8 . The diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c index 21eb0d6357ef..1f10d244f2dd 100644 --- a/sys/dev/igc/if_igc.c +++ b/sys/dev/igc/if_igc.c @@ -108,6 +108,8 @@ static void igc_if_media_status(if_ctx_t, struct ifmediareq *); static int igc_if_media_change(if_ctx_t); static int igc_if_mtu_set(if_ctx_t, uint32_t); static void igc_if_timer(if_ctx_t, uint16_t); +static void igc_if_vlan_register(if_ctx_t, u16); +static void igc_if_vlan_unregister(if_ctx_t, u16); static void igc_if_watchdog_reset(if_ctx_t); static bool igc_if_needs_restart(if_ctx_t, enum iflib_restart_event); @@ -133,6 +135,10 @@ static void igc_if_debug(if_ctx_t); static void igc_update_stats_counters(struct igc_softc *); static void igc_add_hw_stats(struct igc_softc *); static int igc_if_set_promisc(if_ctx_t, int); +static bool igc_if_vlan_filter_capable(if_ctx_t); +static bool igc_if_vlan_filter_used(if_ctx_t); +static void igc_if_vlan_filter_enable(struct igc_softc *); +static void igc_if_vlan_filter_disable(struct igc_softc *); static void igc_setup_vlan_hw_support(if_ctx_t); static void igc_fw_version(struct igc_softc *); static void igc_sbuf_fw_version(struct igc_fw_version *, struct sbuf *); @@ -220,6 +226,8 @@ static device_method_t igc_if_methods[] = { DEVMETHOD(ifdi_promisc_set, igc_if_set_promisc), DEVMETHOD(ifdi_timer, igc_if_timer), DEVMETHOD(ifdi_watchdog_reset, igc_if_watchdog_reset), + DEVMETHOD(ifdi_vlan_register, igc_if_vlan_register), + DEVMETHOD(ifdi_vlan_unregister, igc_if_vlan_unregister), DEVMETHOD(ifdi_get_counter, igc_if_get_counter), DEVMETHOD(ifdi_rx_queue_intr_enable, igc_if_rx_queue_intr_enable), DEVMETHOD(ifdi_tx_queue_intr_enable, igc_if_tx_queue_intr_enable), @@ -447,8 +455,9 @@ igc_set_num_queues(if_ctx_t ctx) #define IGC_CAPS \ IFCAP_HWCSUM | IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | \ - IFCAP_VLAN_HWCSUM | IFCAP_WOL | IFCAP_TSO4 | IFCAP_LRO | \ - IFCAP_VLAN_HWTSO | IFCAP_JUMBO_MTU | IFCAP_HWCSUM_IPV6 | IFCAP_TSO6 + IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER | IFCAP_WOL | IFCAP_TSO4 | \ + IFCAP_LRO | IFCAP_VLAN_HWTSO | IFCAP_JUMBO_MTU | \ + IFCAP_HWCSUM_IPV6 | IFCAP_TSO6 /********************************************************************* * Device initialization routine @@ -1310,20 +1319,24 @@ igc_if_set_promisc(if_ctx_t ctx, int flags) /* Don't disable if in MAX groups */ if (mcnt < MAX_NUM_MULTICAST_ADDRESSES) - reg_rctl &= (~IGC_RCTL_MPE); - IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); + reg_rctl &= ~IGC_RCTL_MPE; if (flags & IFF_PROMISC) { reg_rctl |= (IGC_RCTL_UPE | IGC_RCTL_MPE); /* Turn this on if you want to see bad packets */ if (igc_debug_sbp) reg_rctl |= IGC_RCTL_SBP; - IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); } else if (flags & IFF_ALLMULTI) { reg_rctl |= IGC_RCTL_MPE; reg_rctl &= ~IGC_RCTL_UPE; - IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); } + + if ((flags & IFF_PROMISC) || !igc_if_vlan_filter_used(ctx)) + reg_rctl &= ~IGC_RCTL_VFE; + else + reg_rctl |= IGC_RCTL_VFE; + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg_rctl); + return (0); } @@ -2415,16 +2428,87 @@ igc_initialize_receive_unit(if_ctx_t ctx) return; } +static void +igc_if_vlan_register(if_ctx_t ctx, u16 vtag) +{ + struct igc_softc *sc = iflib_get_softc(ctx); + u32 index, mask; + + index = (vtag >> 5) & 0x7f; + mask = 1U << (vtag & 0x1f); + if ((sc->shadow_vfta[index] & mask) != 0) + return; + sc->shadow_vfta[index] |= mask; + igc_write_vfta(&sc->hw, index, sc->shadow_vfta[index]); +} + +static void +igc_if_vlan_unregister(if_ctx_t ctx, u16 vtag) +{ + struct igc_softc *sc = iflib_get_softc(ctx); + u32 index, mask; + + index = (vtag >> 5) & 0x7f; + mask = 1U << (vtag & 0x1f); + if ((sc->shadow_vfta[index] & mask) == 0) + return; + sc->shadow_vfta[index] &= ~mask; + igc_write_vfta(&sc->hw, index, sc->shadow_vfta[index]); +} + +static bool +igc_if_vlan_filter_capable(if_ctx_t ctx) +{ + if_t ifp = iflib_get_ifp(ctx); + + return ((if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) != 0 && + !igc_disable_crc_stripping); +} + +static bool +igc_if_vlan_filter_used(if_ctx_t ctx) +{ + struct igc_softc *sc = iflib_get_softc(ctx); + + if (!igc_if_vlan_filter_capable(ctx)) + return (false); + + for (int i = 0; i < IGC_VFTA_SIZE; i++) + if (sc->shadow_vfta[i] != 0) + return (true); + + return (false); +} + +static void +igc_if_vlan_filter_enable(struct igc_softc *sc) +{ + u32 reg; + + reg = IGC_READ_REG(&sc->hw, IGC_RCTL); + reg &= ~IGC_RCTL_CFIEN; + reg |= IGC_RCTL_VFE; + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg); +} + +static void +igc_if_vlan_filter_disable(struct igc_softc *sc) +{ + u32 reg; + + reg = IGC_READ_REG(&sc->hw, IGC_RCTL); + reg &= ~(IGC_RCTL_VFE | IGC_RCTL_CFIEN); + IGC_WRITE_REG(&sc->hw, IGC_RCTL, reg); +} + static void igc_setup_vlan_hw_support(if_ctx_t ctx) { struct igc_softc *sc = iflib_get_softc(ctx); struct igc_hw *hw = &sc->hw; - struct ifnet *ifp = iflib_get_ifp(ctx); + if_t ifp = iflib_get_ifp(ctx); u32 reg; - /* igc hardware doesn't seem to implement VFTA for HWFILTER */ - if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING && !igc_disable_crc_stripping) { reg = IGC_READ_REG(hw, IGC_CTRL); @@ -2435,6 +2519,20 @@ igc_setup_vlan_hw_support(if_ctx_t ctx) reg &= ~IGC_CTRL_VME; IGC_WRITE_REG(hw, IGC_CTRL, reg); } + + if (!igc_if_vlan_filter_capable(ctx)) { + igc_if_vlan_filter_disable(sc); + return; + } + + /* Always admit priority-tagged frames. */ + sc->shadow_vfta[0] |= 1U; + + /* A reset may clear the VFTA, so restore the complete desired table. */ + for (int i = 0; i < IGC_VFTA_SIZE; i++) + igc_write_vfta(hw, i, sc->shadow_vfta[i]); + + igc_if_vlan_filter_enable(sc); } static void diff --git a/sys/dev/igc/if_igc.h b/sys/dev/igc/if_igc.h index a090eeb12247..d9834212fee8 100644 --- a/sys/dev/igc/if_igc.h +++ b/sys/dev/igc/if_igc.h @@ -387,6 +387,9 @@ struct igc_softc { /* Multicast array memory */ u8 *mta; + /* Retained across resets to restore the hardware VLAN filter table. */ + u32 shadow_vfta[IGC_VFTA_SIZE]; + /* Info about the interface */ u16 link_active; u16 fc;