Fix basic rates set for 802.11a/g operating modes. This can significantly
improve transfer rates in 802.11a/g. Fix IFS settings in ral(4) too. MFC after: 6 days
This commit is contained in:
parent
a0866c8d4e
commit
30feefb1d2
@ -105,7 +105,7 @@ static void ral_rx_intr(struct ral_softc *);
|
||||
static void ral_beacon_expire(struct ral_softc *);
|
||||
static void ral_wakeup_expire(struct ral_softc *);
|
||||
static void ral_intr(void *);
|
||||
static int ral_ack_rate(int);
|
||||
static int ral_ack_rate(struct ieee80211com *, int);
|
||||
static uint16_t ral_txtime(int, int, uint32_t);
|
||||
static uint8_t ral_plcp_signal(int);
|
||||
static void ral_setup_tx_desc(struct ral_softc *,
|
||||
@ -1006,6 +1006,18 @@ ral_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
|
||||
case IEEE80211_S_RUN:
|
||||
ral_set_chan(sc, ic->ic_curchan);
|
||||
|
||||
/* update basic rate set */
|
||||
if (ic->ic_curmode == IEEE80211_MODE_11B) {
|
||||
/* 11b basic rates: 1, 2Mbps */
|
||||
RAL_WRITE(sc, RAL_ARSP_PLCP_1, 0x3);
|
||||
} else if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) {
|
||||
/* 11a basic rates: 6, 12, 24Mbps */
|
||||
RAL_WRITE(sc, RAL_ARSP_PLCP_1, 0x150);
|
||||
} else {
|
||||
/* 11g basic rates: 1, 2, 5.5, 11, 6, 12, 24Mbps */
|
||||
RAL_WRITE(sc, RAL_ARSP_PLCP_1, 0x15f);
|
||||
}
|
||||
|
||||
if (ic->ic_opmode != IEEE80211_M_MONITOR)
|
||||
ral_set_bssid(sc, ic->ic_bss->ni_bssid);
|
||||
|
||||
@ -1546,14 +1558,16 @@ ral_intr(void *arg)
|
||||
|
||||
#define RAL_ACK_SIZE 14 /* 10 + 4(FCS) */
|
||||
#define RAL_CTS_SIZE 14 /* 10 + 4(FCS) */
|
||||
#define RAL_SIFS 10
|
||||
|
||||
#define RAL_SIFS 10 /* us */
|
||||
#define RAL_TXRX_TURNAROUND 10 /* us */
|
||||
|
||||
/*
|
||||
* Return the expected ack rate for a frame transmitted at rate `rate'.
|
||||
* XXX: this should depend on the destination node basic rate set.
|
||||
*/
|
||||
static int
|
||||
ral_ack_rate(int rate)
|
||||
ral_ack_rate(struct ieee80211com *ic, int rate)
|
||||
{
|
||||
switch (rate) {
|
||||
/* CCK rates */
|
||||
@ -1562,7 +1576,7 @@ ral_ack_rate(int rate)
|
||||
case 4:
|
||||
case 11:
|
||||
case 22:
|
||||
return 4;
|
||||
return (ic->ic_curmode == IEEE80211_MODE_11B) ? 4 : rate;
|
||||
|
||||
/* OFDM rates */
|
||||
case 12:
|
||||
@ -1664,7 +1678,7 @@ ral_setup_tx_desc(struct ral_softc *sc, struct ral_tx_desc *desc,
|
||||
desc->flags |= htole32(RAL_TX_OFDM);
|
||||
|
||||
desc->physaddr = htole32(physaddr);
|
||||
desc->wme = htole16(RAL_LOGCWMAX(8) | RAL_LOGCWMIN(3) | RAL_AIFSN(2));
|
||||
desc->wme = htole16(RAL_AIFSN(3) | RAL_LOGCWMIN(4) | RAL_LOGCWMAX(6));
|
||||
|
||||
/*
|
||||
* Fill PLCP fields.
|
||||
@ -1911,7 +1925,7 @@ ral_tx_data(struct ral_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
|
||||
int rtsrate, ackrate;
|
||||
|
||||
rtsrate = IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan) ? 12 : 4;
|
||||
ackrate = ral_ack_rate(rate);
|
||||
ackrate = ral_ack_rate(ic, rate);
|
||||
|
||||
dur = ral_txtime(m0->m_pkthdr.len + 4, rate, ic->ic_flags) +
|
||||
ral_txtime(RAL_CTS_SIZE, rtsrate, ic->ic_flags) +
|
||||
@ -2021,7 +2035,7 @@ ral_tx_data(struct ral_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
|
||||
if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
|
||||
flags |= RAL_TX_ACK;
|
||||
|
||||
dur = ral_txtime(RAL_ACK_SIZE, ral_ack_rate(rate),
|
||||
dur = ral_txtime(RAL_ACK_SIZE, ral_ack_rate(ic, rate),
|
||||
ic->ic_flags) + RAL_SIFS;
|
||||
*(uint16_t *)wh->i_dur = htole16(dur);
|
||||
}
|
||||
@ -2461,26 +2475,25 @@ ral_update_slot(struct ifnet *ifp)
|
||||
struct ral_softc *sc = ifp->if_softc;
|
||||
struct ieee80211com *ic = &sc->sc_ic;
|
||||
uint8_t slottime;
|
||||
uint16_t sifs, pifs, difs, eifs;
|
||||
uint16_t tx_sifs, tx_pifs, tx_difs, eifs;
|
||||
uint32_t tmp;
|
||||
|
||||
slottime = (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : 20;
|
||||
|
||||
/* update the MAC slot boundaries */
|
||||
sifs = RAL_SIFS;
|
||||
pifs = sifs + slottime;
|
||||
difs = sifs + 2 * slottime;
|
||||
eifs = sifs + ral_txtime(RAL_ACK_SIZE,
|
||||
(ic->ic_curmode == IEEE80211_MODE_11A) ? 12 : 2, 0) + difs;
|
||||
tx_sifs = RAL_SIFS - RAL_TXRX_TURNAROUND;
|
||||
tx_pifs = tx_sifs + slottime;
|
||||
tx_difs = tx_sifs + 2 * slottime;
|
||||
eifs = (ic->ic_curmode == IEEE80211_MODE_11B) ? 364 : 60;
|
||||
|
||||
tmp = RAL_READ(sc, RAL_CSR11);
|
||||
tmp = (tmp & ~0x1f00) | slottime << 8;
|
||||
RAL_WRITE(sc, RAL_CSR11, tmp);
|
||||
|
||||
tmp = pifs << 16 | sifs;
|
||||
tmp = tx_pifs << 16 | tx_sifs;
|
||||
RAL_WRITE(sc, RAL_CSR18, tmp);
|
||||
|
||||
tmp = eifs << 16 | difs;
|
||||
tmp = eifs << 16 | tx_difs;
|
||||
RAL_WRITE(sc, RAL_CSR19, tmp);
|
||||
|
||||
DPRINTF(("setting slottime to %uus\n", slottime));
|
||||
@ -2721,7 +2734,7 @@ ral_init(void *priv)
|
||||
IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp));
|
||||
ral_set_macaddr(sc, ic->ic_myaddr);
|
||||
|
||||
/* set supported basic rates (1, 2, 6, 12, 24) */
|
||||
/* set basic rate set (will be updated later) */
|
||||
RAL_WRITE(sc, RAL_ARSP_PLCP_1, 0x153);
|
||||
|
||||
ral_set_txantenna(sc, sc->tx_ant);
|
||||
|
@ -118,7 +118,7 @@ Static void ural_txeof(usbd_xfer_handle, usbd_private_handle,
|
||||
usbd_status);
|
||||
Static void ural_rxeof(usbd_xfer_handle, usbd_private_handle,
|
||||
usbd_status);
|
||||
Static int ural_ack_rate(int);
|
||||
Static int ural_ack_rate(struct ieee80211com *, int);
|
||||
Static uint16_t ural_txtime(int, int, uint32_t);
|
||||
Static uint8_t ural_plcp_signal(int);
|
||||
Static void ural_setup_tx_desc(struct ural_softc *,
|
||||
@ -737,6 +737,18 @@ ural_task(void *arg)
|
||||
case IEEE80211_S_RUN:
|
||||
ural_set_chan(sc, ic->ic_curchan);
|
||||
|
||||
/* update basic rate set */
|
||||
if (ic->ic_curmode == IEEE80211_MODE_11B) {
|
||||
/* 11b basic rates: 1, 2Mbps */
|
||||
ural_write(sc, RAL_TXRX_CSR11, 0x3);
|
||||
} else if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) {
|
||||
/* 11a basic rates: 6, 12, 24Mbps */
|
||||
ural_write(sc, RAL_TXRX_CSR11, 0x150);
|
||||
} else {
|
||||
/* 11g basic rates: 1, 2, 5.5, 11, 6, 12, 24Mbps */
|
||||
ural_write(sc, RAL_TXRX_CSR11, 0x15f);
|
||||
}
|
||||
|
||||
if (ic->ic_opmode != IEEE80211_M_MONITOR)
|
||||
ural_set_bssid(sc, ic->ic_bss->ni_bssid);
|
||||
|
||||
@ -906,7 +918,7 @@ skip: /* setup a new transfer */
|
||||
* XXX: this should depend on the destination node basic rate set.
|
||||
*/
|
||||
Static int
|
||||
ural_ack_rate(int rate)
|
||||
ural_ack_rate(struct ieee80211com *ic, int rate)
|
||||
{
|
||||
switch (rate) {
|
||||
/* CCK rates */
|
||||
@ -915,7 +927,7 @@ ural_ack_rate(int rate)
|
||||
case 4:
|
||||
case 11:
|
||||
case 22:
|
||||
return 4;
|
||||
return (ic->ic_curmode == IEEE80211_MODE_11B) ? 4 : rate;
|
||||
|
||||
/* OFDM rates */
|
||||
case 12:
|
||||
@ -1016,7 +1028,7 @@ ural_setup_tx_desc(struct ural_softc *sc, struct ural_tx_desc *desc,
|
||||
if (RAL_RATE_IS_OFDM(rate))
|
||||
desc->flags |= htole32(RAL_TX_OFDM);
|
||||
|
||||
desc->wme = htole16(RAL_LOGCWMAX(5) | RAL_LOGCWMIN(3) | RAL_AIFSN(2));
|
||||
desc->wme = htole16(RAL_AIFSN(3) | RAL_LOGCWMIN(4) | RAL_LOGCWMAX(6));
|
||||
desc->wme |= htole16(RAL_IVOFFSET(sizeof (struct ieee80211_frame)));
|
||||
|
||||
/*
|
||||
@ -1236,7 +1248,7 @@ ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
|
||||
flags |= RAL_TX_ACK;
|
||||
flags |= RAL_TX_RETRY(7);
|
||||
|
||||
dur = ural_txtime(RAL_ACK_SIZE, ural_ack_rate(rate),
|
||||
dur = ural_txtime(RAL_ACK_SIZE, ural_ack_rate(ic, rate),
|
||||
ic->ic_flags) + RAL_SIFS;
|
||||
*(uint16_t *)wh->i_dur = htole16(dur);
|
||||
}
|
||||
@ -1949,7 +1961,7 @@ ural_init(void *priv)
|
||||
/* we're ready! */
|
||||
ural_write(sc, RAL_MAC_CSR1, RAL_HOST_READY);
|
||||
|
||||
/* set supported basic rates (1, 2, 6, 12, 24) */
|
||||
/* set basic rate set (will be updated later) */
|
||||
ural_write(sc, RAL_TXRX_CSR11, 0x153);
|
||||
|
||||
if (ural_bbp_init(sc) != 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user