drivers/wlan: Merge the ratectl change commit from FreeBSD.

This is a relatively minor change that mostly just shuffles structs
around, so presumably it will not break any of these drivers.
This commit is contained in:
Augustin Cavalier
2019-01-07 20:17:53 -05:00
parent 6d0f2b487a
commit bf3654699e
19 changed files with 164 additions and 101 deletions
@@ -3329,7 +3329,6 @@ _bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt)
struct bwi_txbuf *tb; struct bwi_txbuf *tb;
int ring_idx, buf_idx; int ring_idx, buf_idx;
struct ieee80211_node *ni; struct ieee80211_node *ni;
struct ieee80211vap *vap;
if (tx_id == 0) { if (tx_id == 0) {
device_printf(sc->sc_dev, "%s: zero tx id\n", __func__); device_printf(sc->sc_dev, "%s: zero tx id\n", __func__);
@@ -3356,7 +3355,7 @@ _bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt)
if ((ni = tb->tb_ni) != NULL) { if ((ni = tb->tb_ni) != NULL) {
const struct bwi_txbuf_hdr *hdr = const struct bwi_txbuf_hdr *hdr =
mtod(tb->tb_mbuf, const struct bwi_txbuf_hdr *); mtod(tb->tb_mbuf, const struct bwi_txbuf_hdr *);
vap = ni->ni_vap; struct ieee80211_ratectl_tx_status txs;
/* NB: update rate control only for unicast frames */ /* NB: update rate control only for unicast frames */
if (hdr->txh_mac_ctrl & htole32(BWI_TXH_MAC_C_ACK)) { if (hdr->txh_mac_ctrl & htole32(BWI_TXH_MAC_C_ACK)) {
@@ -3367,9 +3366,15 @@ _bwi_txeof(struct bwi_softc *sc, uint16_t tx_id, int acked, int data_txcnt)
* well so to avoid over-aggressive downshifting we * well so to avoid over-aggressive downshifting we
* treat any number of retries as "1". * treat any number of retries as "1".
*/ */
ieee80211_ratectl_tx_complete(vap, ni, txs.flags = IEEE80211_RATECTL_STATUS_LONG_RETRY;
(data_txcnt > 1) ? IEEE80211_RATECTL_TX_SUCCESS : txs.long_retries = acked;
IEEE80211_RATECTL_TX_FAILURE, &acked, NULL); if (data_txcnt > 1)
txs.status = IEEE80211_RATECTL_TX_SUCCESS;
else {
txs.status =
IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
}
ieee80211_ratectl_tx_complete(ni, &txs);
} }
ieee80211_tx_complete(ni, tb->tb_mbuf, !acked); ieee80211_tx_complete(ni, tb->tb_mbuf, !acked);
tb->tb_ni = NULL; tb->tb_ni = NULL;
@@ -3263,8 +3263,10 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, uint32_t offset,
} }
/* rssi is in 1/2db units */ /* rssi is in 1/2db units */
rxs.rssi = rssi * 2; rxs.c_rssi = rssi * 2;
rxs.nf = sc->sc_noise; rxs.c_nf = sc->sc_noise;
if (ieee80211_add_rx_params(m, &rxs) == 0)
goto fail;
if (ieee80211_radiotap_active_vap(vap)) { if (ieee80211_radiotap_active_vap(vap)) {
struct iwm_rx_radiotap_header *tap = &sc->sc_rxtap; struct iwm_rx_radiotap_header *tap = &sc->sc_rxtap;
@@ -3301,11 +3303,11 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, uint32_t offset,
IWM_UNLOCK(sc); IWM_UNLOCK(sc);
if (ni != NULL) { if (ni != NULL) {
IWM_DPRINTF(sc, IWM_DEBUG_RECV, "input m %p\n", m); IWM_DPRINTF(sc, IWM_DEBUG_RECV, "input m %p\n", m);
ieee80211_input_mimo(ni, m, &rxs); ieee80211_input_mimo(ni, m);
ieee80211_free_node(ni); ieee80211_free_node(ni);
} else { } else {
IWM_DPRINTF(sc, IWM_DEBUG_RECV, "inputall m %p\n", m); IWM_DPRINTF(sc, IWM_DEBUG_RECV, "inputall m %p\n", m);
ieee80211_input_mimo_all(ic, m, &rxs); ieee80211_input_mimo_all(ic, m);
} }
IWM_LOCK(sc); IWM_LOCK(sc);
@@ -3320,10 +3322,9 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
struct iwm_node *in) struct iwm_node *in)
{ {
struct iwm_mvm_tx_resp *tx_resp = (void *)pkt->data; struct iwm_mvm_tx_resp *tx_resp = (void *)pkt->data;
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct ieee80211_node *ni = &in->in_ni; struct ieee80211_node *ni = &in->in_ni;
struct ieee80211vap *vap = ni->ni_vap;
int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK; int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK;
int failack = tx_resp->failure_frame;
KASSERT(tx_resp->frame_count == 1, ("too many frames")); KASSERT(tx_resp->frame_count == 1, ("too many frames"));
@@ -3339,16 +3340,32 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
le32toh(tx_resp->initial_rate), le32toh(tx_resp->initial_rate),
(int) le16toh(tx_resp->wireless_media_time)); (int) le16toh(tx_resp->wireless_media_time));
txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY |
IEEE80211_RATECTL_STATUS_LONG_RETRY;
txs->short_retries = tx_resp->failure_rts;
txs->long_retries = tx_resp->failure_frame;
if (status != IWM_TX_STATUS_SUCCESS && if (status != IWM_TX_STATUS_SUCCESS &&
status != IWM_TX_STATUS_DIRECT_DONE) { status != IWM_TX_STATUS_DIRECT_DONE) {
ieee80211_ratectl_tx_complete(vap, ni, switch (status) {
IEEE80211_RATECTL_TX_FAILURE, &failack, NULL); case IWM_TX_STATUS_FAIL_SHORT_LIMIT:
return (1); txs->status = IEEE80211_RATECTL_TX_FAIL_SHORT;
} else { break;
ieee80211_ratectl_tx_complete(vap, ni, case IWM_TX_STATUS_FAIL_LONG_LIMIT:
IEEE80211_RATECTL_TX_SUCCESS, &failack, NULL); txs->status = IEEE80211_RATECTL_TX_FAIL_LONG;
return (0); break;
case IWM_TX_STATUS_FAIL_LIFE_EXPIRE:
txs->status = IEEE80211_RATECTL_TX_FAIL_EXPIRED;
break;
default:
txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
break;
} }
} else {
txs->status = IEEE80211_RATECTL_TX_SUCCESS;
}
ieee80211_ratectl_tx_complete(ni, txs);
return (txs->status != IEEE80211_RATECTL_TX_SUCCESS);
} }
static void static void
@@ -427,6 +427,7 @@ struct iwm_softc {
struct mtx sc_mtx; struct mtx sc_mtx;
struct mbufq sc_snd; struct mbufq sc_snd;
struct ieee80211com sc_ic; struct ieee80211com sc_ic;
struct ieee80211_ratectl_tx_status sc_txs;
int sc_flags; int sc_flags;
#define IWM_FLAG_USE_ICT (1 << 0) #define IWM_FLAG_USE_ICT (1 << 0)
@@ -15,6 +15,7 @@
#include <net80211/ieee80211_var.h> #include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_amrr.h> #include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/iwm/if_iwmreg.h> #include <dev/iwm/if_iwmreg.h>
#include <dev/iwm/if_iwmvar.h> #include <dev/iwm/if_iwmvar.h>
@@ -525,6 +525,10 @@ wpi_attach(device_t dev)
wpi_radiotap_attach(sc); wpi_radiotap_attach(sc);
/* Setup Tx status flags (constant). */
sc->sc_txs.flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY |
IEEE80211_RATECTL_STATUS_LONG_RETRY;
callout_init_mtx(&sc->calib_to, &sc->rxon_mtx, 0); callout_init_mtx(&sc->calib_to, &sc->rxon_mtx, 0);
callout_init_mtx(&sc->scan_timeout, &sc->rxon_mtx, 0); callout_init_mtx(&sc->scan_timeout, &sc->rxon_mtx, 0);
callout_init_mtx(&sc->tx_timeout, &sc->txq_state_mtx, 0); callout_init_mtx(&sc->tx_timeout, &sc->txq_state_mtx, 0);
@@ -2051,14 +2055,13 @@ wpi_rx_statistics(struct wpi_softc *sc, struct wpi_rx_desc *desc,
static void static void
wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc) wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
{ {
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct wpi_tx_ring *ring = &sc->txq[desc->qid & 0x3]; struct wpi_tx_ring *ring = &sc->txq[desc->qid & 0x3];
struct wpi_tx_data *data = &ring->data[desc->idx]; struct wpi_tx_data *data = &ring->data[desc->idx];
struct wpi_tx_stat *stat = (struct wpi_tx_stat *)(desc + 1); struct wpi_tx_stat *stat = (struct wpi_tx_stat *)(desc + 1);
struct mbuf *m; struct mbuf *m;
struct ieee80211_node *ni; struct ieee80211_node *ni;
struct ieee80211vap *vap;
uint32_t status = le32toh(stat->status); uint32_t status = le32toh(stat->status);
int ackfailcnt = stat->ackfailcnt / WPI_NTRIES_DEFAULT;
KASSERT(data->ni != NULL, ("no node")); KASSERT(data->ni != NULL, ("no node"));
KASSERT(data->m != NULL, ("no mbuf")); KASSERT(data->m != NULL, ("no mbuf"));
@@ -2075,18 +2078,32 @@ wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
bus_dmamap_unload(ring->data_dmat, data->map); bus_dmamap_unload(ring->data_dmat, data->map);
m = data->m, data->m = NULL; m = data->m, data->m = NULL;
ni = data->ni, data->ni = NULL; ni = data->ni, data->ni = NULL;
vap = ni->ni_vap;
/* /*
* Update rate control statistics for the node. * Update rate control statistics for the node.
*/ */
if (status & WPI_TX_STATUS_FAIL) { txs->short_retries = stat->rtsfailcnt;
ieee80211_ratectl_tx_complete(vap, ni, txs->long_retries = stat->ackfailcnt / WPI_NTRIES_DEFAULT;
IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); if (!(status & WPI_TX_STATUS_FAIL))
} else txs->status = IEEE80211_RATECTL_TX_SUCCESS;
ieee80211_ratectl_tx_complete(vap, ni, else {
IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); switch (status & 0xff) {
case WPI_TX_STATUS_FAIL_SHORT_LIMIT:
txs->status = IEEE80211_RATECTL_TX_FAIL_SHORT;
break;
case WPI_TX_STATUS_FAIL_LONG_LIMIT:
txs->status = IEEE80211_RATECTL_TX_FAIL_LONG;
break;
case WPI_TX_STATUS_FAIL_LIFE_EXPIRE:
txs->status = IEEE80211_RATECTL_TX_FAIL_EXPIRED;
break;
default:
txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
break;
}
}
ieee80211_ratectl_tx_complete(ni, txs);
ieee80211_tx_complete(ni, m, (status & WPI_TX_STATUS_FAIL) != 0); ieee80211_tx_complete(ni, m, (status & WPI_TX_STATUS_FAIL) != 0);
WPI_TXQ_STATE_LOCK(sc); WPI_TXQ_STATE_LOCK(sc);
@@ -170,6 +170,7 @@ struct wpi_softc {
struct mtx sc_mtx; struct mtx sc_mtx;
struct ieee80211com sc_ic; struct ieee80211com sc_ic;
struct ieee80211_ratectl_tx_status sc_txs;
struct mtx tx_mtx; struct mtx tx_mtx;
@@ -14,6 +14,7 @@
#include <net/if_media.h> #include <net/if_media.h>
#include <net80211/ieee80211_var.h> #include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/wpi/if_wpireg.h> #include <dev/wpi/if_wpireg.h>
#include <dev/wpi/if_wpivar.h> #include <dev/wpi/if_wpivar.h>
@@ -207,9 +207,10 @@ static void iwn4965_tx_done(struct iwn_softc *, struct iwn_rx_desc *,
struct iwn_rx_data *); struct iwn_rx_data *);
static void iwn5000_tx_done(struct iwn_softc *, struct iwn_rx_desc *, static void iwn5000_tx_done(struct iwn_softc *, struct iwn_rx_desc *,
struct iwn_rx_data *); struct iwn_rx_data *);
static void iwn_tx_done(struct iwn_softc *, struct iwn_rx_desc *, int, static void iwn_tx_done(struct iwn_softc *, struct iwn_rx_desc *, int, int,
uint8_t); uint8_t);
static void iwn_ampdu_tx_done(struct iwn_softc *, int, int, int, int, void *); static void iwn_ampdu_tx_done(struct iwn_softc *, int, int, int, int, int,
void *);
static void iwn_cmd_done(struct iwn_softc *, struct iwn_rx_desc *); static void iwn_cmd_done(struct iwn_softc *, struct iwn_rx_desc *);
static void iwn_notif_intr(struct iwn_softc *); static void iwn_notif_intr(struct iwn_softc *);
static void iwn_wakeup_intr(struct iwn_softc *); static void iwn_wakeup_intr(struct iwn_softc *);
@@ -3163,6 +3164,7 @@ static void
iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc, iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc,
struct iwn_rx_data *data) struct iwn_rx_data *data)
{ {
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct iwn_ops *ops = &sc->ops; struct iwn_ops *ops = &sc->ops;
struct iwn_node *wn; struct iwn_node *wn;
struct ieee80211_node *ni; struct ieee80211_node *ni;
@@ -3174,7 +3176,7 @@ iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc,
uint64_t bitmap; uint64_t bitmap;
uint16_t ssn; uint16_t ssn;
uint8_t tid; uint8_t tid;
int ackfailcnt = 0, i, lastidx, qid, *res, shift; int i, lastidx, qid, *res, shift;
int tx_ok = 0, tx_err = 0; int tx_ok = 0, tx_err = 0;
DPRINTF(sc, IWN_DEBUG_TRACE | IWN_DEBUG_XMIT, "->%s begin\n", __func__); DPRINTF(sc, IWN_DEBUG_TRACE | IWN_DEBUG_XMIT, "->%s begin\n", __func__);
@@ -3243,15 +3245,15 @@ iwn_rx_compressed_ba(struct iwn_softc *sc, struct iwn_rx_desc *desc,
ni = tap->txa_ni; ni = tap->txa_ni;
bitmap = (le64toh(ba->bitmap) >> shift) & wn->agg[tid].bitmap; bitmap = (le64toh(ba->bitmap) >> shift) & wn->agg[tid].bitmap;
for (i = 0; bitmap; i++) { for (i = 0; bitmap; i++) {
txs->flags = 0; /* XXX TODO */
if ((bitmap & 1) == 0) { if ((bitmap & 1) == 0) {
tx_err ++; tx_err ++;
ieee80211_ratectl_tx_complete(ni->ni_vap, ni, txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL);
} else { } else {
tx_ok ++; tx_ok ++;
ieee80211_ratectl_tx_complete(ni->ni_vap, ni, txs->status = IEEE80211_RATECTL_TX_SUCCESS;
IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL);
} }
ieee80211_ratectl_tx_complete(ni, txs);
bitmap >>= 1; bitmap >>= 1;
} }
@@ -3517,9 +3519,9 @@ iwn4965_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD); bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD);
if (qid >= sc->firstaggqueue) { if (qid >= sc->firstaggqueue) {
iwn_ampdu_tx_done(sc, qid, desc->idx, stat->nframes, iwn_ampdu_tx_done(sc, qid, desc->idx, stat->nframes,
stat->ackfailcnt, &stat->status); stat->rtsfailcnt, stat->ackfailcnt, &stat->status);
} else { } else {
iwn_tx_done(sc, desc, stat->ackfailcnt, iwn_tx_done(sc, desc, stat->rtsfailcnt, stat->ackfailcnt,
le32toh(stat->status) & 0xff); le32toh(stat->status) & 0xff);
} }
} }
@@ -3552,9 +3554,9 @@ iwn5000_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD); bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD);
if (qid >= sc->firstaggqueue) { if (qid >= sc->firstaggqueue) {
iwn_ampdu_tx_done(sc, qid, desc->idx, stat->nframes, iwn_ampdu_tx_done(sc, qid, desc->idx, stat->nframes,
stat->ackfailcnt, &stat->status); stat->rtsfailcnt, stat->ackfailcnt, &stat->status);
} else { } else {
iwn_tx_done(sc, desc, stat->ackfailcnt, iwn_tx_done(sc, desc, stat->rtsfailcnt, stat->ackfailcnt,
le16toh(stat->status) & 0xff); le16toh(stat->status) & 0xff);
} }
} }
@@ -3563,14 +3565,14 @@ iwn5000_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
* Adapter-independent backend for TX_DONE firmware notifications. * Adapter-independent backend for TX_DONE firmware notifications.
*/ */
static void static void
iwn_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, int ackfailcnt, iwn_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, int rtsfailcnt,
uint8_t status) int ackfailcnt, uint8_t status)
{ {
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct iwn_tx_ring *ring = &sc->txq[desc->qid & 0xf]; struct iwn_tx_ring *ring = &sc->txq[desc->qid & 0xf];
struct iwn_tx_data *data = &ring->data[desc->idx]; struct iwn_tx_data *data = &ring->data[desc->idx];
struct mbuf *m; struct mbuf *m;
struct ieee80211_node *ni; struct ieee80211_node *ni;
struct ieee80211vap *vap;
KASSERT(data->ni != NULL, ("no node")); KASSERT(data->ni != NULL, ("no node"));
@@ -3581,17 +3583,33 @@ iwn_tx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, int ackfailcnt,
bus_dmamap_unload(ring->data_dmat, data->map); bus_dmamap_unload(ring->data_dmat, data->map);
m = data->m, data->m = NULL; m = data->m, data->m = NULL;
ni = data->ni, data->ni = NULL; ni = data->ni, data->ni = NULL;
vap = ni->ni_vap;
/* /*
* Update rate control statistics for the node. * Update rate control statistics for the node.
*/ */
if (status & IWN_TX_FAIL) txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY |
ieee80211_ratectl_tx_complete(vap, ni, IEEE80211_RATECTL_STATUS_LONG_RETRY;
IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL); txs->short_retries = rtsfailcnt;
else txs->long_retries = ackfailcnt;
ieee80211_ratectl_tx_complete(vap, ni, if (!(status & IWN_TX_FAIL))
IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL); txs->status = IEEE80211_RATECTL_TX_SUCCESS;
else {
switch (status) {
case IWN_TX_FAIL_SHORT_LIMIT:
txs->status = IEEE80211_RATECTL_TX_FAIL_SHORT;
break;
case IWN_TX_FAIL_LONG_LIMIT:
txs->status = IEEE80211_RATECTL_TX_FAIL_LONG;
break;
case IWN_TX_STATUS_FAIL_LIFE_EXPIRE:
txs->status = IEEE80211_RATECTL_TX_FAIL_EXPIRED;
break;
default:
txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
break;
}
}
ieee80211_ratectl_tx_complete(ni, txs);
/* /*
* Channels marked for "radar" require traffic to be received * Channels marked for "radar" require traffic to be received
@@ -3656,10 +3674,11 @@ iwn_cmd_done(struct iwn_softc *sc, struct iwn_rx_desc *desc)
static void static void
iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes, iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes,
int ackfailcnt, void *stat) int rtsfailcnt, int ackfailcnt, void *stat)
{ {
struct iwn_ops *ops = &sc->ops; struct iwn_ops *ops = &sc->ops;
struct iwn_tx_ring *ring = &sc->txq[qid]; struct iwn_tx_ring *ring = &sc->txq[qid];
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct iwn_tx_data *data; struct iwn_tx_data *data;
struct mbuf *m; struct mbuf *m;
struct iwn_node *wn; struct iwn_node *wn;
@@ -3698,6 +3717,10 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes,
* handled differently. * handled differently.
*/ */
if (nframes == 1) { if (nframes == 1) {
txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY |
IEEE80211_RATECTL_STATUS_LONG_RETRY;
txs->short_retries = rtsfailcnt;
txs->long_retries = ackfailcnt;
if ((*status & 0xff) != 1 && (*status & 0xff) != 2) { if ((*status & 0xff) != 1 && (*status & 0xff) != 2) {
#ifdef NOT_YET #ifdef NOT_YET
printf("ieee80211_send_bar()\n"); printf("ieee80211_send_bar()\n");
@@ -3707,11 +3730,8 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes,
* notification is pushed up to the rate control * notification is pushed up to the rate control
* layer. * layer.
*/ */
ieee80211_ratectl_tx_complete(ni->ni_vap, /* XXX */
ni, txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
IEEE80211_RATECTL_TX_FAILURE,
&ackfailcnt,
NULL);
} else { } else {
/* /*
* If nframes=1, then we won't be getting a BA for * If nframes=1, then we won't be getting a BA for
@@ -3719,12 +3739,9 @@ iwn_ampdu_tx_done(struct iwn_softc *sc, int qid, int idx, int nframes,
* rate control code with how many retries were * rate control code with how many retries were
* needed to send it. * needed to send it.
*/ */
ieee80211_ratectl_tx_complete(ni->ni_vap, txs->status = IEEE80211_RATECTL_TX_SUCCESS;
ni,
IEEE80211_RATECTL_TX_SUCCESS,
&ackfailcnt,
NULL);
} }
ieee80211_ratectl_tx_complete(ni, txs);
} }
bitmap = 0; bitmap = 0;
@@ -238,6 +238,7 @@ struct iwn_softc {
struct cdev *sc_cdev; struct cdev *sc_cdev;
struct mtx sc_mtx; struct mtx sc_mtx;
struct ieee80211com sc_ic; struct ieee80211com sc_ic;
struct ieee80211_ratectl_tx_status sc_txs;
u_int sc_flags; u_int sc_flags;
#define IWN_FLAG_HAS_OTPROM (1 << 1) #define IWN_FLAG_HAS_OTPROM (1 << 1)
@@ -15,6 +15,7 @@
#include <net80211/ieee80211_var.h> #include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_amrr.h> #include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/iwn/if_iwnreg.h> #include <dev/iwn/if_iwnreg.h>
#include <dev/iwn/if_iwnvar.h> #include <dev/iwn/if_iwnvar.h>
@@ -2437,13 +2437,13 @@ mwl_node_getmimoinfo(const struct ieee80211_node *ni,
if (mn->mn_ai.rssi_c > rssi_max) if (mn->mn_ai.rssi_c > rssi_max)
rssi_max = mn->mn_ai.rssi_c; rssi_max = mn->mn_ai.rssi_c;
CVT(mi->rssi[0], mn->mn_ai.rssi_a); CVT(mi->ch[0].rssi[0], mn->mn_ai.rssi_a);
CVT(mi->rssi[1], mn->mn_ai.rssi_b); CVT(mi->ch[1].rssi[0], mn->mn_ai.rssi_b);
CVT(mi->rssi[2], mn->mn_ai.rssi_c); CVT(mi->ch[2].rssi[0], mn->mn_ai.rssi_c);
mi->noise[0] = mn->mn_ai.nf_a; mi->ch[0].noise[0] = mn->mn_ai.nf_a;
mi->noise[1] = mn->mn_ai.nf_b; mi->ch[1].noise[0] = mn->mn_ai.nf_b;
mi->noise[2] = mn->mn_ai.nf_c; mi->ch[2].noise[0] = mn->mn_ai.nf_c;
#undef CVT #undef CVT
} }
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD: releng/11.1/sys/dev/ral/if_ral_pci.c 287197 2015-08-27 08:56
#include <net80211/ieee80211_var.h> #include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h> #include <net80211/ieee80211_radiotap.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/pci/pcireg.h> #include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h> #include <dev/pci/pcivar.h>
@@ -911,17 +911,18 @@ rt2560_encryption_intr(struct rt2560_softc *sc)
static void static void
rt2560_tx_intr(struct rt2560_softc *sc) rt2560_tx_intr(struct rt2560_softc *sc)
{ {
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct rt2560_tx_desc *desc; struct rt2560_tx_desc *desc;
struct rt2560_tx_data *data; struct rt2560_tx_data *data;
struct mbuf *m; struct mbuf *m;
struct ieee80211vap *vap;
struct ieee80211_node *ni; struct ieee80211_node *ni;
uint32_t flags; uint32_t flags;
int retrycnt, status; int status;
bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map, bus_dmamap_sync(sc->txq.desc_dmat, sc->txq.desc_map,
BUS_DMASYNC_POSTREAD); BUS_DMASYNC_POSTREAD);
txs->flags = IEEE80211_RATECTL_STATUS_LONG_RETRY;
for (;;) { for (;;) {
desc = &sc->txq.desc[sc->txq.next]; desc = &sc->txq.desc[sc->txq.next];
data = &sc->txq.data[sc->txq.next]; data = &sc->txq.data[sc->txq.next];
@@ -934,41 +935,37 @@ rt2560_tx_intr(struct rt2560_softc *sc)
m = data->m; m = data->m;
ni = data->ni; ni = data->ni;
vap = ni->ni_vap;
switch (flags & RT2560_TX_RESULT_MASK) { switch (flags & RT2560_TX_RESULT_MASK) {
case RT2560_TX_SUCCESS: case RT2560_TX_SUCCESS:
retrycnt = 0; txs->status = IEEE80211_RATECTL_TX_SUCCESS;
txs->long_retries = 0;
DPRINTFN(sc, 10, "%s\n", "data frame sent successfully"); DPRINTFN(sc, 10, "%s\n", "data frame sent successfully");
if (data->rix != IEEE80211_FIXED_RATE_NONE) if (data->rix != IEEE80211_FIXED_RATE_NONE)
ieee80211_ratectl_tx_complete(vap, ni, ieee80211_ratectl_tx_complete(ni, txs);
IEEE80211_RATECTL_TX_SUCCESS,
&retrycnt, NULL);
status = 0; status = 0;
break; break;
case RT2560_TX_SUCCESS_RETRY: case RT2560_TX_SUCCESS_RETRY:
retrycnt = RT2560_TX_RETRYCNT(flags); txs->status = IEEE80211_RATECTL_TX_SUCCESS;
txs->long_retries = RT2560_TX_RETRYCNT(flags);
DPRINTFN(sc, 9, "data frame sent after %u retries\n", DPRINTFN(sc, 9, "data frame sent after %u retries\n",
retrycnt); txs->long_retries);
if (data->rix != IEEE80211_FIXED_RATE_NONE) if (data->rix != IEEE80211_FIXED_RATE_NONE)
ieee80211_ratectl_tx_complete(vap, ni, ieee80211_ratectl_tx_complete(ni, txs);
IEEE80211_RATECTL_TX_SUCCESS,
&retrycnt, NULL);
status = 0; status = 0;
break; break;
case RT2560_TX_FAIL_RETRY: case RT2560_TX_FAIL_RETRY:
retrycnt = RT2560_TX_RETRYCNT(flags); txs->status = IEEE80211_RATECTL_TX_FAIL_LONG;
txs->long_retries = RT2560_TX_RETRYCNT(flags);
DPRINTFN(sc, 9, "data frame failed after %d retries\n", DPRINTFN(sc, 9, "data frame failed after %d retries\n",
retrycnt); txs->long_retries);
if (data->rix != IEEE80211_FIXED_RATE_NONE) if (data->rix != IEEE80211_FIXED_RATE_NONE)
ieee80211_ratectl_tx_complete(vap, ni, ieee80211_ratectl_tx_complete(ni, txs);
IEEE80211_RATECTL_TX_FAILURE,
&retrycnt, NULL);
status = 1; status = 1;
break; break;
@@ -105,6 +105,7 @@ struct rt2560_vap {
struct rt2560_softc { struct rt2560_softc {
struct ieee80211com sc_ic; struct ieee80211com sc_ic;
struct ieee80211_ratectl_tx_status sc_txs;
struct mtx sc_mtx; struct mtx sc_mtx;
struct mbufq sc_snd; struct mbufq sc_snd;
device_t sc_dev; device_t sc_dev;
@@ -851,12 +851,13 @@ rt2661_eeprom_read(struct rt2661_softc *sc, uint8_t addr)
static void static void
rt2661_tx_intr(struct rt2661_softc *sc) rt2661_tx_intr(struct rt2661_softc *sc)
{ {
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct rt2661_tx_ring *txq; struct rt2661_tx_ring *txq;
struct rt2661_tx_data *data; struct rt2661_tx_data *data;
uint32_t val; uint32_t val;
int error, qid, retrycnt; int error, qid;
struct ieee80211vap *vap;
txs->flags = IEEE80211_RATECTL_TX_FAIL_LONG;
for (;;) { for (;;) {
struct ieee80211_node *ni; struct ieee80211_node *ni;
struct mbuf *m; struct mbuf *m;
@@ -879,31 +880,27 @@ rt2661_tx_intr(struct rt2661_softc *sc)
/* if no frame has been sent, ignore */ /* if no frame has been sent, ignore */
if (ni == NULL) if (ni == NULL)
continue; continue;
else
vap = ni->ni_vap;
switch (RT2661_TX_RESULT(val)) { switch (RT2661_TX_RESULT(val)) {
case RT2661_TX_SUCCESS: case RT2661_TX_SUCCESS:
retrycnt = RT2661_TX_RETRYCNT(val); txs->status = IEEE80211_RATECTL_TX_SUCCESS;
txs->long_retries = RT2661_TX_RETRYCNT(val);
DPRINTFN(sc, 10, "data frame sent successfully after " DPRINTFN(sc, 10, "data frame sent successfully after "
"%d retries\n", retrycnt); "%d retries\n", txs->long_retries);
if (data->rix != IEEE80211_FIXED_RATE_NONE) if (data->rix != IEEE80211_FIXED_RATE_NONE)
ieee80211_ratectl_tx_complete(vap, ni, ieee80211_ratectl_tx_complete(ni, txs);
IEEE80211_RATECTL_TX_SUCCESS,
&retrycnt, NULL);
error = 0; error = 0;
break; break;
case RT2661_TX_RETRY_FAIL: case RT2661_TX_RETRY_FAIL:
retrycnt = RT2661_TX_RETRYCNT(val); txs->status = IEEE80211_RATECTL_TX_FAIL_LONG;
txs->long_retries = RT2661_TX_RETRYCNT(val);
DPRINTFN(sc, 9, "%s\n", DPRINTFN(sc, 9, "%s\n",
"sending data frame failed (too much retries)"); "sending data frame failed (too much retries)");
if (data->rix != IEEE80211_FIXED_RATE_NONE) if (data->rix != IEEE80211_FIXED_RATE_NONE)
ieee80211_ratectl_tx_complete(vap, ni, ieee80211_ratectl_tx_complete(ni, txs);
IEEE80211_RATECTL_TX_FAILURE,
&retrycnt, NULL);
error = 1; error = 1;
break; break;
@@ -98,6 +98,7 @@ struct rt2661_vap {
struct rt2661_softc { struct rt2661_softc {
struct ieee80211com sc_ic; struct ieee80211com sc_ic;
struct ieee80211_ratectl_tx_status sc_txs;
struct mtx sc_mtx; struct mtx sc_mtx;
struct mbufq sc_snd; struct mbufq sc_snd;
device_t sc_dev; device_t sc_dev;
@@ -1083,12 +1083,13 @@ rt2860_intr_coherent(struct rt2860_softc *sc)
static void static void
rt2860_drain_stats_fifo(struct rt2860_softc *sc) rt2860_drain_stats_fifo(struct rt2860_softc *sc)
{ {
struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
struct ieee80211_node *ni; struct ieee80211_node *ni;
uint32_t stat; uint32_t stat;
int retrycnt;
uint8_t wcid, mcs, pid; uint8_t wcid, mcs, pid;
/* drain Tx status FIFO (maxsize = 16) */ /* drain Tx status FIFO (maxsize = 16) */
txs->flags = IEEE80211_RATECTL_STATUS_LONG_RETRY;
while ((stat = RAL_READ(sc, RT2860_TX_STAT_FIFO)) & RT2860_TXQ_VLD) { while ((stat = RAL_READ(sc, RT2860_TX_STAT_FIFO)) & RT2860_TXQ_VLD) {
DPRINTFN(4, ("tx stat 0x%08x\n", stat)); DPRINTFN(4, ("tx stat 0x%08x\n", stat));
@@ -1110,14 +1111,15 @@ rt2860_drain_stats_fifo(struct rt2860_softc *sc)
mcs = (stat >> RT2860_TXQ_MCS_SHIFT) & 0x7f; mcs = (stat >> RT2860_TXQ_MCS_SHIFT) & 0x7f;
pid = (stat >> RT2860_TXQ_PID_SHIFT) & 0xf; pid = (stat >> RT2860_TXQ_PID_SHIFT) & 0xf;
if (mcs + 1 != pid) if (mcs + 1 != pid)
retrycnt = 1; txs->long_retries = 1;
else else
retrycnt = 0; txs->long_retries = 0;
ieee80211_ratectl_tx_complete(ni->ni_vap, ni, txs->status = IEEE80211_RATECTL_TX_SUCCESS;
IEEE80211_RATECTL_TX_SUCCESS, &retrycnt, NULL); ieee80211_ratectl_tx_complete(ni, txs);
} else { } else {
ieee80211_ratectl_tx_complete(ni->ni_vap, ni, txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
IEEE80211_RATECTL_TX_FAILURE, &retrycnt, NULL); txs->long_retries = 1; /* XXX */
ieee80211_ratectl_tx_complete(ni, txs);
if_inc_counter(ni->ni_vap->iv_ifp, if_inc_counter(ni->ni_vap->iv_ifp,
IFCOUNTER_OERRORS, 1); IFCOUNTER_OERRORS, 1);
} }
@@ -116,6 +116,7 @@ struct rt2860_vap {
struct rt2860_softc { struct rt2860_softc {
struct ieee80211com sc_ic; struct ieee80211com sc_ic;
struct ieee80211_ratectl_tx_status sc_txs;
struct mbufq sc_snd; struct mbufq sc_snd;
struct mtx sc_mtx; struct mtx sc_mtx;
device_t sc_dev; device_t sc_dev;
@@ -16,6 +16,7 @@
#include <net80211/ieee80211_var.h> #include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_amrr.h> #include <net80211/ieee80211_amrr.h>
#include <net80211/ieee80211_ratectl.h>
#include <dev/ral/rt2560reg.h> #include <dev/ral/rt2560reg.h>
#include <dev/ral/rt2560var.h> #include <dev/ral/rt2560var.h>