Commit 6cdbbdf3 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

[PATCH] sky2: tx/rx ring data structure split

Split Tx and Rx ring into two different data structures.
Tx needs the next value (to handle partial status), and
Rx always needs the mapaddr (to handle resubmitting same buffer).
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 734d1868
...@@ -958,7 +958,7 @@ static int sky2_up(struct net_device *dev) ...@@ -958,7 +958,7 @@ static int sky2_up(struct net_device *dev)
if (!sky2->tx_le) if (!sky2->tx_le)
goto err_out; 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); GFP_KERNEL);
if (!sky2->tx_ring) if (!sky2->tx_ring)
goto err_out; goto err_out;
...@@ -970,7 +970,7 @@ static int sky2_up(struct net_device *dev) ...@@ -970,7 +970,7 @@ static int sky2_up(struct net_device *dev)
goto err_out; goto err_out;
memset(sky2->rx_le, 0, RX_LE_BYTES); 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); GFP_KERNEL);
if (!sky2->rx_ring) if (!sky2->rx_ring)
goto err_out; goto err_out;
...@@ -1070,7 +1070,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) ...@@ -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_port *sky2 = netdev_priv(dev);
struct sky2_hw *hw = sky2->hw; struct sky2_hw *hw = sky2->hw;
struct sky2_tx_le *le = NULL; struct sky2_tx_le *le = NULL;
struct ring_info *re; struct tx_ring_info *re;
unsigned i, len; unsigned i, len;
dma_addr_t mapping; dma_addr_t mapping;
u32 addr64; u32 addr64;
...@@ -1173,11 +1173,11 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) ...@@ -1173,11 +1173,11 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
/* Record the transmit mapping info */ /* Record the transmit mapping info */
re->skb = skb; re->skb = skb;
re->mapaddr = mapping; pci_unmap_addr_set(re, mapaddr, mapping);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->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, mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset,
frag->size, PCI_DMA_TODEVICE); frag->size, PCI_DMA_TODEVICE);
...@@ -1198,9 +1198,9 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) ...@@ -1198,9 +1198,9 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
fre = sky2->tx_ring fre = sky2->tx_ring
+ ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE;
fre->skb = NULL; pci_unmap_addr_set(fre, mapaddr, mapping);
fre->mapaddr = mapping;
} }
re->idx = sky2->tx_prod; re->idx = sky2->tx_prod;
le->ctrl |= EOP; le->ctrl |= EOP;
...@@ -1239,7 +1239,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) ...@@ -1239,7 +1239,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
spin_lock(&sky2->tx_lock); spin_lock(&sky2->tx_lock);
while (sky2->tx_cons != done) { 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; struct sk_buff *skb;
/* Check for partial status */ /* Check for partial status */
...@@ -1248,15 +1248,17 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) ...@@ -1248,15 +1248,17 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
goto out; goto out;
skb = re->skb; 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); skb_headlen(skb), PCI_DMA_TODEVICE);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
struct ring_info *fre; struct tx_ring_info *fre;
fre = fre =
sky2->tx_ring + (sky2->tx_cons + i + sky2->tx_ring + (sky2->tx_cons + i +
1) % TX_RING_SIZE; 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, skb_shinfo(skb)->frags[i].size,
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
} }
......
...@@ -1777,10 +1777,15 @@ struct sky2_status_le { ...@@ -1777,10 +1777,15 @@ struct sky2_status_le {
u8 opcode; u8 opcode;
} __attribute((packed)); } __attribute((packed));
struct tx_ring_info {
struct sk_buff *skb;
DECLARE_PCI_UNMAP_ADDR(mapaddr);
u16 idx;
};
struct ring_info { struct ring_info {
struct sk_buff *skb; struct sk_buff *skb;
dma_addr_t mapaddr; dma_addr_t mapaddr;
u16 idx;
}; };
struct sky2_port { struct sky2_port {
...@@ -1790,7 +1795,7 @@ struct sky2_port { ...@@ -1790,7 +1795,7 @@ struct sky2_port {
u32 msg_enable; u32 msg_enable;
spinlock_t tx_lock ____cacheline_aligned_in_smp; 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; struct sky2_tx_le *tx_le;
u16 tx_cons; /* next le to check */ u16 tx_cons; /* next le to check */
u16 tx_prod; /* next le to use */ u16 tx_prod; /* next le to use */
......
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