Commit 123e9f1a authored by Nick Nunley's avatar Nick Nunley Committed by David S. Miller

igbvf: use DMA API instead of PCI DMA functions

Signed-off-by: default avatarNicholas Nunley <nicholasx.d.nunley@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59d71989
...@@ -164,10 +164,10 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring, ...@@ -164,10 +164,10 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring,
buffer_info->page_offset ^= PAGE_SIZE / 2; buffer_info->page_offset ^= PAGE_SIZE / 2;
} }
buffer_info->page_dma = buffer_info->page_dma =
pci_map_page(pdev, buffer_info->page, dma_map_page(&pdev->dev, buffer_info->page,
buffer_info->page_offset, buffer_info->page_offset,
PAGE_SIZE / 2, PAGE_SIZE / 2,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
} }
if (!buffer_info->skb) { if (!buffer_info->skb) {
...@@ -178,9 +178,9 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring, ...@@ -178,9 +178,9 @@ static void igbvf_alloc_rx_buffers(struct igbvf_ring *rx_ring,
} }
buffer_info->skb = skb; buffer_info->skb = skb;
buffer_info->dma = pci_map_single(pdev, skb->data, buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
bufsz, bufsz,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
} }
/* Refresh the desc even if buffer_addrs didn't change because /* Refresh the desc even if buffer_addrs didn't change because
* each write-back erases this info. */ * each write-back erases this info. */
...@@ -268,25 +268,25 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter, ...@@ -268,25 +268,25 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
prefetch(skb->data - NET_IP_ALIGN); prefetch(skb->data - NET_IP_ALIGN);
buffer_info->skb = NULL; buffer_info->skb = NULL;
if (!adapter->rx_ps_hdr_size) { if (!adapter->rx_ps_hdr_size) {
pci_unmap_single(pdev, buffer_info->dma, dma_unmap_single(&pdev->dev, buffer_info->dma,
adapter->rx_buffer_len, adapter->rx_buffer_len,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
buffer_info->dma = 0; buffer_info->dma = 0;
skb_put(skb, length); skb_put(skb, length);
goto send_up; goto send_up;
} }
if (!skb_shinfo(skb)->nr_frags) { if (!skb_shinfo(skb)->nr_frags) {
pci_unmap_single(pdev, buffer_info->dma, dma_unmap_single(&pdev->dev, buffer_info->dma,
adapter->rx_ps_hdr_size, adapter->rx_ps_hdr_size,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
skb_put(skb, hlen); skb_put(skb, hlen);
} }
if (length) { if (length) {
pci_unmap_page(pdev, buffer_info->page_dma, dma_unmap_page(&pdev->dev, buffer_info->page_dma,
PAGE_SIZE / 2, PAGE_SIZE / 2,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
buffer_info->page_dma = 0; buffer_info->page_dma = 0;
skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags,
...@@ -369,15 +369,15 @@ static void igbvf_put_txbuf(struct igbvf_adapter *adapter, ...@@ -369,15 +369,15 @@ static void igbvf_put_txbuf(struct igbvf_adapter *adapter,
{ {
if (buffer_info->dma) { if (buffer_info->dma) {
if (buffer_info->mapped_as_page) if (buffer_info->mapped_as_page)
pci_unmap_page(adapter->pdev, dma_unmap_page(&adapter->pdev->dev,
buffer_info->dma, buffer_info->dma,
buffer_info->length, buffer_info->length,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
else else
pci_unmap_single(adapter->pdev, dma_unmap_single(&adapter->pdev->dev,
buffer_info->dma, buffer_info->dma,
buffer_info->length, buffer_info->length,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
buffer_info->dma = 0; buffer_info->dma = 0;
} }
if (buffer_info->skb) { if (buffer_info->skb) {
...@@ -438,8 +438,8 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter, ...@@ -438,8 +438,8 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter,
tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc);
tx_ring->size = ALIGN(tx_ring->size, 4096); tx_ring->size = ALIGN(tx_ring->size, 4096);
tx_ring->desc = pci_alloc_consistent(pdev, tx_ring->size, tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
&tx_ring->dma); &tx_ring->dma, GFP_KERNEL);
if (!tx_ring->desc) if (!tx_ring->desc)
goto err; goto err;
...@@ -480,8 +480,8 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter, ...@@ -480,8 +480,8 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter,
rx_ring->size = rx_ring->count * desc_len; rx_ring->size = rx_ring->count * desc_len;
rx_ring->size = ALIGN(rx_ring->size, 4096); rx_ring->size = ALIGN(rx_ring->size, 4096);
rx_ring->desc = pci_alloc_consistent(pdev, rx_ring->size, rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
&rx_ring->dma); &rx_ring->dma, GFP_KERNEL);
if (!rx_ring->desc) if (!rx_ring->desc)
goto err; goto err;
...@@ -549,7 +549,8 @@ void igbvf_free_tx_resources(struct igbvf_ring *tx_ring) ...@@ -549,7 +549,8 @@ void igbvf_free_tx_resources(struct igbvf_ring *tx_ring)
vfree(tx_ring->buffer_info); vfree(tx_ring->buffer_info);
tx_ring->buffer_info = NULL; tx_ring->buffer_info = NULL;
pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma); dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
tx_ring->dma);
tx_ring->desc = NULL; tx_ring->desc = NULL;
} }
...@@ -574,13 +575,13 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring) ...@@ -574,13 +575,13 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring)
buffer_info = &rx_ring->buffer_info[i]; buffer_info = &rx_ring->buffer_info[i];
if (buffer_info->dma) { if (buffer_info->dma) {
if (adapter->rx_ps_hdr_size){ if (adapter->rx_ps_hdr_size){
pci_unmap_single(pdev, buffer_info->dma, dma_unmap_single(&pdev->dev, buffer_info->dma,
adapter->rx_ps_hdr_size, adapter->rx_ps_hdr_size,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
} else { } else {
pci_unmap_single(pdev, buffer_info->dma, dma_unmap_single(&pdev->dev, buffer_info->dma,
adapter->rx_buffer_len, adapter->rx_buffer_len,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
} }
buffer_info->dma = 0; buffer_info->dma = 0;
} }
...@@ -592,9 +593,10 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring) ...@@ -592,9 +593,10 @@ static void igbvf_clean_rx_ring(struct igbvf_ring *rx_ring)
if (buffer_info->page) { if (buffer_info->page) {
if (buffer_info->page_dma) if (buffer_info->page_dma)
pci_unmap_page(pdev, buffer_info->page_dma, dma_unmap_page(&pdev->dev,
buffer_info->page_dma,
PAGE_SIZE / 2, PAGE_SIZE / 2,
PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
put_page(buffer_info->page); put_page(buffer_info->page);
buffer_info->page = NULL; buffer_info->page = NULL;
buffer_info->page_dma = 0; buffer_info->page_dma = 0;
...@@ -2104,9 +2106,9 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter, ...@@ -2104,9 +2106,9 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
buffer_info->time_stamp = jiffies; buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i; buffer_info->next_to_watch = i;
buffer_info->mapped_as_page = false; buffer_info->mapped_as_page = false;
buffer_info->dma = pci_map_single(pdev, skb->data, len, buffer_info->dma = dma_map_single(&pdev->dev, skb->data, len,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
if (pci_dma_mapping_error(pdev, buffer_info->dma)) if (dma_mapping_error(&pdev->dev, buffer_info->dma))
goto dma_error; goto dma_error;
...@@ -2127,12 +2129,12 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter, ...@@ -2127,12 +2129,12 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
buffer_info->time_stamp = jiffies; buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i; buffer_info->next_to_watch = i;
buffer_info->mapped_as_page = true; buffer_info->mapped_as_page = true;
buffer_info->dma = pci_map_page(pdev, buffer_info->dma = dma_map_page(&pdev->dev,
frag->page, frag->page,
frag->page_offset, frag->page_offset,
len, len,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
if (pci_dma_mapping_error(pdev, buffer_info->dma)) if (dma_mapping_error(&pdev->dev, buffer_info->dma))
goto dma_error; goto dma_error;
} }
...@@ -2644,16 +2646,16 @@ static int __devinit igbvf_probe(struct pci_dev *pdev, ...@@ -2644,16 +2646,16 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
return err; return err;
pci_using_dac = 0; pci_using_dac = 0;
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err) { if (!err) {
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
if (!err) if (!err)
pci_using_dac = 1; pci_using_dac = 1;
} else { } else {
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) { if (err) {
err = pci_set_consistent_dma_mask(pdev, err = dma_set_coherent_mask(&pdev->dev,
DMA_BIT_MASK(32)); DMA_BIT_MASK(32));
if (err) { if (err) {
dev_err(&pdev->dev, "No usable DMA " dev_err(&pdev->dev, "No usable DMA "
"configuration, aborting\n"); "configuration, aborting\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment