* [PATCH 3/3] sky2: beter ram buffer partitioning
@ 2006-12-04 23:53 Stephen Hemminger
2006-12-05 1:08 ` [PATCH] sky2: receive queue watermark tweak Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2006-12-04 23:53 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
Different chips have different sizes of ram buffers, and some versions have
no ram buffer at all!. Be more careful about sizing the ram usage because
it maybe a problem if vendor keeps changing sizes.
There is the (unlikely) possibility that some of the errors on some of the
chips have been caused by partitioning not on a 1K boundary.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
---
drivers/net/sky2.c | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
--- sky2.orig/drivers/net/sky2.c 2006-12-04 12:47:19.000000000 -0800
+++ sky2/drivers/net/sky2.c 2006-12-04 13:19:49.000000000 -0800
@@ -696,10 +696,15 @@
}
-/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
-static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
+/* Assign Ram Buffer allocation to queue */
+static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
{
- pr_debug(PFX "q %d %#x %#x\n", q, start, end);
+ u32 end;
+
+ /* convert from K bytes to qwords used for hw register */
+ start *= 1024/8;
+ space *= 1024/8;
+ end = start + space - 1;
sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -708,7 +713,6 @@
sky2_write32(hw, RB_ADDR(q, RB_RP), start);
if (q == Q_R1 || q == Q_R2) {
- u32 space = end - start + 1;
u32 tp = space - space/4;
/* On receive queue's set the thresholds
@@ -1138,7 +1142,7 @@
struct sky2_port *sky2 = netdev_priv(dev);
struct sky2_hw *hw = sky2->hw;
unsigned port = sky2->port;
- u32 ramsize, rxspace, imask;
+ u32 ramsize, imask;
int cap, err = -ENOMEM;
struct net_device *otherdev = hw->dev[sky2->port^1];
@@ -1191,20 +1195,25 @@
sky2_mac_init(hw, port);
- /* Determine available ram buffer space in qwords. */
- ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
+ /* Register is number of 4K blocks on internal RAM buffer. */
+ ramsize = sky2_read8(hw, B2_E_0) * 4;
+ printk(KERN_INFO PFX "%s: ram buffer %dK\n", dev->name, ramsize);
- if (ramsize > 6*1024/8)
- rxspace = ramsize - (ramsize + 2) / 3;
- else
- rxspace = ramsize / 2;
+ if (ramsize > 0) {
+ u32 rxspace;
- sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
- sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
+ if (ramsize < 16)
+ rxspace = ramsize / 2;
+ else
+ rxspace = 8 + (2*(ramsize - 16))/3;
- /* Make sure SyncQ is disabled */
- sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
- RB_RST_SET);
+ 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);
+ }
sky2_qset(hw, txqaddr[port]);
--
Stephen Hemminger <shemminger@osdl.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] sky2: receive queue watermark tweak
2006-12-04 23:53 [PATCH 3/3] sky2: beter ram buffer partitioning Stephen Hemminger
@ 2006-12-05 1:08 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2006-12-05 1:08 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev
This patch makes the receive performance on some systems go from
714MB/s to 941MB/s. It adjusts the watermark of the receive queue
to be lower, thereby avoiding excess hardware flow control. This is
most important on the systems which have little/no additional buffering.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
---
drivers/net/sky2.c | 11 ++++++++---
drivers/net/sky2.h | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
--- sky2.orig/drivers/net/sky2.c 2006-12-04 16:53:22.000000000 -0800
+++ sky2/drivers/net/sky2.c 2006-12-04 17:03:51.000000000 -0800
@@ -1062,11 +1062,16 @@
sky2->rx_put = sky2->rx_next = 0;
sky2_qset(hw, rxq);
+ /* On PCI express lowering the watermark gives better performance */
+ if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
+ sky2_write32(hw, Q_ADDR(rxq, Q_WM), BMU_WM_PEX);
+
+ /* These chips have no ram buffer?
+ * MAC Rx RAM Read is controlled by hardware */
if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
- (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0)) {
- /* MAC Rx RAM Read is controlled by hardware */
+ (hw->chip_rev == CHIP_REV_YU_EC_U_A1
+ || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
- }
sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
--- sky2.orig/drivers/net/sky2.h 2006-12-04 16:56:24.000000000 -0800
+++ sky2/drivers/net/sky2.h 2006-12-04 17:01:05.000000000 -0800
@@ -680,6 +680,7 @@
BMU_FIFO_ENA | BMU_OP_ON,
BMU_WM_DEFAULT = 0x600,
+ BMU_WM_PEX = 0x80,
};
/* Tx BMU Control / Status Registers (Yukon-2) */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-05 1:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04 23:53 [PATCH 3/3] sky2: beter ram buffer partitioning Stephen Hemminger
2006-12-05 1:08 ` [PATCH] sky2: receive queue watermark tweak Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).