Skip to content

Commit e6a9854

Browse files
jmberglinvjw
authored andcommitted
mac80211/drivers: rewrite the rate control API
So after the previous changes we were still unhappy with how convoluted the API is and decided to make things simpler for everybody. This completely changes the rate control API, now taking into account 802.11n with MCS rates and more control, most drivers don't support that though. Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent cb121ba commit e6a9854

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+889
-685
lines changed

drivers/net/wireless/adm8211.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,14 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
341341
pci_unmap_single(priv->pdev, info->mapping,
342342
info->skb->len, PCI_DMA_TODEVICE);
343343

344-
memset(&txi->status, 0, sizeof(txi->status));
344+
ieee80211_tx_info_clear_status(txi);
345+
345346
skb_pull(skb, sizeof(struct adm8211_tx_hdr));
346347
memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen);
347-
if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK)) {
348-
if (status & TDES0_STATUS_ES)
349-
txi->status.excessive_retries = 1;
350-
else
351-
txi->flags |= IEEE80211_TX_STAT_ACK;
352-
}
348+
if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) &&
349+
!(status & TDES0_STATUS_ES))
350+
txi->flags |= IEEE80211_TX_STAT_ACK;
351+
353352
ieee80211_tx_status_irqsafe(dev, skb);
354353

355354
info->skb = NULL;
@@ -1691,8 +1690,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
16911690
struct ieee80211_hdr *hdr;
16921691
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
16931692
struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info);
1693+
u8 rc_flags;
16941694

1695-
short_preamble = !!(txrate->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE);
1695+
rc_flags = info->control.rates[0].flags;
1696+
short_preamble = !!(rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
16961697
plcp_signal = txrate->bitrate;
16971698

16981699
hdr = (struct ieee80211_hdr *)skb->data;
@@ -1724,10 +1725,10 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
17241725
if (short_preamble)
17251726
txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE);
17261727

1727-
if (info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
1728+
if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
17281729
txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS);
17291730

1730-
txhdr->retry_limit = info->control.retry_limit;
1731+
txhdr->retry_limit = info->control.rates[0].count;
17311732

17321733
adm8211_tx_raw(dev, skb, plcp_signal, hdrlen);
17331734

drivers/net/wireless/ath5k/base.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ ath5k_pci_probe(struct pci_dev *pdev,
541541

542542
/* set up multi-rate retry capabilities */
543543
if (sc->ah->ah_version == AR5K_AR5212) {
544-
hw->max_altrates = 3;
545-
hw->max_altrate_tries = 11;
544+
hw->max_rates = 4;
545+
hw->max_rate_tries = 11;
546546
}
547547

548548
/* Finish private driver data initialization */
@@ -1181,7 +1181,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
11811181
ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,
11821182
(sc->power_level * 2),
11831183
ieee80211_get_tx_rate(sc->hw, info)->hw_value,
1184-
info->control.retry_limit, keyidx, 0, flags, 0, 0);
1184+
info->control.rates[0].count, keyidx, 0, flags, 0, 0);
11851185
if (ret)
11861186
goto err_unmap;
11871187

@@ -1193,7 +1193,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
11931193
break;
11941194

11951195
mrr_rate[i] = rate->hw_value;
1196-
mrr_tries[i] = info->control.retries[i].limit;
1196+
mrr_tries[i] = info->control.rates[i + 1].count;
11971197
}
11981198

11991199
ah->ah_setup_mrr_tx_desc(ah, ds,
@@ -1849,30 +1849,26 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
18491849
pci_unmap_single(sc->pdev, bf->skbaddr, skb->len,
18501850
PCI_DMA_TODEVICE);
18511851

1852-
memset(&info->status, 0, sizeof(info->status));
1853-
info->tx_rate_idx = ath5k_hw_to_driver_rix(sc,
1854-
ts.ts_rate[ts.ts_final_idx]);
1855-
info->status.retry_count = ts.ts_longretry;
1856-
1852+
ieee80211_tx_info_clear_status(info);
18571853
for (i = 0; i < 4; i++) {
1858-
struct ieee80211_tx_altrate *r =
1859-
&info->status.retries[i];
1854+
struct ieee80211_tx_rate *r =
1855+
&info->status.rates[i];
18601856

18611857
if (ts.ts_rate[i]) {
1862-
r->rate_idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]);
1863-
r->limit = ts.ts_retry[i];
1858+
r->idx = ath5k_hw_to_driver_rix(sc, ts.ts_rate[i]);
1859+
r->count = ts.ts_retry[i];
18641860
} else {
1865-
r->rate_idx = -1;
1866-
r->limit = 0;
1861+
r->idx = -1;
1862+
r->count = 0;
18671863
}
18681864
}
18691865

1870-
info->status.excessive_retries = 0;
1866+
/* count the successful attempt as well */
1867+
info->status.rates[ts.ts_final_idx].count++;
1868+
18711869
if (unlikely(ts.ts_status)) {
18721870
sc->ll_stats.dot11ACKFailureCount++;
1873-
if (ts.ts_status & AR5K_TXERR_XRETRY)
1874-
info->status.excessive_retries = 1;
1875-
else if (ts.ts_status & AR5K_TXERR_FILT)
1871+
if (ts.ts_status & AR5K_TXERR_FILT)
18761872
info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
18771873
} else {
18781874
info->flags |= IEEE80211_TX_STAT_ACK;

drivers/net/wireless/ath9k/main.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -457,30 +457,26 @@ void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
457457
DPRINTF(sc, ATH_DBG_XMIT,
458458
"%s: TX complete: skb: %p\n", __func__, skb);
459459

460+
ieee80211_tx_info_clear_status(tx_info);
460461
if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
461462
tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
462-
/* free driver's private data area of tx_info */
463-
if (tx_info->driver_data[0] != NULL)
464-
kfree(tx_info->driver_data[0]);
465-
tx_info->driver_data[0] = NULL;
463+
/* free driver's private data area of tx_info, XXX: HACK! */
464+
if (tx_info->control.vif != NULL)
465+
kfree(tx_info->control.vif);
466+
tx_info->control.vif = NULL;
466467
}
467468

468469
if (tx_status->flags & ATH_TX_BAR) {
469470
tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
470471
tx_status->flags &= ~ATH_TX_BAR;
471472
}
472473

473-
if (tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY)) {
474-
if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) {
475-
/* Frame was not ACKed, but an ACK was expected */
476-
tx_info->status.excessive_retries = 1;
477-
}
478-
} else {
474+
if (!(tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY))) {
479475
/* Frame was ACKed */
480476
tx_info->flags |= IEEE80211_TX_STAT_ACK;
481477
}
482478

483-
tx_info->status.retry_count = tx_status->retries;
479+
tx_info->status.rates[0].count = tx_status->retries + 1;
484480

485481
ieee80211_tx_status(hw, skb);
486482
if (an)

drivers/net/wireless/ath9k/rc.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,24 +1864,21 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
18641864

18651865
hdr = (struct ieee80211_hdr *)skb->data;
18661866
fc = hdr->frame_control;
1867-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1867+
/* XXX: UGLY HACK!! */
1868+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
18681869

18691870
spin_lock_bh(&sc->node_lock);
18701871
an = ath_node_find(sc, hdr->addr1);
18711872
spin_unlock_bh(&sc->node_lock);
18721873

1873-
if (!an || !priv_sta || !ieee80211_is_data(fc)) {
1874-
if (tx_info->driver_data[0] != NULL) {
1875-
kfree(tx_info->driver_data[0]);
1876-
tx_info->driver_data[0] = NULL;
1877-
}
1874+
if (tx_info_priv == NULL)
18781875
return;
1879-
}
1880-
if (tx_info->driver_data[0] != NULL) {
1876+
1877+
if (an && priv_sta && ieee80211_is_data(fc))
18811878
ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
1882-
kfree(tx_info->driver_data[0]);
1883-
tx_info->driver_data[0] = NULL;
1884-
}
1879+
1880+
kfree(tx_info_priv);
1881+
tx_info->control.vif = NULL;
18851882
}
18861883

18871884
static void ath_tx_aggr_resp(struct ath_softc *sc,
@@ -1927,10 +1924,11 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
19271924
}
19281925
}
19291926

1930-
static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1931-
struct ieee80211_sta *sta, void *priv_sta,
1932-
struct sk_buff *skb, struct rate_selection *sel)
1927+
static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1928+
struct ieee80211_tx_rate_control *txrc)
19331929
{
1930+
struct ieee80211_supported_band *sband = txrc->sband;
1931+
struct sk_buff *skb = txrc->skb;
19341932
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
19351933
struct ath_softc *sc = priv;
19361934
struct ieee80211_hw *hw = sc->hw;
@@ -1945,17 +1943,17 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
19451943

19461944
DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
19471945

1948-
/* allocate driver private area of tx_info */
1949-
tx_info->driver_data[0] = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
1950-
ASSERT(tx_info->driver_data[0] != NULL);
1951-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1946+
/* allocate driver private area of tx_info, XXX: UGLY HACK! */
1947+
tx_info->control.vif = kzalloc(sizeof(*tx_info_priv), GFP_ATOMIC);
1948+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
1949+
ASSERT(tx_info_priv != NULL);
19521950

19531951
lowest_idx = rate_lowest_index(sband, sta);
19541952
tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
19551953
/* lowest rate for management and multicast/broadcast frames */
19561954
if (!ieee80211_is_data(fc) ||
19571955
is_multicast_ether_addr(hdr->addr1) || !sta) {
1958-
sel->rate_idx = lowest_idx;
1956+
tx_info->control.rates[0].idx = lowest_idx;
19591957
return;
19601958
}
19611959

@@ -1966,16 +1964,18 @@ static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
19661964
tx_info_priv->rcs,
19671965
&is_probe,
19681966
false);
1967+
#if 0
19691968
if (is_probe)
19701969
sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
1970+
#endif
19711971

19721972
/* Ratecontrol sometimes returns invalid rate index */
19731973
if (tx_info_priv->rcs[0].rix != 0xff)
19741974
ath_rc_priv->prev_data_rix = tx_info_priv->rcs[0].rix;
19751975
else
19761976
tx_info_priv->rcs[0].rix = ath_rc_priv->prev_data_rix;
19771977

1978-
sel->rate_idx = tx_info_priv->rcs[0].rix;
1978+
tx_info->control.rates[0].idx = tx_info_priv->rcs[0].rix;
19791979

19801980
/* Check if aggregation has to be enabled for this tid */
19811981

drivers/net/wireless/ath9k/xmit.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ static void fill_min_rates(struct sk_buff *skb, struct ath_tx_control *txctl)
168168

169169
hdr = (struct ieee80211_hdr *)skb->data;
170170
fc = hdr->frame_control;
171-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
171+
172+
/* XXX: HACK! */
173+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
172174

173175
if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) {
174176
txctl->use_minrate = 1;
@@ -288,13 +290,16 @@ static int ath_tx_prepare(struct ath_softc *sc,
288290

289291
if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
290292
txctl->flags |= ATH9K_TXDESC_NOACK;
291-
if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS)
293+
294+
if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
292295
txctl->flags |= ATH9K_TXDESC_RTSENA;
293296

294297
/*
295298
* Setup for rate calculations.
296299
*/
297-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
300+
301+
/* XXX: HACK! */
302+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
298303
rcs = tx_info_priv->rcs;
299304

300305
if (ieee80211_is_data(fc) && !txctl->use_minrate) {
@@ -855,7 +860,9 @@ static int ath_tx_send_normal(struct ath_softc *sc,
855860

856861
skb = (struct sk_buff *)bf->bf_mpdu;
857862
tx_info = IEEE80211_SKB_CB(skb);
858-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
863+
864+
/* XXX: HACK! */
865+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
859866
memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
860867

861868
/* update starting sequence number for subsequent ADDBA request */
@@ -1249,8 +1256,9 @@ static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
12491256
}
12501257
skb = bf->bf_mpdu;
12511258
tx_info = IEEE80211_SKB_CB(skb);
1252-
tx_info_priv = (struct ath_tx_info_priv *)
1253-
tx_info->driver_data[0];
1259+
1260+
/* XXX: HACK! */
1261+
tx_info_priv = (struct ath_tx_info_priv *) tx_info->control.vif;
12541262
if (ds->ds_txstat.ts_status & ATH9K_TXERR_FILT)
12551263
tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
12561264
if ((ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) == 0 &&
@@ -1431,7 +1439,8 @@ static int ath_tx_send_ampdu(struct ath_softc *sc,
14311439

14321440
skb = (struct sk_buff *)bf->bf_mpdu;
14331441
tx_info = IEEE80211_SKB_CB(skb);
1434-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1442+
/* XXX: HACK! */
1443+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
14351444
memcpy(bf->bf_rcs, tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
14361445

14371446
/* Add sub-frame to BAW */
@@ -1466,7 +1475,7 @@ static u32 ath_lookup_rate(struct ath_softc *sc,
14661475
skb = (struct sk_buff *)bf->bf_mpdu;
14671476
tx_info = IEEE80211_SKB_CB(skb);
14681477
tx_info_priv = (struct ath_tx_info_priv *)
1469-
tx_info->driver_data[0];
1478+
tx_info->control.vif; /* XXX: HACK! */
14701479
memcpy(bf->bf_rcs,
14711480
tx_info_priv->rcs, 4 * sizeof(tx_info_priv->rcs[0]));
14721481

@@ -1927,7 +1936,8 @@ static int ath_tx_start_dma(struct ath_softc *sc,
19271936

19281937
bf->bf_flags = txctl->flags;
19291938
bf->bf_keytype = txctl->keytype;
1930-
tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1939+
/* XXX: HACK! */
1940+
tx_info_priv = (struct ath_tx_info_priv *)tx_info->control.vif;
19311941
rcs = tx_info_priv->rcs;
19321942
bf->bf_rcs[0] = rcs[0];
19331943
bf->bf_rcs[1] = rcs[1];

drivers/net/wireless/b43/dma.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,13 +1387,11 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev,
13871387

13881388
info = IEEE80211_SKB_CB(meta->skb);
13891389

1390-
memset(&info->status, 0, sizeof(info->status));
1391-
13921390
/*
13931391
* Call back to inform the ieee80211 subsystem about
13941392
* the status of the transmission.
13951393
*/
1396-
frame_succeed = b43_fill_txstatus_report(info, status);
1394+
frame_succeed = b43_fill_txstatus_report(dev, info, status);
13971395
#ifdef CONFIG_B43_DEBUG
13981396
if (frame_succeed)
13991397
ring->nr_succeed_tx_packets++;

drivers/net/wireless/b43/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4555,7 +4555,7 @@ static int b43_wireless_init(struct ssb_device *dev)
45554555
BIT(NL80211_IFTYPE_ADHOC);
45564556

45574557
hw->queues = b43_modparam_qos ? 4 : 1;
4558-
hw->max_altrates = 1;
4558+
hw->max_rates = 2;
45594559
SET_IEEE80211_DEV(hw, dev->dev);
45604560
if (is_valid_ether_addr(sprom->et1mac))
45614561
SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);

drivers/net/wireless/b43/pio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,8 @@ void b43_pio_handle_txstatus(struct b43_wldev *dev,
587587
spin_lock(&q->lock); /* IRQs are already disabled. */
588588

589589
info = IEEE80211_SKB_CB(pack->skb);
590-
memset(&info->status, 0, sizeof(info->status));
591590

592-
b43_fill_txstatus_report(info, status);
591+
b43_fill_txstatus_report(dev, info, status);
593592

594593
total_len = pack->skb->len + b43_txhdr_size(dev);
595594
total_len = roundup(total_len, 4);

0 commit comments

Comments
 (0)