Changeset 112

Show
Ignore:
Timestamp:
04/30/03 18:40:22 (9 years ago)
Author:
sam
Message:

updates from freebsd:

o track hal api changes for 32/64 bit tsf
o track wlan api changes for passing recv antenna state
o handle short/long preamble and set xmit antenna state in driver
o record tx antenna state in private node state
o fix rate control algorithm retry statistics to match algorithm expectations
o use a dynamically allocate channel array when querying the hal for the

available channel set so 5212 cards can return all their channels (fixed
size array was too small)

o track hal api change for ath_hal_getratetable

Files:

Legend:

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

    r109 r112  
    400400        u_int32_t val; 
    401401        HAL_STATUS status; 
     402        int i; 
    402403 
    403404        DPRINTF(("ath_init\n")); 
     
    455456         * immediately call back to us to send mgmt frames. 
    456457         */ 
     458        ni = &ic->ic_bss; 
     459        ieee80211_set_node(ic, ni, ic->ic_ibss_chan); 
    457460        if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 
    458                 int i; 
    459461                ni->ni_chan = ic->ic_ibss_chan; 
    460462                ni->ni_intval = ic->ic_lintval; 
    461463                ni->ni_rssi = 0; 
    462464                ni->ni_rstamp = 0; 
     465                ni->ni_rantenna = 0; 
    463466                memset(ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); 
    464467                ni->ni_nrate = 0; 
     
    479482                ieee80211_new_state(dev, IEEE80211_S_RUN, -1); 
    480483        } else { 
    481                 ni->ni_chan = ic->ic_ibss_chan; 
    482484                ieee80211_new_state(dev, IEEE80211_S_SCAN, -1); 
    483485        } 
     
    698700                u_int32_t *tstamp; 
    699701 
    700                 tsf = ath_hal_gettsf(ah); 
     702                tsf = ath_hal_gettsf64(ah); 
    701703                /* XXX: adjust 100us delay to xmit */ 
    702704                tsf += 100; 
     
    12651267                stats->rx_packets++; 
    12661268                stats->rx_bytes += len; 
    1267                 ieee80211_input(dev, skb, ds->ds_rxstat.rs_rssi, 
    1268                         ds->ds_rxstat.rs_tstamp); 
     1269                ieee80211_input(dev, skb, 
     1270                        ds->ds_rxstat.rs_rssi, 
     1271                        ds->ds_rxstat.rs_tstamp, 
     1272                        ds->ds_rxstat.rs_antenna); 
    12691273  rx_next: 
    12701274                TAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); 
     
    12941298        u_int8_t hdrbuf[sizeof(struct ieee80211_frame) + 
    12951299            IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN]; 
    1296         u_int subtype, flags, ctsduration
     1300        u_int subtype, flags, ctsduration, antenna
    12971301        HAL_PKT_TYPE atype; 
    12981302        const HAL_RATE_TABLE *rt; 
     1303        HAL_BOOL shortPreamble; 
     1304        struct ath_nodestat *st; 
    12991305 
    13001306        wh = (struct ieee80211_frame *) skb->data; 
     
    13431349        bf->bf_node = ni; 
    13441350 
     1351        /* setup descriptors */ 
    13451352        ds = bf->bf_desc; 
    13461353        rt = sc->sc_rates[ni->ni_mode]; 
     
    13731380                 */ 
    13741381                txrate = ni->ni_rates[ni->ni_txrate]; 
     1382                /* XXX use table lookup */ 
    13751383                for (rix = 0; rix < rt->rateCount; rix++) 
    13761384                        if (txrate == rt->info[rix].dot11Rate) 
    13771385                                break; 
     1386                /* XXX verify valid rate */ 
    13781387                break; 
    13791388        } 
     
    13811390                /* 11g always uses long preamble */ 
    13821391                txrate = rt->info[rix].rateCode; 
    1383                 flags &= ~HAL_TXDESC_SHORTPRE; 
     1392                shortPreamble = AH_FALSE; 
     1393        } else if (IEEE80211_IS_CHAN_B(ni->ni_chan)) { 
     1394                /* long preamble XXX is this right? */ 
     1395                txrate = rt->info[rix].rateCode; 
     1396                shortPreamble = AH_FALSE; 
    13841397        } else { 
    13851398                /* XXX no control over long/short preamble */ 
    13861399                txrate = rt->info[rix].rateCode | rt->info[rix].shortPreamble; 
    1387                 flags |= HAL_TXDESC_SHORTPRE; 
     1400                shortPreamble = AH_TRUE; 
    13881401        } 
    13891402 
     
    14031416                if (flags & HAL_TXDESC_RTSENA) {        /* SIFS + CTS */ 
    14041417                        ctsduration += ath_hal_computetxtime(ah, 
    1405                                 rt, IEEE80211_ACK_SIZE, 
    1406                                 ctsrate, (flags & HAL_TXDESC_SHORTPRE) != 0); 
     1418                                rt, IEEE80211_ACK_SIZE, ctsrate, shortPreamble); 
    14071419                } 
    14081420                /* SIFS + data */ 
    14091421                ctsduration += ath_hal_computetxtime(ah, rt, pktlen, 
    1410                         txrate, (flags & HAL_TXDESC_SHORTPRE) != 0); 
     1422                        txrate, shortPreamble); 
    14111423                if ((flags & HAL_TXDESC_NOACK) == 0) {  /* SIFS + ACK */ 
    14121424                        ctsduration += ath_hal_computetxtime(ah, 
    1413                                 rt, IEEE80211_ACK_SIZE, 
    1414                                 ctsrate, (flags & HAL_TXDESC_SHORTPRE) != 0); 
     1425                                rt, IEEE80211_ACK_SIZE, ctsrate, shortPreamble); 
    14151426                } 
    14161427        } else 
    14171428                ctsrate = 0; 
     1429 
     1430        /* 
     1431         * For now use the antenna on which the last good 
     1432         * frame was received on.  We assume this field is 
     1433         * initialized to 0 which gives us ``auto'' or the 
     1434         * ``default'' antenna. 
     1435         */ 
     1436        st = ni->ni_private; 
     1437        if (st->st_tx_antenna) 
     1438                antenna = st->st_tx_antenna; 
     1439        else 
     1440                antenna = ni->ni_rantenna; 
    14181441 
    14191442        /* 
     
    14271450                , txrate, 1+10          /* series 0 rate/tries */ 
    14281451                , iswep ? sc->sc_ic.ic_wep_txkey : HAL_TXKEYIX_INVALID 
    1429                 , 0                   /* antenna mode */ 
     1452                , antenna             /* antenna mode */ 
    14301453                , flags                 /* flags */ 
    14311454                , ctsrate               /* rts/cts rate */ 
     
    14821505        struct ath_buf *bf; 
    14831506        struct ath_desc *ds; 
     1507        struct ieee80211_node *ni; 
    14841508        struct ath_nodestat *st; 
    14851509        int sr, lr; 
     
    15101534                spin_unlock(&sc->sc_txqlock); 
    15111535 
    1512                 if (bf->bf_node != NULL) { 
    1513                         st = bf->bf_node->ni_private; 
    1514                         if (ds->ds_txstat.ts_status == 0) 
     1536                ni = bf->bf_node; 
     1537                if (ni != NULL) { 
     1538                        st = ni->ni_private; 
     1539                        if (ds->ds_txstat.ts_status == 0) { 
    15151540                                st->st_tx_ok++; 
    1516                         else { 
     1541                                st->st_tx_antenna = ds->ds_txstat.ts_antenna; 
     1542                        } else { 
    15171543                                st->st_tx_err++; 
    15181544                                if (ds->ds_txstat.ts_status & HAL_TXERR_XRETRY) 
     
    15221548                                if (ds->ds_txstat.ts_status & HAL_TXERR_FILT) 
    15231549                                        sc->sc_stats.ast_tx_filtered++; 
     1550                                st->st_tx_antenna = 0;  /* invalidate */ 
    15241551                        } 
    15251552                        sr = ds->ds_txstat.ts_shortretry; 
     
    15271554                        sc->sc_stats.ast_tx_shortretry += sr; 
    15281555                        sc->sc_stats.ast_tx_longretry += lr; 
    1529                         st->st_tx_retr += sr + lr; 
     1556                        if (sr + lr) 
     1557                                st->st_tx_retr++; 
    15301558                } 
    15311559                pci_unmap_single(sc->sc_pdev, 
     
    17761804        struct ath_hal *ah = sc->sc_ah; 
    17771805        struct ieee80211com *ic = &sc->sc_ic; 
    1778         struct ieee80211_node *ni = &ic->ic_bss;       /* NB: no reference */ 
     1806        struct ieee80211_node *ni; 
    17791807        struct ath_nodestat *st; 
    17801808        int i, error; 
     
    17951823 
    17961824        ostate = ic->ic_state; 
    1797         now = (ath_hal_gettsf(ah) >> 10) & 0xffff; 
     1825        now = (ath_hal_gettsf32(ah) >> 10) & 0xffff; 
    17981826 
    17991827        DPRINTF(("ath_newstate: %s -> %s (%u)\n", 
     
    18071835                goto bad; 
    18081836        } 
     1837        ni = &ic->ic_bss; 
    18091838        error = ath_chan_set(sc, ni->ni_chan); 
    18101839        if (error != 0) 
     
    18841913        del_timer(&sc->sc_cal_ch); 
    18851914        return error; 
     1915} 
     1916 
     1917static int 
     1918ath_getchannels(struct net_device *dev, u_int cc, HAL_BOOL outdoor) 
     1919{ 
     1920        struct ath_softc *sc = dev->priv; 
     1921        struct ieee80211com *ic = &sc->sc_ic; 
     1922        struct ath_hal *ah = sc->sc_ah; 
     1923        HAL_CHANNEL *chans; 
     1924        int i, ix, nchan; 
     1925 
     1926        chans = kmalloc(IEEE80211_CHAN_MAX * sizeof(HAL_CHANNEL), GFP_KERNEL); 
     1927        if (chans == NULL) { 
     1928                printk("%s: unable to allocate channel table\n", dev->name); 
     1929                return ENOMEM; 
     1930        } 
     1931        /* XXX where does the country code, et. al. come from? */ 
     1932        if (!ath_hal_init_channels(ah, chans, IEEE80211_CHAN_MAX, &nchan, 
     1933            CTRY_DEFAULT, HAL_MODE_ALL, AH_TRUE)) { 
     1934                printk("%s: unable to collect channel list from hal\n", 
     1935                        dev->name); 
     1936                kfree(chans); 
     1937                return EINVAL; 
     1938        } 
     1939 
     1940        /* 
     1941         * Convert HAL channels to ieee80211 ones and insert 
     1942         * them in the table according to their channel number. 
     1943         */ 
     1944        for (i = 0; i < nchan; i++) { 
     1945                HAL_CHANNEL *c = &chans[i]; 
     1946                ix = ath_hal_mhz2ieee(c->channel, c->channelFlags); 
     1947                if (ix > IEEE80211_CHAN_MAX) { 
     1948                        printk("%s: bad hal channel %u (%u/%x) ignored\n", 
     1949                                dev->name, ix, c->channel, c->channelFlags); 
     1950                        continue; 
     1951                } 
     1952                /* NB: flags are known to be compatible */ 
     1953                if (ic->ic_channels[ix].ic_freq == 0) { 
     1954                        ic->ic_channels[ix].ic_freq = c->channel; 
     1955                        ic->ic_channels[ix].ic_flags = c->channelFlags; 
     1956                } else { 
     1957#ifdef notdef 
     1958                        /* XXX 802.11 code can't handle this right now */ 
     1959                        /* channels overlap; e.g. 11g and 11a/b */ 
     1960                        ic->ic_channels[ix].ic_flags |= c->channelFlags; 
     1961#endif 
     1962                } 
     1963        } 
     1964        kfree(chans); 
     1965        return 0; 
    18861966} 
    18871967 
     
    19131993                return 0; 
    19141994        } 
    1915         r = ic->ic_sup_rates[mode]; 
    19161995        rt = sc->sc_rates[mode]; 
     1996        if (rt == NULL) 
     1997                return 0; 
    19171998        if (rt->rateCount > IEEE80211_RATE_SIZE) { 
    19181999                DPRINTF(("%s: rate table too small (%u > %u)\n", 
     
    19212002        } else 
    19222003                maxrates = rt->rateCount; 
     2004        r = ic->ic_sup_rates[mode]; 
    19232005        /* XXX must mark basic rates for 11g */ 
    19242006        for (i = 0; i < maxrates; i++) 
     
    20632145} 
    20642146 
    2065 static int 
    2066 ath_getchannels(struct net_device *dev, u_int cc, HAL_BOOL outdoor) 
    2067 { 
    2068         struct ath_softc *sc = dev->priv; 
    2069         struct ieee80211com *ic = &sc->sc_ic; 
    2070         struct ath_hal *ah = sc->sc_ah; 
    2071 #define ATH_MAXCHAN     32              /* number of potential channels */ 
    2072         HAL_CHANNEL chans[ATH_MAXCHAN]; /* XXX get off stack */ 
    2073         int i, ix, nchan; 
    2074  
    2075         /* XXX where does the country code, et. al. come from? */ 
    2076         if (!ath_hal_init_channels(ah, chans, ATH_MAXCHAN, &nchan, 
    2077             CTRY_DEFAULT, HAL_MODE_ALL, AH_TRUE)) { 
    2078                 printk("%s: unable to collect channel list from hal\n", 
    2079                         dev->name); 
    2080                 return EINVAL; 
    2081         } 
    2082  
    2083         /* 
    2084          * Convert HAL channels to ieee80211 ones and insert 
    2085          * them in the table according to their channel number. 
    2086          */ 
    2087         for (i = 0; i < nchan; i++) { 
    2088                 HAL_CHANNEL *c = &chans[i]; 
    2089                 ix = ath_hal_mhz2ieee(c->channel, c->channelFlags); 
    2090                 if (ix > IEEE80211_CHAN_MAX) { 
    2091                         printk("%s: bad hal channel %u (%u/%x) ignored\n", 
    2092                                 dev->name, ix, c->channel, c->channelFlags); 
    2093                         continue; 
    2094                 } 
    2095                 /* NB: flags are known to be compatible */ 
    2096                 if (ic->ic_channels[ix].ic_freq == 0) { 
    2097                         ic->ic_channels[ix].ic_freq = c->channel; 
    2098                         ic->ic_channels[ix].ic_flags = c->channelFlags; 
    2099                 } else { 
    2100 #ifdef notdef 
    2101                         /* XXX 802.11 code can't handle this right now */ 
    2102                         /* channels overlap; e.g. 11g and 11a/b */ 
    2103                         ic->ic_channels[ix].ic_flags |= c->channelFlags; 
    2104 #endif 
    2105                 } 
    2106         } 
    2107         return 0; 
    2108 } 
    2109  
    21102147#ifdef CONFIG_PROC_FS 
    21112148#include <linux/proc_fs.h> 
  • cvs-import/trunk/driver/if_athvar.h

    r108 r112  
    4848        u_int           st_tx_retr;     /* tx retry count */ 
    4949        int             st_tx_upper;    /* tx upper rate req cnt */ 
     50        u_int           st_tx_antenna;  /* antenna for last good frame */ 
    5051}; 
    5152 
     
    160161#define ath_hal_reset(_ah, _opmode, _chan, _outdoor, _pstatus) \ 
    161162        ((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_outdoor), (_pstatus))) 
     163#define ath_hal_getratetable(_ah, _mode) \ 
     164        ((*(_ah)->ah_getRateTable)((_ah), (_mode))) 
    162165#define ath_hal_getmac(_ah, _mac) \ 
    163166        ((*(_ah)->ah_getMacAddress)((_ah), (_mac))) 
     
    194197#define ath_hal_putrxbuf(_ah, _bufaddr) \ 
    195198        ((*(_ah)->ah_setRxDP)((_ah), (_bufaddr))) 
    196 #define ath_hal_gettsf(_ah) \ 
    197         ((*(_ah)->ah_getTsf)((_ah))) 
     199#define ath_hal_gettsf32(_ah) \ 
     200        ((*(_ah)->ah_getTsf32)((_ah))) 
     201#define ath_hal_gettsf64(_ah) \ 
     202        ((*(_ah)->ah_getTsf64)((_ah))) 
    198203#define ath_hal_rxena(_ah) \ 
    199204        ((*(_ah)->ah_enableReceive)((_ah)))