Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-02-26 17:18:39 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2007-03-02 16:32:46 -0800
commit074023e131b7ecba0f7d9ba43ba0df322fc8f129 (patch)
treeb1e2fb05659466aa98ee3c95ea3032bdfeb937a9
parent1df6a4c30fbd43d9c3baf0dcdb2c60af688f0803 (diff)
sky2: fix ram buffer allocation settings
Different chipsets have different amount of ram buffer (some have none), so need to make sure that driver does proper setup for all cases from 0 on to 48K, in units of 1K. This is a backport of the code from 2.6.19 or later Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/net/sky2.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index ea11d510c4d7..71f7126e7915 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -700,8 +700,14 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
}
/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
-static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
+static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
{
+ u32 end;
+
+ start *= 1024/8;
+ space *= 1024/8;
+ end = start + space - 1;
+
pr_debug(PFX "q %d %#x %#x\n", q, start, end);
sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
@@ -1193,20 +1199,21 @@ static int sky2_up(struct net_device *dev)
sky2_mac_init(hw, port);
- /* Determine available ram buffer space in qwords. */
- ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
-
- if (ramsize > 6*1024/8)
- rxspace = ramsize - (ramsize + 2) / 3;
- else
- rxspace = ramsize / 2;
+ /* Determine available ram buffer space (in 4K blocks). */
+ ramsize = sky2_read8(hw, B2_E_0) * 4;
+ if (ramsize != 0) {
+ if (ramsize < 16)
+ rxspace = ramsize / 2;
+ else
+ rxspace = 8 + (2*(ramsize - 16))/3;
- sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
- sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
+ sky2_ramset(hw, rxqaddr[port], 0, rxspace);
+ sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
- /* Make sure SyncQ is disabled */
- sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
- RB_RST_SET);
+ /* Make sure SyncQ is disabled */
+ sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
+ RB_RST_SET);
+ }
sky2_qset(hw, txqaddr[port]);