Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 172080
b: refs/heads/master
c: 03b1320
h: refs/heads/master
v: v3
  • Loading branch information
Alexander Duyck authored and David S. Miller committed Dec 3, 2009
1 parent 7b3f1ad commit f21fed0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 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: 614c12a1581687501f1b0fc721feff69b47abd92
refs/heads/master: 03b1320dfceeb093890cdd7433e910dca6225ddb
9 changes: 6 additions & 3 deletions trunk/drivers/net/e1000e/e1000.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,15 @@ struct e1000_buffer {
unsigned long time_stamp;
u16 length;
u16 next_to_watch;
u16 mapped_as_page;
};
/* Rx */
/* arrays of page information for packet split */
struct e1000_ps_page *ps_pages;
struct {
/* arrays of page information for packet split */
struct e1000_ps_page *ps_pages;
struct page *page;
};
};
struct page *page;
};

struct e1000_ring {
Expand Down
59 changes: 41 additions & 18 deletions trunk/drivers/net/e1000e/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,17 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
static void e1000_put_txbuf(struct e1000_adapter *adapter,
struct e1000_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 @@ -3884,35 +3891,30 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
unsigned int mss)
{
struct e1000_ring *tx_ring = adapter->tx_ring;
struct pci_dev *pdev = adapter->pdev;
struct e1000_buffer *buffer_info;
unsigned int len = skb_headlen(skb);
unsigned int offset, size, count = 0, i;
unsigned int offset = 0, size, 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");
adapter->tx_dma_failed++;
return 0;
}

map = skb_shinfo(skb)->dma_maps;
offset = 0;

while (len) {
buffer_info = &tx_ring->buffer_info[i];
size = min(len, max_per_txd);

buffer_info->length = size;
buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i;
buffer_info->dma = skb_shinfo(skb)->dma_head + offset;
count++;
buffer_info->dma = pci_map_single(pdev, skb->data + offset,
size, PCI_DMA_TODEVICE);
buffer_info->mapped_as_page = false;
if (pci_dma_mapping_error(pdev, buffer_info->dma))
goto dma_error;

len -= size;
offset += size;
count++;

if (len) {
i++;
Expand All @@ -3926,7 +3928,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,

frag = &skb_shinfo(skb)->frags[f];
len = frag->size;
offset = 0;
offset = frag->page_offset;

while (len) {
i++;
Expand All @@ -3939,7 +3941,12 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
buffer_info->length = size;
buffer_info->time_stamp = jiffies;
buffer_info->next_to_watch = i;
buffer_info->dma = map[f] + offset;
buffer_info->dma = pci_map_page(pdev, frag->page,
offset, size,
PCI_DMA_TODEVICE);
buffer_info->mapped_as_page = true;
if (pci_dma_mapping_error(pdev, buffer_info->dma))
goto dma_error;

len -= size;
offset += size;
Expand All @@ -3951,6 +3958,22 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
tx_ring->buffer_info[first].next_to_watch = i;

return count;

dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");
buffer_info->dma = 0;
count--;

while (count >= 0) {
count--;
i--;
if (i < 0)
i += tx_ring->count;
buffer_info = &tx_ring->buffer_info[i];
e1000_put_txbuf(adapter, buffer_info);;
}

return 0;
}

static void e1000_tx_queue(struct e1000_adapter *adapter,
Expand Down

0 comments on commit f21fed0

Please sign in to comment.