From 432f14b4e1a00b1844cf2ce290a75698d7011a87 Mon Sep 17 00:00:00 2001 From: avos Date: Sat, 8 Oct 2016 20:41:08 +0000 Subject: [PATCH] wpi: restore frame header before submitting an mbuf to ieee80211_tx_complete() This change allows to pass packet length to rate control modules and fixes IFCOUNTER_OBYTES calculation. Tested with Intel 3945BG, STA mode. --- sys/dev/wpi/if_wpi.c | 10 +++++++++- sys/dev/wpi/if_wpivar.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index 61034a6f0e0a..b6f69a5aa6ed 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -527,7 +527,8 @@ wpi_attach(device_t dev) wpi_radiotap_attach(sc); /* Setup Tx status flags (constant). */ - sc->sc_txs.flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY | + sc->sc_txs.flags = IEEE80211_RATECTL_STATUS_PKTLEN | + IEEE80211_RATECTL_STATUS_SHORT_RETRY | IEEE80211_RATECTL_STATUS_LONG_RETRY; callout_init_mtx(&sc->calib_to, &sc->rxon_mtx, 0); @@ -2079,9 +2080,15 @@ wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc) m = data->m, data->m = NULL; ni = data->ni, data->ni = NULL; + /* Restore frame header. */ + KASSERT(M_LEADINGSPACE(m) >= data->hdrlen, ("no frame header!")); + M_PREPEND(m, data->hdrlen, M_NOWAIT); + KASSERT(m != NULL, ("%s: m is NULL\n", __func__)); + /* * Update rate control statistics for the node. */ + txs->pktlen = m->m_pkthdr.len; txs->short_retries = stat->rtsfailcnt; txs->long_retries = stat->ackfailcnt / WPI_NTRIES_DEFAULT; if (!(status & WPI_TX_STATUS_FAIL)) @@ -2721,6 +2728,7 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf) data->m = buf->m; data->ni = buf->ni; + data->hdrlen = hdrlen; DPRINTF(sc, WPI_DEBUG_XMIT, "%s: qid %d idx %d len %d nsegs %d\n", __func__, ring->qid, cur, totlen, nsegs); diff --git a/sys/dev/wpi/if_wpivar.h b/sys/dev/wpi/if_wpivar.h index f8b92e2be672..8c45a9c85066 100644 --- a/sys/dev/wpi/if_wpivar.h +++ b/sys/dev/wpi/if_wpivar.h @@ -63,6 +63,7 @@ struct wpi_tx_data { bus_addr_t cmd_paddr; struct mbuf *m; struct ieee80211_node *ni; + int hdrlen; }; struct wpi_tx_ring {