From owner-svn-src-all@freebsd.org Sun Feb 19 05:06:30 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 676EFCDB0F0; Sun, 19 Feb 2017 05:06:30 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2806FAFE; Sun, 19 Feb 2017 05:06:30 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1J56TAa003989; Sun, 19 Feb 2017 05:06:29 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1J56Thb003988; Sun, 19 Feb 2017 05:06:29 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201702190506.v1J56Thb003988@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Sun, 19 Feb 2017 05:06:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313935 - head/sys/dev/e1000 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2017 05:06:30 -0000 Author: sbruno Date: Sun Feb 19 05:06:29 2017 New Revision: 313935 URL: https://svnweb.freebsd.org/changeset/base/313935 Log: Restore PBA setup for igb(4) class devices. Do no write to PBA register on igb(4) devices unless we need to make adjustments for the 82575 and jumbo frames. Remove redundant LPE/~LPE assignments. Move e1000_lv_jumbo_workaround_ich8lan() invokcation into a block so that its not executed in the igb case. Move em(4) class assignments of RCTL values to its own code block. Adjust a few direct accesses of ifp->mtu to use accessor functions. PR: 216734 Submitted by: Kaho Toshikazu Modified: head/sys/dev/e1000/if_em.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Sun Feb 19 03:57:41 2017 (r313934) +++ head/sys/dev/e1000/if_em.c Sun Feb 19 05:06:29 2017 (r313935) @@ -2238,13 +2238,62 @@ em_reset(if_ctx_t ctx) case e1000_pch_spt: pba = E1000_PBA_26K; break; + case e1000_82575: + pba = E1000_PBA_32K; + break; + case e1000_82576: + case e1000_vfadapt: + pba = E1000_READ_REG(hw, E1000_RXPBS); + pba &= E1000_RXPBS_SIZE_MASK_82576; + break; + case e1000_82580: + case e1000_i350: + case e1000_i354: + case e1000_vfadapt_i350: + pba = E1000_READ_REG(hw, E1000_RXPBS); + pba = e1000_rxpbs_adjust_82580(pba); + break; + case e1000_i210: + case e1000_i211: + pba = E1000_PBA_34K; + break; default: if (adapter->hw.mac.max_frame_size > 8192) pba = E1000_PBA_40K; /* 40K for Rx, 24K for Tx */ else pba = E1000_PBA_48K; /* 48K for Rx, 16K for Tx */ } - E1000_WRITE_REG(&adapter->hw, E1000_PBA, pba); + + /* Special needs in case of Jumbo frames */ + if ((hw->mac.type == e1000_82575) && (ifp->if_mtu > ETHERMTU)) { + u32 tx_space, min_tx, min_rx; + pba = E1000_READ_REG(hw, E1000_PBA); + tx_space = pba >> 16; + pba &= 0xffff; + min_tx = (adapter->hw.mac.max_frame_size + + sizeof(struct e1000_tx_desc) - ETHERNET_FCS_SIZE) * 2; + min_tx = roundup2(min_tx, 1024); + min_tx >>= 10; + min_rx = adapter->hw.mac.max_frame_size; + min_rx = roundup2(min_rx, 1024); + min_rx >>= 10; + if (tx_space < min_tx && + ((min_tx - tx_space) < pba)) { + pba = pba - (min_tx - tx_space); + /* + * if short on rx space, rx wins + * and must trump tx adjustment + */ + if (pba < min_rx) + pba = min_rx; + } + E1000_WRITE_REG(hw, E1000_PBA, pba); + } + + if (hw->mac.type < igb_mac_min) + E1000_WRITE_REG(&adapter->hw, E1000_PBA, pba); + + INIT_DEBUGOUT1("em_reset: pba=%dK",pba); /* * These parameters control the automatic generation (Tx) and @@ -2260,7 +2309,7 @@ em_reset(if_ctx_t ctx) * by 1500. * - The pause time is fairly large at 1000 x 512ns = 512 usec. */ - rx_buffer_size = ((E1000_READ_REG(hw, E1000_PBA) & 0xffff) << 10 ); + rx_buffer_size = (pba & 0xffff) << 10; hw->fc.high_water = rx_buffer_size - roundup2(adapter->hw.mac.max_frame_size, 1024); hw->fc.low_water = hw->fc.high_water - 1500; @@ -2305,6 +2354,21 @@ em_reset(if_ctx_t ctx) else E1000_WRITE_REG(hw, E1000_PBA, 26); break; + case e1000_82575: + case e1000_82576: + /* 8-byte granularity */ + hw->fc.low_water = hw->fc.high_water - 8; + break; + case e1000_82580: + case e1000_i350: + case e1000_i354: + case e1000_i210: + case e1000_i211: + case e1000_vfadapt: + case e1000_vfadapt_i350: + /* 16-byte granularity */ + hw->fc.low_water = hw->fc.high_water - 16; + break; case e1000_ich9lan: case e1000_ich10lan: if (if_getmtu(ifp) > ETHERMTU) { @@ -2975,9 +3039,7 @@ em_initialize_receive_unit(if_ctx_t ctx) } else if (adapter->hw.mac.type >= igb_mac_min) { u32 psize, srrctl = 0; - if (ifp->if_mtu > ETHERMTU) { - rctl |= E1000_RCTL_LPE; - + if (if_getmtu(ifp) > ETHERMTU) { /* Set maximum packet len */ psize = scctx->isc_max_frame_size; if (psize <= 4096) { @@ -2993,7 +3055,6 @@ em_initialize_receive_unit(if_ctx_t ctx) psize += VLAN_TAG_SIZE; E1000_WRITE_REG(&adapter->hw, E1000_RLPML, psize); } else { - rctl &= ~E1000_RCTL_LPE; srrctl |= 2048 >> E1000_SRRCTL_BSIZEPKT_SHIFT; rctl |= E1000_RCTL_SZ_2048; } @@ -3039,8 +3100,7 @@ em_initialize_receive_unit(if_ctx_t ctx) rxdctl |= IGB_RX_WTHRESH << 16; E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl); } - } - if (adapter->hw.mac.type >= e1000_pch2lan) { + } else if (adapter->hw.mac.type >= e1000_pch2lan) { if (if_getmtu(ifp) > ETHERMTU) e1000_lv_jumbo_workaround_ich8lan(hw, TRUE); else @@ -3050,15 +3110,18 @@ em_initialize_receive_unit(if_ctx_t ctx) /* Make sure VLAN Filters are off */ rctl &= ~E1000_RCTL_VFE; - if (adapter->rx_mbuf_sz == MCLBYTES) - rctl |= E1000_RCTL_SZ_2048; - else if (adapter->rx_mbuf_sz == MJUMPAGESIZE) - rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; - else if (adapter->rx_mbuf_sz > MJUMPAGESIZE) - rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; + if (adapter->hw.mac.type < igb_mac_min) { + if (adapter->rx_mbuf_sz == MCLBYTES) + rctl |= E1000_RCTL_SZ_2048; + else if (adapter->rx_mbuf_sz == MJUMPAGESIZE) + rctl |= E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX; + else if (adapter->rx_mbuf_sz > MJUMPAGESIZE) + rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX; + + /* ensure we clear use DTYPE of 00 here */ + rctl &= ~0x00000C00; + } - /* ensure we clear use DTYPE of 00 here */ - rctl &= ~0x00000C00; /* Write out the settings */ E1000_WRITE_REG(hw, E1000_RCTL, rctl);