Commit Graph

37 Commits

Author SHA1 Message Date
dyoung 9650f1c575 Use device_suspensor_t instead of struct device_suspensor. 2010-03-14 21:25:59 +00:00
dyoung c1b390d493 A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
2010-02-24 22:37:54 +00:00
pooka 64da563d90 Forward declare struct bpf_if and use that as the type for bpf_if
instead of "void *".  Buys us oo times the type-safety for 0 times
the price.
(no functional change)
2010-01-17 19:45:06 +00:00
dyoung cd6e1fbf91 Expand PMF_FN_* macros. 2010-01-08 19:53:10 +00:00
dyoung 36fffd8d02 In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together.  Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
   #include it from <sys/pmf.h> instead of <sys/device.h> to break the
   circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
   suspend/resume call.  Start to replace instances of PMF_FN_PROTO,
   PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
   device in suspension.  More than one suspensor may hold a device
   at once.  A device stays suspended as long as at least one
   suspensor holds it.  A device resumes when the last suspensor
   releases it.

   Currently, the kernel defines three suspensors,

   3a the system-suspensor: for system suspension, initiated
      by 'sysctl -w machdep.sleep_state=3', by lid closure, by
      power-button press, et cetera,

   3b the drvctl-suspensor: for device suspension by /dev/drvctl
      ioctl, e.g., drvctl -S sip0.

   3c the system self-suspensor: for device drivers that suspend
      themselves and their children.  Several drivers for network
      interfaces put the network device to sleep while it is not
      administratively up, that is, after the kernel calls if_stop(,
      1).  The self-suspensor should not be used directly.  See
      the description of suspensor delegates, below.

   A suspensor can have one or more "delegates".  A suspensor can
   release devices that its delegates hold suspended.  Right now,
   only the system self-suspensor has delegates.  For each device
   that a self-suspending driver attaches, it creates the device's
   self-suspensor, a delegate of the system self-suspensor.

   Suspensors stop a system-wide suspend/resume cycle from waking
   devices that the operator put to sleep with drvctl before the cycle.
   They also help self-suspension to work more simply, safely, and in
   accord with expectations.

4. Add the notion of device activation level, devact_level_t,
   and a routine for checking the current activation level,
   device_activation().  Current activation levels are DEVACT_LEVEL_BUS,
   DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
   indicate that the device's bus is active, that the bus and device are
   active, and that the bus, device, and the functions of the device's
   class (network, audio) are active.

   Suspend/resume calls can be qualified with a devact_level_t.
   The power-management framework treats a devact_level_t that
   qualifies a device suspension as the device's current activation
   level; it only runs hooks to reduce the activation level from
   the presumed current level to the fully suspended state.  The
   framework treats a devact_level_t qualifying device resumption
   as the target activation level; it only runs hooks to raise the
   activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
   drivers.

6. Temporarily add an unused power-management workqueue that I will
   remove or replace, soon.
2009-09-16 16:34:49 +00:00
dyoung 9e037d8311 Experimental support for fragmentation and RTS/CTS.
Delete unused atw_voodoo and constants.

Export Tx/Rx statistics with evcnt(9).

Correct the Short Inter-Frame Space (SIFS) that we write to ADM8211's
registers; I do not recall if that corrected the SIFS that I observed
"on the air."  Use the constant IEEE80211_DUR_DS_EIFS to configure
the ADM8211's EIFS, instead of writing the same "magic" number,
0x64, that my reference driver wrote.

Do not clear OACTIVE in atw_init(), because atw_stop() cleared it
previously by calling atw_txdrain().

Use the net80211 short-preamble flag and instead of ATW_SHPREAMBLE.

Add an ADM8211 workaround from the reference driver, atw_workaround1(),
but don't compile it right now.

In at_intr(), don't stop processing the interrupt status after
restarting the receive ring, but process Tx interrupt status.  If
a packet's Tx lifetime is exceeded, reinitialize the device to get
packets moving again.  If the Tx FIFO underflows, restart the
transmitter, not the receiver!

Avoid losing synchronization with the Rx ring by replicating one
of Charles Hannum's fixes to rtw(4) here: receiving a management
packet may, as a side-effect, reset the Rx ring, so refer to the
softc's Rx ring pointer, sc_rxptr, every time through the loop in
atw_rxintr(), instead of refering to a pointer on the stack, i.

Re-synchronize DMA after reading the OWN bit on an Rx/Tx descriptor.
XXX This needs more work.

Reset sc_tx_timer as Tx descriptors are reclaimed from the device.

Shorten staircases in atw_watchdog().

Remove from softc an unused member, sc_intr_ack.
2009-09-13 22:07:34 +00:00
cegger 529e91fca1 struct device * -> device_t, no functional changes intended. 2009-05-12 14:16:35 +00:00
joerg bcdf6fccac - device/softc split 2008-07-09 20:07:19 +00:00
martin 4685680579 Move to standard TNF 2 clause license 2008-05-04 12:43:45 +00:00
dyoung 5d30fe1a78 Use device_t and accessors. Use PMF instead of legacy power
management.  Establish the shutdown hook using PMF.
2008-03-07 22:04:00 +00:00
perry b6a2ef7569 Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
2007-12-25 18:33:32 +00:00
dyoung aadb8be251 Count received frames, Rx PLCP errors, Rx FCS (CRC32) errors, and
Rx ICV errors using evcnt(9).

In promiscuous mode, and when scanning (hmm), ask the NIC for bad
packets (e.g., those that do not pass CRC32).  Pass bad packets to
radiotap listeners.  Pass packets to radiotap listeners before
stripping FCS.  Re-order operations in atw_rxintr() to accomplish
all of this without passing bad packets up to net80211.

Set radiotap channel once in atw_tune() instead of in atw_rxintr().

Fix an endianness bug: it_len is little-endian, but bpf_mtap2()'s
argument needs to be in host order.
2007-11-16 23:51:02 +00:00
dyoung fba210bf0b Use uintXX_t instead of u_intXX_t. 2007-11-16 06:06:15 +00:00
dyoung b66951c216 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.
2007-11-16 04:58:38 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
dyoung 8cd106d3d2 Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h.  Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t.  XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.
2006-08-31 19:24:37 +00:00
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