[PATCH 34/39] mv643xx_eth: detect extended rx coal register field

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Dale Farnsworth <dale@...>
Cc: <netdev@...>
Date: Tuesday, June 3, 2008 - 7:02 am

Newer hardware has a 16-bit instead of a 14-bit RX coalescing
count field in the SDMA_CONFIG register.  This patch adds a run-time
check for which of the two we have, and adjusts further writes to the
rx coal count field accordingly.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
 drivers/net/mv643xx_eth.c |   38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 8e4ca2b..4168a8a 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -240,6 +240,7 @@ struct mv643xx_eth_shared_private {
 	 * Hardware-specific parameters.
 	 */
 	unsigned int t_clk;
+	int extended_rx_coal_limit;
 };
 
 
@@ -1796,14 +1797,22 @@ static void port_start(struct mv643xx_eth_private *mep)
 static void set_rx_coal(struct mv643xx_eth_private *mep, unsigned int delay)
 {
 	unsigned int coal = ((mep->shared->t_clk / 1000000) * delay) / 64;
+	u32 val;
 
-	if (coal > 0x3fff)
-		coal = 0x3fff;
-
-	wrl(mep, SDMA_CONFIG(mep->port_num),
-		((coal & 0x3fff) << 8) |
-		(rdl(mep, SDMA_CONFIG(mep->port_num))
-			& 0xffc000ff));
+	val = rdl(mep, SDMA_CONFIG(mep->port_num));
+	if (mep->shared->extended_rx_coal_limit) {
+		if (coal > 0xffff)
+			coal = 0xffff;
+		val &= ~0x023fff80;
+		val |= (coal & 0x8000) << 10;
+		val |= (coal & 0x7fff) << 7;
+	} else {
+		if (coal > 0x3fff)
+			coal = 0x3fff;
+		val &= ~0x003fff00;
+		val |= (coal & 0x3fff) << 8;
+	}
+	wrl(mep, SDMA_CONFIG(mep->port_num), val);
 }
 
 static void set_tx_coal(struct mv643xx_eth_private *mep, unsigned int delay)
@@ -2068,6 +2077,20 @@ mv643xx_eth_conf_mbus_windows(struct mv643xx_eth_shared_private *mesp,
 	mesp->win_protect = win_protect;
 }
 
+static void infer_hw_params(struct mv643xx_eth_shared_private *mesp)
+{
+	/*
+	 * Check whether we have a 14-bit coal limit field in bits
+	 * [21:8], or a 16-bit coal limit in bits [25,21:7] of the
+	 * SDMA config register.
+	 */
+	writel(0x02000000, mesp->base + SDMA_CONFIG(0));
+	if (readl(mesp->base + SDMA_CONFIG(0)) & 0x02000000)
+		mesp->extended_rx_coal_limit = 1;
+	else
+		mesp->extended_rx_coal_limit = 0;
+}
+
 static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 {
 	static int mv643xx_eth_version_printed = 0;
@@ -2106,6 +2129,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 	 * Detect hardware parameters.
 	 */
 	mesp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
+	infer_hw_params(mesp);
 
 	platform_set_drvdata(pdev, mesp);
 
-- 
1.5.3.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/39] mv643xx_eth: complete overhaul, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 29/39] mv643xx_eth: general cleanup, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 29/39] mv643xx_eth: general cleanup, Dale Farnsworth, (Thu Jun 5, 8:33 am)
Re: [PATCH 29/39] mv643xx_eth: general cleanup, Lennert Buytenhek, (Fri Jun 6, 4:24 am)
Re: [PATCH 29/39] mv643xx_eth: general cleanup, Dale Farnsworth, (Fri Jun 6, 6:59 am)
[PATCH 19/39] mv643xx_eth: kill -&gt;rx_resource_err, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 19/39] mv643xx_eth: kill -&gt;rx_resource_err, Dale Farnsworth, (Thu Jun 5, 7:48 am)
[PATCH 10/39] mv643xx_eth: clarify irq masking and unmasking, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 02/39] mv643xx_eth: trim unnecessary includes, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 02/39] mv643xx_eth: trim unnecessary includes, Dale Farnsworth, (Thu Jun 5, 7:02 am)
Re: [PATCH 02/39] mv643xx_eth: trim unnecessary includes, Lennert Buytenhek, (Fri Jun 6, 4:18 am)
Re: [PATCH 02/39] mv643xx_eth: trim unnecessary includes, Dale Farnsworth, (Fri Jun 6, 6:55 am)
[PATCH 03/39] mv643xx_eth: shorten reg names, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 18/39] mv643xx_eth: kill superfluous comments, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 18/39] mv643xx_eth: kill superfluous comments, Dale Farnsworth, (Thu Jun 5, 8:03 am)
Re: [PATCH 03/39] mv643xx_eth: shorten reg names, Dale Farnsworth, (Thu Jun 5, 7:21 am)
[PATCH 12/39] mv643xx_eth: get rid of RX_BUF_OFFSET, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 12/39] mv643xx_eth: get rid of RX_BUF_OFFSET, Dale Farnsworth, (Thu Jun 5, 7:37 am)
[PATCH 11/39] mv643xx_eth: move PHY wait defines into callers, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 09/39] mv643xx_eth: remove unused DESC_SIZE define, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 27/39] mv643xx_eth: split out tx queue state, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 26/39] mv643xx_eth: split out rx queue state, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 26/39] mv643xx_eth: split out rx queue state, Dale Farnsworth, (Thu Jun 5, 8:39 am)
Re: [PATCH 27/39] mv643xx_eth: split out tx queue state, Dale Farnsworth, (Thu Jun 5, 8:09 am)
[PATCH 32/39] mv643xx_eth: allow multiple TX queues, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 32/39] mv643xx_eth: allow multiple TX queues, Dale Farnsworth, (Thu Jun 5, 8:41 am)
[PATCH 31/39] mv643xx_eth: allow multiple RX queues, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 31/39] mv643xx_eth: allow multiple RX queues, Dale Farnsworth, (Thu Jun 5, 8:35 am)
[PATCH 34/39] mv643xx_eth: detect extended rx coal register ..., Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 33/39] mv643xx_eth: work around TX hang hardware issue, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 23/39] mv643xx_eth: kill FUNC_RET_STATUS/pkt_info, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 30/39] mv643xx_eth: add tx rate control, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 30/39] mv643xx_eth: add tx rate control, Dale Farnsworth, (Thu Jun 5, 8:51 am)
[PATCH 36/39] mv643xx_eth: be more agressive about RX refill, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
[PATCH 38/39] mv643xx_eth: add PHY-less mode, Lennert Buytenhek, (Tue Jun 3, 7:02 am)
Re: [PATCH 38/39] mv643xx_eth: add PHY-less mode, Dale Farnsworth, (Thu Jun 5, 8:49 am)