From owner-p4-projects@FreeBSD.ORG Sat Feb 16 04:03:31 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E3F4016A41A; Sat, 16 Feb 2008 04:03:30 +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 90D2B16A46C for ; Sat, 16 Feb 2008 04:03:30 +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 8FDDB13C469 for ; Sat, 16 Feb 2008 04:03:30 +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 m1G43UYi074306 for ; Sat, 16 Feb 2008 04:03:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m1G43Uol074303 for perforce@freebsd.org; Sat, 16 Feb 2008 04:03:30 GMT (envelope-from sephe@FreeBSD.org) Date: Sat, 16 Feb 2008 04:03:30 GMT Message-Id: <200802160403.m1G43Uol074303@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 135475 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: Sat, 16 Feb 2008 04:03:31 -0000 http://perforce.freebsd.org/chv.cgi?CH=135475 Change 135475 by sephe@sephe_zealot:sam_wifi on 2008/02/16 04:02:51 Merge following changes from dfly: - Try adjusting TX power as much as possible when doing the initial TX power calibration. Also the second TX power calibration happens 1 second after the initial TX power calibration. if streams are pushed immediately after NIC is brought up, this makes thing work much better for most of the 4306 BBP, whose default TX power seems to be far away from the max TX power. - Add some experimental (commented out) code to force TX power downgrade. Affected files ... .. //depot/projects/wifi/sys/dev/bwi/bwimac.c#6 edit .. //depot/projects/wifi/sys/dev/bwi/bwimac.h#2 edit .. //depot/projects/wifi/sys/dev/bwi/if_bwi.c#19 edit .. //depot/projects/wifi/sys/dev/bwi/if_bwivar.h#11 edit Differences ... ==== //depot/projects/wifi/sys/dev/bwi/bwimac.c#6 (text+ko) ==== @@ -1771,7 +1771,7 @@ * http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */ void -bwi_mac_calibrate_txpower(struct bwi_mac *mac) +bwi_mac_calibrate_txpower(struct bwi_mac *mac, enum bwi_txpwrcb_type type) { struct bwi_softc *sc = mac->mac_sc; struct bwi_rf *rf = &mac->mac_rf; @@ -1803,15 +1803,28 @@ DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n", "no DS tssi"); - if (mac->mac_phy.phy_mode == IEEE80211_MODE_11B) - return; + if (mac->mac_phy.phy_mode == IEEE80211_MODE_11B) { + if (type == BWI_TXPWR_FORCE) { + rf_atten_adj = 0; + bbp_atten_adj = 1; + goto calib; + } else { + return; + } + } error = bwi_rf_get_latest_tssi(mac, tssi, BWI_COMM_MOBJ_TSSI_OFDM); if (error) { DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n", "no OFDM tssi"); - return; + if (type == BWI_TXPWR_FORCE) { + rf_atten_adj = 0; + bbp_atten_adj = 1; + goto calib; + } else { + return; + } } for (i = 0; i < 4; ++i) { @@ -1847,8 +1860,15 @@ txpwr_diff = rf->rf_txpower_max - cur_txpwr; /* XXX ni_txpower */ rf_atten_adj = -howmany(txpwr_diff, 8); - bbp_atten_adj = -(txpwr_diff / 2) - - (BWI_RF_ATTEN_FACTOR * rf_atten_adj); + if (type == BWI_TXPWR_INIT) { + /* + * Move toward EEPROM max TX power as fast as we can + */ + bbp_atten_adj = -txpwr_diff; + } else { + bbp_atten_adj = -(txpwr_diff / 2); + } + bbp_atten_adj -= (BWI_RF_ATTEN_FACTOR * rf_atten_adj); if (rf_atten_adj == 0 && bbp_atten_adj == 0) { DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n", @@ -1857,6 +1877,7 @@ return; } +calib: DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "rf atten adjust %d, bbp atten adjust %d\n", rf_atten_adj, bbp_atten_adj); ==== //depot/projects/wifi/sys/dev/bwi/bwimac.h#2 (text+ko) ==== @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/dev/netif/bwi/bwimac.h,v 1.1 2007/09/08 06:15:54 sephe Exp $ + * $DragonFly: src/sys/dev/netif/bwi/bwimac.h,v 1.2 2008/02/15 11:15:38 sephe Exp $ */ #ifndef _BWI_MAC_H @@ -48,7 +48,8 @@ void bwi_mac_updateslot(struct bwi_mac *, int); void bwi_mac_set_promisc(struct bwi_mac *, int); -void bwi_mac_calibrate_txpower(struct bwi_mac *); +void bwi_mac_calibrate_txpower(struct bwi_mac *, + enum bwi_txpwrcb_type); void bwi_mac_set_tpctl_11bg(struct bwi_mac *, const struct bwi_tpctl *); void bwi_mac_init_tpctl_11bg(struct bwi_mac *); ==== //depot/projects/wifi/sys/dev/bwi/if_bwi.c#19 (text+ko) ==== @@ -1664,7 +1664,12 @@ mac = (struct bwi_mac *)sc->sc_cur_regwin; /* Initial TX power calibration */ - bwi_mac_calibrate_txpower(mac); + bwi_mac_calibrate_txpower(mac, BWI_TXPWR_INIT); +#ifdef notyet + sc->sc_txpwrcb_type = BWI_TXPWR_FORCE; +#else + sc->sc_txpwrcb_type = BWI_TXPWR_CALIB; +#endif if (ic->ic_opmode == IEEE80211_M_STA) { /* fake a join to init the tx rate */ @@ -1684,10 +1689,8 @@ back: error = sc->sc_newstate(ic, nstate, arg); - if (nstate == IEEE80211_S_RUN) { - /* XXX 15 seconds */ - callout_reset(&sc->sc_calib_ch, hz * 15, bwi_calibrate, sc); - } + if (nstate == IEEE80211_S_RUN) + callout_reset(&sc->sc_calib_ch, hz, bwi_calibrate, sc); BWI_UNLOCK(sc); return error; @@ -3571,8 +3574,10 @@ ("current regwin type %d", sc->sc_cur_regwin->rw_type)); mac = (struct bwi_mac *)sc->sc_cur_regwin; - if (ic->ic_opmode != IEEE80211_M_MONITOR) - bwi_mac_calibrate_txpower(mac); + if (ic->ic_opmode != IEEE80211_M_MONITOR) { + bwi_mac_calibrate_txpower(mac, sc->sc_txpwrcb_type); + sc->sc_txpwrcb_type = BWI_TXPWR_CALIB; + } /* XXX 15 seconds */ callout_reset(&sc->sc_calib_ch, hz * 15, bwi_calibrate, sc); ==== //depot/projects/wifi/sys/dev/bwi/if_bwivar.h#11 (text+ko) ==== @@ -62,6 +62,12 @@ #define BWI_LED_EVENT_RX 2 #define BWI_LED_SLOWDOWN(dur) (dur) = (((dur) * 3) / 2) +enum bwi_txpwrcb_type { + BWI_TXPWR_INIT = 0, + BWI_TXPWR_FORCE = 1, + BWI_TXPWR_CALIB = 2 +}; + #define BWI_NOISE_FLOOR -95 /* TODO: noise floor calc */ #define BWI_FRAME_MIN_LEN(hdr) \ ((hdr) + sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) @@ -571,6 +577,7 @@ int sc_rx_rate; int sc_tx_rate; + enum bwi_txpwrcb_type sc_txpwrcb_type; int sc_led_blinking; int sc_led_ticks;