Commit Graph

21 Commits

Author SHA1 Message Date
dyoung cafe884d2c Change macro names to avoid collisions:
BIT -> __BIT
BITS -> __BITS
2006-03-08 08:26:50 +00:00
dyoung f66403a698 Move my bit-twiddling macros to libkern.h from my drivers, where
I had duplicated them.  Improve the macros' names.  Simplify their
implementation.

A brief description of each macro is below.

        BIT(n): Return a bitmask with bit m set, where the least
                significant bit is bit 0.

        BITS(m, n): Return a bitmask with bits m through n, inclusive,
                    set.  It does not matter whether m>n or m<=n.
                    The least significant bit is bit 0.

        A "bitfield" is a span of consecutive bits defined by a
        bitmask, where 1s select the bits in the bitfield.  SHIFTIN,
        SHIFTOUT, and SHIFTOUT_MASK help read and write bitfields
        from device registers.

        SHIFTIN(v, mask): Left-shift bits `v' into the bitfield
                          defined by `mask', and return them.  No
                          side-effects.

        SHIFTOUT(v, mask): Extract and return the bitfield selected
                           by `mask' from `v', right-shifting the
                           bits so that the rightmost selected bit
                           is at bit 0.  No side-effects.

        SHIFTOUT_MASK(mask): Right-shift the bits in `mask' so that
                             the rightmost non-zero bit is at bit
                             0.  This is useful for finding the
                             greatest unsigned value that a bitfield
                             can hold.  No side-effects.  Note that
                             SHIFTOUT_MASK(m) = SHIFTOUT(m, m).

Examples:

/*
 * Register definitions taken from the RFMD RF3000 manual.
 */
#define RF3000_GAINCTL          0x11            /* TX variable gain control */
#define         RF3000_GAINCTL_TXVGC_MASK       BITS(7, 2)
#define         RF3000_GAINCTL_SCRAMBLER        BIT(1)

/*
 * Shift the transmit power into the transmit-power field of the
 * gain-control register and write it to the baseband processor.
 */
atw_rf3000_write(sc, RF3000_GAINCTL,
    SHIFTIN(txpower, RF3000_GAINCTL_TXVGC_MASK));


/*
 * Register definitions taken from the ADMtek ADM8211 manual.
 *
 */
#define ATW_RXSTAT_OWN          BIT(31)         /* 1: NIC may fill descriptor */
/* ... */
#define ATW_RXSTAT_DA1          BIT(17)         /* DA bit 1, admin'd address */
#define ATW_RXSTAT_DA0          BIT(16)         /* DA bit 0, group address */
#define ATW_RXSTAT_RXDR_MASK    BITS(15,12)     /* RX data rate */
#define ATW_RXSTAT_FL_MASK      BITS(11,0)      /* RX frame length, last
                                                 * descriptor only
                                                 */

/* Extract the frame length from the Rx descriptor's
 * status field.
 */
len = SHIFTOUT(rxstat, ATW_RXSTAT_FL_MASK);
2006-03-08 00:24:06 +00:00
dyoung c64e4a2b46 Cosmetic: shift atw flags right by 4 bits. 2005-12-29 21:53:02 +00:00
dyoung 13283d6e4f In atw(4), use ieee80211_compute_duration() to compute IEEE 802.11
Duration and PLCP Length fields, and delete the abominable
atw_frame_setdurs() subroutine.

Make rtw(4) use the new ieee80211_compute_duration() calling
convention.

Add an ieee80211_key argument to ieee80211_compute_duration() and
lightly constify arguments.  Get the crypto header length from the
key argument instead of blithely assuming a WEP header.  Add some
inline documentation.  Account for data padding (IEEE80211_F_DATAPAD).
2005-12-29 21:08:26 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
dyoung 9063402978 Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD.  Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]).  Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
2005-06-22 06:14:51 +00:00
dyoung 31815c9d7a Remove from atw(4) all of the 802.11 duration #defines that I just
moved to sys/net80211/ieee80211.h.
2004-12-19 08:09:23 +00:00
dyoung ce488d2bf7 Pull the IBSS merge logic out of atw and into net80211, since ath
will eventually share it.

In the IBSS merge logic, check conditions in a different order so
that they run faster in the common case---no merge.  Fix the
rate-limiting on the debug outputs (enabled by IFF_LINK0).
2004-07-24 23:53:49 +00:00
dyoung 571aedf36b Print and store Cardbus/PCI revision number.
Begin conditioning device configuration on revision number.  Four
revisions are known:

        1.1/1.5 -> ADM8211A,
        2.0 -> ADM8211B,
        3.0 -> ADM8211C.

The B and C parts, which are not supported yet, have AP capability.
2004-07-23 07:07:55 +00:00
dyoung 72cea14142 Use the new SRAM size constants. 2004-07-23 05:06:26 +00:00
dyoung 50a1923f1d Simplify receive descriptor setup. 2004-07-15 06:13:44 +00:00
dyoung 8218b1f277 I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....
2004-07-15 06:06:53 +00:00
dyoung 4e2ccd85f7 The ADM8211C uses a different BBP type-number for RFMD parts than
the original ADM8211.
2004-06-23 08:13:29 +00:00
dyoung 5e9822c7e9 Get rid of __P. 2004-01-29 10:25:49 +00:00
dyoung a0b92c808f Add atw_pci_enable, atw_pci_disable. Fixes a panic at "ifconfig
down" that was reported by Darren Reed.
2004-01-29 10:06:19 +00:00
dyoung bd26cc12f9 Get rid of empty #if 0/#endif stanza. 2004-01-10 06:02:32 +00:00
dyoung 9270de9dc4 Updates to 802.11 radiotap. The _DB_ flags were used everywhere to
denote a signed dBm Rx power, so rename them to _DBM_ and change
the signedness.  Add new _DB_ flags for unsigned Rx power measured
from an arbitrary reference.

Try to synchronize net80211/ieee80211_radiotap.h with my tcpdump
sources (which public tcpdump has not seen, yet) and with FreeBSD.
2003-12-07 04:49:17 +00:00
dyoung 69ed3fa879 Cosmetic: add some whitespace for readability. 2003-12-07 04:19:27 +00:00
dyoung 23d8f48692 Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
2003-11-16 09:02:42 +00:00
dyoung 372fd2b92a Adapt atw(4) to the new 802.11 layer.
Simplify atw_start, atw_newstate.

Synchronize access to atw_start by bracketing the call to
ieee80211_next_scan in atw_next_scan with splnet()/splx().
2003-10-13 08:22:19 +00:00
dyoung a036b1536b Oops. Add the atw(4) sources, too. 2003-07-06 22:57:23 +00:00