From owner-dev-commits-src-all@freebsd.org Thu Sep 16 15:32:43 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C8B1D67CBA5 for ; Thu, 16 Sep 2021 15:32:43 +0000 (UTC) (envelope-from kevin.bowling@kev009.com) Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H9Lgb4fX1z3tL5 for ; Thu, 16 Sep 2021 15:32:43 +0000 (UTC) (envelope-from kevin.bowling@kev009.com) Received: by mail-yb1-xb2d.google.com with SMTP id z5so13785800ybj.2 for ; Thu, 16 Sep 2021 08:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kev009.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uwy6Cqv8pJIoup6Q4kenXO/Jmyt3MWnzMTvgAHeGurU=; b=PdkC3CoGO+sbnNXgeqFOcH9eb6HLpSA6JJxrmKxUZJGuvOGnjNMt+3IT/tUAy63igj s+psC72Rg7do1xHlnNW05d7T2ewrfByQs/WJ6YnNeJOd36JxBRCCtkAOrh49Gf4qZ07N LH5uHdPc4G1gXNJZjbueFZxJLOpdlDpzznoT0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uwy6Cqv8pJIoup6Q4kenXO/Jmyt3MWnzMTvgAHeGurU=; b=NMsLh7ka0qAJmyTSY9OTTXjmUNLW/0AkAGLcHuufacW2lQTC7mLKaOXCn3TJmf9tFT QWlMcheFjSIujJEjWsyBaQVfNgJH6lcj9v0Cvgb9bybHkH1p36gTccLQRHM682T5pHgK xJ3NSkOwd/Dugm+ejEKEM5wiflYRzi01tn6mydigG1/pGGyYx99/fxjUXHWyc9mqFbh0 FhDDUlQsY5TvxgNak5/jA0gdZAUlkZg55MCLxkwW27oOVyO/+0WRigsThdM6IZduskeU V02R4wnC8A57NdRzBp+rgyr1KoNsb7fx2hbQ+hmgfxqhyBnWlKKd8XatLqLyn1BxtzS8 41Zg== X-Gm-Message-State: AOAM530o9gVxDWNW0j0GPa1cbEuH9ZADLz49yw4zlrq5jxE9r+77R/sG GEN2dR2Fc52sCc3ZZxe8e1yrspmAIRXn6TBROloGFQ== X-Google-Smtp-Source: ABdhPJzmhwGwTPKNhNNhT81vLfvcDAy0TOJaZ83msno4kkBZmiZU4iRc0gmmwqPIX2EnsN7tbfQNcH2sDhVmdceryrc= X-Received: by 2002:a25:3d84:: with SMTP id k126mr7769971yba.43.1631806362791; Thu, 16 Sep 2021 08:32:42 -0700 (PDT) MIME-Version: 1.0 References: <202109152233.18FMX2qw004740@gitrepo.freebsd.org> In-Reply-To: <202109152233.18FMX2qw004740@gitrepo.freebsd.org> From: Kevin Bowling Date: Thu, 16 Sep 2021 08:32:32 +0000 Message-ID: Subject: Re: git: 2796f7cab107 - main - e1000: Fix up HW vlan ops To: Kevin Bowling Cc: src-committers , "" , "dev-commits-src-main@FreeBSD.org" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4H9Lgb4fX1z3tL5 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2021 15:32:43 -0000 PR mentioned should have been 258258 with 230996 as a partial On Wed, Sep 15, 2021 at 10:33 PM Kevin Bowling wrote: > > The branch main has been updated by kbowling (ports committer): > > URL: https://cgit.FreeBSD.org/src/commit/?id=2796f7cab10785ef40efbba97ef67ab319c96e9c > > commit 2796f7cab10785ef40efbba97ef67ab319c96e9c > Author: Kevin Bowling > AuthorDate: 2021-09-15 14:47:19 +0000 > Commit: Kevin Bowling > CommitDate: 2021-09-15 15:03:01 +0000 > > e1000: Fix up HW vlan ops > > * Don't reset the entire adapter for vlan changes, fix up the problems > * Add some functions for vlan filter (vfta) manipulation > * Don't muck with the vfta if we aren't doing HW vlan filtering > * Disable interrupts when manipulating vfta on lem(4)-class NICs > * On the I350 there is a specification update (2.4.20) in which the > suggested workaround is to write to the vfta 10 times (if at first you > don't succeed, try, try again). Our shared code has the goods, use it > * Increase a VF's frame receive size in the case of vlans > > From the referenced PR, this reduced vlan configuration from minutes > to seconds with hundreds or thousands of vlans and prevents wedging the > adapter with needless adapter reinitialization for each vlan ID. > > PR: 230996 > Reviewed by: markj > Tested by: Ozkan KIRIK > MFC after: 2 weeks > Differential Revision: https://reviews.freebsd.org/D30002 > --- > sys/dev/e1000/if_em.c | 166 ++++++++++++++++++++++++++++++++++++++------------ > 1 file changed, 126 insertions(+), 40 deletions(-) > > diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c > index 6e3a8f73190f..7900e550c55f 100644 > --- a/sys/dev/e1000/if_em.c > +++ b/sys/dev/e1000/if_em.c > @@ -297,6 +297,11 @@ static void em_if_debug(if_ctx_t ctx); > static void em_update_stats_counters(struct adapter *); > static void em_add_hw_stats(struct adapter *adapter); > static int em_if_set_promisc(if_ctx_t ctx, int flags); > +static bool em_if_vlan_filter_capable(struct adapter *); > +static bool em_if_vlan_filter_used(struct adapter *); > +static void em_if_vlan_filter_enable(struct adapter *); > +static void em_if_vlan_filter_disable(struct adapter *); > +static void em_if_vlan_filter_write(struct adapter *); > static void em_setup_vlan_hw_support(struct adapter *); > static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); > static void em_print_nvm_info(struct adapter *); > @@ -906,6 +911,9 @@ em_if_attach_pre(if_ctx_t ctx) > scctx->isc_capabilities = scctx->isc_capenable = LEM_CAPS; > if (hw->mac.type < e1000_82543) > scctx->isc_capenable &= ~(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; > /* INTx only */ > scctx->isc_msix_bar = 0; > } > @@ -1335,23 +1343,8 @@ em_if_init(if_ctx_t ctx) > adapter->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx); > em_initialize_receive_unit(ctx); > > - /* Use real VLAN Filter support? */ > - if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) { > - if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER) > - /* Use real VLAN Filter support */ > - em_setup_vlan_hw_support(adapter); > - else { > - u32 ctrl; > - ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL); > - ctrl |= E1000_CTRL_VME; > - E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl); > - } > - } else { > - u32 ctrl; > - ctrl = E1000_READ_REG(&adapter->hw, E1000_CTRL); > - ctrl &= ~E1000_CTRL_VME; > - E1000_WRITE_REG(&adapter->hw, E1000_CTRL, ctrl); > - } > + /* Set up VLAN support and filter */ > + em_setup_vlan_hw_support(adapter); > > /* Don't lose promiscuous settings */ > em_if_set_promisc(ctx, if_getflags(ifp)); > @@ -1670,14 +1663,19 @@ em_if_set_promisc(if_ctx_t ctx, int flags) > > if (flags & IFF_PROMISC) { > reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); > + em_if_vlan_filter_disable(adapter); > /* Turn this on if you want to see bad packets */ > if (em_debug_sbp) > reg_rctl |= E1000_RCTL_SBP; > E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); > - } else if (flags & IFF_ALLMULTI) { > - reg_rctl |= E1000_RCTL_MPE; > - reg_rctl &= ~E1000_RCTL_UPE; > - E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); > + } else { > + if (flags & IFF_ALLMULTI) { > + reg_rctl |= E1000_RCTL_MPE; > + reg_rctl &= ~E1000_RCTL_UPE; > + E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl); > + } > + if (em_if_vlan_filter_used(adapter)) > + em_if_vlan_filter_enable(adapter); > } > return (0); > } > @@ -3323,7 +3321,11 @@ em_initialize_receive_unit(if_ctx_t ctx) > /* are we on a vlan? */ > if (ifp->if_vlantrunk != NULL) > psize += VLAN_TAG_SIZE; > - E1000_WRITE_REG(hw, E1000_RLPML, psize); > + > + if (adapter->vf_ifp) > + e1000_rlpml_set_vf(hw, pszie); > + else > + E1000_WRITE_REG(hw, E1000_RLPML, psize); > } > > /* Set maximum packet buffer len */ > @@ -3420,6 +3422,7 @@ em_if_vlan_register(if_ctx_t ctx, u16 vtag) > bit = vtag & 0x1F; > adapter->shadow_vfta[index] |= (1 << bit); > ++adapter->num_vlans; > + em_if_vlan_filter_write(adapter); > } > > static void > @@ -3432,41 +3435,121 @@ em_if_vlan_unregister(if_ctx_t ctx, u16 vtag) > bit = vtag & 0x1F; > adapter->shadow_vfta[index] &= ~(1 << bit); > --adapter->num_vlans; > + em_if_vlan_filter_write(adapter); > +} > + > +static bool > +em_if_vlan_filter_capable(struct adapter *adapter) > +{ > + if_softc_ctx_t scctx = adapter->shared; > + > + if ((scctx->isc_capenable & IFCAP_VLAN_HWFILTER) && > + !em_disable_crc_stripping) > + return (true); > + > + return (false); > +} > + > +static bool > +em_if_vlan_filter_used(struct adapter *adapter) > +{ > + if (!em_if_vlan_filter_capable(adapter)) > + return (false); > + > + for (int i = 0; i < EM_VFTA_SIZE; i++) > + if (adapter->shadow_vfta[i] != 0) > + return (true); > + > + return (false); > +} > + > +static void > +em_if_vlan_filter_enable(struct adapter *adapter) > +{ > + struct e1000_hw *hw = &adapter->hw; > + u32 reg; > + > + reg = E1000_READ_REG(hw, E1000_RCTL); > + reg &= ~E1000_RCTL_CFIEN; > + reg |= E1000_RCTL_VFE; > + E1000_WRITE_REG(hw, E1000_RCTL, reg); > +} > + > +static void > +em_if_vlan_filter_disable(struct adapter *adapter) > +{ > + struct e1000_hw *hw = &adapter->hw; > + u32 reg; > + > + reg = E1000_READ_REG(hw, E1000_RCTL); > + reg &= ~(E1000_RCTL_VFE | E1000_RCTL_CFIEN); > + E1000_WRITE_REG(hw, E1000_RCTL, reg); > +} > + > +static void > +em_if_vlan_filter_write(struct adapter *adapter) > +{ > + struct e1000_hw *hw = &adapter->hw; > + > + if (adapter->vf_ifp) > + return; > + > + /* Disable interrupts for lem-class devices during the filter change */ > + if (hw->mac.type < em_mac_min) > + em_if_intr_disable(adapter->ctx); > + > + for (int i = 0; i < EM_VFTA_SIZE; i++) > + if (adapter->shadow_vfta[i] != 0) { > + /* XXXKB: incomplete VF support, we return early above */ > + if (adapter->vf_ifp) > + e1000_vfta_set_vf(hw, adapter->shadow_vfta[i], TRUE); > + else > + e1000_write_vfta(hw, i, adapter->shadow_vfta[i]); > + } > + > + /* Re-enable interrupts for lem-class devices */ > + if (hw->mac.type < em_mac_min) > + em_if_intr_enable(adapter->ctx); > } > > static void > em_setup_vlan_hw_support(struct adapter *adapter) > { > + if_softc_ctx_t scctx = adapter->shared; > struct e1000_hw *hw = &adapter->hw; > u32 reg; > > - /* > - * We get here thru init_locked, meaning > - * a soft reset, this has already cleared > - * the VFTA and other state, so if there > - * have been no vlan's registered do nothing. > + /* XXXKB: Return early if we are a VF until VF decap and filter management > + * is ready and tested. > */ > - if (adapter->num_vlans == 0) > + if (adapter->vf_ifp) > + return; > + > + if (scctx->isc_capenable & IFCAP_VLAN_HWTAGGING && > + !em_disable_crc_stripping) { > + reg = E1000_READ_REG(hw, E1000_CTRL); > + reg |= E1000_CTRL_VME; > + E1000_WRITE_REG(hw, E1000_CTRL, reg); > + } else { > + reg = E1000_READ_REG(hw, E1000_CTRL); > + reg &= ~E1000_CTRL_VME; > + E1000_WRITE_REG(hw, E1000_CTRL, reg); > + } > + > + /* If we aren't doing HW filtering, we're done */ > + if (!em_if_vlan_filter_capable(adapter)) { > + em_if_vlan_filter_disable(adapter); > return; > + } > > /* > * A soft reset zero's out the VFTA, so > * we need to repopulate it now. > */ > - for (int i = 0; i < EM_VFTA_SIZE; i++) > - if (adapter->shadow_vfta[i] != 0) > - E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, > - i, adapter->shadow_vfta[i]); > - > - reg = E1000_READ_REG(hw, E1000_CTRL); > - reg |= E1000_CTRL_VME; > - E1000_WRITE_REG(hw, E1000_CTRL, reg); > + em_if_vlan_filter_write(adapter); > > /* Enable the Filter Table */ > - reg = E1000_READ_REG(hw, E1000_RCTL); > - reg &= ~E1000_RCTL_CFIEN; > - reg |= E1000_RCTL_VFE; > - E1000_WRITE_REG(hw, E1000_RCTL, reg); > + em_if_vlan_filter_enable(adapter); > } > > static void > @@ -3481,6 +3564,7 @@ em_if_intr_enable(if_ctx_t ctx) > ims_mask |= adapter->ims; > } > E1000_WRITE_REG(hw, E1000_IMS, ims_mask); > + E1000_WRITE_FLUSH(hw); > } > > static void > @@ -3492,6 +3576,7 @@ em_if_intr_disable(if_ctx_t ctx) > if (adapter->intr_type == IFLIB_INTR_MSIX) > E1000_WRITE_REG(hw, EM_EIAC, 0); > E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); > + E1000_WRITE_FLUSH(hw); > } > > static void > @@ -4101,6 +4186,7 @@ em_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event) > { > switch (event) { > case IFLIB_RESTART_VLAN_CONFIG: > + return (false); > default: > return (true); > } > _______________________________________________ > dev-commits-src-main@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main > To unsubscribe, send any mail to "dev-commits-src-main-unsubscribe@freebsd.org"