netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware
@ 2008-11-18  2:05 Jeff Kirsher
  2008-11-18  2:05 ` [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split Jeff Kirsher
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jeff Kirsher @ 2008-11-18  2:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, jeff, Alexander Duyck, Jeff Kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>

This patch adds the 82576 device to the description for igb in Kconfig.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 drivers/net/Kconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 732ea83..afa2065 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1982,10 +1982,10 @@ config IP1000
 	  will be called ipg.  This is recommended.
 
 config IGB
-       tristate "Intel(R) 82575 PCI-Express Gigabit Ethernet support"
+       tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"
        depends on PCI
        ---help---
-         This driver supports Intel(R) 82575 gigabit ethernet family of
+         This driver supports Intel(R) 82575/82576 gigabit ethernet family of
          adapters.  For more information on how to identify your adapter, go
          to the Adapter & Driver ID Guide at:
 


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

* [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split
  2008-11-18  2:05 [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware Jeff Kirsher
@ 2008-11-18  2:05 ` Jeff Kirsher
  2008-11-20  8:47   ` David Miller
  2008-11-18  2:05 ` [NET-NEXT PATCH 3/3] igb: Fix tx/rx_ring_count parameters for igb on suspend/resume/ring resize Jeff Kirsher
  2008-11-20  8:47 ` [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Kirsher @ 2008-11-18  2:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, jeff, Alexander Duyck, Jeff Kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>

This update replaces the xchg calls that were added with a pair of
assignments as there is no need for the xchg calls and they were found to
cause issues on some architectures.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 drivers/net/igb/igb_main.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 89ffc07..c298ae8 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -3921,8 +3921,10 @@ send_up:
 		next_buffer = &rx_ring->buffer_info[i];
 
 		if (!(staterr & E1000_RXD_STAT_EOP)) {
-			buffer_info->skb = xchg(&next_buffer->skb, skb);
-			buffer_info->dma = xchg(&next_buffer->dma, 0);
+			buffer_info->skb = next_buffer->skb;
+			buffer_info->dma = next_buffer->dma;
+			next_buffer->skb = skb;
+			next_buffer->dma = 0;
 			goto next_desc;
 		}
 


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

* [NET-NEXT PATCH 3/3] igb: Fix tx/rx_ring_count parameters for igb on suspend/resume/ring resize
  2008-11-18  2:05 [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware Jeff Kirsher
  2008-11-18  2:05 ` [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split Jeff Kirsher
@ 2008-11-18  2:05 ` Jeff Kirsher
  2008-11-20  8:48   ` David Miller
  2008-11-20  8:47 ` [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Jeff Kirsher @ 2008-11-18  2:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, jeff, Alexander Duyck, Jeff Kirsher

From: Alexander Duyck <alexander.h.duyck@intel.com>

When suspending the device the ring structure is freed which causes it to
loose track of the count.  To resolve this we need to move the ring count
outside of the ring structure and store it in the adapter struct.

In addition to resolving the suspend/resume issue this patch also addresses
issues seen in the event of memory allocation errors causing uneven ring
sizes on multiple queues.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 drivers/net/igb/igb.h         |    4 ++
 drivers/net/igb/igb_ethtool.c |  102 ++++++++++++++++++++---------------------
 drivers/net/igb/igb_main.c    |   10 ++--
 3 files changed, 59 insertions(+), 57 deletions(-)

diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 4ff6f05..acf2569 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -294,6 +294,8 @@ struct igb_adapter {
 	unsigned int lro_flushed;
 	unsigned int lro_no_desc;
 #endif
+	unsigned int tx_ring_count;
+	unsigned int rx_ring_count;
 };
 
 #define IGB_FLAG_HAS_MSI           (1 << 0)
@@ -325,6 +327,8 @@ extern void igb_reset(struct igb_adapter *);
 extern int igb_set_spd_dplx(struct igb_adapter *, u16);
 extern int igb_setup_tx_resources(struct igb_adapter *, struct igb_ring *);
 extern int igb_setup_rx_resources(struct igb_adapter *, struct igb_ring *);
+extern void igb_free_tx_resources(struct igb_ring *);
+extern void igb_free_rx_resources(struct igb_ring *);
 extern void igb_update_stats(struct igb_adapter *);
 extern void igb_set_ethtool_ops(struct net_device *);
 
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index f89fdc7..7bad3dc 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -714,15 +714,13 @@ static void igb_get_ringparam(struct net_device *netdev,
 			      struct ethtool_ringparam *ring)
 {
 	struct igb_adapter *adapter = netdev_priv(netdev);
-	struct igb_ring *tx_ring = adapter->tx_ring;
-	struct igb_ring *rx_ring = adapter->rx_ring;
 
 	ring->rx_max_pending = IGB_MAX_RXD;
 	ring->tx_max_pending = IGB_MAX_TXD;
 	ring->rx_mini_max_pending = 0;
 	ring->rx_jumbo_max_pending = 0;
-	ring->rx_pending = rx_ring->count;
-	ring->tx_pending = tx_ring->count;
+	ring->rx_pending = adapter->rx_ring_count;
+	ring->tx_pending = adapter->tx_ring_count;
 	ring->rx_mini_pending = 0;
 	ring->rx_jumbo_pending = 0;
 }
@@ -731,12 +729,9 @@ static int igb_set_ringparam(struct net_device *netdev,
 			     struct ethtool_ringparam *ring)
 {
 	struct igb_adapter *adapter = netdev_priv(netdev);
-	struct igb_buffer *old_buf;
-	struct igb_buffer *old_rx_buf;
-	void *old_desc;
+	struct igb_ring *temp_ring;
 	int i, err;
-	u32 new_rx_count, new_tx_count, old_size;
-	dma_addr_t old_dma;
+	u32 new_rx_count, new_tx_count;
 
 	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
 		return -EINVAL;
@@ -749,12 +744,19 @@ static int igb_set_ringparam(struct net_device *netdev,
 	new_tx_count = min(new_tx_count, (u32)IGB_MAX_TXD);
 	new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
 
-	if ((new_tx_count == adapter->tx_ring->count) &&
-	    (new_rx_count == adapter->rx_ring->count)) {
+	if ((new_tx_count == adapter->tx_ring_count) &&
+	    (new_rx_count == adapter->rx_ring_count)) {
 		/* nothing to do */
 		return 0;
 	}
 
+	if (adapter->num_tx_queues > adapter->num_rx_queues)
+		temp_ring = vmalloc(adapter->num_tx_queues * sizeof(struct igb_ring));
+	else
+		temp_ring = vmalloc(adapter->num_rx_queues * sizeof(struct igb_ring));
+	if (!temp_ring)
+		return -ENOMEM;
+
 	while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
 		msleep(1);
 
@@ -766,62 +768,55 @@ static int igb_set_ringparam(struct net_device *netdev,
 	 * because the ISRs in MSI-X mode get passed pointers
 	 * to the tx and rx ring structs.
 	 */
-	if (new_tx_count != adapter->tx_ring->count) {
+	if (new_tx_count != adapter->tx_ring_count) {
+		memcpy(temp_ring, adapter->tx_ring,
+		       adapter->num_tx_queues * sizeof(struct igb_ring));
+
 		for (i = 0; i < adapter->num_tx_queues; i++) {
-			/* Save existing descriptor ring */
-			old_buf = adapter->tx_ring[i].buffer_info;
-			old_desc = adapter->tx_ring[i].desc;
-			old_size = adapter->tx_ring[i].size;
-			old_dma = adapter->tx_ring[i].dma;
-			/* Try to allocate a new one */
-			adapter->tx_ring[i].buffer_info = NULL;
-			adapter->tx_ring[i].desc = NULL;
-			adapter->tx_ring[i].count = new_tx_count;
-			err = igb_setup_tx_resources(adapter,
-						&adapter->tx_ring[i]);
+			temp_ring[i].count = new_tx_count;
+			err = igb_setup_tx_resources(adapter, &temp_ring[i]);
 			if (err) {
-				/* Restore the old one so at least
-				   the adapter still works, even if
-				   we failed the request */
-				adapter->tx_ring[i].buffer_info = old_buf;
-				adapter->tx_ring[i].desc = old_desc;
-				adapter->tx_ring[i].size = old_size;
-				adapter->tx_ring[i].dma = old_dma;
+				while (i) {
+					i--;
+					igb_free_tx_resources(&temp_ring[i]);
+				}
 				goto err_setup;
 			}
-			/* Free the old buffer manually */
-			vfree(old_buf);
-			pci_free_consistent(adapter->pdev, old_size,
-					    old_desc, old_dma);
 		}
+
+		for (i = 0; i < adapter->num_tx_queues; i++)
+			igb_free_tx_resources(&adapter->tx_ring[i]);
+
+		memcpy(adapter->tx_ring, temp_ring,
+		       adapter->num_tx_queues * sizeof(struct igb_ring));
+
+		adapter->tx_ring_count = new_tx_count;
 	}
 
 	if (new_rx_count != adapter->rx_ring->count) {
-		for (i = 0; i < adapter->num_rx_queues; i++) {
+		memcpy(temp_ring, adapter->rx_ring,
+		       adapter->num_rx_queues * sizeof(struct igb_ring));
 
-			old_rx_buf = adapter->rx_ring[i].buffer_info;
-			old_desc = adapter->rx_ring[i].desc;
-			old_size = adapter->rx_ring[i].size;
-			old_dma = adapter->rx_ring[i].dma;
-
-			adapter->rx_ring[i].buffer_info = NULL;
-			adapter->rx_ring[i].desc = NULL;
-			adapter->rx_ring[i].dma = 0;
-			adapter->rx_ring[i].count = new_rx_count;
-			err = igb_setup_rx_resources(adapter,
-						     &adapter->rx_ring[i]);
+		for (i = 0; i < adapter->num_rx_queues; i++) {
+			temp_ring[i].count = new_rx_count;
+			err = igb_setup_rx_resources(adapter, &temp_ring[i]);
 			if (err) {
-				adapter->rx_ring[i].buffer_info = old_rx_buf;
-				adapter->rx_ring[i].desc = old_desc;
-				adapter->rx_ring[i].size = old_size;
-				adapter->rx_ring[i].dma = old_dma;
+				while (i) {
+					i--;
+					igb_free_rx_resources(&temp_ring[i]);
+				}
 				goto err_setup;
 			}
 
-			vfree(old_rx_buf);
-			pci_free_consistent(adapter->pdev, old_size, old_desc,
-					    old_dma);
 		}
+
+		for (i = 0; i < adapter->num_rx_queues; i++)
+			igb_free_rx_resources(&adapter->rx_ring[i]);
+
+		memcpy(adapter->rx_ring, temp_ring,
+		       adapter->num_rx_queues * sizeof(struct igb_ring));
+
+		adapter->rx_ring_count = new_rx_count;
 	}
 
 	err = 0;
@@ -830,6 +825,7 @@ err_setup:
 		igb_up(adapter);
 
 	clear_bit(__IGB_RESETTING, &adapter->state);
+	vfree(temp_ring);
 	return err;
 }
 
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index c298ae8..b1530be 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -76,8 +76,6 @@ static int igb_setup_all_tx_resources(struct igb_adapter *);
 static int igb_setup_all_rx_resources(struct igb_adapter *);
 static void igb_free_all_tx_resources(struct igb_adapter *);
 static void igb_free_all_rx_resources(struct igb_adapter *);
-static void igb_free_tx_resources(struct igb_ring *);
-static void igb_free_rx_resources(struct igb_ring *);
 void igb_update_stats(struct igb_adapter *);
 static int igb_probe(struct pci_dev *, const struct pci_device_id *);
 static void __devexit igb_remove(struct pci_dev *pdev);
@@ -259,11 +257,13 @@ static int igb_alloc_queues(struct igb_adapter *adapter)
 
 	for (i = 0; i < adapter->num_tx_queues; i++) {
 		struct igb_ring *ring = &(adapter->tx_ring[i]);
+		ring->count = adapter->tx_ring_count;
 		ring->adapter = adapter;
 		ring->queue_index = i;
 	}
 	for (i = 0; i < adapter->num_rx_queues; i++) {
 		struct igb_ring *ring = &(adapter->rx_ring[i]);
+		ring->count = adapter->rx_ring_count;
 		ring->adapter = adapter;
 		ring->queue_index = i;
 		ring->itr_register = E1000_ITR;
@@ -1395,6 +1395,8 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
 
 	pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word);
 
+	adapter->tx_ring_count = IGB_DEFAULT_TXD;
+	adapter->rx_ring_count = IGB_DEFAULT_RXD;
 	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
 	adapter->rx_ps_hdr_size = 0; /* disable packet split */
 	adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
@@ -1983,7 +1985,7 @@ static void igb_configure_rx(struct igb_adapter *adapter)
  *
  * Free all transmit software resources
  **/
-static void igb_free_tx_resources(struct igb_ring *tx_ring)
+void igb_free_tx_resources(struct igb_ring *tx_ring)
 {
 	struct pci_dev *pdev = tx_ring->adapter->pdev;
 
@@ -2083,7 +2085,7 @@ static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
  *
  * Free all receive software resources
  **/
-static void igb_free_rx_resources(struct igb_ring *rx_ring)
+void igb_free_rx_resources(struct igb_ring *rx_ring)
 {
 	struct pci_dev *pdev = rx_ring->adapter->pdev;
 


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

* Re: [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware
  2008-11-18  2:05 [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware Jeff Kirsher
  2008-11-18  2:05 ` [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split Jeff Kirsher
  2008-11-18  2:05 ` [NET-NEXT PATCH 3/3] igb: Fix tx/rx_ring_count parameters for igb on suspend/resume/ring resize Jeff Kirsher
@ 2008-11-20  8:47 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2008-11-20  8:47 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, jeff, alexander.h.duyck

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Mon, 17 Nov 2008 18:05:10 -0800

> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> This patch adds the 82576 device to the description for igb in Kconfig.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

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

* Re: [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split
  2008-11-18  2:05 ` [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split Jeff Kirsher
@ 2008-11-20  8:47   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2008-11-20  8:47 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, jeff, alexander.h.duyck

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Mon, 17 Nov 2008 18:05:31 -0800

> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> This update replaces the xchg calls that were added with a pair of
> assignments as there is no need for the xchg calls and they were found to
> cause issues on some architectures.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

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

* Re: [NET-NEXT PATCH 3/3] igb: Fix tx/rx_ring_count parameters for igb on suspend/resume/ring resize
  2008-11-18  2:05 ` [NET-NEXT PATCH 3/3] igb: Fix tx/rx_ring_count parameters for igb on suspend/resume/ring resize Jeff Kirsher
@ 2008-11-20  8:48   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2008-11-20  8:48 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, jeff, alexander.h.duyck

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Mon, 17 Nov 2008 18:05:50 -0800

> From: Alexander Duyck <alexander.h.duyck@intel.com>
> 
> When suspending the device the ring structure is freed which causes it to
> loose track of the count.  To resolve this we need to move the ring count
> outside of the ring structure and store it in the adapter struct.
> 
> In addition to resolving the suspend/resume issue this patch also addresses
> issues seen in the event of memory allocation errors causing uneven ring
> sizes on multiple queues.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

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

end of thread, other threads:[~2008-11-20  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18  2:05 [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware Jeff Kirsher
2008-11-18  2:05 ` [NET-NEXT PATCH 2/3] igb: simplify swap in clean_rx_irq if using packet split Jeff Kirsher
2008-11-20  8:47   ` David Miller
2008-11-18  2:05 ` [NET-NEXT PATCH 3/3] igb: Fix tx/rx_ring_count parameters for igb on suspend/resume/ring resize Jeff Kirsher
2008-11-20  8:48   ` David Miller
2008-11-20  8:47 ` [NET-NEXT PATCH 1/3] igb: update name to reflect new hardware David Miller

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