From owner-p4-projects@FreeBSD.ORG Tue Feb 5 11:29:44 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AF5AE16A41B; Tue, 5 Feb 2008 11:29:44 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C50516A46D for ; Tue, 5 Feb 2008 11:29:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4D07913C46B for ; Tue, 5 Feb 2008 11:29:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m15BTiGm034897 for ; Tue, 5 Feb 2008 11:29:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m15BTikj034894 for perforce@freebsd.org; Tue, 5 Feb 2008 11:29:44 GMT (envelope-from sephe@FreeBSD.org) Date: Tue, 5 Feb 2008 11:29:44 GMT Message-Id: <200802051129.m15BTikj034894@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau To: Perforce Change Reviews Cc: Subject: PERFORCE change 134835 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2008 11:29:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=134835 Change 134835 by sephe@sephe_enigma:sam_wifi on 2008/02/05 11:29:08 Merge rate table changes from vap branch: Instead of installing rate table in channel during attach, drivers are now responsible to get rate table when channel switching happens. All duration calculatoin functions are not take rate table as their first parameter instead of channel. Reminded by: sam Affected files ... .. //depot/projects/wifi/sys/dev/ral/rt2560.c#32 edit .. //depot/projects/wifi/sys/dev/ral/rt2560var.h#10 edit .. //depot/projects/wifi/sys/dev/ral/rt2661.c#24 edit .. //depot/projects/wifi/sys/dev/ral/rt2661var.h#8 edit .. //depot/projects/wifi/sys/net80211/_ieee80211.h#28 edit .. //depot/projects/wifi/sys/net80211/ieee80211.c#61 edit .. //depot/projects/wifi/sys/net80211/ieee80211_phy.c#7 edit .. //depot/projects/wifi/sys/net80211/ieee80211_phy.h#4 edit Differences ... ==== //depot/projects/wifi/sys/dev/ral/rt2560.c#32 (text) ==== @@ -1481,7 +1481,7 @@ desc->plcp_service = 4; len += IEEE80211_CRC_LEN; - if (ieee80211_rate2phytype(ic->ic_curchan, rate) == IEEE80211_T_OFDM) { + if (ieee80211_rate2phytype(sc->sc_currates, rate) == IEEE80211_T_OFDM) { desc->flags |= htole32(RT2560_TX_OFDM); plcp_length = len & 0xfff; @@ -1619,7 +1619,7 @@ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2560_TX_ACK; - dur = ieee80211_ack_duration(ic->ic_curchan, rate, + dur = ieee80211_ack_duration(sc->sc_currates, rate, ic->ic_flags); *(uint16_t *)wh->i_dur = htole16(dur); @@ -1804,12 +1804,12 @@ rtsrate = IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan) ? 12 : 2; - dur = ieee80211_ack_duration(ic->ic_curchan, + dur = ieee80211_ack_duration(sc->sc_currates, rtsrate, ic->ic_flags) - + ieee80211_compute_duration(ic->ic_curchan, + + ieee80211_compute_duration(sc->sc_currates, m0->m_pkthdr.len + IEEE80211_CRC_LEN, rate, ic->ic_flags) - + ieee80211_ack_duration(ic->ic_curchan, + + ieee80211_ack_duration(sc->sc_currates, rate, ic->ic_flags); m = rt2560_get_rts(sc, wh, dur); @@ -1916,7 +1916,7 @@ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2560_TX_ACK; - dur = ieee80211_ack_duration(ic->ic_curchan, rate, + dur = ieee80211_ack_duration(sc->sc_currates, rate, ic->ic_flags); *(uint16_t *)wh->i_dur = htole16(dur); } @@ -2222,6 +2222,7 @@ chan = ieee80211_chan2ieee(ic, c); if (chan == 0 || chan == IEEE80211_CHAN_ANY) return; + sc->sc_currates = ieee80211_get_ratetable(c); if (IEEE80211_IS_CHAN_2GHZ(c)) power = min(sc->txpow[chan - 1], 31); ==== //depot/projects/wifi/sys/dev/ral/rt2560var.h#10 (text) ==== @@ -165,6 +165,7 @@ #define RT2560_F_PRIO_OACTIVE 0x2 #define RT2560_F_DATA_OACTIVE 0x4 int sc_flags; + const struct ieee80211_rate_table *sc_currates; }; int rt2560_attach(device_t, int); ==== //depot/projects/wifi/sys/dev/ral/rt2661.c#24 (text) ==== @@ -1356,7 +1356,7 @@ desc->plcp_service = 4; len += IEEE80211_CRC_LEN; - if (ieee80211_rate2phytype(ic->ic_curchan, rate) == IEEE80211_T_OFDM) { + if (ieee80211_rate2phytype(sc->sc_currates, rate) == IEEE80211_T_OFDM) { desc->flags |= htole32(RT2661_TX_OFDM); plcp_length = len & 0xfff; @@ -1442,7 +1442,7 @@ if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2661_TX_NEED_ACK; - dur = ieee80211_ack_duration(ic->ic_curchan, + dur = ieee80211_ack_duration(sc->sc_currates, rate, ic->ic_flags); *(uint16_t *)wh->i_dur = htole16(dur); @@ -1567,12 +1567,12 @@ rtsrate = IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan) ? 12 : 2; - dur = ieee80211_ack_duration(ic->ic_curchan, + dur = ieee80211_ack_duration(sc->sc_currates, rtsrate, ic->ic_flags) - + ieee80211_compute_duration(ic->ic_curchan, + + ieee80211_compute_duration(sc->sc_currates, m0->m_pkthdr.len + IEEE80211_CRC_LEN, rate, ic->ic_flags) - + ieee80211_ack_duration(ic->ic_curchan, + + ieee80211_ack_duration(sc->sc_currates, rate, ic->ic_flags); m = rt2661_get_rts(sc, wh, dur); @@ -1676,7 +1676,7 @@ if (!noack && !IEEE80211_IS_MULTICAST(wh->i_addr1)) { flags |= RT2661_TX_NEED_ACK; - dur = ieee80211_ack_duration(ic->ic_curchan, rate, + dur = ieee80211_ack_duration(sc->sc_currates, rate, ic->ic_flags); *(uint16_t *)wh->i_dur = htole16(dur); } @@ -2137,6 +2137,8 @@ if (chan == 0 || chan == IEEE80211_CHAN_ANY) return; + sc->sc_currates = ieee80211_get_ratetable(c); + /* select the appropriate RF settings based on what EEPROM says */ rfprog = (sc->rfprog == 0) ? rt2661_rf5225_1 : rt2661_rf5225_2; ==== //depot/projects/wifi/sys/dev/ral/rt2661var.h#8 (text) ==== @@ -168,6 +168,7 @@ int sc_txtap_len; #define RAL_INPUT_RUNNING 1 int sc_flags; + const struct ieee80211_rate_table *sc_currates; }; int rt2661_attach(device_t, int); ==== //depot/projects/wifi/sys/net80211/_ieee80211.h#28 (text+ko) ==== @@ -102,7 +102,6 @@ /* * Channels are specified by frequency and attributes. */ -struct ieee80211_rate_table; struct ieee80211_channel { uint32_t ic_flags; /* see below */ uint16_t ic_freq; /* setting in Mhz */ @@ -112,7 +111,6 @@ int8_t ic_minpower; /* minimum tx power in .5 dBm */ uint8_t ic_state; /* dynamic state */ uint8_t ic_extieee; /* HT40 extension channel number */ - const struct ieee80211_rate_table *ic_rt; /* rate table */ }; #define IEEE80211_CHAN_MAX 255 ==== //depot/projects/wifi/sys/net80211/ieee80211.c#61 (text+ko) ==== @@ -182,8 +182,6 @@ setbit(ic->ic_modecaps, IEEE80211_MODE_11NA); if (IEEE80211_IS_CHAN_HTG(c)) setbit(ic->ic_modecaps, IEEE80211_MODE_11NG); - - ieee80211_set_ratetable(c); } /* initialize candidate channels to all available */ memcpy(ic->ic_chan_active, ic->ic_chan_avail, ==== //depot/projects/wifi/sys/net80211/ieee80211_phy.c#7 (text+ko) ==== @@ -317,10 +317,10 @@ #undef N } -void -ieee80211_set_ratetable(struct ieee80211_channel *c) +const struct ieee80211_rate_table * +ieee80211_get_ratetable(const struct ieee80211_channel *c) { - const struct ieee80211_rate_table *rt; + const struct ieee80211_rate_table *rt = NULL; /* XXX HT */ if (IEEE80211_IS_CHAN_HALF(c)) @@ -348,7 +348,7 @@ panic("%s: no rate table for channel; freq %u flags 0x%x\n", __func__, c->ic_freq, c->ic_flags); } - c->ic_rt = rt; + return rt; } #ifdef notyet @@ -402,9 +402,8 @@ #endif /* notyet */ enum ieee80211_phytype -ieee80211_rate2phytype(const struct ieee80211_channel *c, uint8_t rate) +ieee80211_rate2phytype(const struct ieee80211_rate_table *rt, uint8_t rate) { - const struct ieee80211_rate_table *rt = c->ic_rt; uint8_t rix = rt->rateCodeToIndex[rate]; KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate)); @@ -418,10 +417,9 @@ * sent using rate, phy and short preamble setting. */ uint16_t -ieee80211_ack_duration(const struct ieee80211_channel *c, +ieee80211_ack_duration(const struct ieee80211_rate_table *rt, uint8_t rate, int flags) { - const struct ieee80211_rate_table *rt = c->ic_rt; uint8_t rix = rt->rateCodeToIndex[rate]; KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate)); @@ -437,10 +435,10 @@ } uint16_t -ieee80211_compute_duration(const struct ieee80211_channel *c, +ieee80211_compute_duration(const struct ieee80211_rate_table *rt, uint32_t frameLen, uint16_t rate, int flags) { - return ieee80211_compute_dur(c->ic_rt, frameLen, rate, flags); + return ieee80211_compute_dur(rt, frameLen, rate, flags); } /* ==== //depot/projects/wifi/sys/net80211/ieee80211_phy.h#4 (text+ko) ==== @@ -31,17 +31,19 @@ #ifdef _KERNEL struct ieee80211_channel; +struct ieee80211_rate_table; /* Initialization functions */ void ieee80211_phy_init(void); -void ieee80211_set_ratetable(struct ieee80211_channel *); +const struct ieee80211_rate_table *ieee80211_get_ratetable( + const struct ieee80211_channel *); -uint16_t ieee80211_ack_duration(const struct ieee80211_channel *, +uint16_t ieee80211_ack_duration(const struct ieee80211_rate_table *, uint8_t, int); -uint16_t ieee80211_compute_duration(const struct ieee80211_channel *, +uint16_t ieee80211_compute_duration(const struct ieee80211_rate_table *, uint32_t, uint16_t, int); enum ieee80211_phytype ieee80211_rate2phytype( - const struct ieee80211_channel *, uint8_t); + const struct ieee80211_rate_table *, uint8_t); #endif /* _KERNEL */