History log of /netbsd-current/sys/dev/usb/if_rum.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.70 12-Aug-2022 riastradh

rum(4): Avoid uninitialized garbage in failed register read.

Reported-by: syzbot+f2cba71b1b1bc91029b3@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=7a01863d0fe34a4946516388c436991ba2beaa63


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.69 15-Mar-2020 thorpej

Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.


# 1.68 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.67 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3
# 1.66 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.65 05-May-2019 mrg

branches: 1.65.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.64 12-Sep-2018 christos

Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.


Revision tags: pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.63 02-Aug-2018 riastradh

Fix usb_rem_task_wait API.

- Return whether it removed task from queue or not.
. True if it was on the queue and we intercepted it before it ran.
. False if we could not intercept it: either it wasn't queued,
or it already ran. (Up to caller to distinguish these cases.)
- Pass an optional interlock like callout_halt.

While here, simplify.

ok mrg@


# 1.62 29-Jul-2018 riastradh

Use callout_halt and usb_rem_task_wait in rum(4) detach.

Also comment on sketchiness in rum_newstate that is beyond my scope
right now.

squash! 815cfdcb30208ae2d1cffe19b1cd4ef85ab19f3c


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

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

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


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

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.59 21-Jan-2018 skrll

branches: 1.59.2;
PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

branches: 1.58.2;
Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


# 1.69 15-Mar-2020 thorpej

Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
access to media-related structures / hardware regsiters. Converted
drivers use the new ifmedia_init_with_lock() function for this. The
new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
a compatibility lock to be used instead. Several media-related entry
points must be aware of this compatibility lock, and are able to acquire
it recursively a limited number of times, if needed. This is a SPIN
mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex. The mcx driver still needs to be fully converted to
NET_MPSAFE.


# 1.68 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.67 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: ad-namecache-base3
# 1.66 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.65 05-May-2019 mrg

branches: 1.65.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.64 12-Sep-2018 christos

Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.


Revision tags: pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.63 02-Aug-2018 riastradh

Fix usb_rem_task_wait API.

- Return whether it removed task from queue or not.
. True if it was on the queue and we intercepted it before it ran.
. False if we could not intercept it: either it wasn't queued,
or it already ran. (Up to caller to distinguish these cases.)
- Pass an optional interlock like callout_halt.

While here, simplify.

ok mrg@


# 1.62 29-Jul-2018 riastradh

Use callout_halt and usb_rem_task_wait in rum(4) detach.

Also comment on sketchiness in rum_newstate that is beyond my scope
right now.

squash! 815cfdcb30208ae2d1cffe19b1cd4ef85ab19f3c


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

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

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


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

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.59 21-Jan-2018 skrll

branches: 1.59.2;
PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

branches: 1.58.2;
Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


# 1.68 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.67 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: ad-namecache-base3
# 1.66 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.65 05-May-2019 mrg

branches: 1.65.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.64 12-Sep-2018 christos

Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.


Revision tags: pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.63 02-Aug-2018 riastradh

Fix usb_rem_task_wait API.

- Return whether it removed task from queue or not.
. True if it was on the queue and we intercepted it before it ran.
. False if we could not intercept it: either it wasn't queued,
or it already ran. (Up to caller to distinguish these cases.)
- Pass an optional interlock like callout_halt.

While here, simplify.

ok mrg@


# 1.62 29-Jul-2018 riastradh

Use callout_halt and usb_rem_task_wait in rum(4) detach.

Also comment on sketchiness in rum_newstate that is beyond my scope
right now.

squash! 815cfdcb30208ae2d1cffe19b1cd4ef85ab19f3c


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

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

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


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

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.59 21-Jan-2018 skrll

branches: 1.59.2;
PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

branches: 1.58.2;
Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


# 1.66 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.65 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.64 12-Sep-2018 christos

Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.


Revision tags: pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.63 02-Aug-2018 riastradh

Fix usb_rem_task_wait API.

- Return whether it removed task from queue or not.
. True if it was on the queue and we intercepted it before it ran.
. False if we could not intercept it: either it wasn't queued,
or it already ran. (Up to caller to distinguish these cases.)
- Pass an optional interlock like callout_halt.

While here, simplify.

ok mrg@


# 1.62 29-Jul-2018 riastradh

Use callout_halt and usb_rem_task_wait in rum(4) detach.

Also comment on sketchiness in rum_newstate that is beyond my scope
right now.

squash! 815cfdcb30208ae2d1cffe19b1cd4ef85ab19f3c


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

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

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


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

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.59 21-Jan-2018 skrll

branches: 1.59.2;
PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

branches: 1.58.2;
Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


# 1.65 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.64 12-Sep-2018 christos

Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.


Revision tags: pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.63 02-Aug-2018 riastradh

Fix usb_rem_task_wait API.

- Return whether it removed task from queue or not.
. True if it was on the queue and we intercepted it before it ran.
. False if we could not intercept it: either it wasn't queued,
or it already ran. (Up to caller to distinguish these cases.)
- Pass an optional interlock like callout_halt.

While here, simplify.

ok mrg@


# 1.62 29-Jul-2018 riastradh

Use callout_halt and usb_rem_task_wait in rum(4) detach.

Also comment on sketchiness in rum_newstate that is beyond my scope
right now.

squash! 815cfdcb30208ae2d1cffe19b1cd4ef85ab19f3c


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

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

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


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

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.59 21-Jan-2018 skrll

branches: 1.59.2;
PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

branches: 1.58.2;
Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 1.64 12-Sep-2018 christos

Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.


Revision tags: pgoyette-compat-0906 jdolecek-ncqfixes-base
# 1.63 02-Aug-2018 riastradh

Fix usb_rem_task_wait API.

- Return whether it removed task from queue or not.
. True if it was on the queue and we intercepted it before it ran.
. False if we could not intercept it: either it wasn't queued,
or it already ran. (Up to caller to distinguish these cases.)
- Pass an optional interlock like callout_halt.

While here, simplify.

ok mrg@


# 1.62 29-Jul-2018 riastradh

Use callout_halt and usb_rem_task_wait in rum(4) detach.

Also comment on sketchiness in rum_newstate that is beyond my scope
right now.

squash! 815cfdcb30208ae2d1cffe19b1cd4ef85ab19f3c


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

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

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


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

GC private 802.11 rateset declarations, use the standard ones.

Build tested only.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.59 21-Jan-2018 skrll

branches: 1.59.2;
PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

branches: 1.58.2;
Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


# 1.59 21-Jan-2018 skrll

PR kern/52931 Kernel panics with Atheros usb wireless interface

Audit the flags to usbd_create_xfer so that USBD_FORCE_SHORT_XFER is
supplied wherever such a transfer is setup. We can drop
USBD_SHORT_XFER_OK as it has not bearing on number of TDs


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.58 23-May-2017 khorben

Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


# 1.58 23-May-2017 khorben

Also attach the MW-P54SS USB Wireless Broadband Router from Synet

Tested on NetBSD/amd64 (in HostAP mode)


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 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

branches: 1.56.2;
KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.4; 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.


Revision tags: nick-nhusb-base-20161204
# 1.57 25-Nov-2016 skrll

+#include "opt_usb.h"


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.56 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


# 1.55 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.54 26-May-2016 ozaki-r

Introduce M_CLEARCTX and use it instead of open-coding rcvif

No functional change.


# 1.53 26-May-2016 ozaki-r

Use M_GETCTX

No functional change.


# 1.52 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.51 30-Aug-2015 ryoon

loadfirmware is not NetBSD function. Fix error message.


Revision tags: nick-nhusb-base-20150606
# 1.50 08-Apr-2015 nonaka

Added pmf hook.


Revision tags: nick-nhusb-base-20150406
# 1.49 07-Jan-2015 ozaki-r

Pass a correct firmware size (instead of 0) to firmware_free

firmware_free now uses kmem_free(9) instead of free(9),
so we need to pass a correct size to it.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.48 29-Mar-2014 zafer

branches: 1.48.6; 1.48.10;
Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.


Revision tags: riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8
# 1.47 22-Jan-2013 jmcneill

branches: 1.47.2;
- Add a USBD_MPSAFE flag to usbd_open_pipe. If not set, acquire KERNEL_LOCK
before invoking xfer callbacks on this pipe.
- Add an extra flags parameter to usb_init_task. If USBD_TASKQ_MPSAFE is not
present, acquire KERNEL_LOCK before invoking the task callback.


# 1.46 05-Jan-2013 christos

fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables


# 1.45 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


# 1.44 27-Dec-2012 skrll

Consistent/Correct error message from failing usbd_set_config.

Use aprint_error_dev.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.43 23-Sep-2012 chs

add a bunch of devices. from openbsd.


Revision tags: jmcneill-usbmp-base10
# 1.42 01-Jun-2012 nonaka

branches: 1.42.2;
Add a dependency on bpf module.


# 1.41 31-May-2012 nonaka

Remove duplicate entries.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.40 08-Sep-2011 christos

branches: 1.40.2; 1.40.6;
PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4)


# 1.39 25-Aug-2011 pgoyette

Update the module command-processing routine to match the ioconf files


# 1.38 23-Aug-2011 pgoyette

Update for modular build


# 1.37 23-Aug-2011 pgoyette

In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.36 22-Feb-2011 jmcneill

make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop


# 1.35 21-Feb-2011 jmcneill

sync driver with openbsd


Revision tags: bouyer-quota2-base
# 1.34 13-Feb-2011 dholland

fix typo (clean up the rx list on failure setting it up, not the tx list)
from openbsd -r1.75, mentioned by Alexander Nasonov in PR 42667


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4
# 1.33 03-Nov-2010 dyoung

branches: 1.33.2; 1.33.4;
Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change, except for
if_cue.c where two adjacent instructions inexplicably change order.


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.32 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 uebayasi-xip-base
# 1.31 19-Jan-2010 pooka

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


Revision tags: matt-premerge-20091211
# 1.30 06-Dec-2009 dyoung

Simplify several device-activation hooks.


Revision tags: jym-xensuspend-nbase
# 1.29 28-Sep-2009 pooka

Attach DWA-111.

XXX: Adapter seems to be generally functional, but at least on -nb5
WPA didn't work very well (managed to get authenticated and sometimes
an address via dhcp, but that's it). I can't currently test non-wpa
networks, so don't know if it's an issue only with wpa or with the
connectivity in general.


# 1.28 23-Sep-2009 plunky

fix up USB drivers printing of autoconf information

1. expand the USB_ATTACH_SETUP macro (requested by jmcneill)

2. reorder the attach function so that the first thing it does is print
newlines.

3. after this, we can call usbd_devinfo_alloc(), which polls the device
allowing a context switch, and aprint_normal() the device information.

this avoids problems where autoconf messages are getting mixed up.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.27 02-Aug-2009 tshiozak

add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.26 18-Mar-2009 cegger

bzero -> memset


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.25 03-Jan-2009 yamt

branches: 1.25.2;
remove extra semicolons.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.24 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-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.23 21-Oct-2008 jun

branches: 1.23.2; 1.23.4;
Add
corega K.K CG-WLUSB2GPX


Revision tags: haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 simonb-wapbl-nbase simonb-wapbl-base
# 1.22 08-Jul-2008 uebayasi

Add a device ID seen in Kojinsha notebook. From Ryo Shimizu.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.21 24-May-2008 cube

branches: 1.21.2; 1.21.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base
# 1.20 05-Apr-2008 cegger

branches: 1.20.2; 1.20.4; 1.20.6;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.19 09-Dec-2007 jmcneill

branches: 1.19.10;
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.18 25-Nov-2007 kiyohara

branches: 1.18.2; 1.18.4;
+ Add COREGA CG-WLUSB2GL and ABOCOM WUG2700.
+ make sure ni->ni_txrate is always initialized to a meaningful value by
redefining ic->ic_newassoc.
this should prevent "bogus xmit rate" panics when operating in HostAP
mode.
+ s/RT2573_[TR]X_LIST_COUNT/RUM_[TR]X_LIST_COUNT/
+ Restore the workaround for rate==0 bug.
+ http://www.ralinktech.com/ domain name is for sale.
use official url instead: http://www.ralinktech.com.tw/


Revision tags: jmcneill-base bouyer-xenamd64-base2 bouyer-xenamd64-base
# 1.17 21-Oct-2007 degroote

branches: 1.17.2;
Fix a number of driver which doesn't check wep flag in *_tx_mgt.
It is incorrect because we need to encrypt some management frame in case of
shared authentification.


# 1.16 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.15 26-Aug-2007 dyoung

branches: 1.15.2; 1.15.6;
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.14 15-Aug-2007 kiyohara

Already called *_free_[rt]x_list() in *_stop().


Revision tags: matt-mips64-base nick-csl-alignment-base
# 1.13 11-Jul-2007 drochner

branches: 1.13.2; 1.13.6;
Stopgap fix to avoid crash on detach if the attach failed due to eg
USB problems - just return in detach if the softc appears not to be
filled in completely.
(This is a common problem with usb and probably other drivers which
support detach; we need some API support to deal with this cleanly.)


Revision tags: mjf-ufs-trans-base
# 1.12 09-Jun-2007 kiyohara

Use usb_callout.


Revision tags: yamt-idlelwp-base8
# 1.11 07-May-2007 xtraeme

Sync the list of supported models with OpenBSD, 13 new models were
added.


# 1.10 07-May-2007 xtraeme

Add support for ASUS WL-167g ver 2, from PR kern/35113 (Dave Huang).


Revision tags: thorpej-atomic-base
# 1.9 13-Mar-2007 drochner

Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!


# 1.8 11-Mar-2007 mlelstv

branches: 1.8.2;
print a size_t value with a size_t format.
The cast is necessary in case someone redefines RT2573_TX_DESC_SIZE.


# 1.7 04-Mar-2007 christos

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


Revision tags: itohy-usb1-base ad-audiomp-base
# 1.6 26-Feb-2007 wiz

branches: 1.6.4;
Add casts to debug printf so it also compiles on i386.
Noted by veego@


# 1.5 21-Feb-2007 wiz

Fix debug format strings (found on amd64).


Revision tags: post-newlock2-merge newlock2-nbase newlock2-base
# 1.4 06-Feb-2007 elad

branches: 1.4.2;
PR/35552: Yojiro UO: add new devices for rum(4)

Patch applied, thanks!

(needs regen)


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

branches: 1.3.2; 1.3.4; 1.3.6;
PR/35122: Dieter Roelants: Support for LevelOne WNC-0301USB USB wireless


# 1.2 01-Nov-2006 xtraeme

branches: 1.2.2;
Missing __KERNEL_RCSID()


# 1.1 31-Oct-2006 joerg

Add rum(4) for newer USB Ralink devices. Obtained from OpenBSD.
Special thanks to Sepherosa Ziehau for helping debugging USB issues.
Hook up rum(4) for i386 config files.