All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] sky2 update for net-next
@ 2010-02-12 16:57 Stephen Hemminger
  2010-02-12 16:57 ` [PATCH 01/10] sky2: fix sparse warning Stephen Hemminger
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Several little fixes:
   * Change WoL setup to fix http://bugzilla.kernel.org/show_bug.cgi?id=13764
   * Change Jumbo settings for some chips
   * Mike's changes to avoid free and alloc on driver recovery

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 01/10] sky2: fix sparse warning
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
@ 2010-02-12 16:57 ` Stephen Hemminger
  2010-02-12 16:57 ` [PATCH 02/10] sky2: WoL changes Stephen Hemminger
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: sky2-sparse-warn.patch --]
[-- Type: text/plain, Size: 624 bytes --]

Warning about hidden variable

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/sky2.c	2010-02-11 09:15:11.429362380 -0800
+++ b/drivers/net/sky2.c	2010-02-11 09:15:20.407488037 -0800
@@ -3128,7 +3128,7 @@ static void sky2_reset(struct sky2_hw *h
 		/* check if PSMv2 was running before */
 		reg = sky2_pci_read16(hw, PSM_CONFIG_REG3);
 		if (reg & PCI_EXP_LNKCTL_ASPMC) {
-			int cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+			cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
 			/* restore the PCIe Link Control register */
 			sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg);
 		}

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 02/10] sky2: WoL changes
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
  2010-02-12 16:57 ` [PATCH 01/10] sky2: fix sparse warning Stephen Hemminger
@ 2010-02-12 16:57 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 03/10] sky2: dont enable PME legacy mode Stephen Hemminger
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:57 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: sky2-wol-alt.patch --]
[-- Type: text/plain, Size: 3646 bytes --]

Change Wake On Lan code to be similar to vendor driver. The definition
of Y2_HW_WOL_ON is confusing; what it means is transition to firmware SPI
setting when doing power change.

Since same code is done for both shutdown and suspend, use common
code path.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/sky2.c	2010-02-10 20:05:09.850493345 -0800
+++ b/drivers/net/sky2.c	2010-02-10 20:05:20.711411236 -0800
@@ -251,6 +251,8 @@ static void sky2_power_on(struct sky2_hw
 
 		sky2_pci_write32(hw, PCI_CFG_REG_1, 0);
 
+		sky2_write16(hw, B0_CTST, Y2_HW_WOL_ON);
+
 		/* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
 		reg = sky2_read32(hw, B2_GP_IO);
 		reg |= GLB_GPIO_STAT_RACE_DIS;
@@ -782,6 +784,9 @@ static void sky2_wol_init(struct sky2_po
 	ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT;
 	sky2_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl);
 
+	/* Disable PiG firmware */
+	sky2_write16(hw, B0_CTST, Y2_HW_WOL_OFF);
+
 	/* Turn on legacy PCI-Express PME mode */
 	reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
 	reg1 |= PCI_Y2_PME_LEGACY;
@@ -789,7 +794,6 @@ static void sky2_wol_init(struct sky2_po
 
 	/* block receiver */
 	sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
-
 }
 
 static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
@@ -3272,27 +3276,6 @@ static inline u8 sky2_wol_supported(cons
 	return sky2_is_copper(hw) ? (WAKE_PHY | WAKE_MAGIC) : 0;
 }
 
-static void sky2_hw_set_wol(struct sky2_hw *hw)
-{
-	int wol = 0;
-	int i;
-
-	for (i = 0; i < hw->ports; i++) {
-		struct net_device *dev = hw->dev[i];
-		struct sky2_port *sky2 = netdev_priv(dev);
-
-		if (sky2->wol)
-			wol = 1;
-	}
-
-	if (hw->chip_id == CHIP_ID_YUKON_EC_U ||
-	    hw->chip_id == CHIP_ID_YUKON_EX ||
-	    hw->chip_id == CHIP_ID_YUKON_FE_P)
-		sky2_write32(hw, B0_CTST, wol ? Y2_HW_WOL_ON : Y2_HW_WOL_OFF);
-
-	device_set_wakeup_enable(&hw->pdev->dev, wol);
-}
-
 static void sky2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	const struct sky2_port *sky2 = netdev_priv(dev);
@@ -3311,11 +3294,6 @@ static int sky2_set_wol(struct net_devic
 		return -EOPNOTSUPP;
 
 	sky2->wol = wol->wolopts;
-
-	sky2_hw_set_wol(hw);
-
-	if (!netif_running(dev))
-		sky2_wol_init(sky2);
 	return 0;
 }
 
@@ -4809,7 +4787,6 @@ static void __devexit sky2_remove(struct
 	pci_set_drvdata(pdev, NULL);
 }
 
-#ifdef CONFIG_PM
 static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sky2_hw *hw = pci_get_drvdata(pdev);
@@ -4834,6 +4811,8 @@ static int sky2_suspend(struct pci_dev *
 		wol |= sky2->wol;
 	}
 
+	device_set_wakeup_enable(&pdev->dev, wol != 0);
+
 	sky2_write32(hw, B0_IMSK, 0);
 	napi_disable(&hw->napi);
 	sky2_power_aux(hw);
@@ -4846,6 +4825,7 @@ static int sky2_suspend(struct pci_dev *
 	return 0;
 }
 
+#ifdef CONFIG_PM
 static int sky2_resume(struct pci_dev *pdev)
 {
 	struct sky2_hw *hw = pci_get_drvdata(pdev);
@@ -4895,34 +4875,7 @@ out:
 
 static void sky2_shutdown(struct pci_dev *pdev)
 {
-	struct sky2_hw *hw = pci_get_drvdata(pdev);
-	int i, wol = 0;
-
-	if (!hw)
-		return;
-
-	rtnl_lock();
-	del_timer_sync(&hw->watchdog_timer);
-
-	for (i = 0; i < hw->ports; i++) {
-		struct net_device *dev = hw->dev[i];
-		struct sky2_port *sky2 = netdev_priv(dev);
-
-		if (sky2->wol) {
-			wol = 1;
-			sky2_wol_init(sky2);
-		}
-	}
-
-	if (wol)
-		sky2_power_aux(hw);
-	rtnl_unlock();
-
-	pci_enable_wake(pdev, PCI_D3hot, wol);
-	pci_enable_wake(pdev, PCI_D3cold, wol);
-
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, PCI_D3hot);
+	sky2_suspend(pdev, PMSG_SUSPEND);
 }
 
 static struct pci_driver sky2_driver = {

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 03/10] sky2: dont enable PME legacy mode
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
  2010-02-12 16:57 ` [PATCH 01/10] sky2: fix sparse warning Stephen Hemminger
  2010-02-12 16:57 ` [PATCH 02/10] sky2: WoL changes Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 04/10] sky2: jumbo packet changes Stephen Hemminger
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: sky2-no-pme-legacy.patch --]
[-- Type: text/plain, Size: 1027 bytes --]

This bit is not changed by vendor driver, and should be left alone.
The documentation implies this a debug bit. 
  0 = WAKE# only asserted when VMAIN not available
  1 = WAKE# is depend on wake events and independent of VMAIN.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


--- a/drivers/net/sky2.c	2010-02-10 11:45:02.392648891 -0800
+++ b/drivers/net/sky2.c	2010-02-10 11:45:15.221399139 -0800
@@ -733,7 +733,6 @@ static void sky2_wol_init(struct sky2_po
 	unsigned port = sky2->port;
 	enum flow_control save_mode;
 	u16 ctrl;
-	u32 reg1;
 
 	/* Bring hardware out of reset */
 	sky2_write16(hw, B0_CTST, CS_RST_CLR);
@@ -787,11 +786,6 @@ static void sky2_wol_init(struct sky2_po
 	/* Disable PiG firmware */
 	sky2_write16(hw, B0_CTST, Y2_HW_WOL_OFF);
 
-	/* Turn on legacy PCI-Express PME mode */
-	reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
-	reg1 |= PCI_Y2_PME_LEGACY;
-	sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
-
 	/* block receiver */
 	sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
 }

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 04/10] sky2: jumbo packet changes
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (2 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 03/10] sky2: dont enable PME legacy mode Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 05/10] sky2: Factor out code to calculate packet sizes Stephen Hemminger
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: sky2-ec-nojumbo.patch --]
[-- Type: text/plain, Size: 3498 bytes --]

Change how FIFO is programmed in jumbo mode (to match vendor driver).
Mostly cosmetic, the only register change is that the bits 22,23
are not programemd used.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


---
 drivers/net/sky2.c |   97 +++++++++++++++++++++++------------------------------
 drivers/net/sky2.h |    8 ++--
 2 files changed, 47 insertions(+), 58 deletions(-)

--- a/drivers/net/sky2.h	2010-02-11 15:32:59.821544922 -0800
+++ b/drivers/net/sky2.h	2010-02-11 15:33:34.491857721 -0800
@@ -1895,14 +1895,14 @@ enum {
 
 /*	TX_GMF_CTRL_T	32 bit	Tx GMAC FIFO Control/Test */
 enum {
-	TX_STFW_DIS	= 1<<31,/* Disable Store & Forward (Yukon-EC Ultra) */
-	TX_STFW_ENA	= 1<<30,/* Enable  Store & Forward (Yukon-EC Ultra) */
+	TX_STFW_DIS	= 1<<31,/* Disable Store & Forward */
+	TX_STFW_ENA	= 1<<30,/* Enable  Store & Forward */
 
 	TX_VLAN_TAG_ON	= 1<<25,/* enable  VLAN tagging */
 	TX_VLAN_TAG_OFF	= 1<<24,/* disable VLAN tagging */
 
-	TX_JUMBO_ENA	= 1<<23,/* PCI Jumbo Mode enable (Yukon-EC Ultra) */
-	TX_JUMBO_DIS	= 1<<22,/* PCI Jumbo Mode enable (Yukon-EC Ultra) */
+	TX_PCI_JUM_ENA  = 1<<23,/* PCI Jumbo Mode enable */
+	TX_PCI_JUM_DIS  = 1<<22,/* PCI Jumbo Mode enable */
 
 	GMF_WSP_TST_ON	= 1<<18,/* Write Shadow Pointer Test On */
 	GMF_WSP_TST_OFF	= 1<<17,/* Write Shadow Pointer Test Off */
--- a/drivers/net/sky2.c	2010-02-11 15:32:59.831545305 -0800
+++ b/drivers/net/sky2.c	2010-02-11 15:33:34.491857721 -0800
@@ -798,29 +798,15 @@ static void sky2_set_tx_stfwd(struct sky
 	      hw->chip_rev != CHIP_REV_YU_EX_A0) ||
 	     hw->chip_id >= CHIP_ID_YUKON_FE_P) {
 		/* Yukon-Extreme B0 and further Extreme devices */
-		/* enable Store & Forward mode for TX */
+		sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_ENA);
+	} else if (dev->mtu > ETH_DATA_LEN) {
+		/* set Tx GMAC FIFO Almost Empty Threshold */
+		sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR),
+			     (ECU_JUMBO_WM << 16) | ECU_AE_THR);
 
-		if (dev->mtu <= ETH_DATA_LEN)
-			sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
-				     TX_JUMBO_DIS | TX_STFW_ENA);
-
-		else
-			sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
-				     TX_JUMBO_ENA| TX_STFW_ENA);
-	} else {
-		if (dev->mtu <= ETH_DATA_LEN)
-			sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_ENA);
-		else {
-			/* set Tx GMAC FIFO Almost Empty Threshold */
-			sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR),
-				     (ECU_JUMBO_WM << 16) | ECU_AE_THR);
-
-			sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS);
-
-			/* Can't do offload because of lack of store/forward */
-			dev->features &= ~(NETIF_F_TSO | NETIF_F_SG | NETIF_F_ALL_CSUM);
-		}
-	}
+		sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS);
+	} else
+		sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_ENA);
 }
 
 static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
@@ -2206,14 +2192,20 @@ static int sky2_change_mtu(struct net_de
 	u16 ctl, mode;
 	u32 imask;
 
+	/* MTU size outside the spec */
 	if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
 		return -EINVAL;
 
+	/* MTU > 1500 on yukon FE and FE+ not allowed */
 	if (new_mtu > ETH_DATA_LEN &&
 	    (hw->chip_id == CHIP_ID_YUKON_FE ||
 	     hw->chip_id == CHIP_ID_YUKON_FE_P))
 		return -EINVAL;
 
+	/* TSO, etc on Yukon Ultra and MTU > 1500 not supported */
+	if (new_mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U)
+		dev->features &= ~(NETIF_F_TSO|NETIF_F_SG|NETIF_F_ALL_CSUM);
+
 	if (!netif_running(dev)) {
 		dev->mtu = new_mtu;
 		return 0;

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 05/10] sky2: Factor out code to calculate packet sizes
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (3 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 04/10] sky2: jumbo packet changes Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 06/10] sky2: Allocate initial skbs in sky2_alloc_buffers Stephen Hemminger
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Mike McCormack

[-- Attachment #1: sky2-mike1.patch --]
[-- Type: text/plain, Size: 3023 bytes --]

From: Mike McCormack <mikem@ring3k.org>

Move code to calculate receive threshold and packet size out of
sky2_rx_start() so that is can be called from elsewhere easily.

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>

---
 drivers/net/sky2.c |   57 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 37 insertions(+), 20 deletions(-)

--- a/drivers/net/sky2.c	2010-02-11 09:55:57.641435835 -0800
+++ b/drivers/net/sky2.c	2010-02-11 09:58:16.522894061 -0800
@@ -1049,6 +1049,40 @@ static inline struct sky2_rx_le *sky2_ne
 	return le;
 }
 
+static unsigned sky2_get_rx_threshold(struct sky2_port* sky2)
+{
+	unsigned size;
+
+	/* Space needed for frame data + headers rounded up */
+	size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8);
+
+	/* Stopping point for hardware truncation */
+	return (size - 8) / sizeof(u32);
+}
+
+static unsigned sky2_get_rx_data_size(struct sky2_port* sky2)
+{
+	struct rx_ring_info *re;
+	unsigned size;
+
+	/* Space needed for frame data + headers rounded up */
+	size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8);
+
+	sky2->rx_nfrags = size >> PAGE_SHIFT;
+	BUG_ON(sky2->rx_nfrags > ARRAY_SIZE(re->frag_addr));
+
+	/* Compute residue after pages */
+	size -= sky2->rx_nfrags << PAGE_SHIFT;
+
+	/* Optimize to handle small packets and headers */
+	if (size < copybreak)
+		size = copybreak;
+	if (size < ETH_HLEN)
+		size = ETH_HLEN;
+
+	return size;
+}
+
 /* Build description to hardware for one receive segment */
 static void sky2_rx_add(struct sky2_port *sky2,  u8 op,
 			dma_addr_t map, unsigned len)
@@ -1343,7 +1377,7 @@ static int sky2_rx_start(struct sky2_por
 	struct sky2_hw *hw = sky2->hw;
 	struct rx_ring_info *re;
 	unsigned rxq = rxqaddr[sky2->port];
-	unsigned i, size, thresh;
+	unsigned i, thresh;
 
 	sky2->rx_put = sky2->rx_next = 0;
 	sky2_qset(hw, rxq);
@@ -1364,25 +1398,7 @@ static int sky2_rx_start(struct sky2_por
 	if (!(hw->flags & SKY2_HW_NEW_LE))
 		rx_set_checksum(sky2);
 
-	/* Space needed for frame data + headers rounded up */
-	size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8);
-
-	/* Stopping point for hardware truncation */
-	thresh = (size - 8) / sizeof(u32);
-
-	sky2->rx_nfrags = size >> PAGE_SHIFT;
-	BUG_ON(sky2->rx_nfrags > ARRAY_SIZE(re->frag_addr));
-
-	/* Compute residue after pages */
-	size -= sky2->rx_nfrags << PAGE_SHIFT;
-
-	/* Optimize to handle small packets and headers */
-	if (size < copybreak)
-		size = copybreak;
-	if (size < ETH_HLEN)
-		size = ETH_HLEN;
-
-	sky2->rx_data_size = size;
+	sky2->rx_data_size = sky2_get_rx_data_size(sky2);
 
 	/* Fill Rx ring */
 	for (i = 0; i < sky2->rx_pending; i++) {
@@ -1407,6 +1423,7 @@ static int sky2_rx_start(struct sky2_por
 	 * the register is limited to 9 bits, so if you do frames > 2052
 	 * you better get the MTU right!
 	 */
+	thresh = sky2_get_rx_threshold(sky2);
 	if (thresh > 0x1ff)
 		sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_OFF);
 	else {

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 06/10] sky2: Allocate initial skbs in sky2_alloc_buffers
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (4 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 05/10] sky2: Factor out code to calculate packet sizes Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 07/10] sky2: Refactor sky2_up into two functions Stephen Hemminger
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Mike McCormack

[-- Attachment #1: sky2-mike2.patch --]
[-- Type: text/plain, Size: 4039 bytes --]

From: Mike McCormack <mikem@ring3k.org>

Allocate everything in one place so there's a single point
of failure in sky2_up, and sky2_rx_start can no longer fail.

Don't leave the hardware in a partially initialized state in the
case rx ring allocation fails.

As with the old code, the rx ring still needs to be fully
allocated for sky2_up to succeed.

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
---
 drivers/net/sky2.c |   68 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 38 insertions(+), 30 deletions(-)

--- a/drivers/net/sky2.c	2010-02-11 15:33:38.651857666 -0800
+++ b/drivers/net/sky2.c	2010-02-11 15:33:40.351545123 -0800
@@ -1363,8 +1363,32 @@ static inline void sky2_rx_update(struct
 	sky2_put_idx(sky2->hw, rxq, sky2->rx_put);
 }
 
+static int sky2_alloc_rx_skbs(struct sky2_port *sky2)
+{
+	struct sky2_hw *hw = sky2->hw;
+	unsigned i;
+
+	sky2->rx_data_size = sky2_get_rx_data_size(sky2);
+
+	/* Fill Rx ring */
+	for (i = 0; i < sky2->rx_pending; i++) {
+		struct rx_ring_info *re = sky2->rx_ring + i;
+
+		re->skb = sky2_rx_alloc(sky2);
+		if (!re->skb)
+			return -ENOMEM;
+
+		if (sky2_rx_map_skb(hw->pdev, re, sky2->rx_data_size)) {
+			dev_kfree_skb(re->skb);
+			re->skb = NULL;
+			return -ENOMEM;
+		}
+	}
+	return 0;
+}
+
 /*
- * Allocate and setup receiver buffer pool.
+ * Setup receiver buffer pool.
  * Normal case this ends up creating one list element for skb
  * in the receive ring. Worst case if using large MTU and each
  * allocation falls on a different 64 bit region, that results
@@ -1372,7 +1396,7 @@ static inline void sky2_rx_update(struct
  * One element is used for checksum enable/disable, and one
  * extra to avoid wrap.
  */
-static int sky2_rx_start(struct sky2_port *sky2)
+static void sky2_rx_start(struct sky2_port *sky2)
 {
 	struct sky2_hw *hw = sky2->hw;
 	struct rx_ring_info *re;
@@ -1398,22 +1422,9 @@ static int sky2_rx_start(struct sky2_por
 	if (!(hw->flags & SKY2_HW_NEW_LE))
 		rx_set_checksum(sky2);
 
-	sky2->rx_data_size = sky2_get_rx_data_size(sky2);
-
-	/* Fill Rx ring */
+	/* submit Rx ring */
 	for (i = 0; i < sky2->rx_pending; i++) {
 		re = sky2->rx_ring + i;
-
-		re->skb = sky2_rx_alloc(sky2);
-		if (!re->skb)
-			goto nomem;
-
-		if (sky2_rx_map_skb(hw->pdev, re, sky2->rx_data_size)) {
-			dev_kfree_skb(re->skb);
-			re->skb = NULL;
-			goto nomem;
-		}
-
 		sky2_rx_submit(sky2, re);
 	}
 
@@ -1455,13 +1466,6 @@ static int sky2_rx_start(struct sky2_por
 		sky2_write32(hw, Q_ADDR(txqaddr[sky2->port], Q_TEST),
 			     TBMU_TEST_HOME_ADD_FIX_EN | TBMU_TEST_ROUTING_ADD_FIX_EN);
 	}
-
-
-
-	return 0;
-nomem:
-	sky2_rx_clean(sky2);
-	return -ENOMEM;
 }
 
 static int sky2_alloc_buffers(struct sky2_port *sky2)
@@ -1492,7 +1496,7 @@ static int sky2_alloc_buffers(struct sky
 	if (!sky2->rx_ring)
 		goto nomem;
 
-	return 0;
+	return sky2_alloc_rx_skbs(sky2);
 nomem:
 	return -ENOMEM;
 }
@@ -1501,6 +1505,8 @@ static void sky2_free_buffers(struct sky
 {
 	struct sky2_hw *hw = sky2->hw;
 
+	sky2_rx_clean(sky2);
+
 	if (sky2->rx_le) {
 		pci_free_consistent(hw->pdev, RX_LE_BYTES,
 				    sky2->rx_le, sky2->rx_le_map);
@@ -1590,9 +1596,7 @@ static int sky2_up(struct net_device *de
 	sky2_set_vlan_mode(hw, port, sky2->vlgrp != NULL);
 #endif
 
-	err = sky2_rx_start(sky2);
-	if (err)
-		goto err_out;
+	sky2_rx_start(sky2);
 
 	/* Enable interrupts from phy/mac for port */
 	imask = sky2_read32(hw, B0_IMSK);
@@ -1960,8 +1964,6 @@ static int sky2_down(struct net_device *
 	/* Free any pending frames stuck in HW queue */
 	sky2_tx_complete(sky2, sky2->tx_prod);
 
-	sky2_rx_clean(sky2);
-
 	sky2_free_buffers(sky2);
 
 	return 0;
@@ -2257,7 +2259,11 @@ static int sky2_change_mtu(struct net_de
 
 	sky2_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_ENA_OP_MD);
 
-	err = sky2_rx_start(sky2);
+	err = sky2_alloc_rx_skbs(sky2);
+	if (!err)
+		sky2_rx_start(sky2);
+	else
+		sky2_rx_clean(sky2);
 	sky2_write32(hw, B0_IMSK, imask);
 
 	sky2_read32(hw, B0_Y2_SP_LISR);

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 07/10] sky2: Refactor sky2_up into two functions
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (5 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 06/10] sky2: Allocate initial skbs in sky2_alloc_buffers Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 08/10] sky2: Refactor sky2_down " Stephen Hemminger
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Mike McCormack

[-- Attachment #1: sky2-mike3.patch --]
[-- Type: text/plain, Size: 2194 bytes --]

From: Mike McCormack <mikem@ring3k.org>

Move hardware initialization into sky2_hw_up.

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
---
 drivers/net/sky2.c |   41 +++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 16 deletions(-)

--- a/drivers/net/sky2.c	2010-02-11 15:33:40.351545123 -0800
+++ b/drivers/net/sky2.c	2010-02-11 15:33:44.579670361 -0800
@@ -1525,16 +1525,16 @@ static void sky2_free_buffers(struct sky
 	sky2->rx_ring = NULL;
 }
 
-/* Bring up network interface. */
-static int sky2_up(struct net_device *dev)
+static void sky2_hw_up(struct sky2_port *sky2)
 {
-	struct sky2_port *sky2 = netdev_priv(dev);
 	struct sky2_hw *hw = sky2->hw;
 	unsigned port = sky2->port;
-	u32 imask, ramsize;
-	int cap, err;
+	u32 ramsize;
+	int cap;
 	struct net_device *otherdev = hw->dev[sky2->port^1];
 
+	tx_init(sky2);
+
 	/*
  	 * On dual port PCI-X card, there is an problem where status
 	 * can be received out of order due to split transactions
@@ -1546,16 +1546,7 @@ static int sky2_up(struct net_device *de
 		cmd = sky2_pci_read16(hw, cap + PCI_X_CMD);
  		cmd &= ~PCI_X_CMD_MAX_SPLIT;
  		sky2_pci_write16(hw, cap + PCI_X_CMD, cmd);
-
- 	}
-
-	netif_carrier_off(dev);
-
-	err = sky2_alloc_buffers(sky2);
-	if (err)
-		goto err_out;
-
-	tx_init(sky2);
+	}
 
 	sky2_mac_init(hw, port);
 
@@ -1564,7 +1555,7 @@ static int sky2_up(struct net_device *de
 	if (ramsize > 0) {
 		u32 rxspace;
 
-		pr_debug(PFX "%s: ram buffer %dK\n", dev->name, ramsize);
+		pr_debug(PFX "%s: ram buffer %dK\n", sky2->netdev->name, ramsize);
 		if (ramsize < 16)
 			rxspace = ramsize / 2;
 		else
@@ -1597,6 +1588,24 @@ static int sky2_up(struct net_device *de
 #endif
 
 	sky2_rx_start(sky2);
+}
+
+/* Bring up network interface. */
+static int sky2_up(struct net_device *dev)
+{
+	struct sky2_port *sky2 = netdev_priv(dev);
+	struct sky2_hw *hw = sky2->hw;
+	unsigned port = sky2->port;
+	u32 imask;
+	int err;
+
+	netif_carrier_off(dev);
+
+	err = sky2_alloc_buffers(sky2);
+	if (err)
+		goto err_out;
+
+	sky2_hw_up(sky2);
 
 	/* Enable interrupts from phy/mac for port */
 	imask = sky2_read32(hw, B0_IMSK);

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 08/10] sky2: Refactor sky2_down into two functions
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (6 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 07/10] sky2: Refactor sky2_up into two functions Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 09/10] sky2: Avoid down and up during sky2_reset Stephen Hemminger
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Mike McCormack

[-- Attachment #1: sky2-mike4.patch --]
[-- Type: text/plain, Size: 1595 bytes --]

From: Mike McCormack <mikem@ring3k.org>

Create a sky2_hw_down that brings the hardware down.

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Acked-by: Stephen Hemminber <shemminger@vyatta.com>
---
 drivers/net/sky2.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

--- a/drivers/net/sky2.c	2010-02-11 15:33:44.579670361 -0800
+++ b/drivers/net/sky2.c	2010-02-11 15:46:45.651858252 -0800
@@ -1908,21 +1908,12 @@ static void sky2_tx_reset(struct sky2_hw
 	sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
 }
 
-/* Network shutdown */
-static int sky2_down(struct net_device *dev)
+static void sky2_hw_down(struct sky2_port *sky2)
 {
-	struct sky2_port *sky2 = netdev_priv(dev);
 	struct sky2_hw *hw = sky2->hw;
 	unsigned port = sky2->port;
-	u16 ctrl;
 	u32 imask;
-
-	/* Never really got started! */
-	if (!sky2->tx_le)
-		return 0;
-
-	if (netif_msg_ifdown(sky2))
-		printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
+	u16 ctrl;
 
 	/* Force flow control off */
 	sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
@@ -1972,6 +1963,21 @@ static int sky2_down(struct net_device *
 
 	/* Free any pending frames stuck in HW queue */
 	sky2_tx_complete(sky2, sky2->tx_prod);
+}
+
+/* Network shutdown */
+static int sky2_down(struct net_device *dev)
+{
+	struct sky2_port *sky2 = netdev_priv(dev);
+
+	/* Never really got started! */
+	if (!sky2->tx_le)
+		return 0;
+
+	if (netif_msg_ifdown(sky2))
+		printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
+
+	sky2_hw_down(sky2);
 
 	sky2_free_buffers(sky2);
 

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 09/10] sky2: Avoid down and up during sky2_reset
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (7 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 08/10] sky2: Refactor sky2_down " Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-12 16:58 ` [PATCH 10/10] sky2: version 1.27 Stephen Hemminger
  2010-02-13  0:21 ` [PATCH 00/10] sky2 update for net-next David Miller
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Mike McCormack

[-- Attachment #1: sky2-mike5.patch --]
[-- Type: text/plain, Size: 4152 bytes --]

From: Mike McCormack <mikem@ring3k.org>

Rewrite sky2_reset to work with interrupts disabled and
 avoid freeing and reallocing memory.

The old code used sky2_down and sky2_up to implement sky2_reset,
 which meant interrupts could not be disabled, and the transmit and
 receive ring buffers would be free'd and reallocated.

To avoid the interrupt handler waking the transmit queue while
 we're doing a reset, it's better to have interrupts and NAPI
 polls disabled.

Note: Modified Mike's patch to do IRQ disable in sky2_down before
 calling sky2_hw_down - Stephen

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>

---
 drivers/net/sky2.c |   68 ++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 21 deletions(-)

--- a/drivers/net/sky2.c	2010-02-11 15:46:45.651858252 -0800
+++ b/drivers/net/sky2.c	2010-02-11 15:46:51.181857729 -0800
@@ -1880,10 +1880,6 @@ static void sky2_tx_complete(struct sky2
 
 	sky2->tx_cons = idx;
 	smp_mb();
-
-	/* Wake unless it's detached, and called e.g. from sky2_down() */
-	if (tx_avail(sky2) > MAX_SKB_TX_LE + 4 && netif_device_present(dev))
-		netif_wake_queue(dev);
 }
 
 static void sky2_tx_reset(struct sky2_hw *hw, unsigned port)
@@ -1912,7 +1908,6 @@ static void sky2_hw_down(struct sky2_por
 {
 	struct sky2_hw *hw = sky2->hw;
 	unsigned port = sky2->port;
-	u32 imask;
 	u16 ctrl;
 
 	/* Force flow control off */
@@ -1946,15 +1941,6 @@ static void sky2_hw_down(struct sky2_por
 
 	sky2_rx_stop(sky2);
 
-	/* Disable port IRQ */
-	imask = sky2_read32(hw, B0_IMSK);
-	imask &= ~portirq_msk[port];
-	sky2_write32(hw, B0_IMSK, imask);
-	sky2_read32(hw, B0_IMSK);
-
-	synchronize_irq(hw->pdev->irq);
-	napi_synchronize(&hw->napi);
-
 	spin_lock_bh(&sky2->phy_lock);
 	sky2_phy_power_down(hw, port);
 	spin_unlock_bh(&sky2->phy_lock);
@@ -1969,6 +1955,7 @@ static void sky2_hw_down(struct sky2_por
 static int sky2_down(struct net_device *dev)
 {
 	struct sky2_port *sky2 = netdev_priv(dev);
+	struct sky2_hw *hw = sky2->hw;
 
 	/* Never really got started! */
 	if (!sky2->tx_le)
@@ -1977,6 +1964,14 @@ static int sky2_down(struct net_device *
 	if (netif_msg_ifdown(sky2))
 		printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
 
+	/* Disable port IRQ */
+	sky2_write32(hw, B0_IMSK,
+		     sky2_read32(hw, B0_IMSK) & ~portirq_msk[sky2->port]);
+	sky2_read32(hw, B0_IMSK);
+
+	synchronize_irq(hw->pdev->irq);
+	napi_synchronize(&hw->napi);
+
 	sky2_hw_down(sky2);
 
 	sky2_free_buffers(sky2);
@@ -2475,8 +2470,13 @@ static inline void sky2_tx_done(struct n
 {
 	struct sky2_port *sky2 = netdev_priv(dev);
 
-	if (netif_running(dev))
+	if (netif_running(dev)) {
 		sky2_tx_complete(sky2, last);
+
+		/* Wake unless it's detached, and called e.g. from sky2_down() */
+		if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
+			netif_wake_queue(dev);
+	}
 }
 
 static inline void sky2_skb_rx(const struct sky2_port *sky2,
@@ -3277,20 +3277,46 @@ static int sky2_reattach(struct net_devi
 static void sky2_restart(struct work_struct *work)
 {
 	struct sky2_hw *hw = container_of(work, struct sky2_hw, restart_work);
+	u32 imask;
 	int i;
 
 	rtnl_lock();
-	for (i = 0; i < hw->ports; i++)
-		sky2_detach(hw->dev[i]);
 
 	napi_disable(&hw->napi);
+	synchronize_irq(hw->pdev->irq);
+	imask = sky2_read32(hw, B0_IMSK);
 	sky2_write32(hw, B0_IMSK, 0);
+
+	for (i = 0; i < hw->ports; i++) {
+		struct net_device *dev = hw->dev[i];
+		struct sky2_port *sky2 = netdev_priv(dev);
+
+		if (!netif_running(dev))
+			continue;
+
+		netif_carrier_off(dev);
+		netif_tx_disable(dev);
+		sky2_hw_down(sky2);
+	}
+
 	sky2_reset(hw);
-	sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
-	napi_enable(&hw->napi);
 
-	for (i = 0; i < hw->ports; i++)
-		sky2_reattach(hw->dev[i]);
+	for (i = 0; i < hw->ports; i++) {
+		struct net_device *dev = hw->dev[i];
+		struct sky2_port *sky2 = netdev_priv(dev);
+
+		if (!netif_running(dev))
+			continue;
+
+		sky2_hw_up(sky2);
+		netif_wake_queue(dev);
+	}
+
+	sky2_write32(hw, B0_IMSK, imask);
+	sky2_read32(hw, B0_IMSK);
+
+	sky2_read32(hw, B0_Y2_SP_LISR);
+	napi_enable(&hw->napi);
 
 	rtnl_unlock();
 }

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 10/10] sky2: version 1.27
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (8 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 09/10] sky2: Avoid down and up during sky2_reset Stephen Hemminger
@ 2010-02-12 16:58 ` Stephen Hemminger
  2010-02-13  0:21 ` [PATCH 00/10] sky2 update for net-next David Miller
  10 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2010-02-12 16:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: sky2-1.27.patch --]
[-- Type: text/plain, Size: 343 bytes --]

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/sky2.c	2010-02-11 09:07:28.062232424 -0800
+++ b/drivers/net/sky2.c	2010-02-11 09:07:39.572090343 -0800
@@ -50,7 +50,7 @@
 #include "sky2.h"
 
 #define DRV_NAME		"sky2"
-#define DRV_VERSION		"1.26"
+#define DRV_VERSION		"1.27"
 #define PFX			DRV_NAME " "
 
 /*

-- 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 00/10] sky2 update for net-next
  2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
                   ` (9 preceding siblings ...)
  2010-02-12 16:58 ` [PATCH 10/10] sky2: version 1.27 Stephen Hemminger
@ 2010-02-13  0:21 ` David Miller
  10 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2010-02-13  0:21 UTC (permalink / raw)
  To: shemminger; +Cc: netdev

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Fri, 12 Feb 2010 08:57:57 -0800

> Several little fixes:
>    * Change WoL setup to fix http://bugzilla.kernel.org/show_bug.cgi?id=13764
>    * Change Jumbo settings for some chips
>    * Mike's changes to avoid free and alloc on driver recovery

All applied to net-next-2.6, thanks!

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-02-13  0:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-12 16:57 [PATCH 00/10] sky2 update for net-next Stephen Hemminger
2010-02-12 16:57 ` [PATCH 01/10] sky2: fix sparse warning Stephen Hemminger
2010-02-12 16:57 ` [PATCH 02/10] sky2: WoL changes Stephen Hemminger
2010-02-12 16:58 ` [PATCH 03/10] sky2: dont enable PME legacy mode Stephen Hemminger
2010-02-12 16:58 ` [PATCH 04/10] sky2: jumbo packet changes Stephen Hemminger
2010-02-12 16:58 ` [PATCH 05/10] sky2: Factor out code to calculate packet sizes Stephen Hemminger
2010-02-12 16:58 ` [PATCH 06/10] sky2: Allocate initial skbs in sky2_alloc_buffers Stephen Hemminger
2010-02-12 16:58 ` [PATCH 07/10] sky2: Refactor sky2_up into two functions Stephen Hemminger
2010-02-12 16:58 ` [PATCH 08/10] sky2: Refactor sky2_down " Stephen Hemminger
2010-02-12 16:58 ` [PATCH 09/10] sky2: Avoid down and up during sky2_reset Stephen Hemminger
2010-02-12 16:58 ` [PATCH 10/10] sky2: version 1.27 Stephen Hemminger
2010-02-13  0:21 ` [PATCH 00/10] sky2 update for net-next David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.