[PATCH] [0/6] Bugfixes for pasemi_mac

STALE6918d

11 messages, 3 authors, 2007-09-29 · open the first message on its own page

[PATCH] [0/6] Bugfixes for pasemi_mac

From: Olof Johansson <hidden>
Date: 2007-09-26 21:18:50

Hi,

Following patches are for various bug fixes against current netdev-2.6.24
upstream branch. Please apply.


[PATCH] [1/6] pasemi_mac: fix build break in pasemi_mac_probe()
[PATCH] [2/6] pasemi_mac: fix build break in pasemi_mac_clean_rx()
[PATCH] [3/6] pasemi_mac: set interface speed correctly on XAUI ports
[PATCH] [4/6] pasemi_mac: flags as passed to spin_*_irqsave() should be unsigned long
[PATCH] [5/6] pasemi_mac: don't enable rx before there are buffers on the ring
[PATCH] [6/6] pasemi_mac: pass in count of buffers to replenish rx ring with


Thanks,

-Olof

[PATCH] [1/6] pasemi_mac: fix build break in pasemi_mac_probe()

From: Olof Johansson <hidden>
Date: 2007-09-26 21:19:33

pasemi_mac: fix build break in pasemi_mac_probe()

Fix breakage caused by recent unification of print_mac() stuff.


Signed-off-by: Olof Johansson <redacted>

Index: k.org/drivers/net/pasemi_mac.c
===================================================================
--- k.org.orig/drivers/net/pasemi_mac.c
+++ k.org/drivers/net/pasemi_mac.c
@@ -1155,7 +1155,7 @@ pasemi_mac_probe(struct pci_dev *pdev, c
 	struct net_device *dev;
 	struct pasemi_mac *mac;
 	int err;
-	DECLARE_MAC_BUF(mac);
+	DECLARE_MAC_BUF(mac_buf);
 
 	err = pci_enable_device(pdev);
 	if (err)
@@ -1241,7 +1241,7 @@ pasemi_mac_probe(struct pci_dev *pdev, c
 		       "hw addr %s\n",
 		       dev->name, mac->type == MAC_TYPE_GMAC ? "GMAC" : "XAUI",
 		       mac->dma_if, mac->dma_txch, mac->dma_rxch,
-		       print_mac(mac, dev->dev_addr));
+		       print_mac(mac_buf, dev->dev_addr));
 
 	return err;
 

[PATCH] [2/6] pasemi_mac: fix build break in pasemi_mac_clean_rx()

From: Olof Johansson <hidden>
Date: 2007-09-26 21:19:57

pasemi_mac: fix build break in pasemi_mac_clean_rx()

Fix breakage caused by the unification of stats structs.


Signed-off-by: Olof Johansson <redacted>

Index: k.org/drivers/net/pasemi_mac.c
===================================================================
--- k.org.orig/drivers/net/pasemi_mac.c
+++ k.org/drivers/net/pasemi_mac.c
@@ -530,8 +530,8 @@ static int pasemi_mac_clean_rx(struct pa
 		} else
 			skb->ip_summed = CHECKSUM_NONE;
 
-		dev->stats.rx_bytes += len;
-		dev->stats.rx_packets++;
+		mac->netdev->stats.rx_bytes += len;
+		mac->netdev->stats.rx_packets++;
 
 		skb->protocol = eth_type_trans(skb, mac->netdev);
 		netif_receive_skb(skb);

[PATCH] [3/6] pasemi_mac: set interface speed correctly on XAUI ports

From: Olof Johansson <hidden>
Date: 2007-09-26 21:20:22

pasemi_mac: set interface speed correctly on XAUI ports

Set interface speed for XAUI to 10G per default, not 1G.

Signed-off-by: Olof Johansson <redacted>

Index: 2.6.23/drivers/net/pasemi_mac.c
===================================================================
--- 2.6.23.orig/drivers/net/pasemi_mac.c
+++ 2.6.23/drivers/net/pasemi_mac.c
@@ -794,7 +794,10 @@ static int pasemi_mac_open(struct net_de
 	flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE |
 		PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;
 
-	flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G;
+	if (mac->type == MAC_TYPE_GMAC)
+		flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G;
+	else
+		flags |= PAS_MAC_CFG_PCFG_TSR_10G | PAS_MAC_CFG_PCFG_SPD_10G;
 
 	write_iob_reg(mac, PAS_IOB_DMA_RXCH_CFG(mac->dma_rxch),
 			   PAS_IOB_DMA_RXCH_CFG_CNTTH(0));

[PATCH] [5/6] pasemi_mac: flags as passed to spin_*_irqsave() should be unsigned long

From: Olof Johansson <hidden>
Date: 2007-09-26 21:20:50

pasemi_mac: flags as passed to spin_*_irqsave() should be unsigned long.

Signed-off-by: Tony Breeds <redacted>
Signed-off-by: Olof Johansson <redacted>

---
Found trying to build a -rt kernel, which has a BUILD_BUG_ON(), in this
caswe.

 drivers/net/pasemi_mac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: k.org/drivers/net/pasemi_mac.c
===================================================================
--- k.org.orig/drivers/net/pasemi_mac.c
+++ k.org/drivers/net/pasemi_mac.c
@@ -557,7 +557,7 @@ static int pasemi_mac_clean_tx(struct pa
 	struct pas_dma_xct_descr *dp;
 	unsigned int start, count, limit;
 	unsigned int total_count;
-	int flags;
+	unsigned long flags;
 	struct sk_buff *skbs[32];
 	dma_addr_t dmas[32];
 
@@ -978,7 +978,7 @@ static int pasemi_mac_start_tx(struct sk
 	struct pas_dma_xct_descr *dp;
 	u64 dflags, mactx, ptr;
 	dma_addr_t map;
-	int flags;
+	unsigned long flags;
 
 	dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_SS | XCT_MACTX_CRC_PAD;
 

[PATCH] [5/6] pasemi_mac: don't enable rx before there are buffers on the ring

From: Olof Johansson <hidden>
Date: 2007-09-26 21:21:33

pasemi_mac: don't enable rx before there are buffers on the ring

Reorder initialization of the DMA channels and the interface. Before there
was a time window when the interface was enabled before DMA was enabled.
Also, now there will always be RX buffers available at the time the
MAC interface is enabled, to avoid temporary out-of-buffer errors for the
very first packets (on busy networks).


Signed-off-by: Olof Johansson <redacted>


Index: 2.6.23/drivers/net/pasemi_mac.c
===================================================================
--- 2.6.23.orig/drivers/net/pasemi_mac.c
+++ 2.6.23/drivers/net/pasemi_mac.c
@@ -791,14 +791,6 @@ static int pasemi_mac_open(struct net_de
 
 	write_mac_reg(mac, PAS_MAC_CFG_TXP, flags);
 
-	flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE |
-		PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;
-
-	if (mac->type == MAC_TYPE_GMAC)
-		flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G;
-	else
-		flags |= PAS_MAC_CFG_PCFG_TSR_10G | PAS_MAC_CFG_PCFG_SPD_10G;
-
 	write_iob_reg(mac, PAS_IOB_DMA_RXCH_CFG(mac->dma_rxch),
 			   PAS_IOB_DMA_RXCH_CFG_CNTTH(0));
 
@@ -813,8 +805,6 @@ static int pasemi_mac_open(struct net_de
 	write_iob_reg(mac, PAS_IOB_DMA_COM_TIMEOUTCFG,
 			   PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(0xffffff));
 
-	write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags);
-
 	ret = pasemi_mac_setup_rx_resources(dev);
 	if (ret)
 		goto out_rx_resources;
@@ -842,6 +832,17 @@ static int pasemi_mac_open(struct net_de
 
 	pasemi_mac_replenish_rx_ring(dev);
 
+	flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE |
+		PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;
+
+	if (mac->type == MAC_TYPE_GMAC)
+		flags |= PAS_MAC_CFG_PCFG_TSR_1G | PAS_MAC_CFG_PCFG_SPD_1G;
+	else
+		flags |= PAS_MAC_CFG_PCFG_TSR_10G | PAS_MAC_CFG_PCFG_SPD_10G;
+
+	/* Enable interface in MAC */
+	write_mac_reg(mac, PAS_MAC_CFG_PCFG, flags);
+
 	ret = pasemi_mac_phy_init(dev);
 	/* Some configs don't have PHYs (XAUI etc), so don't complain about
 	 * failed init due to -ENODEV.

[PATCH] [6/6] pasemi_mac: pass in count of buffers to replenish rx ring with

From: Olof Johansson <hidden>
Date: 2007-09-26 21:21:57

pasemi_mac: pass in count of buffers to replenish rx ring with

Refactor replenish_rx_ring to take an argument for how many entries to
fill. Since it's normally available from where it's called anyway, this
is just simpler. It also removes the awkward logic to try to figure out
if we're filling for the first time or not.

Signed-off-by: Olof Johansson <redacted>

Index: k.org/drivers/net/pasemi_mac.c
===================================================================
--- k.org.orig/drivers/net/pasemi_mac.c
+++ k.org/drivers/net/pasemi_mac.c
@@ -375,23 +375,18 @@ static void pasemi_mac_free_rx_resources
 	mac->rx = NULL;
 }
 
-static void pasemi_mac_replenish_rx_ring(struct net_device *dev)
+static void pasemi_mac_replenish_rx_ring(struct net_device *dev, int limit)
 {
 	struct pasemi_mac *mac = netdev_priv(dev);
 	unsigned int i;
 	int start = mac->rx->next_to_fill;
-	unsigned int limit, count;
-
-	limit = RING_AVAIL(mac->rx);
-	/* Check to see if we're doing first-time setup */
-	if (unlikely(mac->rx->next_to_clean == 0 && mac->rx->next_to_fill == 0))
-		limit = RX_RING_SIZE;
+	int count;
 
 	if (limit <= 0)
 		return;
 
 	i = start;
-	for (count = limit; count; count--) {
+	for (count = 0; count < limit; count++) {
 		struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i);
 		u64 *buff = &RX_BUFF(mac, i);
 		struct sk_buff *skb;
@@ -422,10 +417,10 @@ static void pasemi_mac_replenish_rx_ring
 
 	wmb();
 
-	write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), limit - count);
-	write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), limit - count);
+	write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), count);
+	write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), count);
 
-	mac->rx->next_to_fill += limit - count;
+	mac->rx->next_to_fill += count;
 }
 
 static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac)
@@ -543,7 +538,7 @@ static int pasemi_mac_clean_rx(struct pa
 	}
 
 	mac->rx->next_to_clean += limit - count;
-	pasemi_mac_replenish_rx_ring(mac->netdev);
+	pasemi_mac_replenish_rx_ring(mac->netdev, limit-count);
 
 	spin_unlock(&mac->rx->lock);
 
@@ -830,7 +825,7 @@ static int pasemi_mac_open(struct net_de
 	write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch),
 			   PAS_DMA_TXCHAN_TCMDSTA_EN);
 
-	pasemi_mac_replenish_rx_ring(dev);
+	pasemi_mac_replenish_rx_ring(dev, RX_RING_SIZE);
 
 	flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE |
 		PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;

Re: [PATCH] [1/6] pasemi_mac: fix build break in pasemi_mac_probe()

From: David Miller <davem@davemloft.net>
Date: 2007-09-26 21:22:53

From: Olof Johansson <redacted>
Date: Wed, 26 Sep 2007 16:22:43 -0500
pasemi_mac: fix build break in pasemi_mac_probe()

Fix breakage caused by recent unification of print_mac() stuff.


Signed-off-by: Olof Johansson <redacted>
This one is in net-2.6.24 already, thanks!

Re: [PATCH] [2/6] pasemi_mac: fix build break in pasemi_mac_clean_rx()

From: David Miller <davem@davemloft.net>
Date: 2007-09-26 21:24:26

From: Olof Johansson <redacted>
Date: Wed, 26 Sep 2007 16:23:06 -0500
pasemi_mac: fix build break in pasemi_mac_clean_rx()

Fix breakage caused by the unification of stats structs.


Signed-off-by: Olof Johansson <redacted>
Jeff, I added this to my net-2.6.24 tree because it fixes
a regression causes by a change in my tree.

I hope you don't mind :-)  You would just push it to me
in the end anyways :))

Re: [PATCH] [0/6] Bugfixes for pasemi_mac

From: David Miller <davem@davemloft.net>
Date: 2007-09-26 21:26:56

From: Olof Johansson <redacted>
Date: Wed, 26 Sep 2007 16:22:00 -0500
[PATCH] [1/6] pasemi_mac: fix build break in pasemi_mac_probe()
[PATCH] [2/6] pasemi_mac: fix build break in pasemi_mac_clean_rx()
[PATCH] [3/6] pasemi_mac: set interface speed correctly on XAUI ports
[PATCH] [4/6] pasemi_mac: flags as passed to spin_*_irqsave() should be unsigned long
[PATCH] [5/6] pasemi_mac: don't enable rx before there are buffers on the ring
[PATCH] [6/6] pasemi_mac: pass in count of buffers to replenish rx ring with
Jeff, patches #1 and #2 are taken care of in my net-2.6.24
tree, please review and take the rest, thanks!

Re: [PATCH] [3/6] pasemi_mac: set interface speed correctly on XAUI ports

From: Jeff Garzik <hidden>
Date: 2007-09-29 04:46:00

Olof Johansson wrote:
pasemi_mac: set interface speed correctly on XAUI ports

Set interface speed for XAUI to 10G per default, not 1G.

Signed-off-by: Olof Johansson <redacted>
applied 3-6 (davem already got 1-2)

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help