Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 193772
b: refs/heads/master
c: 7101e11
h: refs/heads/master
v: v3
  • Loading branch information
Sathya Perla authored and David S. Miller committed Mar 23, 2010
1 parent fcfcd69 commit 882e44e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 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: 7316ae88c43d47f6503f4c29b4973204e33c3411
refs/heads/master: 7101e111217581a36e2eeae7c4a3815d60673cbc
41 changes: 38 additions & 3 deletions trunk/drivers/net/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,26 +386,48 @@ static void wrb_fill_hdr(struct be_eth_hdr_wrb *hdr, struct sk_buff *skb,
AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len);
}

static void unmap_tx_frag(struct pci_dev *pdev, struct be_eth_wrb *wrb,
bool unmap_single)
{
dma_addr_t dma;

be_dws_le_to_cpu(wrb, sizeof(*wrb));

dma = (u64)wrb->frag_pa_hi << 32 | (u64)wrb->frag_pa_lo;
if (dma != 0) {
if (unmap_single)
pci_unmap_single(pdev, dma, wrb->frag_len,
PCI_DMA_TODEVICE);
else
pci_unmap_page(pdev, dma, wrb->frag_len,
PCI_DMA_TODEVICE);
}
}

static int make_tx_wrbs(struct be_adapter *adapter,
struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb)
{
u64 busaddr;
u32 i, copied = 0;
dma_addr_t busaddr;
int i, copied = 0;
struct pci_dev *pdev = adapter->pdev;
struct sk_buff *first_skb = skb;
struct be_queue_info *txq = &adapter->tx_obj.q;
struct be_eth_wrb *wrb;
struct be_eth_hdr_wrb *hdr;
bool map_single = false;
u16 map_head;

hdr = queue_head_node(txq);
atomic_add(wrb_cnt, &txq->used);
queue_head_inc(txq);
map_head = txq->head;

if (skb->len > skb->data_len) {
int len = skb->len - skb->data_len;
busaddr = pci_map_single(pdev, skb->data, len,
PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(pdev, busaddr))
goto dma_err;
map_single = true;
wrb = queue_head_node(txq);
wrb_fill(wrb, busaddr, len);
be_dws_cpu_to_le(wrb, sizeof(*wrb));
Expand All @@ -419,6 +441,8 @@ static int make_tx_wrbs(struct be_adapter *adapter,
busaddr = pci_map_page(pdev, frag->page,
frag->page_offset,
frag->size, PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(pdev, busaddr))
goto dma_err;
wrb = queue_head_node(txq);
wrb_fill(wrb, busaddr, frag->size);
be_dws_cpu_to_le(wrb, sizeof(*wrb));
Expand All @@ -438,6 +462,16 @@ static int make_tx_wrbs(struct be_adapter *adapter,
be_dws_cpu_to_le(hdr, sizeof(*hdr));

return copied;
dma_err:
txq->head = map_head;
while (copied) {
wrb = queue_head_node(txq);
unmap_tx_frag(pdev, wrb, map_single);
map_single = false;
copied -= wrb->frag_len;
queue_head_inc(txq);
}
return 0;
}

static netdev_tx_t be_xmit(struct sk_buff *skb,
Expand All @@ -462,6 +496,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb,
* *BEFORE* ringing the tx doorbell, so that we serialze the
* tx compls of the current transmit which'll wake up the queue
*/
atomic_add(wrb_cnt, &txq->used);
if ((BE_MAX_TX_FRAG_COUNT + atomic_read(&txq->used)) >=
txq->len) {
netif_stop_queue(netdev);
Expand Down

0 comments on commit 882e44e

Please sign in to comment.