diff options
author | Nick Nunley <nicholasx.d.nunley@intel.com> | 2010-04-27 09:09:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-27 19:29:51 -0400 |
commit | 123e9f1afe7b86f7c719d1289434c5c040758334 (patch) | |
tree | 999e7075c3fad65817c81d8cd69d53f5ce1a7b84 /drivers/net/igbvf | |
parent | 59d71989352deb71bc0bba83802820de765f6e25 (diff) |
igbvf: use DMA API instead of PCI DMA functions
Signed-off-by: Nicholas Nunley <nicholasx.d.nunley@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/igbvf')
-rw-r--r-- | drivers/net/igbvf/netdev.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c index 9ac3f9428195..7012e3da3bdf 100644 --- a/drivers/net/igbvf/netdev.c +++ b/drivers/net/igbvf/netdev.c | |||
@@ -164,10 +164,10 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring, | |||
164 | buffer_info->page_offset ^= PAGE_SIZE / 2; | 164 | buffer_info->page_offset ^= PAGE_SIZE / 2; |
165 | } | 165 | } |
166 | buffer_info->page_dma = | 166 | buffer_info->page_dma = |
167 | pci_map_page(pdev, buffer_info->page, | 167 | dma_map_page(&pdev->dev, buffer_info->page, |
168 | buffer_info->page_offset, | 168 | buffer_info->page_offset, |
169 | PAGE_SIZE / 2, | 169 | PAGE_SIZE / 2, |
170 | PCI_DMA_FROMDEVICE); | 170 | DMA_FROM_DEVICE); |
171 | } | 171 | } |
172 | 172 | ||
173 | if (!buffer_info->skb) { | 173 | if (!buffer_info->skb) { |
@@ -178,9 +178,9 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring, | |||
178 | } | 178 | } |
179 | 179 | ||
180 | buffer_info->skb = skb; | 180 | buffer_info->skb = skb; |
181 | buffer_info->dma = pci_map_single(pdev, skb->data, | 181 | buffer_info->dma = dma_map_single(&pdev->dev, skb->data, |
182 | bufsz, | 182 | bufsz, |
183 | PCI_DMA_FROMDEVICE); | 183 | DMA_FROM_DEVICE); |
184 | } | 184 | } |
185 | /* Refresh the desc even if buffer_addrs didn't change because | 185 | /* Refresh the desc even if buffer_addrs didn't change because |
186 | * each write-back erases this info. */ | 186 | * each write-back erases this info. */ |
@@ -268,25 +268,25 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter, | |||
268 | prefetch(skb->data - NET_IP_ALIGN); | 268 | prefetch(skb->data - NET_IP_ALIGN); |
269 | buffer_info->skb = NULL; | 269 | buffer_info->skb = NULL; |
270 | if (!adapter->rx_ps_hdr_size) { | 270 | if (!adapter->rx_ps_hdr_size) { |
271 | pci_unmap_single(pdev, buffer_info->dma, | 271 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
272 | adapter->rx_buffer_len, | 272 | adapter->rx_buffer_len, |
273 | PCI_DMA_FROMDEVICE); | 273 | DMA_FROM_DEVICE); |
274 | buffer_info->dma = 0; | 274 | buffer_info->dma = 0; |
275 | skb_put(skb, length); | 275 | skb_put(skb, length); |
276 | goto send_up; | 276 | goto send_up; |
277 | } | 277 | } |
278 | 278 | ||
279 | if (!skb_shinfo(skb)->nr_frags) { | 279 | if (!skb_shinfo(skb)->nr_frags) { |
280 | pci_unmap_single(pdev, buffer_info->dma, | 280 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
281 | adapter->rx_ps_hdr_size, | 281 | adapter->rx_ps_hdr_size, |
282 | PCI_DMA_FROMDEVICE); | 282 | DMA_FROM_DEVICE); |
283 | skb_put(skb, hlen); | 283 | skb_put(skb, hlen); |
284 | } | 284 | } |
285 | 285 | ||
286 | if (length) { | 286 | if (length) { |
287 | pci_unmap_page(pdev, buffer_info->page_dma, | 287 | dma_unmap_page(&pdev->dev, buffer_info->page_dma, |
288 | PAGE_SIZE / 2, | 288 | PAGE_SIZE / 2, |
289 | PCI_DMA_FROMDEVICE); | 289 | DMA_FROM_DEVICE); |
290 | buffer_info->page_dma = 0; | 290 | buffer_info->page_dma = 0; |
291 | 291 | ||
292 | skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, | 292 | skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, |
@@ -369,15 +369,15 @@ static void igbvf_put_txbuf(struct igbvf_adapter *adapter, | |||
369 | { | 369 | { |
370 | if (buffer_info->dma) { | 370 | if (buffer_info->dma) { |
371 | if (buffer_info->mapped_as_page) | 371 | if (buffer_info->mapped_as_page) |
372 | pci_unmap_page(adapter->pdev, | 372 | dma_unmap_page(&adapter->pdev->dev, |
373 | buffer_info->dma, | 373 | buffer_info->dma, |
374 | buffer_info->length, | 374 | buffer_info->length, |
375 | PCI_DMA_TODEVICE); | 375 | DMA_TO_DEVICE); |
376 | else | 376 | else |
377 | pci_unmap_single(adapter->pdev, | 377 | dma_unmap_single(&adapter->pdev->dev, |
378 | buffer_info->dma, | 378 | buffer_info->dma, |
379 | buffer_info->length, | 379 | buffer_info->length, |
380 | PCI_DMA_TODEVICE); | 380 | DMA_TO_DEVICE); |
381 | buffer_info->dma = 0; | 381 | buffer_info->dma = 0; |
382 | } | 382 | } |
383 | if (buffer_info->skb) { | 383 | if (buffer_info->skb) { |
@@ -438,8 +438,8 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter, | |||
438 | tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); | 438 | tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); |
439 | tx_ring->size = ALIGN(tx_ring->size, 4096); | 439 | tx_ring->size = ALIGN(tx_ring->size, 4096); |
440 | 440 | ||
441 | tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size, | 441 | tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size, |
442 | &tx_ring->dma); | 442 | &tx_ring->dma, GFP_KERNEL); |
443 | 443 | ||
444 | if (!tx_ring->desc) | 444 | if (!tx_ring->desc) |
445 | goto err; | 445 | goto err; |
@@ -480,8 +480,8 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter, | |||
480 | rx_ring->size = rx_ring->count * desc_len; | 480 | rx_ring->size = rx_ring->count * desc_len; |
481 | rx_ring->size = ALIGN(rx_ring->size, 4096); | 481 | rx_ring->size = ALIGN(rx_ring->size, 4096); |
482 | 482 | ||
483 | rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size, | 483 | rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, |
484 | &rx_ring->dma); | 484 | &rx_ring->dma, GFP_KERNEL); |
485 | 485 | ||
486 | if (!rx_ring->desc) | 486 | if (!rx_ring->desc) |
487 | goto err; | 487 | goto err; |
@@ -549,7 +549,8 @@ void igbvf_free_tx_resources(struct igbvf_ring *tx_ring) | |||
549 | vfree(tx_ring->buffer_info); | 549 | vfree(tx_ring->buffer_info); |
550 | tx_ring->buffer_info = NULL; | 550 | tx_ring->buffer_info = NULL; |
551 | 551 | ||
552 | pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma); | 552 | dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, |
553 | tx_ring->dma); | ||
553 | 554 | ||
554 | tx_ring->desc = NULL; | 555 | tx_ring->desc = NULL; |
555 | } | 556 | } |
@@ -574,13 +575,13 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring) | |||
574 | buffer_info = &rx_ring->buffer_info[i]; | 575 | buffer_info = &rx_ring->buffer_info[i]; |
575 | if (buffer_info->dma) { | 576 | if (buffer_info->dma) { |
576 | if (adapter->rx_ps_hdr_size){ | 577 | if (adapter->rx_ps_hdr_size){ |
577 | pci_unmap_single(pdev, buffer_info->dma, | 578 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
578 | adapter->rx_ps_hdr_size, | 579 | adapter->rx_ps_hdr_size, |
579 | PCI_DMA_FROMDEVICE); | 580 | DMA_FROM_DEVICE); |
580 | } else { | 581 | } else { |
581 | pci_unmap_single(pdev, buffer_info->dma, | 582 | dma_unmap_single(&pdev->dev, buffer_info->dma, |
582 | adapter->rx_buffer_len, | 583 | adapter->rx_buffer_len, |
583 | PCI_DMA_FROMDEVICE); | 584 | DMA_FROM_DEVICE); |
584 | } | 585 | } |
585 | buffer_info->dma = 0; | 586 | buffer_info->dma = 0; |
586 | } | 587 | } |
@@ -592,9 +593,10 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring) | |||
592 | 593 | ||
593 | if (buffer_info->page) { | 594 | if (buffer_info->page) { |
594 | if (buffer_info->page_dma) | 595 | if (buffer_info->page_dma) |
595 | pci_unmap_page(pdev, buffer_info->page_dma, | 596 | dma_unmap_page(&pdev->dev, |
597 | buffer_info->page_dma, | ||
596 | PAGE_SIZE / 2, | 598 | PAGE_SIZE / 2, |
597 | PCI_DMA_FROMDEVICE); | 599 | DMA_FROM_DEVICE); |
598 | put_page(buffer_info->page); | 600 | put_page(buffer_info->page); |
599 | buffer_info->page = NULL; | 601 | buffer_info->page = NULL; |
600 | buffer_info->page_dma = 0; | 602 | buffer_info->page_dma = 0; |
@@ -2104,9 +2106,9 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter, | |||
2104 | buffer_info->time_stamp = jiffies; | 2106 | buffer_info->time_stamp = jiffies; |
2105 | buffer_info->next_to_watch = i; | 2107 | buffer_info->next_to_watch = i; |
2106 | buffer_info->mapped_as_page = false; | 2108 | buffer_info->mapped_as_page = false; |
2107 | buffer_info->dma = pci_map_single(pdev, skb->data, len, | 2109 | buffer_info->dma = dma_map_single(&pdev->dev, skb->data, len, |
2108 | PCI_DMA_TODEVICE); | 2110 | DMA_TO_DEVICE); |
2109 | if (pci_dma_mapping_error(pdev, buffer_info->dma)) | 2111 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) |
2110 | goto dma_error; | 2112 | goto dma_error; |
2111 | 2113 | ||
2112 | 2114 | ||
@@ -2127,12 +2129,12 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter, | |||
2127 | buffer_info->time_stamp = jiffies; | 2129 | buffer_info->time_stamp = jiffies; |
2128 | buffer_info->next_to_watch = i; | 2130 | buffer_info->next_to_watch = i; |
2129 | buffer_info->mapped_as_page = true; | 2131 | buffer_info->mapped_as_page = true; |
2130 | buffer_info->dma = pci_map_page(pdev, | 2132 | buffer_info->dma = dma_map_page(&pdev->dev, |
2131 | frag->page, | 2133 | frag->page, |
2132 | frag->page_offset, | 2134 | frag->page_offset, |
2133 | len, | 2135 | len, |
2134 | PCI_DMA_TODEVICE); | 2136 | DMA_TO_DEVICE); |
2135 | if (pci_dma_mapping_error(pdev, buffer_info->dma)) | 2137 | if (dma_mapping_error(&pdev->dev, buffer_info->dma)) |
2136 | goto dma_error; | 2138 | goto dma_error; |
2137 | } | 2139 | } |
2138 | 2140 | ||
@@ -2644,16 +2646,16 @@ static int __devinit igbvf_probe(struct pci_dev *pdev, | |||
2644 | return err; | 2646 | return err; |
2645 | 2647 | ||
2646 | pci_using_dac = 0; | 2648 | pci_using_dac = 0; |
2647 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); | 2649 | err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); |
2648 | if (!err) { | 2650 | if (!err) { |
2649 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); | 2651 | err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); |
2650 | if (!err) | 2652 | if (!err) |
2651 | pci_using_dac = 1; | 2653 | pci_using_dac = 1; |
2652 | } else { | 2654 | } else { |
2653 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); | 2655 | err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
2654 | if (err) { | 2656 | if (err) { |
2655 | err = pci_set_consistent_dma_mask(pdev, | 2657 | err = dma_set_coherent_mask(&pdev->dev, |
2656 | DMA_BIT_MASK(32)); | 2658 | DMA_BIT_MASK(32)); |
2657 | if (err) { | 2659 | if (err) { |
2658 | dev_err(&pdev->dev, "No usable DMA " | 2660 | dev_err(&pdev->dev, "No usable DMA " |
2659 | "configuration, aborting\n"); | 2661 | "configuration, aborting\n"); |