Commit Graph

69 Commits

Author SHA1 Message Date
thorpej
7a9a30c5e7 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.
2020-03-15 23:04:50 +00:00
christos
aa3d6ec155 revert the 0x% -> %# change for fixed width formats pointed out by uwe. 2020-03-14 02:35:33 +00:00
christos
d3dde16c1a PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log
2020-03-13 18:17:40 +00:00
thorpej
cdaa0e91f5 Adopt <net/if_stats.h>. 2020-01-29 06:35:28 +00:00
mrg
3b24a1344e remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h 2019-05-05 03:17:54 +00:00
christos
60d3fae6ae Don't have modules depend on bpf; they will find the dependency dynamically
at runtime. Otherwise builtin modules will complain about non-builtin bpf.
2018-09-12 21:57:18 +00:00
riastradh
a1de014734 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@
2018-08-02 06:09:04 +00:00
riastradh
0449a44d02 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
2018-07-29 02:01:11 +00:00
msaitoh
3cd62456f9 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.
2018-06-26 06:47:57 +00:00
maya
eddea7af1c GC private 802.11 rateset declarations, use the standard ones.
Build tested only.
2018-05-01 16:18:13 +00:00
skrll
b842161189 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
2018-01-21 13:57:11 +00:00
khorben
c55f55c60a Also attach the MW-P54SS USB Wireless Broadband Router from Synet
Tested on NetBSD/amd64 (in HostAP mode)
2017-05-23 00:32:47 +00:00
skrll
a7c71d30d6 +#include "opt_usb.h" 2016-11-25 12:56:29 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
ozaki-r
d938d837b3 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.
2016-06-10 13:27:10 +00:00
ozaki-r
6bbd2477a9 Introduce M_CLEARCTX and use it instead of open-coding rcvif
No functional change.
2016-05-26 05:04:46 +00:00
ozaki-r
ea0349e714 Use M_GETCTX
No functional change.
2016-05-26 05:01:11 +00:00
skrll
4e8e66439e 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
2016-04-23 10:15:27 +00:00
ryoon
ef8ca4bc6c loadfirmware is not NetBSD function. Fix error message. 2015-08-30 13:09:48 +00:00
nonaka
959874c592 Added pmf hook. 2015-04-08 12:38:13 +00:00
ozaki-r
3cde4cbc35 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.
2015-01-07 07:05:48 +00:00
zafer
b79dc9575c Fix an issue with 11g beacon frames.
From FreeBSD Rev. 226465
Makes 11g wep, wpa2 and hostap work again.
2014-03-29 00:59:05 +00:00
jmcneill
7c64a30e85 - 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.
2013-01-22 12:40:42 +00:00
christos
38f4ff5bf5 fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables
2013-01-05 23:34:16 +00:00
christos
3039e3a5a7 - need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID
2013-01-05 01:30:15 +00:00
skrll
897388ea60 Consistent/Correct error message from failing usbd_set_config.
Use aprint_error_dev.
2012-12-27 16:42:32 +00:00
chs
bd1aea2036 add a bunch of devices. from openbsd. 2012-09-23 01:08:17 +00:00
nonaka
6a9737b9fa Add a dependency on bpf module. 2012-06-01 12:38:25 +00:00
nonaka
8644178b4a Remove duplicate entries. 2012-05-31 12:32:35 +00:00
christos
07ba3f910e PR/45344: Pierre Allegraud: Added Dlink DWA-110 in rum(4) 2011-09-08 22:06:54 +00:00
pgoyette
a4ebf89b5b Update the module command-processing routine to match the ioconf files 2011-08-25 02:27:31 +00:00
pgoyette
75c5b19872 Update for modular build 2011-08-23 12:53:29 +00:00
pgoyette
3016e04310 In preparation for building this as a module, clean-up some gcc
-Wsign-compare issues so it will build with WARNS=4
2011-08-23 12:33:50 +00:00
jmcneill
9f8d6eb8fa make rum_ioctl look like other wireless drivers, now dhcpcd works and
mdnsd doesn't hang my laptop
2011-02-22 00:58:08 +00:00
jmcneill
8793159934 sync driver with openbsd 2011-02-21 23:50:42 +00:00
dholland
74af1ccafe 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
2011-02-13 05:51:24 +00:00
dyoung
68c8418c63 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.
2010-11-03 22:28:31 +00:00
joerg
58e867556f 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.
2010-04-05 07:19:28 +00:00
pooka
10fe49d72c 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.
2010-01-19 22:06:18 +00:00
dyoung
110a4ba3b4 Simplify several device-activation hooks. 2009-12-06 20:20:12 +00:00
pooka
7c544ae12a 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.
2009-09-28 10:22:07 +00:00
plunky
5fab894c54 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.
2009-09-23 19:07:19 +00:00
tshiozak
591b8c1e16 add Melco(Buffalo) WLI-UC-G 11b/11g wifi adaptor (rt2573).
This works fine for 11b, but unstable for 11g.
2009-08-02 20:55:45 +00:00
cegger
c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
yamt
b1fea83762 remove extra semicolons. 2009-01-03 03:43:21 +00:00
dyoung
de87fe677d *** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02🇩🇪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.
2008-11-07 00:20:01 +00:00
jun
3caafa9653 Add
corega K.K CG-WLUSB2GPX
2008-10-21 12:20:44 +00:00
uebayasi
36662bbc30 Add a device ID seen in Kojinsha notebook. From Ryo Shimizu. 2008-07-08 08:44:55 +00:00
cube
3624455eba 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.
2008-05-24 16:40:58 +00:00
cegger
395c8c3fd3 use aprint_*_dev and device_xname 2008-04-05 16:35:35 +00:00