From owner-dev-commits-src-all@freebsd.org Tue Aug 10 19:47:54 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 320BA66D9AD; Tue, 10 Aug 2021 19:47:54 +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 4Gkk560WqMz50qk; Tue, 10 Aug 2021 19:47:54 +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 EE867217D8; Tue, 10 Aug 2021 19:47:53 +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 17AJlr3v085230; Tue, 10 Aug 2021 19:47:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17AJlr8r085229; Tue, 10 Aug 2021 19:47:53 GMT (envelope-from git) Date: Tue, 10 Aug 2021 19:47:53 GMT Message-Id: <202108101947.17AJlr8r085229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 12e8addd320d - main - e1000: rctl/srrctl buffer size init, rfctl fix 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: 12e8addd320df995bfb2b00f51c233541f741ae4 Auto-Submitted: auto-generated 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: Tue, 10 Aug 2021 19:47:54 -0000 The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=12e8addd320df995bfb2b00f51c233541f741ae4 commit 12e8addd320df995bfb2b00f51c233541f741ae4 Author: Kevin Bowling AuthorDate: 2021-08-10 19:47:22 +0000 Commit: Kevin Bowling CommitDate: 2021-08-10 19:47:22 +0000 e1000: rctl/srrctl buffer size init, rfctl fix Simplify the setup of srrctl.BSIZEPKT on igb class NICs. Improve the setup of rctl.BSIZE on lem and em class NICs. Don't try to touch rfctl on lem class NICs. Manipulate rctl.BSEX correctly on lem and em class NICs. Approved by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31457 --- sys/dev/e1000/if_em.c | 76 +++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 52d20e57519a..33d5341ed8ce 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -3170,6 +3170,7 @@ em_initialize_transmit_unit(if_ctx_t ctx) * Enable receive unit. * **********************************************************************/ +#define BSIZEPKT_ROUNDUP ((1<hw; struct em_rx_queue *que; int i; - u32 rctl, rxcsum, rfctl; + uint32_t rctl, rxcsum; INIT_DEBUGOUT("em_initialize_receive_units: begin"); @@ -3224,21 +3225,25 @@ em_initialize_receive_unit(if_ctx_t ctx) } E1000_WRITE_REG(hw, E1000_RDTR, adapter->rx_int_delay.value); - /* Use extended rx descriptor formats */ - rfctl = E1000_READ_REG(hw, E1000_RFCTL); - rfctl |= E1000_RFCTL_EXTEN; - /* - * When using MSI-X interrupts we need to throttle - * using the EITR register (82574 only) - */ - if (hw->mac.type == e1000_82574) { - for (int i = 0; i < 4; i++) - E1000_WRITE_REG(hw, E1000_EITR_82574(i), - DEFAULT_ITR); - /* Disable accelerated acknowledge */ - rfctl |= E1000_RFCTL_ACK_DIS; + if (hw->mac.type >= em_mac_min) { + uint32_t rfctl; + /* Use extended rx descriptor formats */ + rfctl = E1000_READ_REG(hw, E1000_RFCTL); + rfctl |= E1000_RFCTL_EXTEN; + + /* + * When using MSI-X interrupts we need to throttle + * using the EITR register (82574 only) + */ + if (hw->mac.type == e1000_82574) { + for (int i = 0; i < 4; i++) + E1000_WRITE_REG(hw, E1000_EITR_82574(i), + DEFAULT_ITR); + /* Disable accelerated acknowledge */ + rfctl |= E1000_RFCTL_ACK_DIS; + } + E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); } - E1000_WRITE_REG(hw, E1000_RFCTL, rfctl); rxcsum = E1000_READ_REG(hw, E1000_RXCSUM); if (if_getcapenable(ifp) & IFCAP_RXCSUM && @@ -3323,24 +3328,17 @@ em_initialize_receive_unit(if_ctx_t ctx) u32 psize, srrctl = 0; if (if_getmtu(ifp) > ETHERMTU) { - /* Set maximum packet len */ - if (adapter->rx_mbuf_sz <= 4096) { - srrctl |= 4096 >> E1000_SRRCTL_BSIZEPKT_SHIFT; - rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; - } else if (adapter->rx_mbuf_sz > 4096) { - srrctl |= 8192 >> E1000_SRRCTL_BSIZEPKT_SHIFT; - rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; - } psize = scctx->isc_max_frame_size; /* are we on a vlan? */ if (ifp->if_vlantrunk != NULL) psize += VLAN_TAG_SIZE; E1000_WRITE_REG(hw, E1000_RLPML, psize); - } else { - srrctl |= 2048 >> E1000_SRRCTL_BSIZEPKT_SHIFT; - rctl |= E1000_RCTL_SZ_2048; } + /* Set maximum packet buffer len */ + srrctl |= (adapter->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >> + E1000_SRRCTL_BSIZEPKT_SHIFT; + /* * If TX flow control is disabled and there's >1 queue defined, * enable DROP. @@ -3391,17 +3389,29 @@ em_initialize_receive_unit(if_ctx_t ctx) /* Make sure VLAN Filters are off */ rctl &= ~E1000_RCTL_VFE; + /* Set up packet buffer size, overridden by per queue srrctl on igb */ if (hw->mac.type < igb_mac_min) { - if (adapter->rx_mbuf_sz == MCLBYTES) - rctl |= E1000_RCTL_SZ_2048; - else if (adapter->rx_mbuf_sz == MJUMPAGESIZE) + if (adapter->rx_mbuf_sz > 2048 && adapter->rx_mbuf_sz <= 4096) rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; - else if (adapter->rx_mbuf_sz > MJUMPAGESIZE) + else if (adapter->rx_mbuf_sz > 4096 && adapter->rx_mbuf_sz <= 8192) rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; + else if (adapter->rx_mbuf_sz > 8192) + rctl |= E1000_RCTL_SZ_16384 | E1000_RCTL_BSEX; + else { + rctl |= E1000_RCTL_SZ_2048; + rctl &= ~E1000_RCTL_BSEX; + } + } else + rctl |= E1000_RCTL_SZ_2048; - /* ensure we clear use DTYPE of 00 here */ - rctl &= ~0x00000C00; - } + /* + * rctl bits 11:10 are as follows + * lem: reserved + * em: DTYPE + * igb: reserved + * and should be 00 on all of the above + */ + rctl &= ~0x00000C00; /* Write out the settings */ E1000_WRITE_REG(hw, E1000_RCTL, rctl);