From nobody Wed Dec 22 09:03:59 2021 X-Original-To: dev-commits-src-branches@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 63B9318FA405; Wed, 22 Dec 2021 09:04:00 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JJnSJ1218z3wVW; Wed, 22 Dec 2021 09:04:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 02E521A91F; Wed, 22 Dec 2021 09:04:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BM93xYM010795; Wed, 22 Dec 2021 09:03:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BM93x8v010794; Wed, 22 Dec 2021 09:03:59 GMT (envelope-from git) Date: Wed, 22 Dec 2021 09:03:59 GMT Message-Id: <202112220903.1BM93x8v010794@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: ecb7f44be901 - stable/13 - e1000: fix interface capabilities management List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ecb7f44be90190974ee97389827563882345eb2a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640163840; 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=475yUsIfRQcyLCwuUNYRo71grYY0UjuFRqxJcDgOd6o=; b=EOoPdRb9IRj3kmXDpv+Mt57PjPoio8KbEj1mrQGMo9n433F0lV1zkjCBtSOevFgaBVQ8ak K0yFNVM18q/hrK63TqOU1VIsXpqYznm3ywwwO0Kof0zLhv1Y6cZzg/Zcg0qmTQTBlhvkEA 2A+qHmWLqqQpTBbN77EKwytcm28lgGvrS8s9ZN4XCpZGJa65/M/m5qMEjrtRvUPU/Zp4Ah dLYqfPXauVYHY3Z+3T3YaXmbuR+LyuS7E2sZaNPy1F89wM9kAfKHBjcLrub1XYWefsVM4w tR4m2y+d+bDCuQco3q36EHwMTnCT+p8Y1PJAA3McjFeKw4SBTCPLcEgkH2hWsg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640163840; a=rsa-sha256; cv=none; b=UZ0NcS/RL6pBMp2GYr7Buu1pD/ORGQZ/VPoO4y9HuB+kQ10k0Ii3hcULmhUgWVhetOLbxl EAYkBTFn0tYBQqQ4AR5kuVDOVFyyqAlVQO5FbrjkTB1jhcLn+n+9F7SPaPvaRI8Oh0Ctay 6f2qlGx24TpKzfPJP/97kgHTSF90Z4jiQnxUElSTnqbK7ypGnXIVl35Y0019hmfyJOXP+D +2YA8EKU7jLoS0tLFNv06GhlBxOQ1g/Dcuz7hxHZgunsu/tI9GYXamdateD5Egy5PjE+I8 QA2+/zzhRR2zw01S9AEaw3zKcHUoJySfZIBzZd2hTrFT0UNist6Poq7BjIoZTA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=ecb7f44be90190974ee97389827563882345eb2a commit ecb7f44be90190974ee97389827563882345eb2a Author: Vincenzo Maffione AuthorDate: 2021-12-08 08:55:04 +0000 Commit: Vincenzo Maffione CommitDate: 2021-12-22 08:50:35 +0000 e1000: fix interface capabilities management The e1000 drivers (em, lem, igb) are currently looking at the iflib copies of the capabilities bitvectors (scctx->isc_capabilities and scctx->isc_capenable) rather than the ifnet ones (ifp->if_capabilities and ifp->if_capenable). However, the latter are the ones that are actually updated by ifconfig and that should be used by the drivers during interface operation. The former are set by the driver on interface attach (for iflib internal use) and should not be used anymore by the driver. This patch fixes the e1000 driver to use the correct bitvectors. PR: 260068 Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33154 (cherry picked from commit e0f4cdba533693bb6ef9d90243acdad89605b150) --- sys/dev/e1000/if_em.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index b3775b351c70..cb0c01c9c65d 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -297,12 +297,12 @@ static void em_if_debug(if_ctx_t); static void em_update_stats_counters(struct e1000_softc *); static void em_add_hw_stats(struct e1000_softc *); static int em_if_set_promisc(if_ctx_t, int); -static bool em_if_vlan_filter_capable(struct e1000_softc *); -static bool em_if_vlan_filter_used(struct e1000_softc *); +static bool em_if_vlan_filter_capable(if_ctx_t); +static bool em_if_vlan_filter_used(if_ctx_t); static void em_if_vlan_filter_enable(struct e1000_softc *); static void em_if_vlan_filter_disable(struct e1000_softc *); static void em_if_vlan_filter_write(struct e1000_softc *); -static void em_setup_vlan_hw_support(struct e1000_softc *); +static void em_setup_vlan_hw_support(if_ctx_t ctx); static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); static void em_print_nvm_info(struct e1000_softc *); static void em_fw_version_locked(if_ctx_t); @@ -915,14 +915,15 @@ em_if_attach_pre(if_ctx_t ctx) scctx->isc_rxd_size[0] = sizeof(struct e1000_rx_desc); scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP; scctx->isc_txrx = &lem_txrx; - scctx->isc_capabilities = scctx->isc_capenable = LEM_CAPS; + scctx->isc_capabilities = LEM_CAPS; if (hw->mac.type < e1000_82543) - scctx->isc_capenable &= ~(IFCAP_HWCSUM|IFCAP_VLAN_HWCSUM); + scctx->isc_capabilities &= ~(IFCAP_HWCSUM|IFCAP_VLAN_HWCSUM); /* 82541ER doesn't do HW tagging */ if (hw->device_id == E1000_DEV_ID_82541ER || hw->device_id == E1000_DEV_ID_82541ER_LOM) - scctx->isc_capenable &= ~IFCAP_VLAN_HWTAGGING; + scctx->isc_capabilities &= ~IFCAP_VLAN_HWTAGGING; /* INTx only */ scctx->isc_msix_bar = 0; + scctx->isc_capenable = scctx->isc_capabilities; } /* Setup PCI resources */ @@ -1356,7 +1357,7 @@ em_if_init(if_ctx_t ctx) em_initialize_receive_unit(ctx); /* Set up VLAN support and filter */ - em_setup_vlan_hw_support(sc); + em_setup_vlan_hw_support(ctx); /* Don't lose promiscuous settings */ em_if_set_promisc(ctx, if_getflags(ifp)); @@ -1683,7 +1684,7 @@ em_if_set_promisc(if_ctx_t ctx, int flags) reg_rctl &= ~E1000_RCTL_UPE; E1000_WRITE_REG(&sc->hw, E1000_RCTL, reg_rctl); } - if (em_if_vlan_filter_used(sc)) + if (em_if_vlan_filter_used(ctx)) em_if_vlan_filter_enable(sc); } return (0); @@ -3242,12 +3243,12 @@ em_initialize_receive_unit(if_ctx_t ctx) /* Set up L3 and L4 csum Rx descriptor offloads */ rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); - if (scctx->isc_capenable & IFCAP_RXCSUM) { + if (if_getcapenable(ifp) & IFCAP_RXCSUM) { rxcsum |= E1000_RXCSUM_TUOFL | E1000_RXCSUM_IPOFL; if (hw->mac.type > e1000_82575) rxcsum |= E1000_RXCSUM_CRCOFL; else if (hw->mac.type < em_mac_min && - scctx->isc_capenable & IFCAP_HWCSUM_IPV6) + if_getcapenable(ifp) & IFCAP_HWCSUM_IPV6) rxcsum |= E1000_RXCSUM_IPV6OFL; } else { rxcsum &= ~(E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL); @@ -3441,11 +3442,11 @@ em_if_vlan_unregister(if_ctx_t ctx, u16 vtag) } static bool -em_if_vlan_filter_capable(struct e1000_softc *sc) +em_if_vlan_filter_capable(if_ctx_t ctx) { - if_softc_ctx_t scctx = sc->shared; + if_t ifp = iflib_get_ifp(ctx); - if ((scctx->isc_capenable & IFCAP_VLAN_HWFILTER) && + if ((if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) && !em_disable_crc_stripping) return (true); @@ -3453,9 +3454,11 @@ em_if_vlan_filter_capable(struct e1000_softc *sc) } static bool -em_if_vlan_filter_used(struct e1000_softc *sc) +em_if_vlan_filter_used(if_ctx_t ctx) { - if (!em_if_vlan_filter_capable(sc)) + struct e1000_softc *sc = iflib_get_softc(ctx); + + if (!em_if_vlan_filter_capable(ctx)) return (false); for (int i = 0; i < EM_VFTA_SIZE; i++) @@ -3515,10 +3518,11 @@ em_if_vlan_filter_write(struct e1000_softc *sc) } static void -em_setup_vlan_hw_support(struct e1000_softc *sc) +em_setup_vlan_hw_support(if_ctx_t ctx) { - if_softc_ctx_t scctx = sc->shared; + struct e1000_softc *sc = iflib_get_softc(ctx); struct e1000_hw *hw = &sc->hw; + struct ifnet *ifp = iflib_get_ifp(ctx); u32 reg; /* XXXKB: Return early if we are a VF until VF decap and filter management @@ -3527,7 +3531,7 @@ em_setup_vlan_hw_support(struct e1000_softc *sc) if (sc->vf_ifp) return; - if (scctx->isc_capenable & IFCAP_VLAN_HWTAGGING && + if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING && !em_disable_crc_stripping) { reg = E1000_READ_REG(hw, E1000_CTRL); reg |= E1000_CTRL_VME; @@ -3539,7 +3543,7 @@ em_setup_vlan_hw_support(struct e1000_softc *sc) } /* If we aren't doing HW filtering, we're done */ - if (!em_if_vlan_filter_capable(sc)) { + if (!em_if_vlan_filter_capable(ctx)) { em_if_vlan_filter_disable(sc); return; }