Changeset 139

Show
Ignore:
Timestamp:
05/13/03 06:32:01 (9 years ago)
Author:
sam
Message:

o move xmit rate setup from the 802.11 layer to the driver so we can do

something more intelligent later

o correct logic for reseting the h/w when getrfgain indicates new values are

needed

o add rate control and periodic calibration statistics

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cvs-import/trunk/driver/if_ath.c

    r136 r139  
    9191static int      ath_rate_setup(struct net_device *, u_int mode); 
    9292static void     ath_rate_mapsetup(struct net_device *); 
    93 static void     ath_rate_ctl_reset(struct ath_softc *); 
     93static void     ath_rate_ctl_reset(struct ath_softc *, enum ieee80211_state); 
    9494static void     ath_rate_ctl(void *, struct ieee80211_node *); 
    9595 
     
    18251825        HAL_CHANNEL hchan; 
    18261826 
     1827        sc->sc_stats.ast_per_cal++; 
     1828 
    18271829        /* 
    18281830         * Convert to a HAL channel description with the flags 
     
    18371839        if (ath_hal_getrfgain(ah) == HAL_RFGAIN_NEED_CHANGE) { 
    18381840                HAL_STATUS status; 
     1841 
     1842                sc->sc_stats.ast_per_rfgain++; 
    18391843                /* 
    18401844                 * Rfgain is out of bounds, reset the chip 
    18411845                 * to load new gain values. 
    18421846                 */ 
    1843 printk("%s: gain values need update, reset channel\n", dev->name);/*XXX*/ 
    18441847                ath_hal_intrset(ah, 0);         /* disable interrupts */ 
    1845                 ath_hal_stoptxdma(ah, sc->sc_txhalq); 
    1846                 ath_hal_stoptxdma(ah, sc->sc_bhalq); 
    1847                 ath_stoprecv(sc); 
    1848                 if (!ath_hal_reset(ah, ic->ic_opmode, &hchan, AH_FALSE, &status)) 
     1848                netif_stop_queue(dev);          /* conservative */ 
     1849                ath_draintxq(sc);               /* stop xmit side */ 
     1850                ath_stoprecv(sc);               /* stop recv side */ 
     1851                /* NB: indicate channel change so we do a full reset */ 
     1852                if (!ath_hal_reset(ah, ic->ic_opmode, &hchan, AH_TRUE, &status)) 
    18491853                        printk("%s: unable to reset hardware; hal status %u\n", 
    18501854                                dev->name, status); 
    1851                 /* XXX needed? */ 
    1852                 if (ic->ic_flags & IEEE80211_F_WEPON) 
    1853                         ath_initkeytable(sc); 
    1854                 if (ath_startrecv(dev) != 0) 
     1855                ath_hal_intrset(ah, sc->sc_imask); 
     1856                if (ath_startrecv(dev) != 0)    /* restart recv */ 
    18551857                        printk("%s: unable to start recv logic\n", dev->name); 
    1856                 ath_hal_intrset(ah, sc->sc_imask); 
     1858                netif_start_queue(dev);                /* restart xmit */ 
    18571859        } 
    18581860        if (!ath_hal_calibrate(ah, &hchan)) 
     
    18921894        DPRINTF(("%s: %s -> %s\n", __func__, stname[ostate], stname[nstate])); 
    18931895 
    1894         ath_hal_setledstate(ah, leds[nstate]);  /* set LED */ 
     1896        ath_hal_setledstate(ah, leds[nstate]);         /* set LED */ 
    18951897        netif_stop_queue(dev);                  /* before we do anything else */ 
    18961898 
     
    20512053         * Reset the rate control state. 
    20522054         */ 
    2053         ath_rate_ctl_reset(sc); 
     2055        ath_rate_ctl_reset(sc, nstate); 
    20542056        return 0; 
    20552057bad: 
     
    21682170} 
    21692171 
     2172/* 
     2173 * Reset the rate control state for each 802.11 state transition. 
     2174 */ 
    21702175static void 
    2171 ath_rate_ctl_reset(struct ath_softc *sc
     2176ath_rate_ctl_reset(struct ath_softc *sc, enum ieee80211_state state
    21722177{ 
    21732178        struct ieee80211com *ic = &sc->sc_ic; 
     
    21772182        st = &sc->sc_bss_stat; 
    21782183        st->st_tx_ok = st->st_tx_err = st->st_tx_retr = st->st_tx_upper = 0; 
    2179         if (ic->ic_opmode != IEEE80211_M_STA) { 
     2184        if (ic->ic_opmode == IEEE80211_M_STA) { 
     2185                ni = &ic->ic_bss; 
     2186                if (state == IEEE80211_S_RUN) { 
     2187                        /* start with highest negotiated rate */ 
     2188                        KASSERT(ni->ni_rates.rs_nrates > 0, 
     2189                                ("transition to RUN state w/ no rates!")); 
     2190                        ni->ni_txrate = ni->ni_rates.rs_nrates - 1; 
     2191                } else { 
     2192                        /* use lowest rate */ 
     2193                        ni->ni_txrate = 0; 
     2194                } 
     2195        } else { 
    21802196                TAILQ_FOREACH(ni, &ic->ic_node, ni_list) { 
     2197                        ni->ni_txrate = 0;              /* use lowest rate */ 
    21812198                        st = ni->ni_private; 
    21822199                        st->st_tx_ok = st->st_tx_err = st->st_tx_retr = 
     
    21862203} 
    21872204 
     2205/*  
     2206 * Examine and potentially adjust the transmit rate. 
     2207 */ 
    21882208static void 
    21892209ath_rate_ctl(void *arg, struct ieee80211_node *ni) 
     
    21982218         * XXX: very primitive version. 
    21992219         */ 
    2200         (void) sc;                     /* NB: silence compiler */ 
     2220        sc->sc_stats.ast_rate_calls++; 
    22012221 
    22022222        enough = (st->st_tx_ok + st->st_tx_err >= 10); 
     
    22212241                break; 
    22222242        case -1: 
    2223                 if (ni->ni_txrate > 0) 
     2243                if (ni->ni_txrate > 0) { 
    22242244                        ni->ni_txrate--; 
     2245                        sc->sc_stats.ast_rate_drop++; 
     2246                } 
    22252247                st->st_tx_upper = 0; 
    22262248                break; 
     
    22292251                        break; 
    22302252                st->st_tx_upper = 0; 
    2231                 if (ni->ni_txrate + 1 < rs->rs_nrates) 
     2253                if (ni->ni_txrate + 1 < rs->rs_nrates) { 
    22322254                        ni->ni_txrate++; 
     2255                        sc->sc_stats.ast_rate_raise++; 
     2256                } 
    22332257                break; 
    22342258        } 
     
    24022426        STAT(be_nobuf); 
    24032427 
     2428        STAT(per_cal);          STAT(per_rfgain); 
     2429        STAT(rate_calls);       STAT(rate_raise);       STAT(rate_drop); 
     2430 
    24042431        return cp - page; 
    24052432#undef PHYSTAT 
  • cvs-import/trunk/driver/if_athvar.h

    r136 r139  
    8585        u_int32_t       ast_rx_nobuf;   /* rx setup failed 'cuz no skbuff */ 
    8686        u_int32_t       ast_be_nobuf;   /* no skbuff available for beacon */ 
     87        u_int32_t       ast_per_cal;    /* periodic calibration calls */ 
     88        u_int32_t       ast_per_rfgain; /* periodic calibration rfgain reset */ 
     89        u_int32_t       ast_rate_calls; /* rate control checks */ 
     90        u_int32_t       ast_rate_raise; /* rate control raised xmit rate */ 
     91        u_int32_t       ast_rate_drop;  /* rate control dropped xmit rate */ 
    8792}; 
    8893