Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/wi.c
RevisionDateAuthorComments
 1.258  01-Aug-2023  mrg fix simple mis-matched function prototype and definitions.

most of these are like, eg

void foo(int[2]);

with either of these

void foo(int*) { ... }
void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
 1.257  21-Sep-2021  christos don't opencode kauth_cred_get()
 1.256  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.
 1.255  30-Jan-2020  thorpej branches: 1.255.10;
Adopt <net/if_stats.h>.
 1.254  05-Dec-2019  msaitoh branches: 1.254.2;
Remove SIOC[GS]IFMEDIA because ieee80211_ioctl() does the same thing.
 1.253  28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.252  23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.251  23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.250  05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.249  15-Nov-2018  maxv Remove the 'copy' argument from m_devget(), unused. While here rename
off0->off.
 1.248  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!)
 1.247  26-Jun-2018  msaitoh branches: 1.247.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.
 1.246  23-Jun-2018  maxv constify
 1.245  22-Jun-2018  msaitoh It's not required to include net/bpfdesc.h. Remove it.
 1.244  23-Oct-2017  msaitoh branches: 1.244.2;
If if_initialize() failed in the attach function, free resources and return.
 1.243  29-Mar-2017  msaitoh branches: 1.243.6;
Fix 0x%d and 0x%u.
 1.242  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.241  01-Feb-2017  nonaka Added missing splx(s).
 1.240  10-Jun-2016  ozaki-r branches: 1.240.2; 1.240.4;
Introduce m_set_rcvif and m_reset_rcvif

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

No functional change.
 1.239  26-May-2016  ozaki-r Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.
 1.238  26-May-2016  ozaki-r Use M_GETCTX

No functional change.
 1.237  25-Feb-2014  pooka branches: 1.237.6;
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.
 1.236  15-Sep-2013  martin Mark a potentially unused variable
 1.235  15-Aug-2011  dyoung branches: 1.235.2; 1.235.12; 1.235.16;
Use a recursive lock to ensure that only on thread is in wi_ioctl() at
one time. It's a recursive lock because sometimes wi_ioctl() recurses
through the network stack (ick).
 1.234  23-Nov-2010  christos split if_wi
 1.233  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.
 1.232  19-Jan-2010  pooka branches: 1.232.2; 1.232.4;
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.231  15-Sep-2009  dyoung Simplify activation routines. Don't block interrupts, if_deactivate()
does it. Compile-tested, only.
 1.230  12-May-2009  cegger struct device * -> device_t, no functional changes intended.
 1.229  15-Apr-2009  elad Remove a few KAUTH_GENERIC_ISSUSER in favor of more descriptive
alternatives.

Discussed on tech-kern:

http://mail-index.netbsd.org/tech-kern/2009/04/11/msg004798.html

Input from ad@, christos@, dyoung@, tsutsui@.

Okay ad@.
 1.228  12-Nov-2008  ad branches: 1.228.4;
Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.227  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.
 1.226  28-Apr-2008  martin branches: 1.226.6; 1.226.8;
Remove clause 3 and 4 from TNF licenses
 1.225  08-Apr-2008  cegger branches: 1.225.2; 1.225.4;
use aprint_*_dev and device_xname
 1.224  20-Dec-2007  dyoung branches: 1.224.6;
Constify struct ifnet->if_sadl and every use throughout the tree.
Add if_set_sadl() that both sets the link-layer address length and
replaces the current link-layer address with a new one, and use it
throughout the tree.
 1.223  09-Dec-2007  jmcneill branches: 1.223.2;
Merge jmcneill-pm branch.
 1.222  19-Oct-2007  ad branches: 1.222.4; 1.222.6;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.221  01-Sep-2007  dyoung branches: 1.221.4;
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.220  09-Jul-2007  ad branches: 1.220.2; 1.220.6; 1.220.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.219  04-Mar-2007  christos branches: 1.219.2; 1.219.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.218  04-Jan-2007  elad branches: 1.218.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.217  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.216  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.215  21-Jul-2006  ad branches: 1.215.4; 1.215.6;
- Use the LWP cached credentials where sane.
- Minor cosmetic changes.
 1.214  14-May-2006  elad integrate kauth.
 1.213  12-Mar-2006  dyoung branches: 1.213.2;
Note in radiotap header file and manual page that radiotap fields
are little-endian. Fix wi(4) and atw(4) to reflect this fact.
 1.212  20-Feb-2006  thorpej branches: 1.212.2; 1.212.4;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.211  24-Dec-2005  perry branches: 1.211.2; 1.211.4; 1.211.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.210  18-Nov-2005  skrll Adapt drivers to the new net80211(9).

Most of this is from dyoung@. Thanks!
 1.209  10-Aug-2005  christos branches: 1.209.6;
Allow setting the MAC address via wiconfig -m (Lord Isildur)
 1.208  23-Jul-2005  drochner disable SYSCTL_SETUP for _LKM until we have a plan how to deal with
it correctly
 1.207  16-Jul-2005  yamt #ifdef out an unused variable in the case of !WI_DEBUG.
 1.206  15-Jul-2005  dyoung Add a sysctl for turning wi(4) debugging on and off.

Do not print the number of tx commands outstanding on entrance to
wi_cmd_intr unless wi_debug > 1.
 1.205  14-Jul-2005  dyoung Clear IEEE80211_F_DROPUNENC in ic_flags in operating states where
the NIC decryptes & decapsulates WEP frames before passing them to
the host. "Remember" the state of IEEE80211_F_DROPUNENC in
sc_ic_flags, though, and try our best to honor it as we setup the
hardware state.

This is the second patch of this kind. The previous patch was
badly broken because wi_mend_flags was basing its decision to clear
IEEE80211_F_DROPUNENC based on the operating state we were
transitioning FROM instead of the state we were transitioning TO.

This fixes a bug that Simon Burge reported, where dhclient wi0
would not get a lease unless and until you ran 'ifconfig wi0'
concurrently (which would frob the IEEE80211_F_DROPUNENC bit in
the right way). This patch was tested by Simon with his Toshiba
Lucent-clone.
 1.204  06-Jul-2005  dyoung Historically, an(4), ath(4), atw(4), rtw(4), and wi(4) have printed
out their modes and rates at boot. Revert to the historical
behavior.
 1.203  06-Jul-2005  dyoung Avoid an unnecessary API difference between NetBSD and FreeBSD:
back out my change to ieee80211_crypto_encap that made it free its
mbuf argument on error. I had thought it was a bug. It was not.
It's the drivers that are broken. Make an(4), atw(4), ipw(4),
iwi(4), ral(4), rtw(4), ural(4), and wi(4) free the mbuf when
ieee80211_crypto_encap returns NULL. Also, return ath(4) to the
way it was---i.e., free the mbuf.

Thanks to Sam Leffler to pointing out my mistake.
 1.202  06-Jul-2005  dyoung branches: 1.202.2;
Don't write the WEP keys to the device if it is invalid (e.g.,
unplugged) or if it is not enabled. Fixes kern/30592.
 1.201  26-Jun-2005  erh Make sure there is a valid transmit key, before trying to use information
about it. Fixes a crash when configuring wi0.
 1.200  26-Jun-2005  dyoung Do not build AP support if 'options IEEE80211_NO_HOSTAP' is in the
kernel configuration.
 1.199  25-Jun-2005  dyoung Bug fix: fix WEP by managing keys & crypto in the style of the new
net80211. It was especially important to zero the IEEE80211_F_DROPUNENC
(discard unencrypted packets) flag in operating modes where the
firmware decrypts for us. Otherwise, the 802.11 layer discarded
all received frames. See wi_mend_flags. From FreeBSD, with
improvements by me.

For better compliance with the "net80211 way":
set sc_cnfauthmode from ic->ic_bss->ni_authmode. Enter
the RUN state through ieee80211_create_ibss instead of
ieee80211_new_state(IEEE80211_S_RUN). To sync BSSID in ad hoc
mode, use ieee80211_sta_join() instead of
ieee80211_new_state(IEEE80211_S_RUN). From FreeBSD.

Configure the firmware to obey IEEE80211_F_DROPUNENC.

As we change to state RUN in STA mode, generate a link-status
message on the routing socket with a call to ieee80211_notify_node_join()
instead of calling rt_ifmsg directly.

Run normal net80211 processing (ieee80211_newstate) on the ->RUN
transition.
 1.198  22-Jun-2005  dyoung Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.197  27-Mar-2005  dyoung correct logic so we recognize timeout on alloc

Noticed by: Coverity Prevent analysis tool

From FreeBSD. Thanks Sam Leffler for bringing this to my attention.
 1.196  27-Feb-2005  perry nuke trailing whitespace
 1.195  13-Feb-2005  dyoung Bug fix: use the MAC that the firmware tells us, resorting to the
CIS MAC only on error.

(NetBSD these days tries to read the MAC address from the PCMCIA
CIS. Prism cards made by Senao set the MAC in every PCMCIA CIS to
00:02:6f:00:02:15. In a network of Senao cards, this causes MAC
duplication.)
 1.194  17-Jan-2005  dyoung branches: 1.194.2;
Delete an out-of-date comment.
 1.193  14-Dec-2004  dyoung branches: 1.193.2;
In wi_stop, wait for transmit commands to complete. Extract
subroutine wi_txcmd_wait from wi_cmd and wi_stop.

This stops wi from griping, "wi0: command timed out, cmd=0x10b,
arg=0x0", when we down/up the interface. Thanks to Pavel Cahyna
for reporting this bug.
 1.192  13-Dec-2004  dyoung Bug fix: synchronize Transmit commands with all other commands.

Following Charles Hannum's wi(4) optimizations, there could be a
Transmit command outstanding after wi_tx_intr or wi_start returns.
The driver would blithely issue a second command [*] before the
first command was finished, taking the first command's WI_EV_CMD
indication to mean the second command had finished. The driver
would be dreadfully confused when the second command's results did
not meet its expectations (e.g., a RID mismatch error would occur).
The packet transmit section of the code would never read the
WI_EV_CMD it expected, so transmissions would cease.

This patch counts the outstanding transmit commands (there can be
only one) and, if a transmit command is outstanding at the top of
wi_cmd(), wi_cmd waits for the command to complete. If there was
a transmit command outstanding when wi_cmd begins, it calls
wi_cmd_intr() on its way out.

I have tested this on an Orinoco card. Previously, the card would
stop transmitting or the kernel would panic as desynchronization
occurred. Now it works beautifully.

[*] A second command could be issued by wi_ioctl or else by
wi_intr->wi_info_intr->wi_newstate->wi_read_xrid->wi_read_rid.
 1.191  13-Dec-2004  dyoung In wi_tx_intr, be a little more explicit about which fields we're
reading from the Tx-Complete FID.
 1.190  13-Dec-2004  dyoung Refactor. wi_read_rid calls,

wi_read_rid(sc, rid, &val, &buflen) == 0 && buflen == sizeof(val),

become wi_read_xrid calls

wi_read_xrid(sc, rid, &val, sizeof(val)) == 0.

If the actual RID length is different from the expected RID length,
wi_read_rid prints to the log.
 1.189  26-Nov-2004  mycroft Fix what appears to be a byte order error on big-endian systems with Symbol
cards.
 1.188  30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

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

While I am here, patch ieee80211_find_node_for_beacon to do a "best
match" by bssid/ssid/channel, not a "perfect match." This keeps
net80211 from caching duplicate nodes in the table.
 1.185  07-Aug-2004  mycroft Be much more robust with RID values during attach:
* If the device returns a length too short to even contain the RID number,
flag it as not supported and return EOPNOTSUPP, rather than returning a
length of -2 and trying to use the value anyway.
* Check the returned lengths to see if we actually got anything.
* If we get no rate list, fail the attach, so we don't just blow up later.
Allow the frontend to pass in a MAC address.
 1.184  06-Aug-2004  mycroft Use bpf_mtap2().
 1.183  05-Aug-2004  mycroft Put unadulterated dB values in the radiotap header, not the converted dBm
values.
 1.182  23-Jul-2004  mycroft IEEE80211_F_WEPON -> IEEE80211_F_PRIVACY
 1.181  22-Jul-2004  mycroft Add sc_txstart and sc_txstarted, to keep track of the current FID we want to
start and the number we've started that have not been alloced yet. Currently
sc_txstarted is constained to 0 or 1 because of the way we start the next
packet, but this will change.
 1.180  22-Jul-2004  mycroft Copyright maintenance.
 1.179  22-Jul-2004  mycroft Change some DELAY(2) to more sensible values.
 1.178  22-Jul-2004  mycroft Add some histogram code (controlled by an #ifdef) to track how long various
busy-wait loops take.
 1.177  22-Jul-2004  mycroft Keep a count of packets written to the chip but not yet initiated. This
simplifies some logic, and is needed for later changes.
 1.176  22-Jul-2004  mycroft Change some names.
sc_txnext -> sc_txalloc
sc_txcur -> sc_txqueue
 1.175  22-Jul-2004  mycroft Keep a count of FIDs allocated, rather than storing a packet length in the
ring.
 1.174  22-Jul-2004  mycroft Make the radiotap header reflect the actual transmit rate.
 1.173  22-Jul-2004  mycroft Ack events in only one place. Reduces register writes sometimes.
 1.172  22-Jul-2004  mycroft Only read the part of the frame header we use in wi_tx_intr().
 1.171  22-Jul-2004  mycroft Rework the rate-lowering hack:
* Update sc_txpending[] when a packet is written, even before we issue the TX
command, since it may be active when we issue the TX command for the
following packet.
* Do not lower the rate in ni_txrate or id_rateidx, because these are used to
keep track of sc_txpending[], and could cause us to get "stuck" at the lower
rate.
 1.170  22-Jul-2004  mycroft Make the logic in wi_write_txrate() less obscure.
 1.169  22-Jul-2004  mycroft For Intersil firmware, use the ROM rate list to determine the correct bitmask
for BASIC_RATE and SUPPORT_RATE. Always set these, because otherwise probe
frames will not get the correct list.
 1.168  22-Jul-2004  mycroft Missed one change in the previous. Now we really don't try to write it.
 1.167  22-Jul-2004  mycroft Symbol firmware doesn't support the power management register, so don't try to
do power management there.
 1.166  22-Jul-2004  mycroft Whoops, change one back to regular "static" for an inline function.
 1.165  22-Jul-2004  mycroft I hate "static". Add an #ifdef so I can turn it off easily.
 1.164  02-Jul-2004  dyoung Indicate link status changes on the routing socket.
 1.163  02-Jul-2004  dyoung Cosmetic: shift a break-statement into the right column.
 1.162  02-Jul-2004  dyoung wi_start compaction: check for software descriptor exhaustion in
one place. Check for the _RUN state in one place.
 1.161  06-Jun-2004  dyoung Finally, refactor wi_media_change and ieee80211_media_change.
ieee80211_media_change handles a lot more conditions than
wi_media_change did.

This helps with the second bug mentioned in kern/25604, which causes
"SIOCSIFMEDIA: Invalid argument."
 1.160  31-May-2004  dyoung Don't set a frame's WEP bits, the 802.11 layer already has.
 1.159  26-Mar-2004  dyoung branches: 1.159.2;
Actually, disabling RSS rate-adaptation does not make any discernible
difference in locking up STA f/w 8.42.1.
 1.158  26-Mar-2004  dyoung Firmware revisions are decimal.
 1.157  25-Mar-2004  dyoung Enable Tx and TxExc interrupts. Somehow this escaped my initial
commit. The rate adaptation code expects them. Usually wi gets
lucky, and an Rx/Alloc/Info event triggers the interrupt handler,
but I had not intended for wi to count on it.

Without Tx/TxExc interrupts enabled, wi will sometimes exhaust all
its rssdescs and cease transmitting. Usually it sets IFF_OACTIVE
in that situation.
 1.156  17-Mar-2004  dyoung Prevent a buffer overflow that's been seen in the wild. The firmware
will sometimes return 0; subtracting 1 from that yields a too-big
buffer length.
 1.155  17-Mar-2004  dyoung In wi(4), wi_choose_rate used to contain device-independent code.
I have pulled that code into the function ieee80211_rssadapt_choose
so that I can re-use it in ath(4), atw(4), and in other drivers.

In rssadapt(9), I have also created a struct ieee80211_rssadapt_expavgctl
that contains parameters for rate adaptation. When IEEE80211_RSSADAPT_DEBUG
is enabled, I will using sysctl to expose an ieee80211_rssadapt_expavgctl
for each wireless device.

Also in rssadapt(9), I have introduced an interpolate() macro which
makes the exponential-averaging code more compact.
 1.154  10-Feb-2004  dyoung If the firmware returns to us an RSS descriptor index that is out
of bounds, then complain and recover by freeing all of the descriptors.
That will usually provoke additional complaints---see the next
paragraph.

If the firmware returns to us an RSS descriptor that is in-bounds
but out of service (id_node == NULL), then gripe and get out of
the interrupt handler. ***This will still leak RSS descriptors.***
I'm working on a better solution. Possibly I will just free all of
the descriptors.
 1.153  10-Feb-2004  dyoung Disable rate-adaptation for Lucent firmware version 8.42.1, per a
bug report from Simon Burge: the firmware seems to lock up.

If rate-adaptation is disabled on a Lucent card, then do all the
rate-adaptation work *except* for writing the new transmit rate,
since I suspect that is what locks-up the firmware.
 1.152  10-Feb-2004  dyoung Shorten the retry count on Prism APs to improve the speed of
rate-adaptation.
 1.151  10-Feb-2004  dyoung Factor out the initialization/reset of RSS descriptors, making
wi_rssdescs_init, wi_rssdescs_reset, which I will use to receover
when the firmware botches up the RSS descriptor index.
 1.150  10-Feb-2004  dyoung The radiotap header is little-endian.
 1.149  31-Jan-2004  dyoung wi_stop tells which stations' rssadapt descriptors it cleans up
when IFF_DEBUG is set.
 1.148  07-Dec-2003  dyoung Enable RSSI-based rate-adaptation for wi(4). This enables wi(4)-based
APs to run at "full speed" where before they ran at just 1 or 2Mb/s.
The AP will adapt the data rate for each client based on packet
losses and the received signal strength.

I have also enabled rate adaptation for STA mode and for IBSS mode,
but the hardware gives us less control over the data rate in those
modes.
 1.147  04-Dec-2003  keihan netbsd.org -> NetBSD.org

This was the last commit of this kind to src/sys, which is now totally
"NetBSD.org clean". Thanks for the patiance, and sorry for all the commits.
 1.146  16-Nov-2003  dyoung From Steve Woodford (scw@): fix wi(4) and wiconfig(8) on big-endian
machines.
 1.145  16-Nov-2003  dyoung Fix spelling/grammar in a comment.
 1.144  16-Nov-2003  dyoung Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
 1.143  02-Nov-2003  dyoung Use ieee80211_find_rxnode to attribute Rx packets to the write
ieee80211_node. This reduces code duplication. It will help us
support passive scanning and rate adaptation.
 1.142  02-Nov-2003  dyoung Mark the available channels using the ic_channels table instead of
setting bits in ic_chan_avail, which is the responsibility of
ieee80211_ifattach. I cannot believe the previous code worked.
 1.141  02-Nov-2003  dyoung Get the ieee80211_node for management packets from the rcvif field.
 1.140  02-Nov-2003  dyoung Fix bugs in power-saving:

Use a power-saving station's ieee80211_node, which is stored in
the rcvif field.

Do not free a node if it is put onto the power-saving queue.
 1.139  01-Nov-2003  dyoung Bug fix: in wi_cfg_txrate, do not divide the 802.11 rate by 2 and
take off the flags before giving it to wi_write_txrate.

Also add a useful debug message to wi_write_txrate.
 1.138  24-Oct-2003  mycroft In wi_newstate(), read the BSSID into a temporary buffer that has guaranteed
alignment. Fixes a really obscure failure mode on Alpha, and panics on other
machines.
 1.137  19-Oct-2003  dyoung Don't take the 802.11 header off of a frame until after we've given
it to the driver's BPF tap.
 1.136  17-Oct-2003  dyoung ieee80211_newstate() wants for ic->ic_state to equal the previous
state, so do not update ic->ic_state in wi_newstate() before calling
ieee80211_newstate(). Instead, update ic->ic_state when we do not
let ieee80211_newstate() run.
 1.135  16-Oct-2003  dyoung Prepare for wi rate adaptation. Add wi_write_txrate, which only
writes a hardware register when the data rate selection actually
changes. Add wi_cfg_txrate, which writes the data rate selection
regardless.

Name some fields in the wi Tx buffer which we will use for rate
adaptation.

Name the Prism "Alternate Retry Count" RID, WI_RID_ALT_RETRY_COUNT.
 1.134  16-Oct-2003  dyoung The upper & lower bounds on wi RSSI are completely bogus, AFAICT.
 1.133  13-Oct-2003  dyoung Switch wi(4) to the new 802.11 layer.
 1.132  06-Jul-2003  dyoung Still more consolidation of 802.11 media-handling, moving moving
common code from awi and wi into the 802.11 framework. Inspired by
Sam Leffler's patches to FreeBSD.
 1.131  06-Jul-2003  dyoung Improved RSSI->dBm conversion, especially for Lucent cards, for
which I borrowed some conversion constants from the Linux orinoco_cs
driver.
 1.130  19-Jun-2003  rh branches: 1.130.2;
Add and enable monitoring mode for Lucent cards.
 1.129  31-May-2003  dyoung Picky cosmetic change: remove leading space.
 1.128  22-May-2003  dyoung Update to wi interrupt handling:

No longer require a hi-low-hi transition of a status bit before
we believe it. It's a performance killer, and without it there
does not seem to be a race.

Sam Leffler reports that wi_intr needs to be bracketed by
disable/enable interrupts through WI_INT_EN, or else performance
is bad on Lucent. So now we do that.
 1.127  20-May-2003  dyoung Stop wi panics on card ejection in Powerbook in both the enabled
and disabled states. This should fix an x86 panic somebody reported
on icb.
 1.126  17-May-2003  christos Initialize and reset curtxeps to zero each time the error rate is exceeded.
This stops the continuous spewing of error messages, making it just sporadic.
 1.125  16-May-2003  dyoung IEEE80211_LOCK and WI_LOCK conceal enormous differences in locking
semantics on FreeBSD and NetBSD, so I am backing them out until
the macro set is enriched.
 1.124  13-May-2003  dyoung Revert to previous multicast logic, which enami@sm.sony.co.jp says
was correct.
 1.123  13-May-2003  dyoung Begin synchronization with FreeBSD:

1 Add channel mask, transmit rate-mask arguments to wi_scan_ap.
2 Adopt the macros WI_LOCK/WI_UNLOCK for synchronization. FreeBSD
uses a different synchronization mechanism.
3 In wi_cmd, adopt constants WI_DELAY/WI_TIMEOUT for timing.
4 Pull debug messages from into wi_read_nicid from FreeBSD.
5 Bug fix: if IFF_ALLMULTI, don't filter any multicasts.
6 Count and report TX exceptions, but don't generate any additional
interrupts.
 1.122  13-May-2003  dyoung For converge with FreeBSD:
 1.121  13-May-2003  dyoung Track TX exceptions. This will eventually enable round-robin retries
(for fairness) and RTM_LOSING or some such other message to indicate
a losing wireless destination.

From FreeBSD.
 1.120  13-May-2003  dyoung Complete prior patch: dump packets in wi_rx_intr, too.
 1.119  13-May-2003  dyoung Debug code from FreeBSD: handy packet dumps when IFF_DEBUG|IFF_LINK2
are set.
 1.118  13-May-2003  dyoung Misc changes to wi_stop. First, block interrupts in wi_stop. (From
FreeBSD.)

Fix a bug in wi_stop where ejecting from the Powerbook crashes the
system. Essentially, the patch makes sure we write *no* registers
when we are no longer attached.

Also, for consistency w/ FreeBSD, use sc_portnum throughout wi,
instead of hard-coding WI_PORT0 .
 1.117  13-May-2003  dyoung For uniformity between FreeBSD & NetBSD, adopt FreeBSD's more
concise wi_cmd.
 1.116  08-Apr-2003  kml Host AP power saving support. The Host AP notices that the power
saving bit is set in incoming frames from a station, and buffers the
outgoing frames for the station until they are polled for. This
requires support in the driver to set a bit in the TIM bitmap sent
during 802.11 beacons.

So far, support for power saving in Host AP mode is only available
for the PRISM2 chipset.
 1.115  27-Mar-2003  dyoung 802.11 MLME-JOIN.request is an abstract MAC function that is not
necessarily exposed to the host, so Lucent/Agere/whatever is correct
in not supporting it.
 1.114  27-Mar-2003  dyoung HostAP broke in version 1.4.2 of station firmware. Try 1.3.x, 1.4.9,
or later.
 1.113  27-Mar-2003  dyoung Introduced sc_reset to wi_softc. The bus-specific front-end gets
to fill this.
 1.112  25-Feb-2003  dyoung Add support for Prism monitor mode. From Kevin Lahey
<kml@patheticgeek.net>.

This patch does NOT add monitor mode support for the Lucent radios.

awi(4) was only modified for compatibility with the new mediaopt.
It does NOT support monitor mode.

Tested by Kevin, Daniel Carosone, and I.
 1.111  25-Feb-2003  dyoung Disable interrupts before ACKing them to avoid the obvious race.
 1.110  25-Feb-2003  dyoung Following implementation for other RIDs, read the driver's notion
of the fragmentation threshold instead of the hardware's notion.
 1.109  09-Jan-2003  dyoung Oops. This turns off debugging again.
 1.108  09-Jan-2003  dyoung wi_start: write an mbuf chain to the driver using wi_mwrite_bap,
which is safer than the loop there used to be here.

wi_mwrite_bap: if wi_write_bap fails, don't keep on going: this
way you avoid writing garbage to the radio. First time you see
an odd-length mbuf, copy the remainder of the chain to sc_txbuf
and from there to the MAC. This way, you do not read an mbuf past
the end of its data (occasionally you will cross a page doing
that!) and you avoid expensive, excess seeks in the radio's own
buffer chain.

wi_rx_intr: clamp the frame length told to us by the driver to the
most bytes we can fit in our mbuf cluster.

I am still getting e-mails from my testers telling me how much
better this makes things.
 1.107  01-Jan-2003  dyoung A Prism firmware participating in an IBSS network will not send a
LINK_STAT notification for every change of BSSID, so the firmware's
BSSID and the driver's BSSID will get out of sync. This has two
bad affects. First, because the 802.11 framework filters received
packets based on BSSID, many packets can be dropped before the
driver adopts the firmware's BSSID. Second, ifconfig's tells a
misleading BSSID to the operator.

This problem is most apparent in networks where every station does
not hear every other. I reproduce these conditions in an office by
removing/replacing the antennas on my 802.11 cards.

As a solution, in IBSS mode, the driver will ask the firmware for
the BSSID every five seconds. Also, whenever the driver receives
a frame carrying a different BSSID than the driver's BSSID, then
the driver asks the firmware for the BSSID before handing the frame
to ieee80211_input.
 1.106  27-Dec-2002  dyoung On Lucent cards, indicate that changing BSSID with SIOCS80211BSSID
is impossible. Never write to the Prism-only JOIN RID.
 1.105  27-Dec-2002  dyoung The RID for the RSSI->dBm adjustment is not supported by Prism
station firmware version <= 1.1.1.
 1.104  18-Nov-2002  dyoung Only Prism is known to support WI_RID_FRAG_THRESH.
 1.103  16-Nov-2002  dyoung In wi_get_cfg, factor the code for getting the tx rate with the
IEEE 802.11 subsystem.

In wi_write_txrate, document the clever code for computing
WI_RID_TX_RATE from a bit rate.
 1.102  16-Nov-2002  dyoung Support two new RIDs.

WI_RID_DBM_ADJUST: In preparation for capturing Prism packets
containing received signal strength indications (RSSI), read the
constant for conversion from RSSI to dBm (decibels relative to
a milliwatt).

WI_RID_FRAG_THRESH: Get/set the packet fragmentation threshold
on Lucent/Prism.
 1.101  25-Oct-2002  mycroft IBSS mode does in fact work on some earlier Symbol firmware versions, as
witnessed by my home network.
 1.100  15-Oct-2002  onoe Fix to use 104bit key for Intersil/Symbol firmware:
It seems that the firmware accept 104bit key only if
all the keys have 104bit length. We get the length of
the transmit key and use it for all other keys.
Perhaps we should use software WEP for such situation.
 1.99  07-Oct-2002  onoe Update BSSID at every CONNECTED LINK_STAT notification in IBSS mode,
since it can be updated by IBSS merge. Also the lucent firmware 8.10.1
changes random generated bssid every 10 seconds in IBSS creation enable.
PR 18520
 1.98  04-Oct-2002  onoe Handle of AP_IN_RANGE/AP_OUT_RANGE, to fix a problem once the station
is out of ragen, it never comes up again.
For HostAP, prohibit sending DATA frame to an unassociated but authenticated
station.
 1.97  03-Oct-2002  onoe Set IEEE80211_F_IBSSON before test in wi_init() to set CREATE_IBSS
correctly for Lucent firmware to work with IBSS mode.
PR 18520
 1.96  02-Oct-2002  onoe Fix NIC-memory leak for symbol firmware at reinitialization. After 4-5
times changing of 802.11 parameters, such as nwid, the error
"tx buffer allocation failed" occured unless ifconfig down up.

Pass signal streangth and timestamp to ieee80211_input, though it is not
useful for wi driver for now.
 1.95  01-Oct-2002  onoe Do not call wi_stop() with disabled flag set from wi_init(), since it
sometimes call within interrupt and deleting handler causes panic.
Fix to display current tx rate as media.
Clear trailer bytes in ssid fields.
 1.94  01-Oct-2002  onoe Linkstatus AP_IN_RANGE doesn't mean associatted, rather it just mean trying
to associate.
 1.93  01-Oct-2002  onoe Allow SIOCSIFADDR with AF_LINK and WI_RID_MAC_NODE (wiconfig -m)
to set MAC address.
 1.92  01-Oct-2002  onoe initialize sc_txcur and sc_txnext at wi_init to avoid reordering after
reinitialized.
 1.91  30-Sep-2002  onoe old lucent adhoc-demo mode (adhoc,flag0 or wiconfig -p 3) wasn't handled
correctly. To avoid massive extra code in each driver, now if_iee80211subr.c
also handles non-standard old lucent adhoc-demo mode.
This also fixes PR 14227.
 1.90  30-Sep-2002  onoe Jumbo commit for wi driver.
- Eliminate wi_hostap.c since most of the code are duplicated with
net/if_ieee80211subr.c
- Station for Infrastructure network and IBSS also use service functions
as much as possible to be consistent with other wireless drivers.
Now WEP works for station/ibss/hostap.
 1.89  30-Sep-2002  onoe Nuke unneeded member sc_ifp and use #define sc_if instead,
to prepare jumbo commit for wi.c
 1.88  27-Sep-2002  thorpej Increase the timeout in wi_cmd(). Fixes reports of "busy didn't
clear". From David Young <dyoung@ojctech.com>.
 1.87  26-Sep-2002  martin If we wi_stop the card in wi_shutdown, better do that before the frontend
removes power from the pcmcia slot (inside the sc_disable hook).
 1.86  26-Sep-2002  martin Set error = 0 (instead of EINVAL) when it is later tested against != 0.
This allows using wiconfig while the interface is not (yet) marked IFF_UP
again.
 1.85  26-Sep-2002  martin In wi_shutdown only call wi_stop if sc_enabled is set (don't try to send
commands to a card that is not powered up - it will always fail)
 1.84  23-Sep-2002  thorpej Jumbo patch, from David Young <dyoung@ojctech.com>, with small tweaks
by me:
* Speed up reading/writing buffers from the hardware by avoiding
slow forward seeks. In preparation to use the optimization, do
not read overlapping bytes. This is currently disabled, but can
be enabled with OPTIMIZE_RW_DATA.
* Hand 802.11 and Prism-specific frames to BPF. User can watch these
frames by specifying an alternate DLT to e.g. tcpdump(8).
* Add support for SIOC[SG]80211BSSID and SIOC[SG]80211CHANNEL.
* Issue join requests and track join/create state through link-status
notifications.
* Split wi_rxeof into separate routines for receiving Ethernet II,
802.11 data, and 802.11 management frames.
* Bug fix: Account for aligning m_data to a word boundary in the Rx
buffer size check.
* Bug fix: Check for LLC/SNAP even if the firmware tells us the frame
is Ethernet II, as the firmware sometimes gets this wrong.
* Process as many events as possible when we get an interrupt, using
a simple heuristic to avoid reprocessing an event (which can have
bad side-effects). Clamp the time spent in the interrupt handler
to 4ms.
* Redo the timeout loops to be consistent and less prone to error.
* Add delays to timeout loops which were missing them, so that a
fast CPU won't win the race.
* Borrow some timeout loop values from the linux-wlan-ng driver,
which seems to reflect a high level of clue (due to direct support
from Intersil).
* Get rid of silly wi_read_data(..., len + 2) idiom; simply round up
in wi_read_data() and wi_write_data(). Also, protect against a
length of 0.
* Name some frequently-used constants. Correct spelling. Other style nits.
* Bug fix: On Prism, set Create IBSS register to 0 *always*. The meaning
of Create IBSS == 1 is join an IBSS or *ESS*, and we do not want to
join an ESS, because that would put us in an inconsistent state. 0
is the right value for Prism.
* Bug fix: Clean up state at the top of wi_init(), in the event that
we don't reach the bottom.
* Simplify wi_start() by always providing an RFC1042-encoded 802.11
frame to the firmware.
* Larval powersave support for HostAP mode, enabled by WI_HOSTAP_POWERSAVE.
* Bug fix: Call wi_stop() from wi_shutdown().
* Bug fix: sync media options with HostAP mode in wi_sync_media().
* In wi_media_status(), inquire firmware for current media state if
media == auto. From FreeBSD.
* Clean up the way buffer lengths are computed by using pointer
arithmetic rather than magic constants.
* Swap the order of comparisons in addr_cmp() for speed.
* Bug fix: Send ReAssoc Response instead of Assoc Response to a
ReAssoc Request.
* Bug fix: Copy SSID using the correct size.
* Give more meaningful names to offsets in a wi_frame.
* Bug fix: Assign the right values to the named constants for
Rx frame encoding.
* Get rid of useless SNAP constants.
 1.83  21-Aug-2002  onoe Make the meaning of media options consistent with other wireless drivers.
mediaopt adhoc 802.11 adhoc (IBSS) mode. IBSS creation is enabled
for cards which can create IBSS.
mediaopt adhoc,flag0 old lucent adhoc demo mode.
Note that [adhoc] media options for wi driver was used for adhoc demo mode,
which is NOW CHANGED.
 1.82  12-Aug-2002  thorpej wi_keylen is kept in little-endian order, so le16toh() it before
using it in e.g. a memcpy() call.
 1.81  11-Aug-2002  thorpej Pass all 3 parameters to wi_cmd().
 1.80  11-Aug-2002  thorpej * Fix a Lucent <-> Prism2 WEP interop bug. We only want to set the
EXCLUDE_UNENCRYPTED bit in the WI_RID_P2_ENCRYPTION value if we are
in shared key mode. Symbol cards, just to be different, supposedly
always want the EXCLUDE_UNENCRYPTED bit set (confirmed with the
Linux orinoco and spectrum24 drivers).

* Flesh out the Host-AP WEP transmit side. Note this does not yet
work properly; the frame as seen by the receiver FCS's incorrectly.

Both changes from OpenBSD. Not confirmed whether or not Host-AP WEP
works with OpenBSD (mail sent to millert).
 1.79  11-Aug-2002  thorpej Snapshot of work-in-progress: Add AP support for Prism2-based boards.
WEP for APs is not yet implemented, but without WEP, this works well
enough for my laptop to associate with an AP running this code.

Adapted from OpenBSD.
 1.78  11-Aug-2002  thorpej Use WI_RID_DATA_RATES to fetch the supported rates. From OpenBSD.
 1.77  11-Aug-2002  thorpej * Add "wi_flags" to the softc to indicate capabilities of the card. Fill
in this info based on firmware type and version. Replace "wi_has_wep"
with a flag.
* For cards which support IBSS, add "ibss" has a media option.
* For cards which support CREATE_IBSS, add "ibss-master" as a media
option.
* Use the "ibss" and "ibss-master" media options to determine if
we should go into IBSS mode and/or create the IBSS.
* Internally convert between the generic WI_PORTTYPE_IBSS and the
value the firmware wants to use for IBSS.
* When setting the IBSS name, if a desired-SSID is set, and we're
an ibss-master, write the desired-SSID into the own-SSID slot.
This ensures that "ifconfig wi0 nwid FOO" will do the expected
thing.
* Only set the roaming mode if the card supports roaming.

From OpenBSD.
 1.76  11-Aug-2002  thorpej Only read supported rates on Prism2 boards.
 1.75  11-Aug-2002  thorpej Read supported rates from the card and report them. Only add
media types if that rate is supported.

Adapted from OpenBSD.
 1.74  10-Aug-2002  thorpej Fix some whitespace.
 1.73  31-May-2002  mycroft Mask off extraneous bits in the RX frame status when testing it. My cards set
bit 3 in ad hoc mode.
Also, some minor constant folding.
 1.72  18-Apr-2002  onoe branches: 1.72.2; 1.72.4;
(force commit: no changes in the code)
WI_RID_SCAN_APS in previous commit works for Intel Pro/Wirelss 2011
with firmware 2.51.1.
It seems that the firmware automatically updated after the card runs on
Windows 2000 with 2011_2011B_CD_3.0 in Intel web site.
 1.71  16-Apr-2002  onoe Support WI_RID_SCAN_APS (wiconfig -D) for Symbol CF Card.
It apparently requires newer firmware (3.10.4), and doesn't work on
Intel PRO/Wireless 2011 (2.0.11).
 1.70  14-Apr-2002  onoe Some fixes for Symbol card.
- The version string doesn't need to start with 'V'.
- Symbol firmware also support CREATE_IBSS.
- But it doesn't support ROAMING_MODE nor MICROWAVE_OVEN.
 1.69  11-Apr-2002  augustss Put device name at start of line.
 1.68  05-Apr-2002  ichiro Upps, fix typo
 1.67  05-Apr-2002  ichiro fix minor bugs for lucent cards. (point out from Warner Losh)
 1.66  04-Apr-2002  jdolecek move wi_pci_reset() from ic/wi.c to pci/if_wi_pci.c, where is belongs
 1.65  04-Apr-2002  jdolecek fix sligh confusion on whether or not to supply dv_xname to printf() in
error cases of attach
Noticed in kern/16197 by George E Sollish.
 1.64  04-Apr-2002  ichiro using table driven for Prism2 family IDs/Names.
 1.63  03-Apr-2002  ichiro s/WI_NIC_3842/WI_NIC_3842_EVA
 1.62  03-Apr-2002  ichiro add more IDs of PRISM family
 1.61  01-Apr-2002  ichiro add more IDs of PRISM family
 1.60  31-Mar-2002  jdolecek add some bound checking
patch submitted by IWAMOTO Toshihiro in kern/13112
 1.59  31-Mar-2002  ichiro Dont use magic number.
added parameter of WEP flags
 1.58  30-Mar-2002  ichiro added sc_pri_firmware_ver, and print Primary/Station firmware versions.
cosmetic change.
 1.57  30-Mar-2002  ichiro the kind of "firmware" was clarified.
firmware -> station firmware
 1.56  27-Mar-2002  onoe Fix to work Symbol firmware card, which cannot be initialized more than once.
Tested with 3Com 3CRWE737A and Intel Pro/Wireless 2011.
 1.55  25-Mar-2002  dbj changes from Warner Losh to read firmware version for non prism2 cards
 1.54  21-Mar-2002  itohy I have Prism2 with 0.8.2 firmware, and have no problem
using WEP without promisc on the device.
 1.53  17-Mar-2002  dbj don't set prism2 bit when WI_NIC_LUCENT is detected
 1.52  10-Mar-2002  ichiro fix 128bit WEP work with Prism2 Card.
from FreeBSD
 1.51  10-Mar-2002  augustss Add a nic I don't really know much about, but it's used on my D-Link card.
 1.50  06-Mar-2002  dbj return EINPROGRESS instead of EINVAL when trying to read
the results of an AP scan that is not finished
 1.49  04-Mar-2002  dbj Don't attempt to gather unrequested statistics.

Allow SIOCSWAVELAN with WI_RID_IFACE_STATS to request
an immediate statistics update.

We might in the future want to have SIOCGWAVELAN with
WI_RID_IFACE_STATS return an error if a statistics gathering is in
progress. Then the caller could request fresh statistics and gather
them when they are done. Instead, we currently just return whatever
statistics are available, which may be up to 60 seconds old.
 1.48  04-Mar-2002  dbj fix byte swapping when gathering statistics
this should complete the fix to pr 14385
AP scanning and statistic gathering should work on le hosts now
 1.47  04-Mar-2002  dbj correctly handle AP scanning result when there are no APs
 1.46  04-Mar-2002  dbj used %02x instead of %x when printing out BSS ids
 1.45  04-Mar-2002  dbj s/Faild/Failed/
 1.44  26-Feb-2002  dbj use #ifdef WI_DEBUG instead of #if WI_DEBUG
 1.43  26-Feb-2002  dbj avoid walking full length of unknown stats structure.
this partially addresses pr14385.
there is still a byte swapping bug retrieving the
stats structure. Since both the type and the length
are incorrectly swapped, we would timeout while reading
an extra long section (caused by the byteswapped length)
of garbage data.
turning on WI_DEBUG now just reports the unknown info type
which can be seen to be obviously incorrectly swapped
on macppc
 1.42  18-Feb-2002  yamt fix indent
 1.41  18-Feb-2002  yamt add a missing splx in the case of error.
 1.40  17-Feb-2002  martin Protect calls to wi_cmd() from callout handlers by proper splnet()/splx()
pairs. Without this, the interrupt handler will steal the "command completed"
status and wi_cmd will busy loop until it times out.

Add some error output to make failure modes like this more prominent.

This should fix PR 14559.
 1.39  13-Feb-2002  itojun make the driver even more silent; print state change messages only if IFF_DEBUG.
 1.38  01-Feb-2002  martin Don't display some (non-exceptional) events unless IFF_DEBUG is set.
I have a card that fires a continuos stream of "connected" events (one
every 30 seconds) while it hasn't found any peer.
 1.37  21-Jan-2002  ichiro if AP is nothing, FrameLen is 3 or less.
 1.36  21-Jan-2002  ichiro Print Association status changes to the console.
 1.35  21-Jan-2002  ichiro "Association Faild" was added to "Link Stat" messages.
;
Implement wi_scan into wi.c.
forces if_wi to initiate one round of access point scan.
This code was written by jrb@cs.pdx.edu, modified and bug-fixed by ichiro@netbsd.org
 1.34  20-Jan-2002  ichiro mistake bit number of tx_rate
case 4 -> case 5
 1.33  20-Jan-2002  ichiro When the length of the key of WEP was 5 or less octets, WEP was set to 40Bit.
5.5MBps were added to ifmedia.
 1.32  18-Jan-2002  ichiro to use 104bit WEP key
 1.31  09-Jan-2002  drochner print link status changes to the console
 1.30  05-Jan-2002  explorer revert changes I made a long time ago. This should undo the changes which are causing problems on some non-x86 platforms. I'll probsably redo some of these changes, but after the next release branch.
 1.29  13-Nov-2001  lukem add/cleanup RCSID
 1.28  11-Nov-2001  christos Get rid of duplicate RID definitions.
 1.27  14-Oct-2001  ichiro branches: 1.27.2;
The description about soft-reset of WI_PCI_COR was added
and WI_PCI_SOFT_RESET was used.
Cosmetic change.
 1.26  13-Oct-2001  ichiro Add Intersil Prism2.5 Mini-PCI wavelan.
 1.25  22-Sep-2001  explorer Implement two major items:

(1) Add an IOCTL to tell the Lucent based cards how often to
do an access point scan. These results are returned by
calling another IOCTL to get the most recent scan data.

This function works with prism2 cards as well, but the
data is returned in a different format, or perhaps it is
data only for the closest access point.

(2) For prism2 cards, add the ability to put it into LAN monitor
mode, where (via BPF) all packets can be received. This
mode works best with "wiconfig wi0 -p 3 -f ?" to put the
card into pseudo-IBSS mode (to keep it from channel-hopping
and scanning for access points) and to set the frequency of
the AP you wish to monitor.

The returned data has a partial wi_frame header (down to the
wi_dat_len field) followed by the raw data of the packet.
I have and will put up on http://www.flame.org/NetBSD/wireless/
some simple utilities which do some perhaps interesting things,
like scan for access points, capture packets, etc.
 1.24  16-Aug-2001  wiz branches: 1.24.2;
Fix indentation in switch statement, per kern/13725 by seebs.
 1.23  13-Aug-2001  wiz Space nit. kern/13712 by seebs.
 1.22  26-Jul-2001  jdolecek make local variable 'len' in wi_set_nwkey() size_t (hence unsigned)
this one is merely cosmetic, no functional change
 1.21  07-Jul-2001  thorpej branches: 1.21.2;
bzero -> memset
 1.20  07-Jul-2001  thorpej bcopy -> memcpy
 1.19  07-Jul-2001  thorpej bcmp -> memcmp
 1.18  27-Jun-2001  nathanw The back end driver doesn't need PCMCIA headers, but it does need
<machine/bus.h>.
 1.17  12-Jun-2001  thorpej branches: 1.17.2;
Don't need INET or NS includes here.
 1.16  04-Jun-2001  toshii Don't pass nonpositive repeat count to CSR_*_MULTI_2.
Should fix kern/13092.
 1.15  02-Jun-2001  toshii Use bus_space_{read,write}_multi_stream_2 where available.
 1.14  20-May-2001  ichiro add more comment about firmware of EVAL-CARD.
 1.13  20-May-2001  ichiro chenge chip and card identity,
print RF-chipset, Medium Access Controller(MAC) and CARD-identity
 1.12  16-May-2001  ichiro support BUFFALO AirStation WLI-PCM-S11
this card are PRISM2.5 card.
 1.11  16-May-2001  tsubai Big-endian support.
 1.10  16-May-2001  ichiro add prism chip identity, Prism2 with SST flush.
 1.9  16-May-2001  ichiro cosmetic change.
change version format: <major>.<minor> variant <num>
 1.8  15-May-2001  ichiro fixed mistake.
major version and minor version were made reverse.
 1.7  15-May-2001  ichiro Fix indentation in recent commit.
 1.6  15-May-2001  ichiro getting prism2 firm ver routine to wi_get_id().
if firm ver is more than 0.8c3, promiscuous mode is off.

typo WI_RID_STA_IDENEITY -> WI_RID_STA_IDENTITY
 1.5  15-May-2001  ichiro WEP cannot be used when Prism2 Firm version is lower than 0.8.3.
Although WEP is used in Windows also in an old firm,
because WEP is processed by the windows driver side.
If Prism2 Firm version is more than 0.8.3, WEP does work without 'Promiscuous ON'.
 1.4  15-May-2001  ichiro It enabled it to control roaming mode and authentication mode.
Roaming mode can change value into 'firm mode' and disable.
Authentication mode can change into 'Open System authentication'
and 'Shared Key Authentication' with Prism2 chip.

wi_get_id() was introduced in order that chip might judge automatically
whether it is Prism2 chip. Therefore, a pp_prism2 entry in
"struct wi_pcmcia_product" became unnecessary.
 1.3  08-May-2001  ichiro change promisc mode in case of SIOCSIFFLAGS of wi_ioctl.
Fix indentation.
 1.2  08-May-2001  ichiro delay(10) is too much enough for command waiting routine.
 1.1  06-May-2001  ichiro divided into PCMCIA attachment and common code of wi.
since if_wi_ieee.h does not depend for pcmcia,
sys/dev/pcmcia/if_wi_ieee.h was moved to sys/dev/ic/wi_ieee.h .
 1.17.2.24  15-Jan-2003  thorpej Sync with HEAD.
 1.17.2.23  03-Jan-2003  thorpej Sync with HEAD.
 1.17.2.22  29-Dec-2002  thorpej Sync with HEAD.
 1.17.2.21  11-Dec-2002  thorpej Sync with HEAD.
 1.17.2.20  11-Nov-2002  nathanw Catch up to -current
 1.17.2.19  18-Oct-2002  nathanw Catch up to -current.
 1.17.2.18  23-Sep-2002  thorpej Sync with HEAD.
 1.17.2.17  27-Aug-2002  nathanw Catch up to -current.
 1.17.2.16  13-Aug-2002  nathanw Catch up to -current.
 1.17.2.15  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.17.2.14  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.17.2.13  20-Jun-2002  nathanw Catch up to -current.
 1.17.2.12  17-Apr-2002  nathanw Catch up to -current.
 1.17.2.11  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.17.2.10  28-Feb-2002  nathanw Catch up to -current.
 1.17.2.9  11-Jan-2002  nathanw More catchup.
 1.17.2.8  09-Jan-2002  nathanw Catch up to -current. No, really, for sure this time.
 1.17.2.7  08-Jan-2002  nathanw Catch up to -current.
 1.17.2.6  15-Nov-2001  thorpej Merge from -current; compilation fix (pcmcia front-end out of sync
with bus-independent part .. merge error, I guess).
 1.17.2.5  08-Oct-2001  nathanw Catch up to -current.
 1.17.2.4  26-Sep-2001  nathanw Catch up to -current.
Again.
 1.17.2.3  24-Aug-2001  nathanw Catch up with -current.
 1.17.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.17.2.1  12-Jun-2001  nathanw file wi.c was added on branch nathanw_sa on 2001-06-21 20:03:30 +0000
 1.21.2.8  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.21.2.7  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.21.2.6  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.21.2.5  16-Mar-2002  jdolecek Catch up with -current.
 1.21.2.4  11-Feb-2002  jdolecek Sync w/ -current.
 1.21.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.2.2  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.21.2.1  03-Aug-2001  lukem update to -current
 1.24.2.1  01-Oct-2001  fvdl Catch up with -current.
 1.27.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.72.4.1  01-Jun-2002  tv Pull up revision 1.73 (requested by mycroft in ticket #109):
Makes some cards with Symbol firmware work in ad-hoc mode.
 1.72.2.2  29-Aug-2002  gehenna catch up with -current.
 1.72.2.1  20-Jun-2002  gehenna catch up with -current.
 1.130.2.12  11-Dec-2005  christos Sync with head.
 1.130.2.11  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.130.2.10  01-Apr-2005  skrll Sync with HEAD.
 1.130.2.9  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.130.2.8  15-Feb-2005  skrll Sync with HEAD.
 1.130.2.7  17-Jan-2005  skrll Sync with HEAD.
 1.130.2.6  18-Dec-2004  skrll Sync with HEAD.
 1.130.2.5  29-Nov-2004  skrll Sync with HEAD.
 1.130.2.4  02-Nov-2004  skrll Sync with HEAD.
 1.130.2.3  19-Oct-2004  skrll Sync with HEAD
 1.130.2.2  12-Aug-2004  skrll Sync with HEAD.
 1.130.2.1  03-Aug-2004  skrll Sync with HEAD
 1.159.2.2  23-Jul-2004  he branches: 1.159.2.2.2;
Pull up revisions 1.162-1.181 (requested by mycroft in tickets #700,#701):
Many bug fixes and performance fixes for the wi(4) driver,
as well as changes paving the way for further performance
improvements.
 1.159.2.1  07-Jun-2004  jdc Pull up revision 1.161 (requested by dyoung in ticket #449).

Finally, refactor wi_media_change and ieee80211_media_change.
ieee80211_media_change handles a lot more conditions than
wi_media_change did.

This helps with the second bug mentioned in kern/25604, which causes
"SIOCSIFMEDIA: Invalid argument."
 1.159.2.2.2.1  24-Jan-2005  he Pull up revision 1.188 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.193.2.1  29-Apr-2005  kent sync with -current
 1.194.2.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.202.2.6  21-Jan-2008  yamt sync with head
 1.202.2.5  27-Oct-2007  yamt sync with head.
 1.202.2.4  03-Sep-2007  yamt sync with head.
 1.202.2.3  26-Feb-2007  yamt sync with head.
 1.202.2.2  30-Dec-2006  yamt sync with head.
 1.202.2.1  21-Jun-2006  yamt sync with head.
 1.209.6.1  22-Nov-2005  yamt sync with head.
 1.211.6.2  01-Jun-2006  kardel Sync with head.
 1.211.6.1  22-Apr-2006  simonb Sync with head.
 1.211.4.1  09-Sep-2006  rpaulo sync with head
 1.211.2.1  01-Mar-2006  yamt sync with head.
 1.212.4.3  19-Apr-2006  elad sync with head.
 1.212.4.2  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.212.4.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.212.2.3  11-Aug-2006  yamt sync with head
 1.212.2.2  24-May-2006  yamt sync with head.
 1.212.2.1  13-Mar-2006  yamt sync with head.
 1.213.2.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.215.6.2  10-Dec-2006  yamt sync with head.
 1.215.6.1  22-Oct-2006  yamt sync with head
 1.215.4.2  12-Jan-2007  ad Sync with head.
 1.215.4.1  18-Nov-2006  ad Sync with head.
 1.218.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.219.4.1  11-Jul-2007  mjf Sync with head.
 1.219.2.3  23-Oct-2007  ad Sync with head.
 1.219.2.2  09-Oct-2007  ad Sync with head.
 1.219.2.1  01-Jul-2007  ad Adapt to callout API change.
 1.220.8.2  09-Jan-2008  matt sync with HEAD
 1.220.8.1  06-Nov-2007  matt sync with HEAD
 1.220.6.3  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.220.6.2  04-Sep-2007  joerg Convert wi(4) to jmcneill-pm style power management.
 1.220.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.220.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.221.4.1  25-Oct-2007  bouyer Sync with HEAD.
 1.222.6.1  11-Dec-2007  yamt sync with head.
 1.222.4.1  26-Dec-2007  ad Sync with head.
 1.223.2.1  02-Jan-2008  bouyer Sync with HEAD
 1.224.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.224.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.225.4.6  11-Aug-2010  yamt sync with head.
 1.225.4.5  11-Mar-2010  yamt sync with head
 1.225.4.4  16-Sep-2009  yamt sync with head
 1.225.4.3  16-May-2009  yamt sync with head
 1.225.4.2  04-May-2009  yamt sync with head.
 1.225.4.1  16-May-2008  yamt sync with head.
 1.225.2.1  18-May-2008  yamt sync with head.
 1.226.8.2  28-Apr-2009  skrll Sync with HEAD.
 1.226.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.226.6.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.228.4.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.232.4.2  05-Mar-2011  rmind sync with head
 1.232.4.1  30-May-2010  rmind sync with head
 1.232.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.235.16.1  18-May-2014  rmind sync with head
 1.235.12.2  03-Dec-2017  jdolecek update from HEAD
 1.235.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.235.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.237.6.4  28-Aug-2017  skrll Sync with HEAD
 1.237.6.3  05-Feb-2017  skrll Sync with HEAD
 1.237.6.2  09-Jul-2016  skrll Sync with HEAD
 1.237.6.1  29-May-2016  skrll Sync with HEAD
 1.240.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.240.2.2  26-Apr-2017  pgoyette Sync with HEAD
 1.240.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.243.6.2  26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.243.6.1  10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.244.2.4  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.244.2.3  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.244.2.2  28-Jul-2018  pgoyette Sync with HEAD
 1.244.2.1  25-Jun-2018  pgoyette Sync with HEAD
 1.247.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.247.2.1  10-Jun-2019  christos Sync with HEAD
 1.254.2.1  29-Feb-2020  ad Sync with head.
 1.255.10.1  17-Jun-2021  thorpej Sync w/ HEAD.

RSS XML Feed