History log of /netbsd-current/sys/dev/ic/atw.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.172 21-Sep-2021 christos

don't opencode kauth_cred_get()


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.171 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.170 29-Jan-2020 thorpej

branches: 1.170.10;
Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.169 10-Nov-2019 chs

branches: 1.169.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609
# 1.168 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.167 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

branches: 1.164.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.171 16-Jun-2021 riastradh

if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.170 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.169 10-Nov-2019 chs

branches: 1.169.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609
# 1.168 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.167 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

branches: 1.164.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.170 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.169 10-Nov-2019 chs

in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.


Revision tags: netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609
# 1.168 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.167 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

branches: 1.164.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.169 10-Nov-2019 chs

in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.


Revision tags: netbsd-9-base phil-wifi-20190609
# 1.168 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.167 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

branches: 1.164.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.168 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.167 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.167 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.166 23-May-2019 msaitoh

-No functional change:
- KNF
- u_int*_t -> uint*_t.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


Revision tags: isaki-audio2-base
# 1.165 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.164 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.163 01-May-2018 maya

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.162 23-Oct-2017 msaitoh

branches: 1.162.2;
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

branches: 1.161.6;
wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


# 1.162 23-Oct-2017 msaitoh

- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

branches: 1.160.2; 1.160.4;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


Revision tags: nick-nhusb-base-20170204
# 1.161 02-Feb-2017 nonaka

wlan interfaces make interrupt routine running on softint context.

see http://mail-index.netbsd.org/tech-kern/2016/12/06/msg021281.html

tested device:
* ath at pci: AR5212, AR5424
* athn at pci: AR9287
* ipw at pci: 2100BG
* iwi at pci: 2915ABG
* iwm at pci: 3165, 7260, 8260
* iwn at pci: 4945, 6235
* ral at pci: RT2560
* rtwn at pci: RTL8192CE


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.160 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529
# 1.159 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.158 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.157 26-Jan-2016 christos

PR/50692: David Binderman: Set the right wake up bits.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE nick-nhusb-base-20151226 netbsd-7-0-RELEASE nick-nhusb-base-20150921 netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.156 22-Nov-2013 riz

branches: 1.156.6;
Put back and properly mark a variable which is used iff ATW_DEBUG.


# 1.155 17-Oct-2013 christos

- remove unused variables
- move variables inside ifdef sections
- ifdef notdef unused code
- use __USE for debugging variables


# 1.154 14-Sep-2013 joerg

Don't include atw_hw_decrypted, it is not used. Keep it for
documentation purposes.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.153 02-Apr-2011 mbalmer

branches: 1.153.4; 1.153.14; 1.153.18;
Fix misplaced parenthesis. From henning.petersen@t-online.de, thanks.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.152 13-Nov-2010 uebayasi

branches: 1.152.2;
Include sys/proc.h for curproc.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.151 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9
# 1.150 24-Feb-2010 dyoung

branches: 1.150.2;
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.


Revision tags: uebayasi-xip-base
# 1.149 19-Jan-2010 pooka

branches: 1.149.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


# 1.148 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211
# 1.147 12-Nov-2009 dyoung

Simplify activation hook.


Revision tags: jym-xensuspend-nbase
# 1.146 16-Sep-2009 dyoung

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.


Revision tags: yamt-nfs-mp-base8
# 1.145 13-Sep-2009 dyoung

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.


# 1.144 05-Sep-2009 tsutsui

Invert logic around nested pmf(9) registrations for readability.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5
# 1.143 26-May-2009 dyoung

Wrap some long lines. No functional change intended.


Revision tags: yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 jym-xensuspend-base nick-hppapmap-base mjf-devfs2-base
# 1.142 16-Dec-2008 christos

branches: 1.142.2;
replace bitmask_snprintf(9) with snprintb(3)


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.141 07-Nov-2008 dyoung

*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.140 09-Jul-2008 joerg

branches: 1.140.2;
- device/softc split


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.139 30-Apr-2008 ad

branches: 1.139.2; 1.139.4; 1.139.6;
Make various bits of debug code compile again.


# 1.138 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.137 08-Apr-2008 cegger

branches: 1.137.2; 1.137.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.136 11-Mar-2008 dyoung

Prepare for PMF self-suspension: in the if_stop() methods, clear
IFF_UP and IFF_RUNNING before running the 'disable' step, instead
of after. Soon I will handle the 'disable' step by calling into
PMF, which may call if_stop(, 0). Ordinarily, that is harmless.
This change lets the if_stop() routines exit early when they find
on entry that IFF_RUNNING is not set.


# 1.135 07-Mar-2008 dyoung

Use device_t and accessors. Use PMF instead of legacy power
management. Establish the shutdown hook using PMF.


Revision tags: nick-net80211-sync-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.134 16-Nov-2007 dyoung

branches: 1.134.10; 1.134.14;
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.


# 1.133 16-Nov-2007 dyoung

Cosmetic: rename some variables and constants. Move some constants
from atw.c to atwreg.h.


# 1.132 16-Nov-2007 dyoung

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.


# 1.131 15-Nov-2007 dyoung

Use __arraycount().


Revision tags: jmcneill-base
# 1.130 19-Oct-2007 ad

branches: 1.130.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 vmlocking-base
# 1.129 29-Sep-2007 scw

branches: 1.129.2;
s/NPBFILTER/NBPFILTER/ in some #endif comments. No functional change.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base
# 1.128 01-Sep-2007 dyoung

branches: 1.128.2;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.127 09-Jul-2007 ad

branches: 1.127.2; 1.127.6; 1.127.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.126 04-Mar-2007 christos

branches: 1.126.2; 1.126.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.125 24-Nov-2006 christos

branches: 1.125.4;
fix spelling of accommodate; from Zapher.


# 1.124 16-Nov-2006 christos

__unused removal on arguments; approved by core.


# 1.123 13-Nov-2006 dyoung

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.


Revision tags: yamt-splraiseipl-base2
# 1.122 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.121 04-Oct-2006 christos

prevent empty if.


# 1.120 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.119 31-Aug-2006 dyoung

branches: 1.119.2; 1.119.4;
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.


# 1.118 17-Aug-2006 christos

Fix all the -D*DEBUG* code that it was rotting away and did not even compile.
Mostly from Arnaud Lacombe, many thanks!


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 elad-kernelauth-base simonb-timecounters-base
# 1.117 06-Apr-2006 dyoung

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.


# 1.116 06-Apr-2006 dyoung

Correct sc_bbptype, sc_rftype bounds checks. Fixes Coverity CID
1541.


Revision tags: yamt-pdpolicy-base3
# 1.115 28-Mar-2006 dyoung

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....


Revision tags: peter-altq-base yamt-pdpolicy-base2
# 1.114 12-Mar-2006 dyoung

branches: 1.114.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.


# 1.113 08-Mar-2006 lukem

Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.


# 1.112 08-Mar-2006 dyoung

Change macro names to avoid collisions:

BIT -> __BIT
BITS -> __BITS


# 1.111 08-Mar-2006 dyoung

Straggler from previous commit: rename macro LSHIFT->SHIFTIN.


# 1.110 08-Mar-2006 dyoung

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);


Revision tags: yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.109 20-Feb-2006 thorpej

branches: 1.109.2; 1.109.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.108 19-Feb-2006 dyoung

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.


# 1.107 18-Feb-2006 dyoung

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.


# 1.106 18-Feb-2006 dyoung

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.


# 1.105 29-Dec-2005 dyoung

branches: 1.105.2; 1.105.4; 1.105.6;
Remove declaration of deleted subroutine, atw_change_ibss().


# 1.104 29-Dec-2005 dyoung

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().


# 1.103 29-Dec-2005 dyoung

atw_start() need not update IFF_OACTIVE if it hasn't put a new
packet on the transmit ring, so don't do that.


# 1.102 29-Dec-2005 dyoung

Assert consistency of IFF_OACTIVE / out of sw/hw transmit descriptors
state.


# 1.101 29-Dec-2005 dyoung

Always tickle the Receive Demand Register (ATW_RDR) after re-enabling
the receiver.


# 1.100 29-Dec-2005 dyoung

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.


# 1.99 29-Dec-2005 dyoung

Cosmetic: make a three-step staircase out of a four-step staircase.


# 1.98 29-Dec-2005 dyoung

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.


# 1.97 29-Dec-2005 dyoung

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.


# 1.96 29-Dec-2005 dyoung

Delete atw_media_status(). Let SIOCGIFMEDIA call ieee80211_media_status()
directly for media status.


# 1.95 29-Dec-2005 dyoung

Use the fragmentation threshold in the ieee80211com.

XXX Need to condition on frame type = data.


# 1.94 29-Dec-2005 dyoung

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.


# 1.93 29-Dec-2005 dyoung

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).


# 1.92 24-Dec-2005 perry

Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.91 23-Nov-2005 dyoung

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.


Revision tags: yamt-readahead-base2
# 1.90 18-Nov-2005 skrll

Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!


Revision tags: yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.89 07-Jul-2005 dyoung

branches: 1.89.6;
Don't write WEP keys to the chip unless it is enabled.

Suspend and restart the transmit/receive engines while writing WEP
keys.


# 1.88 06-Jul-2005 dyoung

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.


# 1.87 26-Jun-2005 dyoung

branches: 1.87.2;
Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.


# 1.86 25-Jun-2005 dyoung

Cosmetic: join lines.


# 1.85 22-Jun-2005 dyoung

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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.84 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.83 31-Jan-2005 thorpej

Eliminate use of M_HASFCS.


Revision tags: yamt-km-base kent-audio1-beforemerge
# 1.82 04-Jan-2005 dyoung

branches: 1.82.2; 1.82.4;
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.


# 1.81 27-Dec-2004 mycroft

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.


Revision tags: kent-audio1-base
# 1.80 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.79 10-Aug-2004 dyoung

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.


# 1.78 28-Jul-2004 dyoung

branches: 1.78.2;
Vastly simplify ieee80211_ibss_merge, eliminating the needless
callbacks. Change the reference IBSS-merge implementation in atw
to match.


# 1.77 27-Jul-2004 dyoung

Cancel scan callout when the device detaches. Pointed out by Todd
Miller.


# 1.76 24-Jul-2004 dyoung

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).


# 1.75 24-Jul-2004 dyoung

Doh, we really do need to set bit ATW_NAR_MM in ATW_NAR, or else
no multicast packets are let through.


# 1.74 24-Jul-2004 dyoung

Add atw_nar_init, atw_next_scan prototypes (thanks Todd Miller)
and sort prototypes.

In-line atw_tsft.


# 1.73 23-Jul-2004 mycroft

Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com.
* Implement the locking macros that are used under FreeBSD and Linux.


# 1.72 23-Jul-2004 mycroft

Fix mismerge.


# 1.71 23-Jul-2004 mycroft

IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY


# 1.70 23-Jul-2004 dyoung

Instrument atw(4) delays so that I can experiment and shorten the
conservative delays that I derived from the reference driver.


# 1.69 23-Jul-2004 dyoung

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.


# 1.68 23-Jul-2004 dyoung

Fix IBSS merges in atw(4).


# 1.67 23-Jul-2004 dyoung

Use the new SRAM size constants.


# 1.66 16-Jul-2004 dyoung

The RSSI field in the Rx descriptor is the unadulterated content
of the DIVCTL/RSSI register on the RF3000 baseband. Mask all but
the RSSI bits.


# 1.65 15-Jul-2004 dyoung

Insist that callers use atw_write_sram to copy even-length buffers
to even offsets in the ADM8211 SRAM.

assert->KASSERT


# 1.64 15-Jul-2004 dyoung

Totally revamp device initialization using clue from the reference
driver. I also have re-organized the code a lot.


# 1.63 15-Jul-2004 dyoung

Totally revamp device resets using clue from the reference driver.


# 1.62 15-Jul-2004 dyoung

Make atw_read_srom static.


# 1.61 15-Jul-2004 dyoung

Re-organize, add new, and remove old prototypes.


# 1.60 15-Jul-2004 dyoung

Once again, stop calling the bus front-end's interrupt-acknowledgement
callback.


# 1.59 15-Jul-2004 dyoung

Totally revamp the way that I program the synthesizer and baseband.


# 1.58 15-Jul-2004 dyoung

Take the paranoia out of the code for writing baseband registers.


# 1.57 15-Jul-2004 dyoung

Simplify the Rx filter setup, following the AL981 code in tlp(4).


# 1.56 15-Jul-2004 dyoung

Countdown correctly to the Target Beacon Transmission Time.
Borrowing an idea from the reference driver, use no 64-bit arithmetic.


# 1.55 15-Jul-2004 dyoung

In atw_start_beacon, set CAP0 as well as BCNT and CAP1.


# 1.54 15-Jul-2004 dyoung

Simplify IBSS merge code.


# 1.53 15-Jul-2004 dyoung

Only write the SSID buffer to the ADM8211 SRAM up to the end of
the SSID, not up to the end of the buffer. Given the (too
conservative?) delays involved, this should save some time when we
join a new network.


# 1.52 15-Jul-2004 dyoung

Change the order in which I write the BSSID registers on the ADM8211,
to match the reference driver. This probably does not make any
functional difference.


# 1.51 15-Jul-2004 dyoung

Set up the Tx descriptor ring more safely. Fix an endianness bug.
"It's a wonder this ever worked." (Actually, it's not.)


# 1.50 15-Jul-2004 dyoung

Re-synchronize TSFT after an IBSS merge.


# 1.49 15-Jul-2004 dyoung

Delay for tens of milliseconds lot after writing the Network Access
Register. I am slavishly imitating the reference driver, here.
I will come back and lower the delays later.


# 1.48 15-Jul-2004 dyoung

In the transmit interrupt handler, do not unnecessarily synchronize
all the descriptors for a buffer chain. Just synchronize the last
one, which has the interesting stuff.

I still synchronize all the descriptors for the buffer chain if
super-verbose debugging is enabled, since the driver will print
all the descriptors for the chain.


# 1.47 15-Jul-2004 dyoung

Remove a less-than-helpful comment.


# 1.46 15-Jul-2004 dyoung

Clamp the length of a received packet, just in case the chip lies.


# 1.45 15-Jul-2004 dyoung

When super-verbose debugging is enabled, convert Rx descriptors'
endianness before printing them.


# 1.44 15-Jul-2004 dyoung

Delete some dead code.

Don't call back into the bus-specific code for resets any longer.
It does not seem to be necessary.


# 1.43 15-Jul-2004 dyoung

During scans, initialize the BSSID to ff:ff:ff:ff:ff:ff before
sending the first probe request.


# 1.42 15-Jul-2004 dyoung

Clear dead code out of atw_clear_sram.


# 1.41 15-Jul-2004 dyoung

Don't send data packets until the interface is in state RUN. This
stops ARP and IPv6 Neighbor Discovery packets from trickling out
the interface before it is time.


# 1.40 15-Jul-2004 dyoung

I'm not treating the lost beacon count specially any more. It is
kind of a dumb way to track the link condition, anyway....


# 1.39 15-Jul-2004 dyoung

Rid atw of some dead code and some test instrumentation.


# 1.38 15-Jul-2004 dyoung

In ad hoc mode, don't set the mysterious EA bit in the Network
Access Register. ADMtek's reference driver does not use it at all,
and it does not seem to make any difference whether I leave it in
or take it out.


# 1.37 23-Jun-2004 dyoung

Only drain the transmit queue if we are idling the transmit section.


# 1.36 23-Jun-2004 dyoung

After we wait for the MAC's transmit section to idle, drain the
transmit queue and cancel the watchdog timer. This ends the annoying
"atw0: transmit timeout" messages that disrupted my WiFi tonight.


# 1.35 23-Jun-2004 dyoung

Fix a commit-o: handle all cases in the switch-statement.


# 1.34 23-Jun-2004 dyoung

Don't skip the reset! atw was not getting reset at device attachment.
atw seems to work better now that it gets this right: for one thing,
the RSSI can be seen to change as I walk around the office with my
laptop.

Thanks to Todd C. Miller for pointing out my mistake.


# 1.33 23-Jun-2004 dyoung

Fix typo: change ATW_RFTYPE_RFMD and family to ATW_BBPTYPE_RFMD.

This does not make any functional difference: each manufacturer's
RF type-number is the same as its BBP type-number.


# 1.32 06-Jun-2004 dyoung

In ad hoc mode, ignore the MAC's link up/down indication, since it
does not appear to be reliable.


# 1.31 05-Jun-2004 dyoung

No need to detect and exit on short 802.11 packets, since
ieee80211_input will do that (and tap the packet).


# 1.30 31-May-2004 dyoung

It's only necessary to set do_encrypt in one place, so do that.


# 1.29 31-May-2004 dyoung

Cosmetic: fix comment typo, change bit-test style.


# 1.28 31-May-2004 dyoung

Name the shift, txpower << 2 -> LSHIFT(txpower, RF3000_GAINCTL_TXVGC_MASK).


# 1.27 31-May-2004 dyoung

Wrap a line. Remove a useless comment.


# 1.26 31-May-2004 dyoung

Describe Tx/Rx state a little better using clue from the ADM8211C/CR
datasheet.


# 1.25 31-May-2004 dyoung

Use bpf_mtap2.


Revision tags: netbsd-2-0-base
# 1.24 17-Feb-2004 dyoung

branches: 1.24.2;
Move the RF Microdevices RF3000 & Silicon Laboratories SI4126/SI4136
register sets into their own header files for re-use by future
drivers.


# 1.23 29-Jan-2004 dyoung

Get rid of __P.


# 1.22 29-Jan-2004 dyoung

Only pass 802.11 frames up if they are greater than the minimum
size or else if monitor mode is enabled.


# 1.21 29-Jan-2004 dyoung

Avoid division by zero when computing the link-lost lost-beacons
threshold.


# 1.20 29-Jan-2004 dyoung

Deal with the RSSI as an unsigned value.


# 1.19 13-Jan-2004 dyoung

NetBSD's KASSERT takes just one argument while FreeBSD's takes two,
so I have added IASSERT(cond, complaint) to the compatibility header
file and s/KASSERT/IASSERT/'d.


# 1.18 10-Jan-2004 dyoung

Rounding to the nearest multiple of 2 with roundup(constant, 2) is
easier to read than `constant + 1'.


# 1.17 10-Jan-2004 dyoung

In atw_rf3000_tune, enable I/O with the modem and RF front-end
"just in time" instead of at the top of the function.


# 1.16 10-Jan-2004 dyoung

Do not set IEEE80211_F_IBSSON in hostap mode. Treat hostap-mode
when the link condition changes by returning.

Note that hostap mode still does not work in atw, and ADMtek has
told me that the hardware will not support it, but I remain hopeful.


# 1.15 10-Jan-2004 dyoung

Report received-early interrupt with a debug printf.

Print the Serial EEPROM and the MAC address it contains when
atw_debug > 0, because atw_debug > 1 is a little too strict.


# 1.14 10-Jan-2004 dyoung

Misc. cosmetic changes.

Add a debug printf to the input path.


# 1.13 10-Jan-2004 dyoung

Use new docs provided by RFMD to give some meaning to
previously-undocumented registers and magic numbers on the RF3000
baseband.


# 1.12 16-Nov-2003 dyoung

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.


# 1.11 02-Nov-2003 dyoung

No need to check which state we're changing FROM when we deactivate
the scan callout.


# 1.10 02-Nov-2003 dyoung

Get a clue from ath(4) and move the ieee80211_new_state() calls in
atw_init to one place.


# 1.9 02-Nov-2003 dyoung

Fix thinko that breaks IBSS merges in atw(4). sc->sc_opmode !=
ic->ic_opmode!


# 1.8 02-Nov-2003 dyoung

Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.


# 1.7 25-Oct-2003 christos

make this compile again. I should really rename the FreeBSD KASSERT to
KASSERT2 or something.


# 1.6 25-Oct-2003 christos

KASSERT takes 2 arguments here.


# 1.5 25-Oct-2003 christos

Fix uninitialized variable warnings


# 1.4 16-Oct-2003 dyoung

Cosmetic change: shorten 6 lines to 2.


# 1.3 13-Oct-2003 dyoung

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().


# 1.2 20-Sep-2003 dyoung

Allow channels 1-14 in MMK2, for real. Fixes PR 22530 from
FUKAUMI Naoki.


# 1.1 06-Jul-2003 dyoung

Oops. Add the atw(4) sources, too.