Commit b27faf8e authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville

b43: Rename the DMA ring pointers

Rename the DMA ring pointers to have more descriptive and standard
names. Also remove the 6th unused TX ring. We can add it back later,
if we need it. The unused TX-status rx-ring is also removed, as that's
only used by legacy devices not supported by this driver anyway.

This is no functional change, except less memory allocation for
the removed rings.
Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e6f5b934
...@@ -589,15 +589,13 @@ struct b43_phy { ...@@ -589,15 +589,13 @@ struct b43_phy {
/* Data structures for DMA transmission, per 80211 core. */ /* Data structures for DMA transmission, per 80211 core. */
struct b43_dma { struct b43_dma {
struct b43_dmaring *tx_ring0; struct b43_dmaring *tx_ring_AC_BK; /* Background */
struct b43_dmaring *tx_ring1; struct b43_dmaring *tx_ring_AC_BE; /* Best Effort */
struct b43_dmaring *tx_ring2; struct b43_dmaring *tx_ring_AC_VI; /* Video */
struct b43_dmaring *tx_ring3; struct b43_dmaring *tx_ring_AC_VO; /* Voice */
struct b43_dmaring *tx_ring4; struct b43_dmaring *tx_ring_mcast; /* Multicast */
struct b43_dmaring *tx_ring5;
struct b43_dmaring *rx_ring;
struct b43_dmaring *rx_ring0;
struct b43_dmaring *rx_ring3; /* only available on core.rev < 5 */
}; };
/* Context information for a noise calculation (Link Quality). */ /* Context information for a noise calculation (Link Quality). */
......
...@@ -879,15 +879,15 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev, ...@@ -879,15 +879,15 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
} }
/* Main cleanup function. */ /* Main cleanup function. */
static void b43_destroy_dmaring(struct b43_dmaring *ring) static void b43_destroy_dmaring(struct b43_dmaring *ring,
const char *ringname)
{ {
if (!ring) if (!ring)
return; return;
b43dbg(ring->dev->wl, "DMA-%u 0x%04X (%s) max used slots: %d/%d\n", b43dbg(ring->dev->wl, "DMA-%u %s max used slots: %d/%d\n",
(unsigned int)(ring->type), (unsigned int)(ring->type), ringname,
ring->mmio_base, ring->max_used_slots, ring->nr_slots);
(ring->tx) ? "TX" : "RX", ring->max_used_slots, ring->nr_slots);
/* Device IRQs are disabled prior entering this function, /* Device IRQs are disabled prior entering this function,
* so no need to take care of concurrency with rx handler stuff. * so no need to take care of concurrency with rx handler stuff.
*/ */
...@@ -900,33 +900,26 @@ static void b43_destroy_dmaring(struct b43_dmaring *ring) ...@@ -900,33 +900,26 @@ static void b43_destroy_dmaring(struct b43_dmaring *ring)
kfree(ring); kfree(ring);
} }
#define destroy_ring(dma, ring) do { \
b43_destroy_dmaring((dma)->ring, __stringify(ring)); \
(dma)->ring = NULL; \
} while (0)
void b43_dma_free(struct b43_wldev *dev) void b43_dma_free(struct b43_wldev *dev)
{ {
struct b43_dma *dma = &dev->dma; struct b43_dma *dma = &dev->dma;
b43_destroy_dmaring(dma->rx_ring3); destroy_ring(dma, rx_ring);
dma->rx_ring3 = NULL; destroy_ring(dma, tx_ring_AC_BK);
b43_destroy_dmaring(dma->rx_ring0); destroy_ring(dma, tx_ring_AC_BE);
dma->rx_ring0 = NULL; destroy_ring(dma, tx_ring_AC_VI);
destroy_ring(dma, tx_ring_AC_VO);
b43_destroy_dmaring(dma->tx_ring5); destroy_ring(dma, tx_ring_mcast);
dma->tx_ring5 = NULL;
b43_destroy_dmaring(dma->tx_ring4);
dma->tx_ring4 = NULL;
b43_destroy_dmaring(dma->tx_ring3);
dma->tx_ring3 = NULL;
b43_destroy_dmaring(dma->tx_ring2);
dma->tx_ring2 = NULL;
b43_destroy_dmaring(dma->tx_ring1);
dma->tx_ring1 = NULL;
b43_destroy_dmaring(dma->tx_ring0);
dma->tx_ring0 = NULL;
} }
int b43_dma_init(struct b43_wldev *dev) int b43_dma_init(struct b43_wldev *dev)
{ {
struct b43_dma *dma = &dev->dma; struct b43_dma *dma = &dev->dma;
struct b43_dmaring *ring;
int err; int err;
u64 dmamask; u64 dmamask;
enum b43_dmatype type; enum b43_dmatype type;
...@@ -956,83 +949,57 @@ int b43_dma_init(struct b43_wldev *dev) ...@@ -956,83 +949,57 @@ int b43_dma_init(struct b43_wldev *dev)
err = -ENOMEM; err = -ENOMEM;
/* setup TX DMA channels. */ /* setup TX DMA channels. */
ring = b43_setup_dmaring(dev, 0, 1, type); dma->tx_ring_AC_BK = b43_setup_dmaring(dev, 0, 1, type);
if (!ring) if (!dma->tx_ring_AC_BK)
goto out; goto out;
dma->tx_ring0 = ring;
ring = b43_setup_dmaring(dev, 1, 1, type); dma->tx_ring_AC_BE = b43_setup_dmaring(dev, 1, 1, type);
if (!ring) if (!dma->tx_ring_AC_BE)
goto err_destroy_tx0; goto err_destroy_bk;
dma->tx_ring1 = ring;
ring = b43_setup_dmaring(dev, 2, 1, type); dma->tx_ring_AC_VI = b43_setup_dmaring(dev, 2, 1, type);
if (!ring) if (!dma->tx_ring_AC_VI)
goto err_destroy_tx1; goto err_destroy_be;
dma->tx_ring2 = ring;
ring = b43_setup_dmaring(dev, 3, 1, type); dma->tx_ring_AC_VO = b43_setup_dmaring(dev, 3, 1, type);
if (!ring) if (!dma->tx_ring_AC_VO)
goto err_destroy_tx2; goto err_destroy_vi;
dma->tx_ring3 = ring;
ring = b43_setup_dmaring(dev, 4, 1, type); dma->tx_ring_mcast = b43_setup_dmaring(dev, 4, 1, type);
if (!ring) if (!dma->tx_ring_mcast)
goto err_destroy_tx3; goto err_destroy_vo;
dma->tx_ring4 = ring;
ring = b43_setup_dmaring(dev, 5, 1, type); /* setup RX DMA channel. */
if (!ring) dma->rx_ring = b43_setup_dmaring(dev, 0, 0, type);
goto err_destroy_tx4; if (!dma->rx_ring)
dma->tx_ring5 = ring; goto err_destroy_mcast;
/* setup RX DMA channels. */ /* No support for the TX status DMA ring. */
ring = b43_setup_dmaring(dev, 0, 0, type); B43_WARN_ON(dev->dev->id.revision < 5);
if (!ring)
goto err_destroy_tx5;
dma->rx_ring0 = ring;
if (dev->dev->id.revision < 5) {
ring = b43_setup_dmaring(dev, 3, 0, type);
if (!ring)
goto err_destroy_rx0;
dma->rx_ring3 = ring;
}
b43dbg(dev->wl, "%u-bit DMA initialized\n", b43dbg(dev->wl, "%u-bit DMA initialized\n",
(unsigned int)type); (unsigned int)type);
err = 0; err = 0;
out: out:
return err; return err;
err_destroy_rx0: err_destroy_mcast:
b43_destroy_dmaring(dma->rx_ring0); destroy_ring(dma, tx_ring_mcast);
dma->rx_ring0 = NULL; err_destroy_vo:
err_destroy_tx5: destroy_ring(dma, tx_ring_AC_VO);
b43_destroy_dmaring(dma->tx_ring5); err_destroy_vi:
dma->tx_ring5 = NULL; destroy_ring(dma, tx_ring_AC_VI);
err_destroy_tx4: err_destroy_be:
b43_destroy_dmaring(dma->tx_ring4); destroy_ring(dma, tx_ring_AC_BE);
dma->tx_ring4 = NULL; err_destroy_bk:
err_destroy_tx3: destroy_ring(dma, tx_ring_AC_BK);
b43_destroy_dmaring(dma->tx_ring3); return err;
dma->tx_ring3 = NULL;
err_destroy_tx2:
b43_destroy_dmaring(dma->tx_ring2);
dma->tx_ring2 = NULL;
err_destroy_tx1:
b43_destroy_dmaring(dma->tx_ring1);
dma->tx_ring1 = NULL;
err_destroy_tx0:
b43_destroy_dmaring(dma->tx_ring0);
dma->tx_ring0 = NULL;
goto out;
} }
/* Generate a cookie for the TX header. */ /* Generate a cookie for the TX header. */
static u16 generate_cookie(struct b43_dmaring *ring, int slot) static u16 generate_cookie(struct b43_dmaring *ring, int slot)
{ {
u16 cookie = 0x1000; u16 cookie;
/* Use the upper 4 bits of the cookie as /* Use the upper 4 bits of the cookie as
* DMA controller ID and store the slot number * DMA controller ID and store the slot number
...@@ -1042,30 +1009,9 @@ static u16 generate_cookie(struct b43_dmaring *ring, int slot) ...@@ -1042,30 +1009,9 @@ static u16 generate_cookie(struct b43_dmaring *ring, int slot)
* It can also not be 0xFFFF because that is special * It can also not be 0xFFFF because that is special
* for multicast frames. * for multicast frames.
*/ */
switch (ring->index) { cookie = (((u16)ring->index + 1) << 12);
case 0:
cookie = 0x1000;
break;
case 1:
cookie = 0x2000;
break;
case 2:
cookie = 0x3000;
break;
case 3:
cookie = 0x4000;
break;
case 4:
cookie = 0x5000;
break;
case 5:
cookie = 0x6000;
break;
default:
B43_WARN_ON(1);
}
B43_WARN_ON(slot & ~0x0FFF); B43_WARN_ON(slot & ~0x0FFF);
cookie |= (u16) slot; cookie |= (u16)slot;
return cookie; return cookie;
} }
...@@ -1079,22 +1025,19 @@ struct b43_dmaring *parse_cookie(struct b43_wldev *dev, u16 cookie, int *slot) ...@@ -1079,22 +1025,19 @@ struct b43_dmaring *parse_cookie(struct b43_wldev *dev, u16 cookie, int *slot)
switch (cookie & 0xF000) { switch (cookie & 0xF000) {
case 0x1000: case 0x1000:
ring = dma->tx_ring0; ring = dma->tx_ring_AC_BK;
break; break;
case 0x2000: case 0x2000:
ring = dma->tx_ring1; ring = dma->tx_ring_AC_BE;
break; break;
case 0x3000: case 0x3000:
ring = dma->tx_ring2; ring = dma->tx_ring_AC_VI;
break; break;
case 0x4000: case 0x4000:
ring = dma->tx_ring3; ring = dma->tx_ring_AC_VO;
break; break;
case 0x5000: case 0x5000:
ring = dma->tx_ring4; ring = dma->tx_ring_mcast;
break;
case 0x6000:
ring = dma->tx_ring5;
break; break;
default: default:
B43_WARN_ON(1); B43_WARN_ON(1);
...@@ -1239,20 +1182,20 @@ static struct b43_dmaring * select_ring_by_priority(struct b43_wldev *dev, ...@@ -1239,20 +1182,20 @@ static struct b43_dmaring * select_ring_by_priority(struct b43_wldev *dev,
B43_WARN_ON(1); B43_WARN_ON(1);
/* fallthrough */ /* fallthrough */
case 0: case 0:
ring = dev->dma.tx_ring3; /* AC_VO */ ring = dev->dma.tx_ring_AC_VO;
break; break;
case 1: case 1:
ring = dev->dma.tx_ring2; /* AC_VI */ ring = dev->dma.tx_ring_AC_VI;
break; break;
case 2: case 2:
ring = dev->dma.tx_ring1; /* AC_BE */ ring = dev->dma.tx_ring_AC_BE;
break; break;
case 3: case 3:
ring = dev->dma.tx_ring0; /* AC_BK */ ring = dev->dma.tx_ring_AC_BK;
break; break;
} }
} else } else
ring = dev->dma.tx_ring1; ring = dev->dma.tx_ring_AC_BE;
return ring; return ring;
} }
...@@ -1273,7 +1216,7 @@ int b43_dma_tx(struct b43_wldev *dev, ...@@ -1273,7 +1216,7 @@ int b43_dma_tx(struct b43_wldev *dev,
hdr = (struct ieee80211_hdr *)skb->data; hdr = (struct ieee80211_hdr *)skb->data;
if (ctl->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM) { if (ctl->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM) {
/* The multicast ring will be sent after the DTIM */ /* The multicast ring will be sent after the DTIM */
ring = dev->dma.tx_ring4; ring = dev->dma.tx_ring_mcast;
/* Set the more-data bit. Ucode will clear it on /* Set the more-data bit. Ucode will clear it on
* the last frame for us. */ * the last frame for us. */
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
...@@ -1441,25 +1384,6 @@ static void dma_rx(struct b43_dmaring *ring, int *slot) ...@@ -1441,25 +1384,6 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
sync_descbuffer_for_cpu(ring, meta->dmaaddr, ring->rx_buffersize); sync_descbuffer_for_cpu(ring, meta->dmaaddr, ring->rx_buffersize);
skb = meta->skb; skb = meta->skb;
if (ring->index == 3) {
/* We received an xmit status. */
struct b43_hwtxstatus *hw = (struct b43_hwtxstatus *)skb->data;
int i = 0;
while (hw->cookie == 0) {
if (i > 100)
break;
i++;
udelay(2);
barrier();
}
b43_handle_hwtxstatus(ring->dev, hw);
/* recycle the descriptor buffer. */
sync_descbuffer_for_device(ring, meta->dmaaddr,
ring->rx_buffersize);
return;
}
rxhdr = (struct b43_rxhdr_fw4 *)skb->data; rxhdr = (struct b43_rxhdr_fw4 *)skb->data;
len = le16_to_cpu(rxhdr->frame_len); len = le16_to_cpu(rxhdr->frame_len);
if (len == 0) { if (len == 0) {
...@@ -1516,7 +1440,7 @@ static void dma_rx(struct b43_dmaring *ring, int *slot) ...@@ -1516,7 +1440,7 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
skb_pull(skb, ring->frameoffset); skb_pull(skb, ring->frameoffset);
b43_rx(ring->dev, skb, rxhdr); b43_rx(ring->dev, skb, rxhdr);
drop: drop:
return; return;
} }
...@@ -1562,21 +1486,19 @@ static void b43_dma_tx_resume_ring(struct b43_dmaring *ring) ...@@ -1562,21 +1486,19 @@ static void b43_dma_tx_resume_ring(struct b43_dmaring *ring)
void b43_dma_tx_suspend(struct b43_wldev *dev) void b43_dma_tx_suspend(struct b43_wldev *dev)
{ {
b43_power_saving_ctl_bits(dev, B43_PS_AWAKE); b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
b43_dma_tx_suspend_ring(dev->dma.tx_ring0); b43_dma_tx_suspend_ring(dev->dma.tx_ring_AC_BK);
b43_dma_tx_suspend_ring(dev->dma.tx_ring1); b43_dma_tx_suspend_ring(dev->dma.tx_ring_AC_BE);
b43_dma_tx_suspend_ring(dev->dma.tx_ring2); b43_dma_tx_suspend_ring(dev->dma.tx_ring_AC_VI);
b43_dma_tx_suspend_ring(dev->dma.tx_ring3); b43_dma_tx_suspend_ring(dev->dma.tx_ring_AC_VO);
b43_dma_tx_suspend_ring(dev->dma.tx_ring4); b43_dma_tx_suspend_ring(dev->dma.tx_ring_mcast);
b43_dma_tx_suspend_ring(dev->dma.tx_ring5);
} }
void b43_dma_tx_resume(struct b43_wldev *dev) void b43_dma_tx_resume(struct b43_wldev *dev)
{ {
b43_dma_tx_resume_ring(dev->dma.tx_ring5); b43_dma_tx_resume_ring(dev->dma.tx_ring_mcast);
b43_dma_tx_resume_ring(dev->dma.tx_ring4); b43_dma_tx_resume_ring(dev->dma.tx_ring_AC_VO);
b43_dma_tx_resume_ring(dev->dma.tx_ring3); b43_dma_tx_resume_ring(dev->dma.tx_ring_AC_VI);
b43_dma_tx_resume_ring(dev->dma.tx_ring2); b43_dma_tx_resume_ring(dev->dma.tx_ring_AC_BE);
b43_dma_tx_resume_ring(dev->dma.tx_ring1); b43_dma_tx_resume_ring(dev->dma.tx_ring_AC_BK);
b43_dma_tx_resume_ring(dev->dma.tx_ring0);
b43_power_saving_ctl_bits(dev, 0); b43_power_saving_ctl_bits(dev, 0);
} }
...@@ -1594,11 +1594,10 @@ static void b43_interrupt_tasklet(struct b43_wldev *dev) ...@@ -1594,11 +1594,10 @@ static void b43_interrupt_tasklet(struct b43_wldev *dev)
/* Check the DMA reason registers for received data. */ /* Check the DMA reason registers for received data. */
if (dma_reason[0] & B43_DMAIRQ_RX_DONE) if (dma_reason[0] & B43_DMAIRQ_RX_DONE)
b43_dma_rx(dev->dma.rx_ring0); b43_dma_rx(dev->dma.rx_ring);
if (dma_reason[3] & B43_DMAIRQ_RX_DONE)
b43_dma_rx(dev->dma.rx_ring3);
B43_WARN_ON(dma_reason[1] & B43_DMAIRQ_RX_DONE); B43_WARN_ON(dma_reason[1] & B43_DMAIRQ_RX_DONE);
B43_WARN_ON(dma_reason[2] & B43_DMAIRQ_RX_DONE); B43_WARN_ON(dma_reason[2] & B43_DMAIRQ_RX_DONE);
B43_WARN_ON(dma_reason[3] & B43_DMAIRQ_RX_DONE);
B43_WARN_ON(dma_reason[4] & B43_DMAIRQ_RX_DONE); B43_WARN_ON(dma_reason[4] & B43_DMAIRQ_RX_DONE);
B43_WARN_ON(dma_reason[5] & B43_DMAIRQ_RX_DONE); B43_WARN_ON(dma_reason[5] & B43_DMAIRQ_RX_DONE);
......
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