Commit Graph

126 Commits

Author SHA1 Message Date
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
christos
1665d5e960 fix spelling of accommodate; from Zapher. 2006-11-24 19:46:58 +00:00
christos
168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
dyoung
075fd7d1e9 Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion.  This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.
2006-11-13 03:35:59 +00:00
christos
4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos
2f0f18be71 prevent empty if. 2006-10-04 15:03:25 +00:00
jmcneill
f135e0d607 Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
2006-09-24 03:53:07 +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
christos
35ca6c8b5b Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!
2006-08-17 17:11:27 +00:00
dyoung
3bda9d9f8c In atw_start, do not initialize lasttx with -1, but initialize it
with the next free transmit descriptor.  Now, it is more obvious
that lasttx is not an illegal negative index into the descriptor
ring.  Remove a superfluous assertion.

Addresses Coverity CID 1319.
2006-04-06 06:08:26 +00:00
dyoung
660587743a Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.
2006-04-06 05:47:23 +00:00
dyoung
b307a01ecd Revamp ieee80211_get_rate. Now it does not use the rateset in the
ic->ic_bss, but it uses the rateset in its new ieee80211_node
argument, instead.  If the rate is fixed by ic->ic_fixed_rate, but
the fixed rate is not in the node's rateset, choose a reasonable
default: prefer the lowest basic rate or, if there is no basic
rate, prefer the lowest rate, period.

Change a printf complaint to a debug message.

Adapt drivers to suit new ieee80211_get_rate calling convention.

XXX I really need to replace ieee80211_get_rate with a bitrate
XXX adaptation algorithm.  Soon, soon....
2006-03-28 00:48:10 +00:00
dyoung
c205496a96 Note in radiotap header file and manual page that radiotap fields
are little-endian.  Fix wi(4) and atw(4) to reflect this fact.
2006-03-12 03:22:02 +00:00
lukem
a1f606d3fd Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
2006-03-08 23:46:22 +00:00
dyoung
cafe884d2c Change macro names to avoid collisions:
BIT -> __BIT
BITS -> __BITS
2006-03-08 08:26:50 +00:00
dyoung
ce412dc403 Straggler from previous commit: rename macro LSHIFT->SHIFTIN. 2006-03-08 00:26:43 +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
thorpej
3ddf26777f Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
2006-02-20 16:50:36 +00:00
dyoung
e1a75e8134 ADM8211 hardware WEP is not working (probably due to a bug in 802.11
Duration / PLCP Length calculation), so temporarily switch to
software WEP, which is working.
2006-02-19 08:02:46 +00:00
dyoung
e315c6b227 When atw_enable is called, power may have been removed and re-applied,
so invalidate the WEP SRAM to force us to write the keys back to
the hardware.
2006-02-18 22:12:01 +00:00
dyoung
f66ad201c4 Fix serious regression in AP-client mode: program adapter's BSSID
as we enter the IEEE80211_S_AUTH and IEEE80211_S_ASSOC states, so
that we don't send 802.11 Authentication and Association frames
with BSSID=00:00:00:00:00:00.
2006-02-18 22:07:11 +00:00
dyoung
a44e108963 Remove declaration of deleted subroutine, atw_change_ibss(). 2005-12-29 22:20:03 +00:00
dyoung
8f13266467 Extract subroutine is_running().
If ieee80211_ioctl() returns ERESTART, reinitialize interface with
atw_init().

Don't discard the error returned by atw_init() in atw_media_change().
2005-12-29 22:04:21 +00:00
dyoung
bca4a72a2a atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.
2005-12-29 22:01:43 +00:00
dyoung
17fde28ad0 Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.
2005-12-29 21:59:07 +00:00
dyoung
512b9ec012 Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.
2005-12-29 21:51:43 +00:00
dyoung
38c346abf0 A couple changes to the hardware reset:
Wait for the SWR bit in ATW_PAR to turn to 0, instead of waiting
for the whole register to turn to 0.

For ease of comparison with a reference driver, re-order operations.
2005-12-29 21:49:59 +00:00
dyoung
67f05eef6b Cosmetic: make a three-step staircase out of a four-step staircase. 2005-12-29 21:45:56 +00:00
dyoung
0a56b050db Revamp state machine:
1 Only stop beacon generation on an ->INIT transition.

        2 Merge AUTH and ASSOC cases, they do the same thing (tune
          a new channel).

        3 Start beacon generation in IBSS, AP, *and* "adhoc demo"
          mode.

Cosmetic tweak: rewrap a statement.
2005-12-29 21:44:33 +00:00
dyoung
3c1ba11dc5 Adapt atw(4) to the new IBSS merge idiom, where ieee80211_ibss_merge()
does not return ENETRESET to indicate the station should adopt a
new BSSID, but it triggers a RUN->RUN transition, instead.
2005-12-29 21:40:41 +00:00
dyoung
271d64132c Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.
2005-12-29 21:37:27 +00:00
dyoung
4875b8dbae Use the fragmentation threshold in the ieee80211com.
XXX Need to condition on frame type = data.
2005-12-29 21:34:53 +00:00
dyoung
2e64aa7e41 In atw_init(), always call atw_write_wep() to write the WEP state
to the h/w.  This prevents a spurious call to atw_write_wep() later,
in IEEE80211_S_RUN state, when net80211 times-out ieee80211_nodes.
It is important to avoid a spurious atw_write_wep() call because
in IBSS mode, at least, WEP re-initialization reliably locks up
the transmitter.

XXX There must be a bug in atw_write_wep() that causes it to lock
XXX up the transmitter.  I will revisit it later.
2005-12-29 21:32:06 +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
perry
93124077ae Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 20:27:29 +00:00
dyoung
5e4572a5a8 Misc. bug fixes:
1 Reset both IFF_OACTIVE and the transmit watchdog timer in
  appropriate places to avoid both wedging the transmit section
  and spurious transmit timeouts.

2 Reset IFF_ALLMULTI at the top of atw_filter_setup so that the
  NIC will filter the multicast packets we are not interested in
  after we come out of promiscuous mode.

3 In atw_txdrain, count drained transmit descriptors to avoid
  descriptor exhaustion.
2005-11-23 01:11:23 +00:00
skrll
302689559d Adapt drivers to the new net80211(9).
Most of this is from dyoung@. Thanks!
2005-11-18 16:53:56 +00:00
dyoung
86283b24c9 Don't write WEP keys to the chip unless it is enabled.
Suspend and restart the transmit/receive engines while writing WEP
keys.
2005-07-07 00:12:22 +00:00
dyoung
83a9bf2c5c Historically, an(4), ath(4), atw(4), rtw(4), and wi(4) have printed
out their modes and rates at boot.  Revert to the historical
behavior.
2005-07-06 23:58:14 +00:00
dyoung
7bcee8c697 Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.
2005-06-26 04:37:25 +00:00
dyoung
133d421bca Cosmetic: join lines. 2005-06-25 03:41:50 +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
perry
f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
thorpej
67568419ee Eliminate use of M_HASFCS. 2005-01-31 03:04:25 +00:00
dyoung
5dc6377838 IBSS-merge clean-up, inspired by some Linux patches from Jon Anderson
(mail@janderson.ca): remove ieee80211_ibss_merge's TSFT argument.
Do the TSFT comparison in the drivers (ath, atw).  Remove a lot of
extraneous debug statements from ieee80211_ibss_merge.

Set the ieee80211_node's state to IEEE80211_STA_BSS after it's been
copied to the ic_bss, not before.

In struct ieee80211_node, make the ni_tstamp field a union of a
uint64_t and the 8 TSF octets so that it's easier to compare a
neighbor's TSF with the local TSF.

Log IBSS merges (Greg Troxel's suggestion).  Also log IBSS creation.
These are rare and important events that deserve to be logged.
2005-01-04 00:56:51 +00:00
mycroft
06e4fe7f62 Replace d_plcp_svc with d_residue. The latter is the number of whole
empty/unused octets to fill out the data time slot.  The value is constrained
by math to 0 for <= 5.5Mb, 0-1 for 11Mb, and 0-2 for 22Mb.  It is used to
signal to the MAC that there is residue.
2004-12-27 01:51:49 +00:00
thorpej
e9818f5b5e When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
2004-10-30 18:08:34 +00:00
dyoung
8abb07d1ac Make the node table into an LRU cache: least-recently used nodes
are at the end of the node queue.  Change the reference-counting
discipline: ni->ni_refcnt indicates how many times net80211 has
granted ni to the driver.  Every node in the table with ni_refcnt=0
is eligible to be garbage-collected.  The mere presence of a node
in the table does not any longer indicate its auth/assoc state;
nodes have a ni_state variable, now.  A sysctl,
net.link.ieee80211.maxnodecache, controls the maximum LRU cache
size.

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match."  This keeps
net80211 from caching duplicate nodes in the table.
2004-08-10 00:57:20 +00:00
dyoung
6f9ff5e059 Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks.  Change the reference IBSS-merge implementation in atw
to match.
2004-07-28 08:12:49 +00:00
dyoung
24fb56e3b4 Cancel scan callout when the device detaches. Pointed out by Todd
Miller.
2004-07-27 23:57:02 +00:00