Patchwork [U-Boot] e1000e : Set Receive Threshold granularity to number of

login
register
mail settings
Submitter Ruchika Gupta
Date April 19, 2012, 11:28 a.m.
Message ID <1334834928-27157-1-git-send-email-ruchika.gupta@freescale.com>
Download mbox | patch
Permalink /patch/153654/
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Comments

Wolfgang Denk - April 19, 2012, 6:35 a.m.
Dear Ruchika Gupta,

In message <1334834928-27157-1-git-send-email-ruchika.gupta@freescale.com> you wrote:
> In RXDCTL register, WTHRESH controls the write back of processed receive
> descriptors. WTHRESH controls the write back of processed receive
> descriptors. ...


Please fix both the Subject (which is truncated and too long anyway) and the
commit message (which is redundant).


Best regards,

Wolfgang Denk
Ruchika Gupta - April 19, 2012, 11:28 a.m.
In RXDCTL register, WTHRESH controls the write back of processed receive
descriptors. WTHRESH controls the write back of processed receive
descriptors. This threshold refers to the number of receive
descriptors in the Ethernet controllers on-chip buffer which are
ready to be written back to host memory. In the absence of
external events (explicit flushes), the write back occurs only after
more than WTHRESH descriptors are available for write back.
A value of WTHRESH can be in either cache line units, or based on
number of descriptors based on RXDCTL.GRAN. By default it is set to
cache line granularoty.

In e1000e driver, receive descriptor queue is configured such that
hardware can add only 1 descriptor at a time. So the WTHRESH granularity
should be set to single descriptor. This would ensure that every time 
controller fills a Rx descriptor, it is flushed to host memory.

This change fixes timeout which was seen when tftping large files.

Signed-off-by: Ruchika Gupta <ruchika.gupta@freescale.com>
Signed-off-by: Vakul Garg <vakul@freescale.com>
Acked-by: Roy Zang <tie-fei.zang@freescale.com>
---
 drivers/net/e1000.c |   10 ++++++++++
 drivers/net/e1000.h |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 98145bc..1f3c2b0 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -1703,6 +1703,16 @@  e1000_init_hw(struct eth_device *nic)
 		E1000_WRITE_REG(hw, TXDCTL, ctrl);
 	}
 
+	/* Set the receive descriptor write back policy */
+
+	if (hw->mac_type >= e1000_82571) {
+		ctrl = E1000_READ_REG(hw, RXDCTL);
+		ctrl =
+		    (ctrl & ~E1000_RXDCTL_WTHRESH) |
+		    E1000_RXDCTL_FULL_RX_DESC_WB;
+		E1000_WRITE_REG(hw, RXDCTL, ctrl);
+	}
+
 	switch (hw->mac_type) {
 	default:
 		break;
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index 720d8c6..cdb0e36 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -1518,6 +1518,7 @@  struct e1000_hw {
 #define E1000_RXDCTL_HTHRESH 0x00003F00	/* RXDCTL Host Threshold */
 #define E1000_RXDCTL_WTHRESH 0x003F0000	/* RXDCTL Writeback Threshold */
 #define E1000_RXDCTL_GRAN    0x01000000	/* RXDCTL Granularity */
+#define E1000_RXDCTL_FULL_RX_DESC_WB 0x01010000	/* GRAN=1, WTHRESH=1 */
 
 /* Transmit Descriptor Control */
 #define E1000_TXDCTL_PTHRESH 0x0000003F	/* TXDCTL Prefetch Threshold */