Skip to content

Commit

Permalink
ath9k: Remove ath9k_rate_table
Browse files Browse the repository at this point in the history
Maintaining two sets of rate tables is redundant, remove one
and use struct ath_rate_table exclusively.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Sujith authored and John W. Linville committed Nov 26, 2008
1 parent a8efee4 commit e63835b
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 374 deletions.
26 changes: 3 additions & 23 deletions drivers/net/wireless/ath9k/ath9k.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,22 +401,6 @@ enum ath9k_int {
ATH9K_INT_NOCARD = 0xffffffff
};

struct ath9k_rate_table {
int rateCount;
u8 rateCodeToIndex[256];
struct {
u8 valid;
u8 phy;
u32 rateKbps;
u8 rateCode;
u8 shortPreamble;
u8 dot11Rate;
u8 controlRate;
u16 lpAckDuration;
u16 spAckDuration;
} info[32];
};

#define ATH9K_RATESERIES_RTS_CTS 0x0001
#define ATH9K_RATESERIES_2040 0x0002
#define ATH9K_RATESERIES_HALFGI 0x0004
Expand Down Expand Up @@ -828,6 +812,8 @@ struct chan_centers {
u16 ext_center;
};

struct ath_rate_table;

/* Helpers */

enum wireless_mode ath9k_hw_chan2wmode(struct ath_hal *ah,
Expand All @@ -838,7 +824,7 @@ bool ath9k_get_channel_edges(struct ath_hal *ah,
u16 flags, u16 *low,
u16 *high);
u16 ath9k_hw_computetxtime(struct ath_hal *ah,
const struct ath9k_rate_table *rates,
struct ath_rate_table *rates,
u32 frameLen, u16 rateix,
bool shortPreamble);
u32 ath9k_hw_mhz2ieee(struct ath_hal *ah, u32 freq, u32 flags);
Expand Down Expand Up @@ -883,12 +869,6 @@ void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore);
void ath9k_hw_beaconinit(struct ath_hal *ah, u32 next_beacon, u32 beacon_period);
void ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah,
const struct ath9k_beacon_state *bs);

/* Rate table */

const struct ath9k_rate_table *ath9k_hw_getratetable(struct ath_hal *ah,
u32 mode);

/* HW Capabilities */

bool ath9k_hw_fill_cap_info(struct ath_hal *ah);
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/ath9k/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static void ath_beacon_setup(struct ath_softc *sc,
struct ath_hal *ah = sc->sc_ah;
struct ath_desc *ds;
struct ath9k_11n_rate_series series[4];
const struct ath9k_rate_table *rt;
struct ath_rate_table *rt;
int flags, antenna;
u8 rix, rate;
int ctsrate = 0;
Expand Down Expand Up @@ -106,10 +106,10 @@ static void ath_beacon_setup(struct ath_softc *sc,
* XXX everything at min xmit rate
*/
rix = 0;
rt = sc->sc_currates;
rate = rt->info[rix].rateCode;
rt = sc->hw_rate_table[sc->sc_curmode];
rate = rt->info[rix].ratecode;
if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
rate |= rt->info[rix].shortPreamble;
rate |= rt->info[rix].short_preamble;

ath9k_hw_set11n_txdesc(ah, ds,
skb->len + FCS_LEN, /* frame length */
Expand Down
52 changes: 9 additions & 43 deletions drivers/net/wireless/ath9k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,9 @@ static u8 parse_mpdudensity(u8 mpdudensity)

/*
* Set current operating mode
*
* This function initializes and fills the rate table in the ATH object based
* on the operating mode.
*/
static void ath_setcurmode(struct ath_softc *sc, enum wireless_mode mode)
{
const struct ath9k_rate_table *rt;
int i;

rt = ath9k_hw_getratetable(sc->sc_ah, mode);
BUG_ON(!rt);

memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap));
for (i = 0; i < 256; i++) {
u8 ix = rt->rateCodeToIndex[i];

if (ix == 0xff)
continue;

sc->sc_hwmap[i].ieeerate =
rt->info[ix].dot11Rate & IEEE80211_RATE_VAL;
sc->sc_hwmap[i].rateKbps = rt->info[ix].rateKbps;

if (rt->info[ix].shortPreamble ||
rt->info[ix].phy == PHY_OFDM) {
/* XXX: Handle this */
}

/* NB: this uses the last entry if the rate isn't found */
/* XXX beware of overlow */
}
sc->sc_currates = rt;
sc->sc_curmode = mode;
/*
* All protection frames are transmited at 2Mb/s for
Expand All @@ -126,37 +97,36 @@ static void ath_setcurmode(struct ath_softc *sc, enum wireless_mode mode)
*/
static void ath_setup_rates(struct ath_softc *sc, enum ieee80211_band band)
{
struct ath_hal *ah = sc->sc_ah;
const struct ath9k_rate_table *rt = NULL;
struct ath_rate_table *rate_table = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_rate *rate;
int i, maxrates;

switch (band) {
case IEEE80211_BAND_2GHZ:
rt = ath9k_hw_getratetable(ah, ATH9K_MODE_11G);
rate_table = sc->hw_rate_table[ATH9K_MODE_11G];
break;
case IEEE80211_BAND_5GHZ:
rt = ath9k_hw_getratetable(ah, ATH9K_MODE_11A);
rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
break;
default:
break;
}

if (rt == NULL)
if (rate_table == NULL)
return;

sband = &sc->sbands[band];
rate = sc->rates[band];

if (rt->rateCount > ATH_RATE_MAX)
if (rate_table->rate_cnt > ATH_RATE_MAX)
maxrates = ATH_RATE_MAX;
else
maxrates = rt->rateCount;
maxrates = rate_table->rate_cnt;

for (i = 0; i < maxrates; i++) {
rate[i].bitrate = rt->info[i].rateKbps / 100;
rate[i].hw_value = rt->info[i].rateCode;
rate[i].bitrate = rate_table->info[i].ratekbps / 100;
rate[i].hw_value = rate_table->info[i].ratecode;
sband->n_bitrates++;
DPRINTF(sc, ATH_DBG_CONFIG,
"%s: Rate: %2dMbps, ratecode: %2d\n",
Expand Down Expand Up @@ -1000,12 +970,10 @@ int ath_init(u16 devid, struct ath_softc *sc)

/* Setup rate tables */

ath_rate_attach(sc);
ath_setup_rates(sc, IEEE80211_BAND_2GHZ);
ath_setup_rates(sc, IEEE80211_BAND_5GHZ);

/* NB: setup here so ath_rate_update is happy */
ath_setcurmode(sc, ATH9K_MODE_11A);

/*
* Allocate hardware transmit queues: one queue for
* beacon frames and one data queue for each QoS
Expand Down Expand Up @@ -1071,8 +1039,6 @@ int ath_init(u16 devid, struct ath_softc *sc)
sc->sc_ani.sc_noise_floor = ATH_DEFAULT_NOISE_FLOOR;
setup_timer(&sc->sc_ani.timer, ath_ani_calibrate, (unsigned long)sc);

ath_rate_attach(sc);

if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER,
ATH9K_CIPHER_TKIP, NULL)) {
/*
Expand Down
5 changes: 0 additions & 5 deletions drivers/net/wireless/ath9k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,7 @@ struct ath_softc {
/* Rate */
struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
const struct ath9k_rate_table *sc_currates;
u8 sc_protrix; /* protection rate index */
struct {
u32 rateKbps; /* transfer rate in kbs */
u8 ieeerate; /* IEEE rate */
} sc_hwmap[256]; /* h/w rate ix mappings */

/* Channel, Band */
struct ieee80211_channel channels[IEEE80211_NUM_BANDS][ATH_CHAN_MAX];
Expand Down
Loading

0 comments on commit e63835b

Please sign in to comment.