Changeset 4096

Show
Ignore:
Timestamp:
09/03/09 23:10:20 (3 years ago)
Author:
proski
Message:

Rewrite handling of the fixed rates

Make srate signed, or checks for it being less than 0 don't work.
Consistently use IEEE80211_FIXED_RATE_NONE. Fix misleading comments.

Survive the case when the fixed rate is not in the rate table. It can
happen e.g. a CCK rate is used with an 802.11a channel, or in the STA
mode when an OFDM rate is used with 802.11b. The driver should catch
it, but it doesn't. In any case, it's not a reason for an oops.

Remove the debugging message if everything is fine. In case of an
error, specify the VAP name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/branches/madwifi-0.9.4/ath_rate/amrr/amrr.c

    r3907 r4096  
    7979#define DPRINTF(sc, _fmt, ...) 
    8080#endif 
     81 
     82#include "release.h" 
     83static char *version = "0.1 (" RELEASE_VERSION ")"; 
     84static char *dev_info = "ath_rate_amrr"; 
    8185 
    8286static int ath_rateinterval = 1000;             /* rate ctl interval (ms)  */ 
     
    268272 
    269273        KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); 
    270         if (vap->iv_fixed_rate == -1) { 
     274 
     275        if (vap->iv_fixed_rate != IEEE80211_FIXED_RATE_NONE) { 
    271276                /* 
    272                  * No fixed rate is requested. For 11b start with 
    273                  * the highest negotiated rate; otherwise, for 11g 
    274                  * and 11a, we start "in the middle" at 24Mb or 36Mb. 
     277                 * A fixed rate is to be used.  Find the corresponding 
     278                 * index in the rate table. 
    275279                 */ 
    276                 srate = ni->ni_rates.rs_nrates - 1; 
    277                 if (sc->sc_curmode != IEEE80211_MODE_11B) { 
    278                         /* 
    279                          * Scan the negotiated rate set to find the 
    280                          * closest rate. 
    281                          */ 
    282                         /* NB: the rate set is assumed sorted */ 
    283                         for (; srate >= 0 && RATE(srate) > 72; srate--); 
    284                         KASSERT(srate >= 0, ("bogus rate set")); 
    285                 } 
    286         } else { 
     280                for (srate = 0; srate < ni->ni_rates.rs_nrates; srate++) 
     281                        if (vap->iv_fixed_rate == 
     282                            (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL)) { 
     283                                ath_rate_update(sc, ni, srate); 
     284                                return; 
     285                        } 
     286 
     287                printk(KERN_WARNING "%s: %s: fixed rate %u%sMbps is not " 
     288                       "available and will be ignored\n", vap->iv_dev->name, 
     289                       dev_info, vap->iv_fixed_rate / 2, 
     290                       (vap->iv_fixed_rate & 1) ? ".5" : ""); 
     291        } 
     292 
     293        /* 
     294         * No fixed rate is requested. For 11b start with 
     295         * the highest negotiated rate; otherwise, for 11g 
     296         * and 11a, we start "in the middle" at 24Mb or 36Mb. 
     297         */ 
     298        srate = ni->ni_rates.rs_nrates - 1; 
     299        if (sc->sc_curmode != IEEE80211_MODE_11B) { 
    287300                /* 
    288                  * A fixed rate is to be used; ic_fixed_rate is an 
    289                  * index into the supported rate set.  Convert this 
    290                  * to the index into the negotiated rate set for 
    291                  * the node.  We know the rate is there because the 
    292                  * rate set is checked when the station associates. 
     301                 * Scan the negotiated rate set to find the 
     302                 * closest rate. 
    293303                 */ 
    294                 srate = ni->ni_rates.rs_nrates - 1; 
    295                 for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--); 
    296                 KASSERT(srate >= 0, 
    297                        ("fixed rate %d not in rate set", vap->iv_fixed_rate)); 
    298         } 
     304                /* NB: the rate set is assumed sorted */ 
     305                for (; srate >= 0 && RATE(srate) > 72; srate--); 
     306                KASSERT(srate >= 0, ("bogus rate set")); 
     307        } 
     308 
    299309        ath_rate_update(sc, ni, srate); 
    300310#undef RATE 
     
    553563}; 
    554564 
    555 #include "release.h" 
    556 static char *version = "0.1 (" RELEASE_VERSION ")"; 
    557 static char *dev_info = "ath_rate_amrr"; 
    558  
    559565MODULE_AUTHOR("INRIA, Mathieu Lacage"); 
    560566MODULE_DESCRIPTION("AMRR Rate control algorithm"); 
  • madwifi/branches/madwifi-0.9.4/ath_rate/minstrel/minstrel.c

    r4025 r4096  
    611611        unsigned int x; 
    612612        int retry_index, tx_time; 
    613         int srate; 
    614613        int ndx = 0; 
    615614 
     
    672671 
    673672        if (vap->iv_fixed_rate != IEEE80211_FIXED_RATE_NONE) { 
    674                 srate = sn->num_rates - 1; 
    675  
    676                 /* A fixed rate is to be used; ic_fixed_rate is an 
    677                  * index into the supported rate set.  Convert this 
    678                  * to the index into the negotiated rate set for 
    679                  * the node.  We know the rate is there because the 
    680                  * rate set is checked when the station associates. */ 
    681                 /* NB: the rate set is assumed sorted */ 
    682                 for (; srate >= 0 && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--); 
    683  
    684                 KASSERT(srate >= 0, 
    685                         ("fixed rate %d not in rate set", vap->iv_fixed_rate)); 
    686  
    687                 sn->static_rate_ndx = srate; 
    688                 ni->ni_txrate = srate; 
    689                 DPRINTF(sc, "%s: %s %s fixed rate %d%sMbps\n", 
    690                         dev_info, __func__, ether_sprintf(ni->ni_macaddr),  
    691                         sn->rates[srate].rate / 2, 
    692                         (sn->rates[srate].rate % 0x1) ? ".5" : " "); 
    693                 return; 
    694         } 
    695          
     673                int srate; 
     674 
     675                /* 
     676                 * A fixed rate is to be used.  Find the corresponding 
     677                 * index in the rate table. 
     678                 */ 
     679                for (srate = 0; srate < sn->num_rates; srate++) 
     680                        if (vap->iv_fixed_rate == 
     681                            (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL)) { 
     682                                sn->static_rate_ndx = srate; 
     683                                ni->ni_txrate = srate; 
     684                                return; 
     685                        } 
     686 
     687                printk(KERN_WARNING "%s: %s: fixed rate %u%sMbps is not " 
     688                       "available and will be ignored\n", vap->iv_dev->name, 
     689                       dev_info, vap->iv_fixed_rate / 2, 
     690                       (vap->iv_fixed_rate & 1) ? ".5" : ""); 
     691        } 
     692 
    696693        for (x = 0; x < ni->ni_rates.rs_nrates; x++) { 
    697694                sn->rs_rateattempts     [x] = 0; 
  • madwifi/branches/madwifi-0.9.4/ath_rate/onoe/onoe.c

    r3907 r4096  
    7878#define DPRINTF(sc, _fmt, ...) 
    7979#endif 
     80 
     81#include "release.h" 
     82static char *version = "1.0 (" RELEASE_VERSION ")"; 
     83static char *dev_info = "ath_rate_onoe"; 
    8084 
    8185/* 
     
    253257 
    254258        KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); 
    255         if (vap->iv_fixed_rate == IEEE80211_FIXED_RATE_NONE) { 
     259 
     260        if (vap->iv_fixed_rate != IEEE80211_FIXED_RATE_NONE) { 
    256261                /* 
    257                  * No fixed rate is requested. For 11b start with 
    258                  * the highest negotiated rate; otherwise, for 11g 
    259                  * and 11a, we start "in the middle" at 24Mb or 36Mb. 
     262                 * A fixed rate is to be used.  Find the corresponding 
     263                 * index in the rate table. 
    260264                 */ 
    261                 srate = ni->ni_rates.rs_nrates - 1; 
    262                 if (sc->sc_curmode != IEEE80211_MODE_11B) { 
    263                         /* 
    264                          * Scan the negotiated rate set to find the 
    265                          * closest rate. 
    266                          */ 
    267                         /* NB: the rate set is assumed sorted */ 
    268                         for (; srate >= 0 && RATE(srate) > 72; srate--); 
    269                         KASSERT(srate >= 0, ("bogus rate set")); 
    270                 } 
    271         } else { 
     265                for (srate = 0; srate < ni->ni_rates.rs_nrates; srate++) 
     266                        if (vap->iv_fixed_rate == 
     267                            (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL)) { 
     268                                ath_rate_update(sc, ni, srate); 
     269                                return; 
     270                        } 
     271 
     272                printk(KERN_WARNING "%s: %s: fixed rate %u%sMbps is not " 
     273                       "available and will be ignored\n", vap->iv_dev->name, 
     274                       dev_info, vap->iv_fixed_rate / 2, 
     275                       (vap->iv_fixed_rate & 1) ? ".5" : ""); 
     276        } 
     277 
     278        /* 
     279         * No fixed rate is requested. For 11b start with 
     280         * the highest negotiated rate; otherwise, for 11g 
     281         * and 11a, we start "in the middle" at 24Mb or 36Mb. 
     282         */ 
     283        srate = ni->ni_rates.rs_nrates - 1; 
     284        if (sc->sc_curmode != IEEE80211_MODE_11B) { 
    272285                /* 
    273                  * A fixed rate is to be used; iv_fixed_rate is the 
    274                  * 802.11 rate code.  Convert this to the index into 
    275                  * the negotiated rate set for the node.  We know the 
    276                  * rate is there because the rate set is checked when 
    277                  * the station associates. 
     286                 * Scan the negotiated rate set to find the 
     287                 * closest rate. 
    278288                 */ 
    279289                /* NB: the rate set is assumed sorted */ 
    280                 srate = ni->ni_rates.rs_nrates - 1; 
    281                 for (; srate >= 0 && RATE(srate) != vap->iv_fixed_rate; srate--); 
    282                 KASSERT(srate >= 0, 
    283                         ("fixed rate %d not in rate set", vap->iv_fixed_rate)); 
    284         } 
     290                for (; srate >= 0 && RATE(srate) > 72; srate--); 
     291                KASSERT(srate >= 0, ("bogus rate set")); 
     292        } 
     293 
    285294        ath_rate_update(sc, ni, srate); 
    286295#undef RATE 
     
    499508}; 
    500509 
    501 #include "release.h" 
    502 static char *version = "1.0 (" RELEASE_VERSION ")"; 
    503 static char *dev_info = "ath_rate_onoe"; 
    504  
    505510MODULE_AUTHOR("Errno Consulting, Sam Leffler"); 
    506511MODULE_DESCRIPTION("Atsushi Onoe's rate control algorithm for Atheros devices"); 
  • madwifi/branches/madwifi-0.9.4/ath_rate/sample/sample.c

    r3907 r4096  
    777777        const HAL_RATE_TABLE *rt = sc->sc_currates; 
    778778        unsigned int x, y; 
    779         unsigned int srate; 
    780779        sn->num_rates = 0; 
    781780 
     
    812811        } 
    813812 
    814         if (vap->iv_fixed_rate != -1) { 
    815                 srate = sn->num_rates - 1
     813        if (vap->iv_fixed_rate != IEEE80211_FIXED_RATE_NONE) { 
     814                int srate
    816815 
    817816                /* 
    818                  * A fixed rate is to be used; ic_fixed_rate is an 
    819                  * index into the supported rate set.  Convert this 
    820                  * to the index into the negotiated rate set for 
    821                  * the node.  We know the rate is there because the 
    822                  * rate set is checked when the station associates. 
     817                 * A fixed rate is to be used.  Find the corresponding 
     818                 * index in the rate table. 
    823819                 */ 
    824                 /* NB: the rate set is assumed sorted */ 
    825                 for (; srate >= 0 && (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL) != vap->iv_fixed_rate; srate--); 
    826  
    827                 KASSERT(srate >= 0, 
    828                         ("fixed rate %u not in rate set", vap->iv_fixed_rate)); 
    829  
    830                 sn->static_rate_ndx = srate; 
    831                 ni->ni_txrate = srate; 
    832                 DPRINTF(sc, "%s: %s %s fixed rate %u%sMbps\n", 
    833                         dev_info, __func__, ether_sprintf(ni->ni_macaddr),  
    834                         sn->rates[srate].rate / 2, 
    835                         (sn->rates[srate].rate % 0x1) ? ".5" : " "); 
    836                 return; 
    837         } 
    838          
     820                for (srate = 0; srate < sn->num_rates; srate++) 
     821                        if (vap->iv_fixed_rate == 
     822                            (ni->ni_rates.rs_rates[srate] & IEEE80211_RATE_VAL)) { 
     823                                sn->static_rate_ndx = srate; 
     824                                ni->ni_txrate = srate; 
     825                                return; 
     826                        } 
     827 
     828                printk(KERN_WARNING "%s: %s: fixed rate %u%sMbps is not " 
     829                       "available and will be ignored\n", vap->iv_dev->name, 
     830                       dev_info, vap->iv_fixed_rate / 2, 
     831                       (vap->iv_fixed_rate & 1) ? ".5" : ""); 
     832        } 
    839833 
    840834        for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) {