Replace some magic numbers with HFA3861A register names.

Do not alias the Rx descriptor word ar_ctl to ar_rssi with a #define.
Instead, call the member ar_ctlrssi.

Convert the ugly macro ATW_RXDESC_INIT() to an inline subroutine,
atw_rxdesc_init().

Do not load an empty IEEE80211_RADIOTAP_FLAGS field into the Tx
radiotap header.
This commit is contained in:
dyoung 2007-11-16 04:58:38 +00:00
parent 67612c1e03
commit b66951c216
3 changed files with 42 additions and 47 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: atw.c,v 1.131 2007/11/15 22:49:46 dyoung Exp $ */
/* $NetBSD: atw.c,v 1.132 2007/11/16 04:58:38 dyoung Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.131 2007/11/15 22:49:46 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.132 2007/11/16 04:58:38 dyoung Exp $");
#include "bpfilter.h"
@ -1357,7 +1357,7 @@ atw_init(struct ifnet *ifp)
goto out;
}
} else
ATW_INIT_RXDESC(sc, i);
atw_init_rxdesc(sc, i);
}
sc->sc_rxptr = 0;
@ -2626,7 +2626,7 @@ atw_add_rxbuf(struct atw_softc *sc, int idx)
bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
ATW_INIT_RXDESC(sc, idx);
atw_init_rxdesc(sc, idx);
return (0);
}
@ -3088,7 +3088,7 @@ atw_rxintr(struct atw_softc *sc)
ATW_CDRXSYNC(sc, i, BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
rxstat = le32toh(sc->sc_rxdescs[i].ar_stat);
rssi0 = le32toh(sc->sc_rxdescs[i].ar_rssi);
rssi0 = le32toh(sc->sc_rxdescs[i].ar_ctlrssi);
rate0 = __SHIFTOUT(rxstat, ATW_RXSTAT_RXDR_MASK);
if (rxstat & ATW_RXSTAT_OWN)
@ -3140,7 +3140,7 @@ atw_rxintr(struct atw_softc *sc)
PRINTERR(ATW_RXSTAT_CRC32E, "FCS error");
PRINTERR(ATW_RXSTAT_ICVE, "WEP ICV error");
#undef PRINTERR
ATW_INIT_RXDESC(sc, i);
atw_init_rxdesc(sc, i);
continue;
}
@ -3161,7 +3161,7 @@ atw_rxintr(struct atw_softc *sc)
m = rxs->rxs_mbuf;
if (atw_add_rxbuf(sc, i) != 0) {
ifp->if_ierrors++;
ATW_INIT_RXDESC(sc, i);
atw_init_rxdesc(sc, i);
bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
continue;
@ -3181,6 +3181,7 @@ atw_rxintr(struct atw_softc *sc)
* bits. Mask those off.
*
* TBD Treat other basebands.
* TBD Use short-preamble bit and such in RF3000_RXSTAT.
*/
if (sc->sc_bbptype == ATW_BBPTYPE_RFMD)
rssi = rssi0 & RF3000_RSSI_MASK;
@ -3514,8 +3515,6 @@ atw_start(struct ifnet *ifp)
tap->at_chan_freq = htole16(ic->ic_curchan->ic_freq);
tap->at_chan_flags = htole16(ic->ic_curchan->ic_flags);
/* TBD tap->at_flags */
bpf_mtap2(sc->sc_radiobpf, (void *)tap,
tap->at_ihdr.it_len, m0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: atwreg.h,v 1.17 2007/01/09 09:36:28 dyoung Exp $ */
/* $NetBSD: atwreg.h,v 1.18 2007/11/16 04:58:39 dyoung Exp $ */
/*
* Copyright (c) 2003 The NetBSD Foundation, Inc. All rights reserved.
@ -48,6 +48,8 @@
*/
#include <lib/libkern/libkern.h>
#include <dev/ic/rf3000reg.h>
#include <dev/ic/hfa3861areg.h>
/* ADM8211 Host Control and Status Registers */
@ -520,10 +522,10 @@
/* was magic 0x100E0C0A */
#define ATW_MMIWADDR_INTERSIL \
(__SHIFTIN(0x0c, ATW_MMIWADDR_GAIN_MASK) | \
__SHIFTIN(0x0a, ATW_MMIWADDR_RATE_MASK) | \
__SHIFTIN(0x0e, ATW_MMIWADDR_LENHI_MASK) | \
__SHIFTIN(0x10, ATW_MMIWADDR_LENLO_MASK))
(__SHIFTIN(HFA3861A_CR6, ATW_MMIWADDR_GAIN_MASK) | \
__SHIFTIN(HFA3861A_CR5, ATW_MMIWADDR_RATE_MASK) | \
__SHIFTIN(HFA3861A_CR7, ATW_MMIWADDR_LENHI_MASK) | \
__SHIFTIN(HFA3861A_CR8, ATW_MMIWADDR_LENLO_MASK))
/* was magic 0x00009101
*
@ -540,13 +542,10 @@
#define ATW_MMIRADDR1_RSSI_MASK __BITS(15, 8)
#define ATW_MMIRADDR1_RXSTAT_MASK __BITS(7, 0)
/* was magic 0x00007c7e
*
* TBD document registers for Intersil 3861 baseband
*/
/* was magic 0x00007c7e */
#define ATW_MMIRADDR1_INTERSIL \
(__SHIFTIN(0x7c, ATW_MMIRADDR1_RSSI_MASK) | \
__SHIFTIN(0x7e, ATW_MMIRADDR1_RXSTAT_MASK))
(__SHIFTIN(HFA3861A_CR61, ATW_MMIRADDR1_RSSI_MASK) | \
__SHIFTIN(HFA3861A_CR62, ATW_MMIRADDR1_RXSTAT_MASK))
/* was magic 0x00000301 */
#define ATW_MMIRADDR1_RFMD \
@ -954,13 +953,11 @@ struct atw_txdesc {
/* Rx descriptor */
struct atw_rxdesc {
volatile uint32_t ar_stat;
volatile uint32_t ar_ctl;
volatile uint32_t ar_ctlrssi;
volatile uint32_t ar_buf1;
volatile uint32_t ar_buf2;
} __attribute__((__packed__, __aligned__(4)));
#define ar_rssi ar_ctl
#define ATW_RXCTL_RER __BIT(25) /* end of ring */
#define ATW_RXCTL_RCH __BIT(24) /* ar_buf2 is 2nd chain */
#define ATW_RXCTL_RBS2_MASK __BITS(23,12) /* ar_buf2 byte count */

View File

@ -1,4 +1,4 @@
/* $NetBSD: atwvar.h,v 1.23 2007/03/04 06:01:50 christos Exp $ */
/* $NetBSD: atwvar.h,v 1.24 2007/11/16 04:58:39 dyoung Exp $ */
/*
* Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. All rights reserved.
@ -166,14 +166,13 @@ struct atw_rx_radiotap_header {
u_int8_t ar_antsignal;
} __attribute__((__packed__));
#define ATW_TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
#define ATW_TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct atw_tx_radiotap_header {
struct ieee80211_radiotap_header at_ihdr;
u_int8_t at_flags;
u_int8_t at_rate;
u_int8_t at_pad;
u_int16_t at_chan_freq;
u_int16_t at_chan_flags;
} __attribute__((__packed__));
@ -401,26 +400,26 @@ do { \
* field is only 11 bits, we must subtract 1 from the length to avoid
* having it truncated to 0!
*/
#define ATW_INIT_RXDESC(sc, x) \
do { \
struct atw_rxsoft *__rxs = &sc->sc_rxsoft[(x)]; \
struct atw_rxdesc *__rxd = &sc->sc_rxdescs[(x)]; \
struct mbuf *__m = __rxs->rxs_mbuf; \
\
__rxd->ar_buf1 = \
htole32(__rxs->rxs_dmamap->dm_segs[0].ds_addr); \
__rxd->ar_buf2 = /* for descriptor chaining */ \
htole32(ATW_CDRXADDR((sc), ATW_NEXTRX((x)))); \
__rxd->ar_ctl = \
htole32(__SHIFTIN(((__m->m_ext.ext_size - 1) & ~0x3U), \
ATW_RXCTL_RBS1_MASK) | \
0 /* ATW_RXCTL_RCH */ | \
((x) == (ATW_NRXDESC - 1) ? ATW_RXCTL_RER : 0)); \
__rxd->ar_stat = htole32(ATW_RXSTAT_OWN); \
\
ATW_CDRXSYNC((sc), (x), \
BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
} while (0)
static inline void
atw_init_rxdesc(struct atw_softc *sc, int x)
{
struct atw_rxsoft *rxs = &sc->sc_rxsoft[x];
struct atw_rxdesc *rxd = &sc->sc_rxdescs[x];
struct mbuf *m = rxs->rxs_mbuf;
rxd->ar_buf1 =
htole32(rxs->rxs_dmamap->dm_segs[0].ds_addr);
rxd->ar_buf2 = /* for descriptor chaining */
htole32(ATW_CDRXADDR((sc), ATW_NEXTRX(x)));
rxd->ar_ctlrssi =
htole32(__SHIFTIN(((m->m_ext.ext_size - 1) & ~0x3U),
ATW_RXCTL_RBS1_MASK) |
0 /* ATW_RXCTL_RCH */ |
(x == (ATW_NRXDESC - 1) ? ATW_RXCTL_RER : 0));
rxd->ar_stat = htole32(ATW_RXSTAT_OWN);
ATW_CDRXSYNC((sc), x, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
}
/* country codes from ADM8211 SROM */
#define ATW_COUNTRY_FCC 0 /* USA 1-11 */