Changeset 112
- Timestamp:
- 04/30/03 18:40:22 (9 years ago)
- Files:
-
- cvs-import/trunk/driver/if_ath.c (modified) (22 diffs)
- cvs-import/trunk/driver/if_athvar.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cvs-import/trunk/driver/if_ath.c
r109 r112 400 400 u_int32_t val; 401 401 HAL_STATUS status; 402 int i; 402 403 403 404 DPRINTF(("ath_init\n")); … … 455 456 * immediately call back to us to send mgmt frames. 456 457 */ 458 ni = &ic->ic_bss; 459 ieee80211_set_node(ic, ni, ic->ic_ibss_chan); 457 460 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { 458 int i;459 461 ni->ni_chan = ic->ic_ibss_chan; 460 462 ni->ni_intval = ic->ic_lintval; 461 463 ni->ni_rssi = 0; 462 464 ni->ni_rstamp = 0; 465 ni->ni_rantenna = 0; 463 466 memset(ni->ni_tstamp, 0, sizeof(ni->ni_tstamp)); 464 467 ni->ni_nrate = 0; … … 479 482 ieee80211_new_state(dev, IEEE80211_S_RUN, -1); 480 483 } else { 481 ni->ni_chan = ic->ic_ibss_chan;482 484 ieee80211_new_state(dev, IEEE80211_S_SCAN, -1); 483 485 } … … 698 700 u_int32_t *tstamp; 699 701 700 tsf = ath_hal_gettsf (ah);702 tsf = ath_hal_gettsf64(ah); 701 703 /* XXX: adjust 100us delay to xmit */ 702 704 tsf += 100; … … 1265 1267 stats->rx_packets++; 1266 1268 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); 1269 1273 rx_next: 1270 1274 TAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); … … 1294 1298 u_int8_t hdrbuf[sizeof(struct ieee80211_frame) + 1295 1299 IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN]; 1296 u_int subtype, flags, ctsduration ;1300 u_int subtype, flags, ctsduration, antenna; 1297 1301 HAL_PKT_TYPE atype; 1298 1302 const HAL_RATE_TABLE *rt; 1303 HAL_BOOL shortPreamble; 1304 struct ath_nodestat *st; 1299 1305 1300 1306 wh = (struct ieee80211_frame *) skb->data; … … 1343 1349 bf->bf_node = ni; 1344 1350 1351 /* setup descriptors */ 1345 1352 ds = bf->bf_desc; 1346 1353 rt = sc->sc_rates[ni->ni_mode]; … … 1373 1380 */ 1374 1381 txrate = ni->ni_rates[ni->ni_txrate]; 1382 /* XXX use table lookup */ 1375 1383 for (rix = 0; rix < rt->rateCount; rix++) 1376 1384 if (txrate == rt->info[rix].dot11Rate) 1377 1385 break; 1386 /* XXX verify valid rate */ 1378 1387 break; 1379 1388 } … … 1381 1390 /* 11g always uses long preamble */ 1382 1391 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; 1384 1397 } else { 1385 1398 /* XXX no control over long/short preamble */ 1386 1399 txrate = rt->info[rix].rateCode | rt->info[rix].shortPreamble; 1387 flags |= HAL_TXDESC_SHORTPRE;1400 shortPreamble = AH_TRUE; 1388 1401 } 1389 1402 … … 1403 1416 if (flags & HAL_TXDESC_RTSENA) { /* SIFS + CTS */ 1404 1417 ctsduration += ath_hal_computetxtime(ah, 1405 rt, IEEE80211_ACK_SIZE, 1406 ctsrate, (flags & HAL_TXDESC_SHORTPRE) != 0); 1418 rt, IEEE80211_ACK_SIZE, ctsrate, shortPreamble); 1407 1419 } 1408 1420 /* SIFS + data */ 1409 1421 ctsduration += ath_hal_computetxtime(ah, rt, pktlen, 1410 txrate, (flags & HAL_TXDESC_SHORTPRE) != 0);1422 txrate, shortPreamble); 1411 1423 if ((flags & HAL_TXDESC_NOACK) == 0) { /* SIFS + ACK */ 1412 1424 ctsduration += ath_hal_computetxtime(ah, 1413 rt, IEEE80211_ACK_SIZE, 1414 ctsrate, (flags & HAL_TXDESC_SHORTPRE) != 0); 1425 rt, IEEE80211_ACK_SIZE, ctsrate, shortPreamble); 1415 1426 } 1416 1427 } else 1417 1428 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; 1418 1441 1419 1442 /* … … 1427 1450 , txrate, 1+10 /* series 0 rate/tries */ 1428 1451 , iswep ? sc->sc_ic.ic_wep_txkey : HAL_TXKEYIX_INVALID 1429 , 0/* antenna mode */1452 , antenna /* antenna mode */ 1430 1453 , flags /* flags */ 1431 1454 , ctsrate /* rts/cts rate */ … … 1482 1505 struct ath_buf *bf; 1483 1506 struct ath_desc *ds; 1507 struct ieee80211_node *ni; 1484 1508 struct ath_nodestat *st; 1485 1509 int sr, lr; … … 1510 1534 spin_unlock(&sc->sc_txqlock); 1511 1535 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) { 1515 1540 st->st_tx_ok++; 1516 else { 1541 st->st_tx_antenna = ds->ds_txstat.ts_antenna; 1542 } else { 1517 1543 st->st_tx_err++; 1518 1544 if (ds->ds_txstat.ts_status & HAL_TXERR_XRETRY) … … 1522 1548 if (ds->ds_txstat.ts_status & HAL_TXERR_FILT) 1523 1549 sc->sc_stats.ast_tx_filtered++; 1550 st->st_tx_antenna = 0; /* invalidate */ 1524 1551 } 1525 1552 sr = ds->ds_txstat.ts_shortretry; … … 1527 1554 sc->sc_stats.ast_tx_shortretry += sr; 1528 1555 sc->sc_stats.ast_tx_longretry += lr; 1529 st->st_tx_retr += sr + lr; 1556 if (sr + lr) 1557 st->st_tx_retr++; 1530 1558 } 1531 1559 pci_unmap_single(sc->sc_pdev, … … 1776 1804 struct ath_hal *ah = sc->sc_ah; 1777 1805 struct ieee80211com *ic = &sc->sc_ic; 1778 struct ieee80211_node *ni = &ic->ic_bss; /* NB: no reference */1806 struct ieee80211_node *ni; 1779 1807 struct ath_nodestat *st; 1780 1808 int i, error; … … 1795 1823 1796 1824 ostate = ic->ic_state; 1797 now = (ath_hal_gettsf (ah) >> 10) & 0xffff;1825 now = (ath_hal_gettsf32(ah) >> 10) & 0xffff; 1798 1826 1799 1827 DPRINTF(("ath_newstate: %s -> %s (%u)\n", … … 1807 1835 goto bad; 1808 1836 } 1837 ni = &ic->ic_bss; 1809 1838 error = ath_chan_set(sc, ni->ni_chan); 1810 1839 if (error != 0) … … 1884 1913 del_timer(&sc->sc_cal_ch); 1885 1914 return error; 1915 } 1916 1917 static int 1918 ath_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; 1886 1966 } 1887 1967 … … 1913 1993 return 0; 1914 1994 } 1915 r = ic->ic_sup_rates[mode];1916 1995 rt = sc->sc_rates[mode]; 1996 if (rt == NULL) 1997 return 0; 1917 1998 if (rt->rateCount > IEEE80211_RATE_SIZE) { 1918 1999 DPRINTF(("%s: rate table too small (%u > %u)\n", … … 1921 2002 } else 1922 2003 maxrates = rt->rateCount; 2004 r = ic->ic_sup_rates[mode]; 1923 2005 /* XXX must mark basic rates for 11g */ 1924 2006 for (i = 0; i < maxrates; i++) … … 2063 2145 } 2064 2146 2065 static int2066 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 insert2085 * 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 notdef2101 /* 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 #endif2105 }2106 }2107 return 0;2108 }2109 2110 2147 #ifdef CONFIG_PROC_FS 2111 2148 #include <linux/proc_fs.h> cvs-import/trunk/driver/if_athvar.h
r108 r112 48 48 u_int st_tx_retr; /* tx retry count */ 49 49 int st_tx_upper; /* tx upper rate req cnt */ 50 u_int st_tx_antenna; /* antenna for last good frame */ 50 51 }; 51 52 … … 160 161 #define ath_hal_reset(_ah, _opmode, _chan, _outdoor, _pstatus) \ 161 162 ((*(_ah)->ah_reset)((_ah), (_opmode), (_chan), (_outdoor), (_pstatus))) 163 #define ath_hal_getratetable(_ah, _mode) \ 164 ((*(_ah)->ah_getRateTable)((_ah), (_mode))) 162 165 #define ath_hal_getmac(_ah, _mac) \ 163 166 ((*(_ah)->ah_getMacAddress)((_ah), (_mac))) … … 194 197 #define ath_hal_putrxbuf(_ah, _bufaddr) \ 195 198 ((*(_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))) 198 203 #define ath_hal_rxena(_ah) \ 199 204 ((*(_ah)->ah_enableReceive)((_ah)))
