History log of /netbsd-current/sys/dev/pci/if_wpi.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.92 05-Dec-2021 msaitoh

s/persistant/persistent/ in comment.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.91 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
# 1.90 05-Feb-2021 christos

branches: 1.90.4;
PR/55975: Riccardo Mottola: Don't try to lock a mutex from an interrupt context.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.89 20-Mar-2020 sevan

branches: 1.89.4;
Apply the same change as for if_iwi.c r1.114 here.

This driver sleeps during wpi_media_change(), and thus requires an adaptive
mutex for the media lock.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.88 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


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

branches: 1.87.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
# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.91 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
# 1.90 05-Feb-2021 christos

PR/55975: Riccardo Mottola: Don't try to lock a mutex from an interrupt context.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.89 20-Mar-2020 sevan

branches: 1.89.4;
Apply the same change as for if_iwi.c r1.114 here.

This driver sleeps during wpi_media_change(), and thus requires an adaptive
mutex for the media lock.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.88 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


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

branches: 1.87.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
# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.90 05-Feb-2021 christos

PR/55975: Riccardo Mottola: Don't try to lock a mutex from an interrupt context.


Revision tags: thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.89 20-Mar-2020 sevan

Apply the same change as for if_iwi.c r1.114 here.

This driver sleeps during wpi_media_change(), and thus requires an adaptive
mutex for the media lock.


Revision tags: is-mlppp-base ad-namecache-base3
# 1.88 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


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

branches: 1.87.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-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.89 20-Mar-2020 sevan

Apply the same change as for if_iwi.c r1.114 here.

This driver sleeps during wpi_media_change(), and thus requires an adaptive
mutex for the media lock.


Revision tags: ad-namecache-base3
# 1.88 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


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

branches: 1.87.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-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base
# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.88 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.87 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
# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.87 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
# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.86 24-Jun-2019 jakllsch

Put back correct recieve ring allocation size which was lost just over
five years ago mae culpa.

Found by msaitoh@

Should fix PR kern/54320 once pulled up.


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 26-Jun-2018 msaitoh

branches: 1.80.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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.85 22-Dec-2018 maxv

Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.


# 1.84 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.83 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: jdolecek-ncqfixes-base
# 1.82 20-Aug-2018 riastradh

Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.


# 1.81 20-Aug-2018 riastradh

What we have created, we must destroy.


Revision tags: pgoyette-compat-0728 phil-wifi-base
# 1.80 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 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.79 23-Oct-2017 msaitoh

branches: 1.79.2;
If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

branches: 1.78.2;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.79 23-Oct-2017 msaitoh

If if_initialize() failed in the attach function, free resources and return.


Revision tags: matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.78 23-May-2017 ozaki-r

Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.78 23-May-2017 ozaki-r

Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: 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.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

branches: 1.75.2;
Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


Revision tags: nick-nhusb-base-20170204
# 1.77 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


# 1.76 02-Feb-2017 jakllsch

wpi(4): use MSI if available.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.75 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 10-Jun-2016 ozaki-r

branches: 1.74.2;
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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.


# 1.75 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.74 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.73 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.72 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.71 09-Jan-2015 bouyer

Take sc_rsw_mtx before calling wpi_getrfkill() from wpi_init(),
Problem reported and patch tested by chris at chriswareham.net


# 1.70 06-Jan-2015 bouyer

As proposed on tech-net@, introduce a new switch type, PSWITCH_TYPE_RADIO,
to be used to report to userland hardware radio switch changes.
powerd(8) will call a "radio_button" script to handle the event.
This script can e.g. start or stop wpa_supplicant.
Update wpi(4) to report PSWITCH_TYPE_RADIO events to sysmon.


# 1.69 19-Dec-2014 bouyer

Consistently take the interface down when the radio swicth is off.


Revision tags: nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.68 08-Aug-2014 jmcneill

branches: 1.68.2; 1.68.4;
wpi_fix_channel hack no longer needed with recent scanning changes


# 1.67 07-Aug-2014 jmcneill

Scan one channel at a time instead of trying to do them all at once and
trying to outsmart the ieee80211 state machine.


# 1.66 07-Aug-2014 jmcneill

scanning fixes


# 1.65 07-Aug-2014 jmcneill

simplify wpi_rx_intr rbuf handling and add some more bus_dmamap_sync; fixes stalls when downloading large files for me


# 1.64 05-Aug-2014 jmcneill

bus_dmamap_sync for rx descriptors too, derived from openbsd driver


# 1.63 05-Aug-2014 jmcneill

Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.


# 1.62 05-Jul-2014 jakllsch

Use M_ZERO. From OpenBSD if_wpi.c 1.53.


# 1.61 05-Jul-2014 jakllsch

Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.


# 1.60 02-Jul-2014 jakllsch

No need to duplicate the members of the wpi_cmd_data structure within
the wpi_scan_hdr structure when we can just put the wpi_cmd_data
structure within the wpi_scan_hdr structure.

This also brings our if_wpireg.h mostly in line with OpenBSD's 1.18.


# 1.59 16-Jun-2014 jakllsch

wpi(4): mostly cosmetic changes to source, also a little bit of diff
reduction relative to OpenBSD as of late 2007.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base
# 1.58 29-Mar-2014 christos

branches: 1.58.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.57 25-Feb-2014 pooka

Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.56 30-Mar-2013 christos

branches: 1.56.4;
replace function with macro


# 1.55 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.54 25-Nov-2012 riastradh

Rework firmware reference counting and error messages in wpi(4).

. Clarify the shared firmware abstraction in wpi_cached_firmware
and its new sibling wpi_release_firmware.
. Fix typo in wpa_cache_firmware error branch leading to free NULL.
. Fix leak in wpi_load_firmware error branch.
. Sprinkle some kasserts to executably document invariants.
. A little KNF here and there.

Based on a patch from dh in PR kern/44144.


Revision tags: yamt-pagecache-base6
# 1.53 04-Aug-2012 riastradh

branches: 1.53.2;
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.


# 1.52 02-Jun-2012 dsl

Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.51 12-May-2012 khorben

No longer wrongly advertise ad-hoc (IBSS) mode as being supported.

Fixes kern/46101

No objection from current-users@


Revision tags: 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-base2 netbsd-6-base
# 1.50 30-Jan-2012 drochner

branches: 1.50.2;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.


Revision tags: jmcneill-usbmp-pre-base2 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.49 02-Apr-2011 mbalmer

branches: 1.49.4; 1.49.8;
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.48 15-Nov-2010 uebayasi

branches: 1.48.2;
tsleep needs sys/proc.h.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.47 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.46 24-Feb-2010 dyoung

branches: 1.46.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.45 19-Jan-2010 pooka

branches: 1.45.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.44 08-Jan-2010 dyoung

Expand PMF_FN_* macros.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.43 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 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.42 06-May-2009 cegger

struct cfdata * -> cfdata_t, no functional changes intended.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base nick-hppapmap-base haad-dm-base mjf-devfs2-base
# 1.41 12-Nov-2008 joerg

branches: 1.41.4;
Cache wpi firmware in memory, free it only on invalid content or when
the last user is detached. This stops wpi from accessing the disk on
resume.


# 1.40 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-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.39 02-Jul-2008 cube

branches: 1.39.2; 1.39.4; 1.39.6;
Protect private mbuf external data storage allocater with a mutex, as it
was done in nfe(4), sk(4) and msk(4). And maybe some others.
Confirmed to fix the usual issue of data corruption by Jared McNeill.


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.38 28-Apr-2008 drochner

branches: 1.38.2; 1.38.4;
fix error handling after m_pullup()


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.37 11-Mar-2008 dyoung

branches: 1.37.2; 1.37.4;
pci_disable_retry() is now a no-op, so don't call it any more.


# 1.36 29-Feb-2008 dyoung

Use PMF_FN_ARGS, PMF_FN_PROTO.


Revision tags: nick-net80211-sync-base bouyer-xeni386-nbase bouyer-xeni386-base mjf-devfs-base hpcarm-cleanup-base
# 1.35 19-Jan-2008 simonb

branches: 1.35.2; 1.35.6;
Use M_80211_NODE as malloc type for a 80211 node as rest of net80211
code does, instead of M_DEVBUF. Fixes panics if KMEMSTATS are enabled.
Also use M_ZERO instead of memset on malloc()'s results.


# 1.34 09-Jan-2008 degroote

Add some sysctl to retrieve the radio state (and the debug level).

While here, fixe the return value in case where radio is off (suggested by
joerg@).


Revision tags: vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 matt-armv6-base
# 1.33 09-Dec-2007 jmcneill

branches: 1.33.2;
Merge jmcneill-pm branch.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 vmlocking-nbase jmcneill-pm-base reinoud-bufcleanup-base
# 1.32 01-Dec-2007 jmcneill

branches: 1.32.2; 1.32.4;
Prefix the regulatory domain and address output with the device name.


# 1.31 28-Nov-2007 degroote

In wpi_init, check for the status of radio switch and print a useful message
in this case.


# 1.30 23-Nov-2007 plunky

when using CFATTACH_DECL_NEW(), we must remember to record the
device_t if we wish to use it.

sc->sc_dev = self;


# 1.29 23-Nov-2007 joerg

If memory for the firmware image couldn't be allocated, print only
one error message.


Revision tags: bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.28 16-Nov-2007 degroote

Use device_t instead of struct device* and use associated functions
Use callout_setfunc and callout_scheduler instead of callout_reset

No functionnal change expected


# 1.27 07-Nov-2007 ad

Merge from vmlocking:

- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.


Revision tags: jmcneill-base
# 1.26 21-Oct-2007 degroote

branches: 1.26.2;
802.11 header may have different sizes. Deals correctly with this.


# 1.25 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.24 02-Sep-2007 degroote

branches: 1.24.4;
The service queue isn't used anymore so don't allocate it.
It saves a bit of memory and reduces diff with other BSD.


# 1.23 02-Sep-2007 degroote

Fix scanning code for wpi based on the iwi code.

Keep track of the status of the scan.
On a transition IEEE80211_S_SCAN -> IEEE80211_S_SCAN, don't stop the previous
scan, finish the current scan.
When we receive some frames in the IEEE80211_S_SCAN state, set current_channel
based on the value advertised in beacons or probre reponse.

Moreover, it fixes WPA issues for me.


# 1.22 01-Sep-2007 dyoung

Instead of IF_POLL()'ing and IF_DEQUEUE()'ing, just IF_DEQUEUE().


# 1.21 01-Sep-2007 dyoung

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.


# 1.20 26-Aug-2007 dyoung

branches: 1.20.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


# 1.19 15-Aug-2007 degroote

Fix possible "packet corruption" which appears on high load


Revision tags: matt-mips64-base
# 1.18 04-Aug-2007 degroote

branches: 1.18.2;
Call wpi_stop at the beginning of wpi_init so we are sure that wpi is really
stopped (in particular interrupt are disabled).


# 1.17 18-Jul-2007 degroote

branches: 1.17.4;
change firmware loading code to adopt the new 2.14.4 firmware layout (from
OpenBSD).

While here, remove some dead code I added when I ported the code from OpenBSD.


IMPORTANT : You must download the 2.14.4 firmware or update your
sysutils/wpi-firmware2 to the last revision (2.14.4) or the driver will stop
working.


Revision tags: nick-csl-alignment-base
# 1.16 11-Jul-2007 degroote

branches: 1.16.2;
Fix more build issues on amd64 (exposed by WPI_DEBUG)


Revision tags: mjf-ufs-trans-base
# 1.15 11-Jul-2007 xtraeme

Use %zu to print a size_t, fixes the build on amd64.


# 1.14 09-Jul-2007 ad

Merge some of the less invasive changes from the vmlocking branch:

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


# 1.13 09-Jul-2007 degroote

Fix some conflicts in my previous commit.
Sorry for the bad commit

Thanks to dogcow@ for the report.


# 1.12 09-Jul-2007 degroote

Sync the driver with the OpenBSD one

1/ Update the driver to use the new firmware images from Intel (2.14.3.)
2/ Read the list of supported channels from the EEPROM instead of having
it hard-coded in the driver.
3/ Limit output power to what is specified in EEPROM.
4/ Decrease output power for highest OFDM rates to reduce distortion.
5/ Automatically adjust output power to temperature changes for increased
throughput and range.
6/ Attach the adapter's onboard thermal sensor to the sensor framework.
7/ Replace 'magic' fields in structures with their correct definitions.
8/ Rewrite the firmware load in order to reduce the diff with OpenBSD one

NOTE2: you must install sysutils/wpi-firmware2 in order to use the new
driver

NOTE2: if you are using a channel not allowed by the regulatory domain
of your adapter, you will no longer be able to associate.

Thanks a lot for his hard work to damien@OpenBSD.org


# 1.11 04-Jul-2007 pooka

wsize is size_t = unsigned and should be printed with %zu instead
of %zd. cosmetics for PR 36591 by khorben.


# 1.10 18-Jun-2007 degroote

Add a workaround in the case where we have low number of rbuf.
It seems to fix problem of frozen network with wpi.

ok by @joerg.


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

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


Revision tags: ad-audiomp-base post-newlock2-merge newlock2-nbase newlock2-base
# 1.8 25-Jan-2007 njoly

branches: 1.8.2;
Fix compilation on platforms where sizeof int/size_t differs.
Successfully tested on amd64.

ok by tron@


# 1.7 13-Jan-2007 degroote

Sync the wpi driver with the openbsd one. Thanks to Jean-Baptiste
Campesato for his work.
Fix PR/34463


ok dyoung@ joerg@


Revision tags: yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 netbsd-4-base
# 1.6 16-Nov-2006 christos

branches: 1.6.2; 1.6.4; 1.6.6;
__unused removal on arguments; approved by core.


# 1.5 31-Oct-2006 joerg

Move AMRR code out of wpi(4) and ural(4) into net80211 itself.
From OpenBSD.


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

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


# 1.3 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 rpaulo-netinet-merge-pcb-base yamt-pdpolicy-base8
# 1.2 13-Aug-2006 oster

branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Apply a change from damien in OpenBSD: fix a use-after-free (read)
of a mbuf in wpi_tx_intr().


# 1.1 13-Aug-2006 simonb

Add a port of the OpenBSD Intel 3945ABG wpi(4) wireless driver, by
Jean-Baptiste Campesato.

From PR kern/33778.