Skip to contentSkip to conversation

Bugfixes for pasemi_mac

PATCH In review Olof Johansson 3 participants 11 messages Sep 26, 2007 – Sep 29, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Bugfixes for pasemi_mac

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

#1 lore raw

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

pasemi_mac: fix build break in pasemi_mac_probe()

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

drivers/net/pasemi_mac.c +2 -2
Index: 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;
 
maintainer
#2 lore raw

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

From: Olof Johansson <[email protected]>
Date: Wed, 26 Sep 2007 16:22:43 -0500

Quoted 6 lines

pasemi_mac: fix build break in pasemi_mac_probe()

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

This one is in net-2.6.24 already, thanks!

#3 lore raw

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

In reply to Olof Johansson

pasemi_mac: fix build break in pasemi_mac_clean_rx()

Fix breakage caused by the unification of stats structs.

drivers/net/pasemi_mac.c +2 -2
Index: 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);
maintainer
#4 lore raw

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

From: Olof Johansson <[email protected]>
Date: Wed, 26 Sep 2007 16:23:06 -0500

Quoted 6 lines

pasemi_mac: fix build break in pasemi_mac_clean_rx()

Fix breakage caused by the unification of stats structs.

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 :))

#5 lore raw

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

In reply to Olof Johansson

pasemi_mac: set interface speed correctly on XAUI ports

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

drivers/net/pasemi_mac.c +4 -1
Index: 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));
#6 lore raw

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

Quoted 5 lines · Olof Johansson

pasemi_mac: set interface speed correctly on XAUI ports

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

applied 3-6 (davem already got 1-2)

#7 lore raw

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

In reply to Olof Johansson

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

---
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(-)
drivers/net/pasemi_mac.c +2 -2
Index: 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;
 
#8 lore raw

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

In reply to Olof Johansson

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).

drivers/net/pasemi_mac.c +11 -10
Index: 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.
#9 lore raw

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

In reply to Olof Johansson

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.

drivers/net/pasemi_mac.c +8 -13
Index: 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;
maintainer
#10 lore raw
In reply to Olof Johansson

From: Olof Johansson <[email protected]>
Date: Wed, 26 Sep 2007 16:22:00 -0500

Quoted 6 lines

[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!