From nobody Mon Aug 3 12:34:51 2026 X-Original-To: dev-commits-src-main@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 4hDGMw0W9jz6nJhy for ; Mon, 03 Aug 2026 12:34:52 +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 4hDGMv70q0z3f1m for ; Mon, 03 Aug 2026 12:34:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785760492; 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=DNvn5hwJFPjIOc9CWhG6zPctEQkKlIgEegrwLVVtCOzQUexMtCUcX/jChDo3fOyv5meHcA FBXp1lWa2QiEy9bmusrdSavG2tV2H40go4fETYZKvsCYXhqlCtpXgfFSY8dxQuCQ9oN1Xs h2gDlpqbDgc7i3drwy5pKIGcmC6NxXhBuIEHBI6avnMSLLeEDYrH+28VburcA4JIQbDuS4 SpcgujJVRC9/ZHaQS9ei/DoX5xg7LCnqPzifq2OxlgIWUzvVhiL46hqwAw9ca/pfVBR5dq YvJAHb0BxHhMtojrXqgcPN+Xd83H2/Zo0tHPY/suwzLxlY2+RbbEi1zCK6AoRg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785760492; a=rsa-sha256; cv=none; b=paCkvfEhtxaJ3SMsXpWTRfy15qjlrhBKcWf8xLyw4NPyx2wCnUQzSx7CiEdJVYToymfKJt xLlRfGld0/hqmIdNloUq9vA2OlPd80TpInsRUcTsii/GrsntOP3tfLuGhC6EcUT3Lg7dJF /Jh0YfHYLw1pGQPhbyH5CWdgSK5P1fxWkxVUmtXI9CGYQRUeLVaRzD+ILVZglkkF5MMpn7 w8UOwIi5bjTDqTaV5E6FRgJ6tzsgqTUSbuz4EGjvZ0hcJ3pQtyShjt0x/MYbvuhKvRlhpw qGGBlG9mtBK3QbqQq4y25FHw+Xt6DQTutK5dMoPUl8VLIPrd1T+UJCaDe+p1Gg== 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=1785760492; 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=LaZ5y0v6GCahxmVUiEAEBcSPBkJxJnv59gEgTo3pNXNa6cGP0oEGI++4eV6EZOlzcUUR1U T97pZfzfVlJFMgeqjZhgrDyo31a8XdNuH8za9Dg4X+KSVPxe0s3+jGXCDLjCwLgPbmBqzN hiHUHHnQk8PwhyLEj33Y+48E17F0h2If/GNT8KY9PJ4NeFIOeSjdy1Q1E2Bgi184UoJsr3 o/1b7cb6txTkmO7fNY51q9f8gSdqg49rMPLbMut418T+zQvqojciz9z6nJELwIeWyhYHC5 iS3SucOH9daNiz0E+1rzMZ1H2XFIszWZJbfr31YWTY+2guvrfBRPjHxjdm+rsA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hDGMv5fQNz11Cr for ; Mon, 03 Aug 2026 12:34:51 +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 the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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;