svn commit: r313935 - head/sys/dev/e1000

Sean Bruno sbruno at FreeBSD.org
Sun Feb 19 05:06:30 UTC 2017


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 <kaho at elam.kais.kyoto-u.ac.jp>

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);
 


More information about the svn-src-head mailing list