Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 172085
b: refs/heads/master
c: a7d5ca4
h: refs/heads/master
i:
  172083: 4564dd6
v: v3
  • Loading branch information
Alexander Duyck authored and David S. Miller committed Dec 3, 2009
1 parent 8707561 commit 161c43b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6366ad331f436388129dfc044db871de79604e4d
refs/heads/master: a7d5ca40ff56e2cd4e30bbe91f2d0deab6bfc006
1 change: 1 addition & 0 deletions trunk/drivers/net/igbvf/igbvf.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct igbvf_buffer {
unsigned long time_stamp;
u16 length;
u16 next_to_watch;
u16 mapped_as_page;
};
/* Rx */
struct {
Expand Down
65 changes: 51 additions & 14 deletions trunk/drivers/net/igbvf/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,20 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter,
static void igbvf_put_txbuf(struct igbvf_adapter *adapter,
struct igbvf_buffer *buffer_info)
{
buffer_info->dma = 0;
if (buffer_info->dma) {
if (buffer_info->mapped_as_page)
pci_unmap_page(adapter->pdev,
buffer_info->dma,
buffer_info->length,
PCI_DMA_TODEVICE);
else
pci_unmap_single(adapter->pdev,
buffer_info->dma,
buffer_info->length,
PCI_DMA_TODEVICE);
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;
}
Expand Down Expand Up @@ -2088,27 +2098,24 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
unsigned int first)
{
struct igbvf_buffer *buffer_info;
struct pci_dev *pdev = adapter->pdev;
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 >= IGBVF_MAX_DATA_PER_TXD);
buffer_info->length = len;
/* set time_stamp *before* dma to help avoid a possible race */
buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i;
buffer_info->dma = skb_shinfo(skb)->dma_head;
buffer_info->dma = pci_map_single(pdev, skb->data, len,
PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(pdev, buffer_info->dma))
goto dma_error;


for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
struct skb_frag_struct *frag;
Expand All @@ -2125,14 +2132,44 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,
buffer_info->length = len;
buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i;
buffer_info->dma = map[count];
buffer_info->mapped_as_page = true;
buffer_info->dma = pci_map_page(pdev,
frag->page,
frag->page_offset,
len,
PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(pdev, buffer_info->dma))
goto dma_error;
count++;
}

tx_ring->buffer_info[i].skb = skb;
tx_ring->buffer_info[first].next_to_watch = i;

return count + 1;
return ++count;

dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");

/* clear timestamp and dma mappings for failed buffer_info mapping */
buffer_info->dma = 0;
buffer_info->time_stamp = 0;
buffer_info->length = 0;
buffer_info->next_to_watch = 0;
buffer_info->mapped_as_page = false;
count--;

/* clear timestamp and dma mappings for remaining portion of packet */
while (count >= 0) {
count--;
i--;
if (i < 0)
i += tx_ring->count;
buffer_info = &tx_ring->buffer_info[i];
igbvf_put_txbuf(adapter, buffer_info);
}

return 0;
}

static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter,
Expand Down

0 comments on commit 161c43b

Please sign in to comment.