From nobody Wed Dec 22 13:44:50 2021 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 E457B18E473F; Wed, 22 Dec 2021 13:44:51 +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 4JJvhM3JTHz4WSs; Wed, 22 Dec 2021 13:44:51 +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 04D311E1DD; Wed, 22 Dec 2021 13:44:50 +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 1BMDioD8087732; Wed, 22 Dec 2021 13:44:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BMDioVi087731; Wed, 22 Dec 2021 13:44:50 GMT (envelope-from git) Date: Wed, 22 Dec 2021 13:44:50 GMT Message-Id: <202112221344.1BMDioVi087731@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: 677d9b1694e0 - stable/12 - e1000: fix interface capabilities management 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/12 X-Git-Reftype: branch X-Git-Commit: 677d9b1694e0062dbd0ceb86f4f13dd30c7af6a4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640180691; 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=pwaM23SeiaQTJAgeeWZUZhx6GrdnIwMyzbT1TK7D1BY=; b=iyPkXNmrtYGyM78pZ532Ods69EtULKHhJpBm1ZvdNFKrhxJLSjmPrZr3Xb9FqSa4nXM/uI 1jYQznF+MgseC5CO6GwvM7D43RBIo7ssPqPaEfL2f3S6cVjj3ugfl6VK7bnroUsZnqCaFs uO13o8a/MgxeeWKu/uzQ5wnttkigHlFzkFKIUVPYo0RizzN/WTbsxqTZaNJfl/62a0Tbvh FaW7jtWPSxZbtc+CzLQ/igrmt+2sZlFfBYjUrleoT40aAzvRw8MNumBmeSZOkhwbgimAKZ iaQPKhdUb697o5SkEBS2UpVfy/h7TfHiWTf4NxzrUBbpO+9sBs94Edxz/RSExw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640180691; a=rsa-sha256; cv=none; b=CE3UmE5iywzeXUpEhx5rt4jstOPUOQUewRsBHwSHtUdAZ1sCQFbWngocBFZTT7fnA8HiU8 v5pXpkULWuQRFwO1RMeETcfC8sR+eJwekAyorfMT9pDYj/f47M9qEsKbxVRxF8vHkkWVRM jYntmgX/mnhpOTEmPKqWMfMaAdp2DSFbrvkJUd4fdmhm4xr0IlOry6w/TxPkW+5c8AyMeQ DcIYeV5DiQOPKuVf1L005iR0NAM8ktZTjCZOfUHDRno8+PrZBg+GfnRWBN/pM7VUEMq6aL GkZ+NuXWk0CtDQly4F0CT8kIvQIqeYQFxAvdgHAvWgrLRQBydZc0EkQRzVW63g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=677d9b1694e0062dbd0ceb86f4f13dd30c7af6a4 commit 677d9b1694e0062dbd0ceb86f4f13dd30c7af6a4 Author: Vincenzo Maffione AuthorDate: 2021-12-08 08:55:04 +0000 Commit: Vincenzo Maffione CommitDate: 2021-12-22 13:44:39 +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 b542860b4a96..696c6007cd9f 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); @@ -916,14 +916,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 */ @@ -1357,7 +1358,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)); @@ -1684,7 +1685,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); @@ -3230,12 +3231,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); @@ -3429,11 +3430,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); @@ -3441,9 +3442,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++) @@ -3503,10 +3506,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 @@ -3515,7 +3519,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; @@ -3527,7 +3531,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; }