From nobody Wed Dec 08 09:00:25 2021 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 E2BE218C08B9; Wed, 8 Dec 2021 09:00:25 +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 4J8B2d4TlSz4gSB; Wed, 8 Dec 2021 09:00:25 +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 7B76A107AF; Wed, 8 Dec 2021 09:00:25 +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 1B890PeZ033601; Wed, 8 Dec 2021 09:00:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B890PAE033600; Wed, 8 Dec 2021 09:00:25 GMT (envelope-from git) Date: Wed, 8 Dec 2021 09:00:25 GMT Message-Id: <202112080900.1B890PAE033600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vincenzo Maffione Subject: git: e0f4cdba5336 - main - e1000: fix interface capabilities management 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e0f4cdba533693bb6ef9d90243acdad89605b150 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638954025; 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=NQpIlfXrPH9McAhaZqsLDq31ppt+wbLj4xwO2zFkFUk=; b=V+oBqBZNiaeLepB39AkQL9yzpLQcCPro3Oh59Jd6LTzry3QvYym6xa3YB86zzH34WY7a+7 48ty42pCaGzsVS2cPORuyIUL4VMJRU0V7tyNZSX5iCQFPT/3jk3JaC/kGO0O8tjg2MWLNa +KHUYRuIcH96kJCBFqst5RSECx8BC0mB+k07mdnlqk4hMA1K6s131jZ99lWi4oPlRrUpwg wae9dRv4zP/dBvNi7pcc1iDhqe/52Ovi5TuDLoV3y/Q/VTO27mILKOjCUeGnSZvyuu90ys GmPzi/P1tp48xlXS2lWFALUsNYyQi8Fw5NNst88vN+/W7+mAHFAYQxvX9fk9Vg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638954025; a=rsa-sha256; cv=none; b=eJArKEb7QnsgWGvFinTy6jc4DRmJ1rdWtwYEPdnAEugDP6lVxip7V2o/an5O+7KIT1Zdah SdFPNMgKlMG0pH6vkA84VnM0AWCZ+zC3+jEo95NWAYamLFIXL+HgjaWT1MVHu+cndwXjHl K1cnvrl3h6+jAyZKpEmGhEcy9PgRIQubt14h/4RNfs3X0vG22c8Gjt9hZqbYCTwFBzu2p1 5GUSsW9GfGteveNG0br5h0Z/20jNZpaS0zxwlpu8kqIpprbnjacgfwtwL0vIwMMZLweaE0 ouguRSL0/YXJjq/RjGjpC68Tg8urZcZjtYnn8JMK9TMSzfAioxqwD17np2aCcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=e0f4cdba533693bb6ef9d90243acdad89605b150 commit e0f4cdba533693bb6ef9d90243acdad89605b150 Author: Vincenzo Maffione AuthorDate: 2021-12-08 08:55:04 +0000 Commit: Vincenzo Maffione CommitDate: 2021-12-08 08:55:40 +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 --- 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; }