aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/net/sky2.c24
-rw-r--r--drivers/net/sky2.h9
2 files changed, 20 insertions, 13 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index b1a5886a48a..1eefacbfcd2 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -958,7 +958,7 @@ static int sky2_up(struct net_device *dev)
if (!sky2->tx_le)
goto err_out;
- sky2->tx_ring = kzalloc(TX_RING_SIZE * sizeof(struct ring_info),
+ sky2->tx_ring = kcalloc(TX_RING_SIZE, sizeof(struct tx_ring_info),
GFP_KERNEL);
if (!sky2->tx_ring)
goto err_out;
@@ -970,7 +970,7 @@ static int sky2_up(struct net_device *dev)
goto err_out;
memset(sky2->rx_le, 0, RX_LE_BYTES);
- sky2->rx_ring = kzalloc(sky2->rx_pending * sizeof(struct ring_info),
+ sky2->rx_ring = kcalloc(sky2->rx_pending, sizeof(struct ring_info),
GFP_KERNEL);
if (!sky2->rx_ring)
goto err_out;
@@ -1070,7 +1070,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
struct sky2_port *sky2 = netdev_priv(dev);
struct sky2_hw *hw = sky2->hw;
struct sky2_tx_le *le = NULL;
- struct ring_info *re;
+ struct tx_ring_info *re;
unsigned i, len;
dma_addr_t mapping;
u32 addr64;
@@ -1173,11 +1173,11 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
/* Record the transmit mapping info */
re->skb = skb;
- re->mapaddr = mapping;
+ pci_unmap_addr_set(re, mapaddr, mapping);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
- struct ring_info *fre;
+ struct tx_ring_info *fre;
mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset,
frag->size, PCI_DMA_TODEVICE);
@@ -1198,9 +1198,9 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
fre = sky2->tx_ring
+ ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE;
- fre->skb = NULL;
- fre->mapaddr = mapping;
+ pci_unmap_addr_set(fre, mapaddr, mapping);
}
+
re->idx = sky2->tx_prod;
le->ctrl |= EOP;
@@ -1239,7 +1239,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
spin_lock(&sky2->tx_lock);
while (sky2->tx_cons != done) {
- struct ring_info *re = sky2->tx_ring + sky2->tx_cons;
+ struct tx_ring_info *re = sky2->tx_ring + sky2->tx_cons;
struct sk_buff *skb;
/* Check for partial status */
@@ -1248,15 +1248,17 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
goto out;
skb = re->skb;
- pci_unmap_single(sky2->hw->pdev, re->mapaddr,
+ pci_unmap_single(sky2->hw->pdev,
+ pci_unmap_addr(re, mapaddr),
skb_headlen(skb), PCI_DMA_TODEVICE);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
- struct ring_info *fre;
+ struct tx_ring_info *fre;
fre =
sky2->tx_ring + (sky2->tx_cons + i +
1) % TX_RING_SIZE;
- pci_unmap_page(sky2->hw->pdev, fre->mapaddr,
+ pci_unmap_page(sky2->hw->pdev,
+ pci_unmap_addr(fre, mapaddr),
skb_shinfo(skb)->frags[i].size,
PCI_DMA_TODEVICE);
}
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 1a91c2d4561..95518921001 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1777,10 +1777,15 @@ struct sky2_status_le {
u8 opcode;
} __attribute((packed));
+struct tx_ring_info {
+ struct sk_buff *skb;
+ DECLARE_PCI_UNMAP_ADDR(mapaddr);
+ u16 idx;
+};
+
struct ring_info {
struct sk_buff *skb;
dma_addr_t mapaddr;
- u16 idx;
};
struct sky2_port {
@@ -1790,7 +1795,7 @@ struct sky2_port {
u32 msg_enable;
spinlock_t tx_lock ____cacheline_aligned_in_smp;
- struct ring_info *tx_ring;
+ struct tx_ring_info *tx_ring;
struct sky2_tx_le *tx_le;
u16 tx_cons; /* next le to check */
u16 tx_prod; /* next le to use */