From cf2afadc08810c62a6f6dae177b056eaea8f5656 Mon Sep 17 00:00:00 2001 From: proski Date: Tue, 28 Apr 2009 05:59:25 +0000 Subject: [PATCH] Fix sample and minstrel algorithms for AR5416 Use correct shifts for the rate data. Remove excessive debug statements that would have to be extended even further to deal with AR5416. The code has been taken from the FreeBSD driver. The original coding style has been preserved. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4015 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath_rate/minstrel/minstrel.c | 28 +++++++++++++++------- ath_rate/minstrel/minstrel.h | 10 ++++++++ ath_rate/sample/sample.c | 46 +++++++++++++----------------------- ath_rate/sample/sample.h | 10 ++++++++ 4 files changed, 57 insertions(+), 37 deletions(-) diff --git a/ath_rate/minstrel/minstrel.c b/ath_rate/minstrel/minstrel.c index f466b10..eba7332 100644 --- a/ath_rate/minstrel/minstrel.c +++ b/ath_rate/minstrel/minstrel.c @@ -470,10 +470,10 @@ ath_rate_tx_complete(struct ath_softc *sc, int tries = 0; int mrr; int final_ndx; - int rate0, tries0, ndx0; - int rate1, tries1, ndx1; - int rate2, tries2, ndx2; - int rate3, tries3, ndx3; + int rate0, tries0, ndx0, hwrate0; + int rate1, tries1, ndx1, hwrate1; + int rate2, tries2, ndx2, hwrate2; + int rate3, tries3, ndx3, hwrate3; /* This is the index in the retry chain we finish at. * With no retransmits, it is always 0. @@ -520,19 +520,31 @@ ath_rate_tx_complete(struct ath_softc *sc, * call will always return 6,3,2,2. For some packets, we can * get a mrr of 0, -1, -1, -1, which indicates there is no * chain installed for that packet */ - rate0 = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate0)].ieeerate; + if (sc->sc_ah->ah_magic != 0x20065416) { + hwrate0 = MS(ds->ds_ctl3, AR_XmitRate0); + hwrate1 = MS(ds->ds_ctl3, AR_XmitRate1); + hwrate2 = MS(ds->ds_ctl3, AR_XmitRate2); + hwrate3 = MS(ds->ds_ctl3, AR_XmitRate3); + } else { + hwrate0 = MS(ds->ds_ctl3, AR5416_XmitRate0); + hwrate1 = MS(ds->ds_ctl3, AR5416_XmitRate1); + hwrate2 = MS(ds->ds_ctl3, AR5416_XmitRate2); + hwrate3 = MS(ds->ds_ctl3, AR5416_XmitRate3); + } + + rate0 = sc->sc_hwmap[hwrate0].ieeerate; tries0 = MS(ds->ds_ctl2, AR_XmitDataTries0); ndx0 = rate_to_ndx(sn, rate0); - rate1 = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate1)].ieeerate; + rate1 = sc->sc_hwmap[hwrate1].ieeerate; tries1 = MS(ds->ds_ctl2, AR_XmitDataTries1); ndx1 = rate_to_ndx(sn, rate1); - rate2 = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate2)].ieeerate; + rate2 = sc->sc_hwmap[hwrate2].ieeerate; tries2 = MS(ds->ds_ctl2, AR_XmitDataTries2); ndx2 = rate_to_ndx(sn, rate2); - rate3 = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate3)].ieeerate; + rate3 = sc->sc_hwmap[hwrate3].ieeerate; tries3 = MS(ds->ds_ctl2, AR_XmitDataTries3); ndx3 = rate_to_ndx(sn, rate3); diff --git a/ath_rate/minstrel/minstrel.h b/ath_rate/minstrel/minstrel.h index 0de34a1..7e1c692 100644 --- a/ath_rate/minstrel/minstrel.h +++ b/ath_rate/minstrel/minstrel.h @@ -209,6 +209,16 @@ struct minstrel_node { #define AR_XmitRate3 0x000f8000 /* series 3 tx rate */ #define AR_XmitRate3_S 15 +/* TX ds_ctl3 for 5416 */ +#define AR5416_XmitRate0 0x000000ff /* series 0 tx rate */ +#define AR5416_XmitRate0_S 0 +#define AR5416_XmitRate1 0x0000ff00 /* series 1 tx rate */ +#define AR5416_XmitRate1_S 8 +#define AR5416_XmitRate2 0x00ff0000 /* series 2 tx rate */ +#define AR5416_XmitRate2_S 16 +#define AR5416_XmitRate3 0xff000000 /* series 3 tx rate */ +#define AR5416_XmitRate3_S 24 + #define MS(_v, _f) (((_v) & (_f)) >> _f##_S) #endif /* _DEV_ATH_RATE_MINSTEL_H */ diff --git a/ath_rate/sample/sample.c b/ath_rate/sample/sample.c index 0c62f3e..749ff06 100644 --- a/ath_rate/sample/sample.c +++ b/ath_rate/sample/sample.c @@ -681,31 +681,7 @@ ath_rate_tx_complete(struct ath_softc *sc, MAC_ADDR(an->an_node.ni_macaddr), __func__); return; } - mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT) && ENABLE_MRR; - - - if (sc->sc_mrretry && ts->ts_status) { - /* this packet failed */ - DPRINTF(sc, ATH_DEBUG_RATE, "%s: " MAC_FMT " size %u rate/try %u/%u %u/%u %u/%u %u/%u status %s retries (%u/%u)\n", - dev_info, - MAC_ADDR(an->an_node.ni_macaddr), - bin_to_size(size_to_bin(frame_size)), - sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate0)].ieeerate, - MS(ds->ds_ctl2, AR_XmitDataTries0), - sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate1)].ieeerate, - MS(ds->ds_ctl2, AR_XmitDataTries1), - sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate2)].ieeerate, - MS(ds->ds_ctl2, AR_XmitDataTries2), - sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate3)].ieeerate, - MS(ds->ds_ctl2, AR_XmitDataTries3), - ts->ts_status ? "FAIL" : "OK", - short_tries, long_tries); - } - - mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT) && ENABLE_MRR; - - if (!mrr || !(ts->ts_rate & HAL_TXSTAT_ALTRATE)) { /* only one rate was used */ int ndx = rate_to_ndx(sn, final_rate); @@ -718,7 +694,7 @@ ath_rate_tx_complete(struct ath_softc *sc, short_tries, long_tries, ts->ts_status); } } else { - unsigned int rate[4], tries[4]; + unsigned int rate[4], tries[4], hwrate[4]; int ndx[4]; int finalTSIdx = ts->ts_finaltsi; @@ -726,19 +702,31 @@ ath_rate_tx_complete(struct ath_softc *sc, * Process intermediate rates that failed. */ - rate[0] = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate0)].ieeerate; + if (sc->sc_ah->ah_magic != 0x20065416) { + hwrate[0] = MS(ds->ds_ctl3, AR_XmitRate0); + hwrate[1] = MS(ds->ds_ctl3, AR_XmitRate1); + hwrate[2] = MS(ds->ds_ctl3, AR_XmitRate2); + hwrate[3] = MS(ds->ds_ctl3, AR_XmitRate3); + } else { + hwrate[0] = MS(ds->ds_ctl3, AR5416_XmitRate0); + hwrate[1] = MS(ds->ds_ctl3, AR5416_XmitRate1); + hwrate[2] = MS(ds->ds_ctl3, AR5416_XmitRate2); + hwrate[3] = MS(ds->ds_ctl3, AR5416_XmitRate3); + } + + rate[0] = sc->sc_hwmap[hwrate[0]].ieeerate; tries[0] = MS(ds->ds_ctl2, AR_XmitDataTries0); ndx[0] = rate_to_ndx(sn, rate[0]); - rate[1] = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate1)].ieeerate; + rate[1] = sc->sc_hwmap[hwrate[1]].ieeerate; tries[1] = MS(ds->ds_ctl2, AR_XmitDataTries1); ndx[1] = rate_to_ndx(sn, rate[1]); - rate[2] = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate2)].ieeerate; + rate[2] = sc->sc_hwmap[hwrate[2]].ieeerate; tries[2] = MS(ds->ds_ctl2, AR_XmitDataTries2); ndx[2] = rate_to_ndx(sn, rate[2]); - rate[3] = sc->sc_hwmap[MS(ds->ds_ctl3, AR_XmitRate3)].ieeerate; + rate[3] = sc->sc_hwmap[hwrate[3]].ieeerate; tries[3] = MS(ds->ds_ctl2, AR_XmitDataTries3); ndx[3] = rate_to_ndx(sn, rate[3]); diff --git a/ath_rate/sample/sample.h b/ath_rate/sample/sample.h index 306ad36..2bed32c 100644 --- a/ath_rate/sample/sample.h +++ b/ath_rate/sample/sample.h @@ -135,6 +135,16 @@ struct sample_node { #define AR_XmitRate3 0x000f8000 /* series 3 tx rate */ #define AR_XmitRate3_S 15 +/* TX ds_ctl3 for 5416 */ +#define AR5416_XmitRate0 0x000000ff /* series 0 tx rate */ +#define AR5416_XmitRate0_S 0 +#define AR5416_XmitRate1 0x0000ff00 /* series 1 tx rate */ +#define AR5416_XmitRate1_S 8 +#define AR5416_XmitRate2 0x00ff0000 /* series 2 tx rate */ +#define AR5416_XmitRate2_S 16 +#define AR5416_XmitRate3 0xff000000 /* series 3 tx rate */ +#define AR5416_XmitRate3_S 24 + #define MS(_v, _f) (((_v) & (_f)) >> _f##_S) #endif /* _DEV_ATH_RATE_SAMPLE_H */