Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bwn/if_bwn.c
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | |||||
static int bwn_dma_nextslot(struct bwn_dma_ring *, int); | static int bwn_dma_nextslot(struct bwn_dma_ring *, int); | ||||
static void bwn_dma_rxeof(struct bwn_dma_ring *, int *); | static void bwn_dma_rxeof(struct bwn_dma_ring *, int *); | ||||
static int bwn_dma_newbuf(struct bwn_dma_ring *, | static int bwn_dma_newbuf(struct bwn_dma_ring *, | ||||
struct bwn_dmadesc_generic *, struct bwn_dmadesc_meta *, | struct bwn_dmadesc_generic *, struct bwn_dmadesc_meta *, | ||||
int); | int); | ||||
static void bwn_dma_buf_addr(void *, bus_dma_segment_t *, int, | static void bwn_dma_buf_addr(void *, bus_dma_segment_t *, int, | ||||
bus_size_t, int); | bus_size_t, int); | ||||
static uint8_t bwn_dma_check_redzone(struct bwn_dma_ring *, struct mbuf *); | static uint8_t bwn_dma_check_redzone(struct bwn_dma_ring *, struct mbuf *); | ||||
static void bwn_ratectl_tx_complete(const struct ieee80211_node *, | |||||
const struct bwn_txstatus *); | |||||
static void bwn_dma_handle_txeof(struct bwn_mac *, | static void bwn_dma_handle_txeof(struct bwn_mac *, | ||||
const struct bwn_txstatus *); | const struct bwn_txstatus *); | ||||
static int bwn_dma_tx_start(struct bwn_mac *, struct ieee80211_node *, | static int bwn_dma_tx_start(struct bwn_mac *, struct ieee80211_node *, | ||||
struct mbuf *); | struct mbuf *); | ||||
static int bwn_dma_getslot(struct bwn_dma_ring *); | static int bwn_dma_getslot(struct bwn_dma_ring *); | ||||
static struct bwn_dma_ring *bwn_dma_select(struct bwn_mac *, | static struct bwn_dma_ring *bwn_dma_select(struct bwn_mac *, | ||||
uint8_t); | uint8_t); | ||||
static int bwn_dma_attach(struct bwn_mac *); | static int bwn_dma_attach(struct bwn_mac *); | ||||
▲ Show 20 Lines • Show All 5,617 Lines • ▼ Show 20 Lines | #endif | ||||
BWN_LOCK(sc); | BWN_LOCK(sc); | ||||
return; | return; | ||||
drop: | drop: | ||||
device_printf(sc->sc_dev, "%s: dropped\n", __func__); | device_printf(sc->sc_dev, "%s: dropped\n", __func__); | ||||
} | } | ||||
static void | static void | ||||
bwn_ratectl_tx_complete(const struct ieee80211_node *ni, | |||||
const struct bwn_txstatus *status) | |||||
{ | |||||
struct ieee80211_ratectl_tx_status txs; | |||||
int retrycnt = 0; | |||||
/* | |||||
* If we don't get an ACK, then we should log the | |||||
* full framecnt. That may be 0 if it's a PHY | |||||
* failure, so ensure that gets logged as some | |||||
* retry attempt. | |||||
*/ | |||||
txs.flags = IEEE80211_RATECTL_STATUS_LONG_RETRY; | |||||
if (status->ack) { | |||||
txs.status = IEEE80211_RATECTL_TX_SUCCESS; | |||||
retrycnt = status->framecnt - 1; | |||||
} else { | |||||
txs.status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED; | |||||
retrycnt = status->framecnt; | |||||
if (retrycnt == 0) | |||||
retrycnt = 1; | |||||
} | |||||
txs.long_retries = retrycnt; | |||||
ieee80211_ratectl_tx_complete(ni, &txs); | |||||
} | |||||
static void | |||||
bwn_dma_handle_txeof(struct bwn_mac *mac, | bwn_dma_handle_txeof(struct bwn_mac *mac, | ||||
const struct bwn_txstatus *status) | const struct bwn_txstatus *status) | ||||
{ | { | ||||
struct bwn_dma *dma = &mac->mac_method.dma; | struct bwn_dma *dma = &mac->mac_method.dma; | ||||
struct bwn_dma_ring *dr; | struct bwn_dma_ring *dr; | ||||
struct bwn_dmadesc_generic *desc; | struct bwn_dmadesc_generic *desc; | ||||
struct bwn_dmadesc_meta *meta; | struct bwn_dmadesc_meta *meta; | ||||
struct bwn_softc *sc = mac->mac_sc; | struct bwn_softc *sc = mac->mac_sc; | ||||
int slot; | int slot; | ||||
int retrycnt = 0; | |||||
BWN_ASSERT_LOCKED(sc); | BWN_ASSERT_LOCKED(sc); | ||||
dr = bwn_dma_parse_cookie(mac, status, status->cookie, &slot); | dr = bwn_dma_parse_cookie(mac, status, status->cookie, &slot); | ||||
if (dr == NULL) { | if (dr == NULL) { | ||||
device_printf(sc->sc_dev, "failed to parse cookie\n"); | device_printf(sc->sc_dev, "failed to parse cookie\n"); | ||||
return; | return; | ||||
} | } | ||||
KASSERT(dr->dr_tx, ("%s:%d: fail", __func__, __LINE__)); | KASSERT(dr->dr_tx, ("%s:%d: fail", __func__, __LINE__)); | ||||
while (1) { | while (1) { | ||||
KASSERT(slot >= 0 && slot < dr->dr_numslots, | KASSERT(slot >= 0 && slot < dr->dr_numslots, | ||||
("%s:%d: fail", __func__, __LINE__)); | ("%s:%d: fail", __func__, __LINE__)); | ||||
dr->getdesc(dr, slot, &desc, &meta); | dr->getdesc(dr, slot, &desc, &meta); | ||||
if (meta->mt_txtype == BWN_DMADESC_METATYPE_HEADER) | if (meta->mt_txtype == BWN_DMADESC_METATYPE_HEADER) | ||||
bus_dmamap_unload(dr->dr_txring_dtag, meta->mt_dmap); | bus_dmamap_unload(dr->dr_txring_dtag, meta->mt_dmap); | ||||
else if (meta->mt_txtype == BWN_DMADESC_METATYPE_BODY) | else if (meta->mt_txtype == BWN_DMADESC_METATYPE_BODY) | ||||
bus_dmamap_unload(dma->txbuf_dtag, meta->mt_dmap); | bus_dmamap_unload(dma->txbuf_dtag, meta->mt_dmap); | ||||
if (meta->mt_islast) { | if (meta->mt_islast) { | ||||
KASSERT(meta->mt_m != NULL, | KASSERT(meta->mt_m != NULL, | ||||
("%s:%d: fail", __func__, __LINE__)); | ("%s:%d: fail", __func__, __LINE__)); | ||||
/* | bwn_ratectl_tx_complete(meta->mt_ni, status); | ||||
* If we don't get an ACK, then we should log the | |||||
* full framecnt. That may be 0 if it's a PHY | |||||
* failure, so ensure that gets logged as some | |||||
* retry attempt. | |||||
*/ | |||||
if (status->ack) { | |||||
retrycnt = status->framecnt - 1; | |||||
} else { | |||||
retrycnt = status->framecnt; | |||||
if (retrycnt == 0) | |||||
retrycnt = 1; | |||||
} | |||||
ieee80211_ratectl_tx_complete(meta->mt_ni->ni_vap, meta->mt_ni, | |||||
status->ack ? | |||||
IEEE80211_RATECTL_TX_SUCCESS : | |||||
IEEE80211_RATECTL_TX_FAILURE, | |||||
&retrycnt, 0); | |||||
ieee80211_tx_complete(meta->mt_ni, meta->mt_m, 0); | ieee80211_tx_complete(meta->mt_ni, meta->mt_m, 0); | ||||
meta->mt_ni = NULL; | meta->mt_ni = NULL; | ||||
meta->mt_m = NULL; | meta->mt_m = NULL; | ||||
} else | } else | ||||
KASSERT(meta->mt_m == NULL, | KASSERT(meta->mt_m == NULL, | ||||
("%s:%d: fail", __func__, __LINE__)); | ("%s:%d: fail", __func__, __LINE__)); | ||||
dr->dr_usedslot--; | dr->dr_usedslot--; | ||||
Show All 11 Lines | |||||
static void | static void | ||||
bwn_pio_handle_txeof(struct bwn_mac *mac, | bwn_pio_handle_txeof(struct bwn_mac *mac, | ||||
const struct bwn_txstatus *status) | const struct bwn_txstatus *status) | ||||
{ | { | ||||
struct bwn_pio_txqueue *tq; | struct bwn_pio_txqueue *tq; | ||||
struct bwn_pio_txpkt *tp = NULL; | struct bwn_pio_txpkt *tp = NULL; | ||||
struct bwn_softc *sc = mac->mac_sc; | struct bwn_softc *sc = mac->mac_sc; | ||||
int retrycnt = 0; | |||||
BWN_ASSERT_LOCKED(sc); | BWN_ASSERT_LOCKED(sc); | ||||
tq = bwn_pio_parse_cookie(mac, status->cookie, &tp); | tq = bwn_pio_parse_cookie(mac, status->cookie, &tp); | ||||
if (tq == NULL) | if (tq == NULL) | ||||
return; | return; | ||||
tq->tq_used -= roundup(tp->tp_m->m_pkthdr.len + BWN_HDRSIZE(mac), 4); | tq->tq_used -= roundup(tp->tp_m->m_pkthdr.len + BWN_HDRSIZE(mac), 4); | ||||
tq->tq_free++; | tq->tq_free++; | ||||
/* XXX ieee80211_tx_complete()? */ | |||||
if (tp->tp_ni != NULL) { | if (tp->tp_ni != NULL) { | ||||
/* | /* | ||||
* Do any tx complete callback. Note this must | * Do any tx complete callback. Note this must | ||||
* be done before releasing the node reference. | * be done before releasing the node reference. | ||||
*/ | */ | ||||
/* | bwn_ratectl_tx_complete(tp->tp_ni, status); | ||||
* If we don't get an ACK, then we should log the | |||||
* full framecnt. That may be 0 if it's a PHY | |||||
* failure, so ensure that gets logged as some | |||||
* retry attempt. | |||||
*/ | |||||
if (status->ack) { | |||||
retrycnt = status->framecnt - 1; | |||||
} else { | |||||
retrycnt = status->framecnt; | |||||
if (retrycnt == 0) | |||||
retrycnt = 1; | |||||
} | |||||
ieee80211_ratectl_tx_complete(tp->tp_ni->ni_vap, tp->tp_ni, | |||||
status->ack ? | |||||
IEEE80211_RATECTL_TX_SUCCESS : | |||||
IEEE80211_RATECTL_TX_FAILURE, | |||||
&retrycnt, 0); | |||||
if (tp->tp_m->m_flags & M_TXCB) | if (tp->tp_m->m_flags & M_TXCB) | ||||
ieee80211_process_callback(tp->tp_ni, tp->tp_m, 0); | ieee80211_process_callback(tp->tp_ni, tp->tp_m, 0); | ||||
ieee80211_free_node(tp->tp_ni); | ieee80211_free_node(tp->tp_ni); | ||||
tp->tp_ni = NULL; | tp->tp_ni = NULL; | ||||
} | } | ||||
m_freem(tp->tp_m); | m_freem(tp->tp_m); | ||||
tp->tp_m = NULL; | tp->tp_m = NULL; | ||||
TAILQ_INSERT_TAIL(&tq->tq_pktlist, tp, tp_list); | TAILQ_INSERT_TAIL(&tq->tq_pktlist, tp, tp_list); | ||||
▲ Show 20 Lines • Show All 1,470 Lines • Show Last 20 Lines |