Re: [net-next PATCH 5/5] igb: cleanup tx dma so map & unmap use matching calls

Previous thread: [net-next PATCH 4/5] igb: rework igb_set_multi so that vfs are properly updated by Jeff Kirsher on Friday, March 20, 2009 - 3:17 am. (2 messages)

Next thread: [net-next PATCH 3/5] igb: update driver to use setup_timer function by Jeff Kirsher on Friday, March 20, 2009 - 3:17 am. (8 messages)
From: Jeff Kirsher
Date: Friday, March 20, 2009 - 3:17 am

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

The igb driver was using map_single to map the skbs and then unmap_page to
unmap them.  This update changes that so instead uses skb_dma_map and
skb_dma_unmap.

In addition the next_to_watch member of the buffer_info struct was being
set uneccesarily.  I removed the spots where it was set without being needed.

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 |   66 +++++++++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index a977bd7..d6f7af8 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -2257,19 +2257,14 @@ static void igb_free_all_tx_resources(struct igb_adapter *adapter)
 static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter,
 					   struct igb_buffer *buffer_info)
 {
-	if (buffer_info->dma) {
-		pci_unmap_page(adapter->pdev,
-				buffer_info->dma,
-				buffer_info->length,
-				PCI_DMA_TODEVICE);
-		buffer_info->dma = 0;
-	}
+	buffer_info->dma = 0;
 	if (buffer_info->skb) {
+		skb_dma_unmap(&adapter->pdev->dev, buffer_info->skb,
+		              DMA_TO_DEVICE);
 		dev_kfree_skb_any(buffer_info->skb);
 		buffer_info->skb = NULL;
 	}
 	buffer_info->time_stamp = 0;
-	buffer_info->next_to_watch = 0;
 	/* buffer_info must be completely set up in the transmit path */
 }
 
@@ -3078,25 +3073,33 @@ static inline int igb_tx_map_adv(struct igb_adapter *adapter,
 	unsigned int len = skb_headlen(skb);
 	unsigned int count = 0, i;
 	unsigned int f;
+	dma_addr_t *map;
 
 	i = tx_ring->next_to_use;
 
+	if (skb_dma_map(&adapter->pdev->dev, skb, DMA_TO_DEVICE)) {
+		dev_err(&adapter->pdev->dev, "TX DMA map failed\n");
+		return 0;
+	}
+
+	map = skb_shinfo(skb)->dma_maps;
+
 	buffer_info = &tx_ring->buffer_info[i];
 	BUG_ON(len >= IGB_MAX_DATA_PER_TXD);
 ...
From: David Miller
Date: Saturday, March 21, 2009 - 4:57 pm

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.
--

Previous thread: [net-next PATCH 4/5] igb: rework igb_set_multi so that vfs are properly updated by Jeff Kirsher on Friday, March 20, 2009 - 3:17 am. (2 messages)

Next thread: [net-next PATCH 3/5] igb: update driver to use setup_timer function by Jeff Kirsher on Friday, March 20, 2009 - 3:17 am. (8 messages)