Commit Graph

5554 Commits

Author SHA1 Message Date
maxv
335e3606f2 Move uvideo's parsers into usbdi.c, to make them global. Rename
usb_desc_iter_peek_next -> usb_desc_iter_peek for consistency.
2020-02-08 07:38:17 +00:00
msaitoh
41e8782383 Cast to uint32_t to avoid undefined behavior in smsc_setmacaddress.
Found by kUBSan.
2020-02-05 07:24:07 +00:00
skrll
11704b9814 Adopt <net/if_stats.h> 2020-02-04 07:35:21 +00:00
mrg
ddeb337bff don't call usb_syncmem() for zero-length packets. 2020-02-04 06:30:46 +00:00
thorpej
4947e861f2 Use ifmedia_fini(). 2020-02-04 05:44:14 +00:00
maya
1893f08fad Remove more urio(4) traces.
Pointed out by maxv, thanks.
2020-02-03 19:37:42 +00:00
kre
442e7c4f3e urio(4) has gone - remove it from here as well, so any kernel config
files that reference it will fail to configure, rather than later
failing to build.
2020-02-03 12:56:26 +00:00
mlelstv
dcf76c79ba urio(4) was deleted 2020-01-29 21:52:16 +00:00
maya
5e031685d6 remove urio(4), a driver for the Rio500 MP3 player.
At this point it is highly unlikely this 1999 device still has users,
but it still comes up in the context of maxv's USB-fuzzing (and any device
could pretend to be a urio(4)), so it's best to get rid of it.

Renamed all major entries to obsolete, as was done in previous removals.

This still requires an update to sanitizers, but they're located in
"external", perhaps it should be first committed upstream?

Proposed on tech-kern a month ago.
2020-01-29 18:39:00 +00:00
thorpej
cdaa0e91f5 Adopt <net/if_stats.h>. 2020-01-29 06:35:28 +00:00
thorpej
72f872d2b2 Adopt <net/if_stats.h>. 2020-01-29 06:17:07 +00:00
riastradh
c837f63abc Use __BIT. 2020-01-26 22:34:17 +00:00
riastradh
0b3f0fd87c Unconditionally enable UATP_DEBUG. 2020-01-26 22:19:54 +00:00
riastradh
aa44508fe1 Downgrade noisy message from aprint_verbose to DPRINTF. 2020-01-26 22:19:39 +00:00
riastradh
7823daf7bc Work around quirk of Fountain and Geyser 1 trackpads.
Sometimes they get desynchronized, but we know the last packet is a
17-byte packet, so if we get one early then stop here.

Tested by macallan on an iBook and a PowerBook.  This code path
shouldn't break anything on MacBooks because they have different
total numbers of sensors so this branch won't be reached.
2020-01-26 22:19:27 +00:00
maya
09ad70fb6c Remove uyurex(4).
This is a driver for a "nonsense machine" made by the art group Maywa-Denki
in 2008. It was disabled by default.

Unfortunately even so it draws development attention (flaws found in the
code, MP-ification needs) and it is best not to continue to maintain this
driver.

Proposed without objections on tech-kern.
2020-01-17 15:00:20 +00:00
skrll
752c3237b0 If malloc fails in zyd_node_alloc then return NULL. From nick-nhusb 2020-01-15 08:21:00 +00:00
skrll
c6828b08e2 Use modern interfaces and kill tsleep/wakeup. From nick-nhusb branch. 2020-01-15 08:20:13 +00:00
skrll
3db7d1a277 Trailing whitespace 2020-01-15 08:13:20 +00:00
skrll
bf343540f8 Use a define instead of a magic constant. NFCI. 2020-01-15 08:02:53 +00:00
macallan
ed787f4d25 send PMF events for volume and brightness control keys on Apple keyboards 2020-01-08 23:28:56 +00:00
maxv
f76a68287e Localify, constify. 2020-01-07 06:42:26 +00:00
msaitoh
9ffb315967 Fix a bug that IFF_ALLMULTI is almost always set. 2020-01-06 15:19:00 +00:00
mlelstv
90e85cec6c Avoid race condition. Patch from bouyer@ 2020-01-04 22:30:06 +00:00
jmcneill
c47914cb8a Add a quirk for the HAILUCK USB keyboard / touchpad device with product 1e.
The keyboard does not function properly unless the touchpad's intr endpoint
is active.
2020-01-03 12:39:39 +00:00
jmcneill
7ee1f951f1 regen 2020-01-03 12:35:57 +00:00
jmcneill
f0cf68d29b Add HAILUCK keyboard (product 1e) 2020-01-03 12:35:33 +00:00
maxv
56fc3d1e80 Remove the call to KERNEL_UNLOCK_ONE(), it was forgotten when the biglock
was dropped in rev1.63. Found via vHCI.
2020-01-02 08:08:30 +00:00
maxv
e85888420e Fix buffer overflows: validate the lengths at attach time, given that they
are apparently not supposed to be variable. Drop sc_ilen since it is
unused.
2020-01-01 09:08:28 +00:00
maxv
64d3794063 Fix buffer overflows. Also add missing mutex_exit. 2020-01-01 09:05:03 +00:00
maxv
8fdfc138ab Fix buffer overflows. sc_{o,f}len are controlled by the USB device. By
crafting the former the device can leak stack data. By crafting the latter
the device can overwrite the stack. The combination of the two means the
device can ROP the kernel and obtain code execution (demonstrated with an
actual exploit over vHCI).

Truncate the lengths to the size of the buffers, and also drop sc_ilen
since it is unused. Patch tested with vHCI+kASan.
2020-01-01 09:03:00 +00:00
skrll
f9e25f1249 Remove a stray ' 2019-12-31 18:11:18 +00:00
skrll
112deea71c Acquire bus lock (if not polling) when changing xfer status, resetting
the timeout and ringing the doorbell in the start methods.
2019-12-29 09:17:51 +00:00
msaitoh
a0403cde04 s/transfered/transferred/ 2019-12-27 09:41:48 +00:00
msaitoh
65ac1eace8 URL_TCR_IFG0 is not bit 4 but bit3. From OpenBSD. 2019-12-27 08:53:30 +00:00
msaitoh
e1ca6a8735 s/recive/receive/ in comment. 2019-12-27 08:22:49 +00:00
thorpej
601e178380 Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus().  "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
2019-12-22 23:23:29 +00:00
gson
52f0ad4e7d Code that's #if'ed out still ought to compile. 2019-12-19 15:17:30 +00:00
christos
edc0c34588 Protect network ioctls from non-authorized users. (Ilja Van Sprundel) 2019-12-17 04:54:36 +00:00
tsutsui
1e72df6a03 Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
2019-12-15 16:48:25 +00:00
maya
3029dd4875 Don't assume mii is not null here. Some drivers like urndis don't use
mii, so they always have mii == NULL.

ok riastradh. fixes PR kern/54762
2019-12-14 15:40:43 +00:00
maxv
954f6141d7 Fix gross use-after-free. Found by a custom query on LGTM. 2019-12-13 14:10:32 +00:00
bouyer
79dd41fe30 reading usbdi.c it looks like usbd_get_config_descriptor() can actually
return NULL, so check for this.
I got NULL pointer dereference here with a device showing:
[   303.732632] ugen0: autoconfiguration error: setting configuration index 0 failed
2019-12-11 11:54:23 +00:00
maxv
8d129e6ebf localify 2019-12-06 07:12:38 +00:00
msaitoh
4f6b47a515 Remove SIOC[GS]IFMEDIA because ieee80211_ioctl() does the same thing. 2019-12-05 03:11:40 +00:00
riastradh
2a8e1ccd61 Fix inequality for refcnt drain: -1 here means all refs gone. 2019-12-03 05:01:58 +00:00
riastradh
ccd4e40866 Fix order of nulling un->un_pri->unp_ec.ec_mii.
Can't null it until after if_detach prevents further use.

While here, fix conditionals in usbnet_tick_task to use the unp_dying
flag, not the nullness of mii (or of ifp, which never null because
it's an embedded member).
2019-12-03 05:01:45 +00:00
mlelstv
b9aa28ee06 Don't deregister twice with pmf. 2019-12-01 21:02:09 +00:00
mlelstv
b9245c5465 Reset MCU ready status before resetting the MCU.
Fixes PR kern/54728
2019-12-01 21:01:19 +00:00
maxv
43e684e6ce minor adjustments, to avoid warnings on debug builds 2019-12-01 12:47:10 +00:00
maxv
97b908dcc6 localify 2019-12-01 08:23:09 +00:00
gson
3286e5198c Preserve the toggleCarry bit in the Endpoint Descriptor in
ohci_abort_xfer().  Fixes the OHCI part of PR kern/50278.
2019-11-29 14:15:41 +00:00
gson
1488c5045a Preserve the toggleCarry bit in the Endpoint Descriptor when handling
a DataUnderrun condition.  Fixes PR kern/54070.
2019-11-29 14:13:04 +00:00
maxv
28885f8e61 localify 2019-11-28 17:09:10 +00:00
gson
8b9242afb5 Change 0x%jx -> %#jx as suggested by christos. 2019-11-26 10:34:16 +00:00
gson
88b2e353f0 Convert debug printfs to usbhist. 2019-11-26 10:24:17 +00:00
maxv
0fd9b2db93 Not a bug strictly speaking, but compute the address only after the length
checks, for clarity and to appease kUBSan.
2019-11-17 11:28:48 +00:00
chs
d47bcd296c in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
2019-11-10 21:16:21 +00:00
mrg
3d9ffcffd7 add a note about ifnet lock vs usbnet locks. 2019-11-06 07:30:59 +00:00
isaki
3477e919b3 Use kmem_zalloc() instead of kmem_alloc() to initialize structure.
struct audio_format added a member since isaki-audio2.
Fix PR kern/54662 "uaudio sometimes not recognized".
2019-11-04 05:46:39 +00:00
maya
c52ff42a4c check if buf/bufsz are non-NULL before freeing.
not all control messages that can be received result in buf being
initialized, we might get a spurious different control message

seen in practice when swapping modes a few times on a urndis device

urndis0: SAMSUNG ...
autoconfiguration error: urndis0: invalid address
panic: kernel diagnostic assertion "p != NULL" failed: file "/cvs/src/sys/kern/subr_kmem.c", line 263
cpu0: Begin traceback...
vpanic() at netbsd:vpanic+0x178
kern_assert() at netbsd:kern_assert+0x48
kmem_intr_free() at netbsd:kmem_intr_free+0xca
urndis_attach() at netbsd:urndis_attach+0x4c2
2019-10-31 11:59:40 +00:00
maya
ac76aef9cb we want to check that the allocation is going to be zero, not whether
some pointer is NULL (oops).

Should be the right version this time!
2019-10-23 01:30:54 +00:00
maya
4ab0974ee9 Check if size is zero, too.
PR kern/53734
2019-10-23 01:03:36 +00:00
maya
0555c41502 Avoid kmem_alloc(0,..), which hits an assertion.
PR kern/53734: Prevent kernel panic during Wide Vision FHD Camera detection
2019-10-23 00:52:39 +00:00
bad
580b92a46f allocate a random mac address if on-chip mac is all zeroes.
helps ure(4) on NanoPi R1.

partly from ganbold@freebsd r346052.

XXX pullup-9
2019-10-16 13:11:16 +00:00
bad
8197ba699a read mac address of ure version 4c10 from URE_PLA_IDR, save as 4c00.
from ganbold@freebsd r346052.

XXX pullup-9
2019-10-16 13:02:51 +00:00
bad
6e08bf3e28 use ether_snprintf instead of open coding it. 2019-10-10 23:30:02 +00:00
mlelstv
d164e220a0 Merge more changes from FreeBSD/OpenBSD. My two run(4) devices now work
again.
2019-10-08 07:30:58 +00:00
skrll
dd2790e42c Avoid a warning 2019-10-07 09:37:16 +00:00
martin
6bac96dfb5 Regen 2019-10-06 17:23:05 +00:00
martin
d0ba02edad Add a few TP-Link "Archer" wlan devices 2019-10-06 17:22:29 +00:00
mrg
49e1839354 remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned.  codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
2019-10-05 23:27:20 +00:00
maxv
c3375309d2 Fix memory leaks. Was wondering where memory had gone after several hours
of attach/detach with vHCI.
2019-10-03 05:20:31 +00:00
maxv
6336c2341d More less kmem_zalloc(0). 2019-10-03 05:16:16 +00:00
maxv
1f5569dfbd Improvements:
- Don't process packets if the USB device is detached. Contrary to the
   other HCIs, vHCI has no timeout, so we never collect the pending
   packets, and must drop them synchronously.

 - Fix refcounting bug in vhci_device_ctrl_abort.

 - Implement vhci_activate.

 - Add a few KASSERTs.
2019-10-03 05:13:23 +00:00
chs
02991323a4 in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
2019-10-01 18:00:07 +00:00
christos
864734c343 subdevlen is an array length, make it unsigned 2019-09-26 01:35:08 +00:00
dsainty
8c74e515a9 Purge an ancient email address, use dsainty@NetBSD.org instead 2019-09-22 07:28:35 +00:00
mrg
fe950ae3d5 add mos(4) driver for Moschip MCS7730/MCS7830/MCS7832 usb ethernet.
ported from openbsd.  usbnet version loses about 40% of code.
2019-09-20 10:34:54 +00:00
maxv
a5267215ad Reset ud_pipe0 to NULL before calling usbd_setup_pipe_flags(). If the call
fails we call usbd_remove_device(), which tries to free ud_pipe0, but it
was already freed.

While here, add two sanity checks, to prevent possible surprises.
2019-09-15 09:24:38 +00:00
maxv
d74a36247d Add missing length checks on descriptors, to prevent buffer overflows.
Found via KASAN+vHCI. Some remain however, but it looks like the code
needs to be re-thought along the way, so it will be fixed later.
2019-09-15 09:21:36 +00:00
maxv
d076b30c4f Don't kmem_alloc(0) if there are no endpoints, otherwise panic. Found via
vHCI.
2019-09-15 09:18:17 +00:00
maxv
ce2468ca8f Fix error handling, to prevent kernel crashes at detach time. The code is
slightly reorganized. Found via vHCI.
2019-09-14 15:24:23 +00:00
maxv
ed42779f0f Fix NULL deref. Found by vHCI. 2019-09-14 15:22:31 +00:00
maxv
6b4d444809 Fix error handling, to prevent kernel crashes at detach time. Found by
vHCI.
2019-09-14 15:21:19 +00:00
maxv
d398d1820e Fix possible NULL deref. Found by vHCI. 2019-09-14 15:19:52 +00:00
maxv
c05f1b8fe0 Fix error handling, to prevent kernel crashes when detaching an upgt0
device.

Found with vHCI.
2019-09-14 12:53:24 +00:00
maxv
f1f5729782 Fix NULL deref, to prevent kernel crashes when detaching an udsbr0 device.
Found with vHCI.
2019-09-14 12:50:16 +00:00
maxv
146bab28ab Fix error handling, to prevent kernel crashes when detaching an ugensa0
device. Also move usbd_add_drv_event() down, after we are sure the attach
didn't fail.

Found with vHCI.
2019-09-14 12:48:51 +00:00
maxv
757acb6a07 Fix NULL deref, to prevent kernel crashes when detaching an uipaq0 device.
Found with vHCI.
2019-09-14 12:46:00 +00:00
maxv
db34b78164 Fix error handling, to prevent kernel crashes when detaching an ural0
device.

Found with vHCI.
2019-09-14 12:42:36 +00:00
maxv
a3a7006815 Fix error handling, to prevent kernel crashes when detaching an urio0
device.

Found with vHCI.
2019-09-14 12:41:32 +00:00
maxv
e11ff9627d Fix error handling, to prevent kernel crashes when detaching an urtw0
device. Also, fail safely if we didn't recognize the RF chip, to prevent
kernel crashes at attach time. Note that other panics are there, maybe
they also should be removed.

Found with vHCI.
2019-09-14 12:40:31 +00:00
maxv
ad99383a25 Fix error handling, to prevent kernel crashes when detaching an umcs0
device.

Found with vHCI.
2019-09-14 12:38:40 +00:00
maxv
04e3b21c77 Fix NULL derefs, to prevent kernel crashes when detaching an otus0 device.
Found with vHCI.
2019-09-14 12:37:34 +00:00
maxv
09bd92d610 Fix error handling, to prevent kernel crashes when detaching an athn0
device.

Found with vHCI.
2019-09-14 12:36:35 +00:00
maxv
1cd2167233 Fixes:
- Insert at the tail and not the head. I just noticed that the packets
   were in inverted order in the fifos when attaching a virtual urtw0.

 - Remove VHCI_DEBUG, which I mistakenly left enabled in rev1.
2019-09-14 12:32:08 +00:00
maxv
250ccf12c0 Add vHCI, a driver which allows to send and receive USB packets directly
from userland via /dev/vhci. Using this, it becomes possible to test and
fuzz the USB stack and all the USB drivers without having the associated
hardware.

The vHCI device has four ports independently addressable.

For each xfer on each port, we create two packets: a setup packet (which
indicates mostly the type of request) and a data packet (which contains
the raw data). These packets are processed by read and write operations
on /dev/vhci: userland poll-reads it to fetch usb_device_request_t
structures, and dispatches the requests depending on bRequest and
bmRequestType.

A few ioctls are available:

	VHCI_IOC_GET_INFO   - Get the current status
	VHCI_IOC_SET_PORT   - Choose a vHCI port
	VHCI_IOC_USB_ATTACH - Attach a USB device on the current port
	VHCI_IOC_USB_DETACH - Detach the USB device on the current port

vHCI has already allowed me to automatically find several bugs in the USB
stack and its drivers.
2019-09-14 06:57:51 +00:00
ryo
f59808c0b0 Support serial speeds up to 12mbaud with newer FTDI chips.
baudrate calculation code uftdi_encode_baudrate() from FreeBSD uftdi.c@r330385
2019-09-13 20:50:45 +00:00
msaitoh
70b25bc928 if_flags is neither int nor short. It's unsigned short. 2019-09-13 07:55:05 +00:00
msaitoh
3e4f0a1996 Make it compilable with UPL_DEBUG. 2019-09-13 07:47:39 +00:00
mrg
bcd7a20db0 document usbnet_private locking. minor knf. 2019-09-09 07:20:16 +00:00
mrg
e62002f7f2 normalise an error message. 2019-09-08 19:00:33 +00:00
mrg
0801a2c6b2 - use CALLARGS vs CALLED for better usbhist
- turn off usbnetdebug default
- log for all entry/exit points of usbnet_pipe_intr()
- in usbnet_start_locked() track whether any packet has been
  transmitted for setting the timer.  avoids spurious
  "watchdog timeouts"
- in usbnet_stop() use callout_halt() vs callout_halt, and
  also stop the usb task.  fixes crash of usbtask after the
  phy has detached.
- add a little more defensive checking in the tick task, and
  add some high-log-level logs.
- in usbnet_detach() move the call to usbnet_stop_ifp() above
  the calls to callout/usbtask stopping.
- set ec_mii and unp_pri to NULL when freeing their data
2019-09-08 18:59:32 +00:00
mrg
98772cd1fd avoid non-debug kernel build issues. 2019-09-08 18:58:38 +00:00
mrg
b5a7b981e4 fix ryzen usb issue: we set TD size to '1', where has xhci spec 4.11.2.4
says final TRB for a TD should have this set to '0'.  since we currently
only generate sinel TRB TDs, set this to 0.

XXX: pullup-all

from sc.dying
2019-09-07 22:56:47 +00:00
mrg
411a89fa06 fix 32-bit debug build, and also vmstat -y. reported by sc.dying. 2019-09-07 22:20:42 +00:00
mrg
7577d0518b don't try to set dying when we haven't usbnet_attach()d yet.
reported by maxv.
2019-08-30 05:59:17 +00:00
mrg
1b6af9ef42 fix a lock hang reported by sc.dying in PR#54495.
remove locking in usbnet_tick().  assume that all locking
needs are handled inside usbnet_tick_task(), which runs in
the usbtask thread.  ensure that usbnet private is valid
before using it.

also check NULL private pointer in usbnet_isdying().
all the other cases should never happen.
2019-08-29 09:17:51 +00:00
mrg
af73cd8177 s/no free/no freelist entry/ in a debug message. 2019-08-28 07:11:19 +00:00
mrg
b67634221b introduce and use XHCIHIST_CALLARGS(). reduces lots of double logs,
and includes useful info in all cases instead of just "called".

add a couple of more logs that i've wanted while debugging ryzen3
vs USB issues.
2019-08-28 07:09:52 +00:00
mrg
749ea25de9 in usbnet_detach(), check both that the private pointer has
been allocated and that unp_attached is true before trying
to access anything else.

fixes a detach problem noticed by maxv when, eg, the call
to usbd_set_config_no() fails and attach bails early.
2019-08-28 06:07:21 +00:00
mrg
e7ee04e67f add new usbd_do_request_len() that can allocate a larger than
request size buffer.  reimplement usbd_do_request_flags() in
terms of this.  use this for fetching string descriptors.

fixes a very strange problem where an axe(4) attaching (either
has ugen(4) or axe(4)) would ask for 2 bytes, usb_mem.c would
allocate a 2 byte fragment, perform the operation, and sometime
shortly afterwards (usually by the time the next allocation
is made for this fragment), would become corrupted (usually
two bytes were written with 0x0304.)

(initial request of 4 bytes also avoids the problem on this
device.  it really seems like a HC problem -- host should not
allow the device to write more than req.wLength!  nor should
it allow this write to happen after completion.)

avoid an (almost) always double-log in usbd_transfer().
2019-08-28 01:44:39 +00:00
maxv
6c06594c15 Fix bug, remove {0,0} because we switched to usb_lookup(). 2019-08-27 17:24:51 +00:00
rin
b12de7cf94 PR kern/54486
Revert workaround introduced in rev 1.94:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/if_axe.c#rev1.94

This is a problem specific to ARMv6+, and addressed by
arch/arm/conf/Makefile.arm rev 1.50:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/arm/conf/Makefile.arm#rev1.50

XXX
pullup netbsd-9
2019-08-26 17:26:33 +00:00
mrg
73b99555aa regen with new moschip/sitcom adapters. 2019-08-26 02:02:16 +00:00
mrg
8eaca76a17 add MosChip MCS7730 and Sitecom Europe LN030 ethernet adapters. 2019-08-26 02:01:18 +00:00
mrg
bbd2121cde don't try to deref a maybe-NULL pointer. instead of logging
potentially garbage (if not NULL), log the request length.
2019-08-24 07:43:00 +00:00
mrg
d2cd7b5a8e aue depends upon usbnet 2019-08-23 08:45:25 +00:00
mrg
1013e94b7f update the list of splusb drivers (it's grown unfortunately) and
explicitly state that they should be converted.
2019-08-23 07:29:29 +00:00
mrg
4167cbe574 avoid using old bsd types (u_int etc) so that this compiles with
_POSIX_C_SOURCE as noted in PR#48339.
2019-08-23 07:17:31 +00:00
mrg
e538cfe91b - remove items that are fixed (usually in the distant past)
- usbnet is (almost) done for non wifi
- non trivial usbdi documentation exists now
2019-08-23 07:13:03 +00:00
mrg
48d4f9a608 convert aue(4) to usbnet(9).
besides the not-enabled umb(4), this completes the conversion
of all the non-wifi usb network devices.
2019-08-23 04:34:51 +00:00
mrg
d8e1e46eab convert a debug message to an error message. will help more quickly
identify next time xhci version changes.
2019-08-23 04:34:01 +00:00
mrg
8352fa6550 s/UBSNET_MII_DECL_DEFAULT/USBNET_MII_DECL_DEFAULT/. from sc.dying. 2019-08-23 04:32:57 +00:00
mrg
543abf08ea - remove unused uncd_rx_cnt
- add USBNETHIST_CALLARGSN and use it in many places
- add more history logs
- add a log if watchdog abort leaves uncd_tx_cnt non zero
- add a unique (32-bit) number for a each usbnet device and
  use it for logging
- explicitly check for full tx ring in usbnet_start_locked()
  and return early, which avoids setting the 5 second timer
  and triggering a watchdog
- reset uncd_tx_prod and uncd_tx_cnt to zero in stop
2019-08-23 04:29:28 +00:00
mrg
d2638a5cd2 - move software parts into if_aue.c.
- s/Static/static/.
2019-08-22 09:16:08 +00:00
mrg
c7e750b5e0 fix more kernhist vs 32 bit issues. 2019-08-22 07:38:06 +00:00
mrg
c92aec79da like most things: turn debug off by default, sysctl to enable 2019-08-22 00:25:18 +00:00
mrg
de0a3ab576 usbhist(9):
- add a USBHIST_CALLARGSN() that only prints the message if debug level is N

aue(4):
- switch from printf() to usbhist for debugging
2019-08-22 00:24:07 +00:00
mrg
52a4543a10 convert pairs of USBHIST_CALLED()+USBHIST_LOG*() into
USBHIST_CALLARGS() calls.  this reduces the number of
kernel history lines consumed by these callers, and
for the +LOGN versions, add useful log info to a
message that just says "called!".

reduces the line spam which means the total info in a
full log is significantly increased.
2019-08-21 10:48:37 +00:00
mrg
e95f086a6d match xhci version 3.10. allows properly finding all the USB
busses on new ryzen 3 based systems.

unfortunately, the USB busses are still non-functional.
2019-08-21 06:19:43 +00:00
skrll
bf124cc4a9 typo in error message 2019-08-20 12:40:18 +00:00
mrg
65dae9683e couple more changes to usbnet(9):
- MII read/write reg return int instead of usbd_status (requested by skrll)
- usbnet_attach_ifp(9) changes arg, two mii-specific flags are placed by a
  pointer to new struct usbnet_mii.  if not NULL, then attach an MII to this
  interface like previous have_mii parameter.  use this to allow ure(4) to
  properly pass PHY location to mii_attach().

welcome netbsd 9.99.10.
2019-08-20 06:37:06 +00:00
mrg
dd6018f574 properly fix the kernhist calls.
one must cast and cast and cast and maybe a fish will be caught...
2019-08-20 06:18:54 +00:00
mrg
26347c3def axe, udav, url, cue, kue, smsc, udav[*], upl, url and urdnis
are now all ported to usbmp and mpsafe interfaces, and have
all been tested too.

[*] udav has an issue with usbnet port for some devices.
2019-08-19 08:07:55 +00:00
mrg
43e0dcd183 move the check against un_phyno from usbnet back into the drivers
that do this (axe, axen, mue, smsc, ure.)  it made mii scanning
only work for phy 0, and aue needs it for at least one device.

fix smsc to return usbd_status not -1 on failure.  XXX smsc was
writing to '*val' even in error cases, it does not now.

remove a double call to IFQ_SET_READY() (noticed by chuq).

avoid unlock+instant relock by using usbnet_lock_mii_un_locked().
2019-08-19 07:33:37 +00:00
mrg
6134657d6b move the call to rnd_attach_source() earlier and add a matching
call to rnd_detach_source() into detach.

fixes an attach-detach-reattach issue where the rnd source was
already known.
2019-08-19 07:20:07 +00:00
mrg
9e4638357c add USBHIST_CALLARGS() frontend to KERNHIST_CALLARGS().
add USBNETHIST_CALLARGS() frontend to USBHIST_CALLARGS().

use both in read/write reg, instead of aprint.

use %jx and (uintptr_t) and fix the 32 bit debug build.
2019-08-19 06:35:14 +00:00
mrg
5346b6bc69 regen and add kue adapters:
ACTIONTEC KL5KUSB101 USB Ethernet adapter
ALLIEDTELESYN AT-USB10 USB Ethernet Adapter
SILICOM Psion Gold Port Ethernet (existing usbdevs entry)
2019-08-18 11:46:38 +00:00
mrg
d756f89bf3 add two kue(4) adapters:
ACTIONTEC KL5KUSB101 USB Ethernet adapter
ALLIEDTELESYN AT-USB10 USB Ethernet Adapter
2019-08-18 11:45:23 +00:00
mrg
31a1e537ff fix a think-o in the previous: don't return when saving the first error.
from skrll@.
2019-08-18 09:46:58 +00:00
mrg
be798422ee update usbnet slight:
- drivers that want to use if_input() will also set _if_input.  for
  now, avoid attaching a per-cpu queue for them.  use if_initialize()
  and if_register().
- when stopping pipes, don't give up after the first failure, but
  keep the first failure error for return and keep going
- if 0 a KASSERT() in usbnet_init_rx_tx().  there's a path via
  if_mcast_op() that can have the ifnet unlocked today..
- in usbnet_watchdog(), abort the pipe instead of faking tx
  completion.  avoids issues with devices with more than one tx
  descriptor, as well as avoiding triggering usb asserts.

with these, upl(4) port to usbnet(9) now works.  (would be a version
bump, but upl(4) and the unported umb(4) are the only consumers that
would care.)
2019-08-18 09:29:38 +00:00
mrg
017f58c1c0 regen for new upl(3) devices. 2019-08-18 09:05:49 +00:00
mrg
bc015ef7d0 add 3 devices for upl(4) host-to-host networking:
- belkin F5U258
- national instruments USB host to host adapter
- prolific id 25a1
2019-08-18 09:05:31 +00:00
mrg
3e0a07ba5e usbnet_ifp() doesn't work before usbnet_attach(). avoid it. 2019-08-18 08:16:34 +00:00
mrg
9d146cdb5b kue now depends upon usbnet. 2019-08-16 08:52:46 +00:00
mrg
2a27f0ae08 port kue(4) to usbnet(9). interesting notes:
- move KUE_RXFILT_PROMISC setting into kue_setiff() from kue_init()
  to avoid multiple setting KUE_CMD_SET_PKT_FILTER reg multiple times
- software-only constructs moved from if_kuereg.h into if_kue.c
- kue is the first (umb(4) will need it to, i think) to have its own
  autoconf detach routine remain
- un_tx_xfer_flags is 0 here, not USBD_FORCE_SHORT_XFER
- fix a potential data exposure (but probably not without a USB
  protocol tap).  kue needs the transfers to be 64-byte aligned, and
  while i doubt it sends more than the frame provided, were sending
  random kernel data (whatever was the 0-63 bytes to alignment) to
  the device.

diffstat says:
2 files changed, 189 insertions(+), 739 deletions(-)
2019-08-16 08:51:09 +00:00
mrg
305fe6fd7f internal to usbnet:
add buflen param to usbnet_newbuf().  use this to skip allocating
an mbuf cluster for small packets (ported from kue(4).)

remove usbnet_rx_start_pipes()'s always usbnet_rxeof argument.
2019-08-16 08:38:21 +00:00
mrg
10dd824698 make the default debug level zero. 2019-08-16 08:29:20 +00:00
mrg
d1509fdd73 port cue(4), mue(4) and url(4) to usbnet(9). diffstat says:
8 files changed, 911 insertions(+), 3087 deletions(-)
2019-08-15 08:02:32 +00:00
mrg
f2c22b6b6e - usbnet_rx_loop_cb's usbd_xfer parameter is never used and available
in the usbnet_chain if needed.  remove it
- usbnet media status change already set link to false, don't repeat
  this in every driver
- don't clear link in stop, nothing was re-enabling it for non-MII
- add optional uno_tick_cb(struct usbnet *un) that is called from the
  usbnet tick timer
- remove wrong debug sysctl prototype

rx_loop and timer are kernel versions changes, but hopefully this is
the last one for usbnet.  working with 3 more drivers now (cue, mue
and url), leaving only aue, kue, upl and umb undone (aue may work
with previously supported devices, mine doesn't work with our driver,
kue and upl have patches for testing and umb is undone.)
2019-08-15 05:52:23 +00:00
mrg
f1e87e99ec introduce usbnet_set_dying(). will be used by url(4) conversion.
bump version.

introduce USBNET_MODULE() that encompasses almost all the module
specific code for usbnet modules.  they still need to include
the relevant ioconf.c, but everything else is now just, eg,

	USBNET_MODULE(axen)
2019-08-14 03:44:58 +00:00
skrll
34523e0b29 Trailing whitespace 2019-08-12 08:52:39 +00:00
skrll
56c14853c7 Fix an unused register field define 2019-08-12 08:40:09 +00:00
mrg
c9e9d49af6 don't set dv_private. it's a bad pattern and only didn't
trip kmem_free() lossage because struct usbnet is at the
start of the softc.

for now, enforce this as part of the ABI.

catch up urndis with tx_prepare checking buffer length,
and also add an assert to usbnet_start_locked() to match.
2019-08-11 23:55:43 +00:00
mrg
662413259f relax an assert to be mutex_owned || polling.
half of the patch i sent for netbsd-8 in PR#54331.
the other half is already applied.
2019-08-11 22:55:03 +00:00
hannken
afc093924a urndis_attach: change "sc->sc_bulkout_no" to "un->un_ed[USBNET_ENDPT_TX]"
in DPRINTF().

Kernels ALL/amd64 and ALL/i386 compile again.
2019-08-11 13:16:10 +00:00
skrll
3463df1c95 Fix and improve USMSC_DEBUG 2019-08-11 12:16:59 +00:00
skrll
e2e66b347c Convert smsc_dbg_printf to usbhist 2019-08-11 11:17:35 +00:00
skrll
a4d5367342 Appease module build 2019-08-11 08:56:53 +00:00
skrll
c0fc7198ff Correct the length of the buffer to copy into the mbuf. Spotted by
sc dying.
2019-08-11 07:58:16 +00:00
skrll
4f5cfaedc9 G/C 2019-08-11 07:12:08 +00:00
skrll
48384726d0 Add a check in smsc_tx_prepare for the mbuf being too big. Discussed
with mrg@
2019-08-11 06:54:14 +00:00
mrg
70dcdf5643 void -Wsign-compare issue and add a stupid cast.
revert this if m_pkthdr.len becomes unsigned.
2019-08-11 05:14:41 +00:00
mrg
32428abeb6 copy a pattern from if_udav.c, which already had "too much" check.
even though overflow or underflow is really unlikely here, reorder
various expressions to reduce the likelyhood even further.
2019-08-11 02:37:03 +00:00
mrg
b28f903426 - use usbnet_isowned*() more
- more const
2019-08-11 01:31:19 +00:00
mrg
d15f8e912e adjust some comments to reality. 2019-08-11 01:29:45 +00:00
mrg
97f70a3c6e in tx_prepare callback make sure to reject any mbuf that is larger
than can fit in the buffer.  done at the driver and not usbnet
layer because the driver knows how much beyond the mbuf data needs
to be sent (headers and trailers.)

axen(4) had a KASSERT() for this condition, but there's no
invariant here we can check so it's best as an error return.

XXX: only tested on these drivers, needs to be copied to udav, smsc
and urndis after testing as well as the not commited conversions.
2019-08-11 01:04:33 +00:00
yhardy
2873e725d2 Initialize tcpalib for ums devices.
In r1.3 of src/sys/dev/hid/hidms.c, tpcalib is used for any hidms
device reporting absolute coordinates. So ums devices reporting
absolute coordinates also need to initialize tcpalib - do it for
all ums devices. An uninitialized tcpalib stops a mouse with
absolute coordinates from "moving".

OK: ryoon@
2019-08-10 06:30:26 +00:00
mrg
67ffe18e15 add a blank line after rcsid(s) 2019-08-10 02:32:27 +00:00
mrg
dbbc1953bd reduce the scope of struct usbnet:
- move a large number of members internal to usbnet.c's new
  "struct usbnet_private".
- provide accessors for a few of these
- move struct usbnet_cdata into usbnet.c as well, but move
  bufsz, list count, and xfer flags back out into struct usbnet,
  and have them set as part of the setup efore usbnet_attach()
- split the intr pipe parts into their own structure
- move all the main usbnet*lock* code into usbnet.c too

usbnet_attach() goes down to 2 args, and the inputs needed are
now the full contents of 'struct usbnet' besides the driver
owned 'un_flags' and usbnet owned 'un_pri'.

welcome netbsd 9.99.6.
2019-08-10 02:17:36 +00:00
skrll
1dfe9d1aec G/C 2019-08-09 07:54:05 +00:00
mrg
f344de3eff missed commit should be paired with if_ure.c 1.20. 2019-08-09 06:46:35 +00:00
mrg
4cae2f1ab5 switch to usbnet as softc, using un_flags. 2019-08-09 06:44:42 +00:00
mrg
4f807ebda6 switch urndis(4) to usbnet. thanks to maya@ for testing and helping
fix the few issues in the conversion.
2019-08-09 06:38:39 +00:00
mrg
b3b45ca053 update ethernet driver notes: mark udav as done, and every thing
except umb(4) as patch available, with urndis probably working
(need to test the latest change before being commited.)

still need testers for:  aue, cue, kue, mue, upl and url.
no umb patch yet.
2019-08-09 02:56:51 +00:00
mrg
e4ce9137e1 use new un_flags member of usbnet:
- axen(4) and cdce(4) are now able to use struct usbnet directly
  as softc, udav also done but untested
2019-08-09 02:52:59 +00:00
mrg
1c9a69203e ride 9.99.5 bump: add un_flags here. many of the softc's only have
a flags member to control device-specific issues, and this means
they can use "struct usbnet" as their softc directly.
2019-08-09 02:14:35 +00:00
mrg
d066f229b9 update usbnet some:
- move rx/tx xfer flags into usbnet_cdata
- move the callbacks into usbnet_ops structure
- move rx/tx xfer flags arguments from usbnet_init_rx_tx()
  and move them all into usbnet_attach() arguments
- s/miibus/mii/ in some places for consistency

other clean up:
- create wrapper functions for callbacks, move knowledge about
  special handling (OK to be missing, error eating) there.
- use cdata pointer if already available
- provide some more macros (will be real functions later) for
  accessing usbnet members, use existing ones more

bump kernel version.
2019-08-09 01:17:33 +00:00
mrg
52faf1b92d fix arm64 build (new le32toh() call needs sys/endian.h which is
probably include by some other header on amd64?)
2019-08-08 18:03:40 +00:00
maya
fcd2c8f203 Teach urndis to handle some REMOTE_NDIS_INDICATE_STATUS_MSG. If the status
is reasonable, don't tell userland we got an error. Stops spurious EIO.
From openbsd.
2019-08-08 06:16:39 +00:00
macallan
b584b574ef match USB_PRODUCT_SAMSUNG_ANDROID too
now this works with my Galaxy S8 active
2019-08-07 22:26:28 +00:00
skrll
190517fa68 Compare against 0 for missing endpoint. From mrg@ 2019-08-07 20:34:12 +00:00
skrll
8339293720 Convert udav(4) to usbnet. Based on a diff from mrg@ 2019-08-07 19:21:48 +00:00
maya
da40c6df90 Don't tell userland about ENETRESET even if a usbnet driver didn't define
un_ioctl_cb.
2019-08-07 10:01:05 +00:00
maxv
c31afa7698 Introduce USB_DESCRIPTOR_SIZE (3), and fix two bugs:
1) In usbd_find_idesc(), make sure the tables we're reading fit in the
    allocated buffer, otherwise small overflow (seen on KASAN, with
    bLength=1).
 2) Modify usbd_find_edesc(), to fix the same issues as 1).

ok mrg@
2019-08-07 08:47:09 +00:00
mrg
a0c32f13c5 fix module build: s/axen/smsc/ in one place. 2019-08-07 08:16:24 +00:00
skrll
291a5bb322 Trailing whitespace 2019-08-07 07:25:50 +00:00
skrll
2957315885 usmsc needs usbnet 2019-08-07 07:25:09 +00:00
skrll
e47b6af5fd Note that smsc(4) is done 2019-08-07 07:08:02 +00:00
skrll
3466ca851a Convert smsc(4) to usbnet 2019-08-07 07:05:54 +00:00
msaitoh
9f16390b43 Fix panic when setting multicast addresses. Write the hash table outside of
ETHER_LOC()/ETHER_UNLOCK().
2019-08-07 06:31:03 +00:00
mrg
f3e2d55b17 fix two issues, found by maya@ while testing urndis:
- avoid an KASSERT() in usbnet_rx_tx_init() when called early
- move the pmf and usb driver event calls out of the mii specific code,
  now suspend is able to work on them again.

urndis port to usbnet works with additional ipv6 lossage that
may indicate it doesn't work (not commited yet.)
2019-08-07 01:47:18 +00:00
pgoyette
97b627eca5 Many years ago someone created a new __link_set_sysctl_funcs to hold
the list of routines that need to be called for setting up sysctl
variables.  This worked great for all code included in the kernel
itself, but didn't deal with modules that want to create their own
sysctl data.  So, we ended up with a lot of #ifdef _MODULE blocks
so modules could explicitly call their setup functions when loaded
as non-built-in modules.

So today, we complete the task that was started so many years ago.

When modules are loaded, after we've called xxx_modcmd(INIT...) we
check if the module contains its own __link_set_sysctl_funcs, and
if so we call the functions listed.  We add a struct sysctllog member
to the struct module so we can call sysctl_teardown() when the module
gets unloaded.  (The sequence of events ensures that the sysctl stuff
doesn't get created until the rest of the module's init code does any
required memory allocation.)

So, no more need to explicitly call the sysctl setup routines when
built as a loadable module.
2019-08-07 00:38:01 +00:00
mrg
fd4f65184c mark axe(4) and ure(4) as needing usbnet 2019-08-06 01:44:24 +00:00
mrg
599c0927d8 for ethernet usb network devices, print the mac addr in usbnet. 2019-08-06 01:42:22 +00:00
mrg
76b0c5e318 extend usbnet to cope with if_upl, if_smsc, and if_umb needs:
- usbnet_enqueue() can set mbuf flags and csum_data
- usbnet_input() for non-ethernet based devices (upl, umb)
- allow a complete override for ioctl()
- remove converted list -- we have compiling and/or working patches for
  all the devices except for umb(4), will be merged as testing happens

hopefully this is the last ABI change, though  it may end up being
extended for additional smsc(4)  support.


hello for real netbsd 9.99.3!
2019-08-06 00:19:57 +00:00
skrll
61aabaa0fe Typo in error message 2019-08-05 07:03:55 +00:00
mrg
916d2ae82c move / re-add some headers to fix INET6 builds. 2019-08-04 18:04:18 +00:00
mrg
c564f35f60 add a list of done/todo items to the shared ethernet driver code. 2019-08-04 09:10:48 +00:00
mrg
20f8866f0d convert axe(4) and ure(4) to usbnet.
axe loses 838 lines (37%) and ure loses 716 lines (36%).
2019-08-04 09:03:46 +00:00
mrg
fa8dd7eff9 - adjust usbnet interface to allow usbd_open_pipe_intr(), from the
new comment:
	 * if un_intr_buf is not NULL, use usbd_open_pipe_intr() not
	 * usbd_open_pipe() for USBNET_ENDPT_INTR, with this buffer,
	 * size, and interval.
  the standard handling is in usbnet.c, with a callback to deal with
  the interrupt it self.  not fully tested, designed for if_aue.c
  and a few others not yet converted.
- make usbhist for usbnet.c work, thanks paulg
- usbnet_init_rx_tx() clears out all allocations upon failure now
- add usbnet_ec() to get a pointer to the struct ethercom
- add usbnet_{lock,unlock,owned}*() to lock/unlock the various locks
  and *owned*() for asserting

welcome 9.99.3!
2019-08-04 08:59:13 +00:00
skrll
a51c6b3a0b Trailing white space 2019-08-03 15:58:14 +00:00
mrg
c0b6c00c71 fix locking botch. 2019-08-01 01:19:21 +00:00
mrg
9c80f1e403 remove unused code and use common ethernet media code where equivalent. 2019-08-01 00:10:22 +00:00
mrg
699d292a9e couple of minor API updates:
- change the read/write register callbacks to have the same phy/reg
  order as the MII code.
- add "mii_flags" param to usbnet_attach_ifp().  axe(4) wants it.

also:
- add usbnet debug code, sysctl node support
- remove commented DPRINTF()s accidentally left in place
- add usbnet_softc()
- reorder some attach code to be consistent
- re-add USBD_FORCE_SHORT_XFER for axen rx chain

ride 9.99.2 bump.
2019-07-31 23:47:16 +00:00
maxv
1815c58abf 1) Make sure we have a complete endpoint descriptor header, otherwise
small overflow.
 2) Make sure the total length of the bos descriptor did not change in
    the meantime, otherwise severe memory corruption.
 3) Make sure we have a complete hid descriptor header, otherwise
    small overflow.
 4) Error out if the report descriptor is zero-sized, otherwise panic.

ok skrll@ mrg@
2019-07-31 19:40:59 +00:00
mrg
c74543b01d if_axe.c has been updated for modern times. 2019-07-31 11:02:49 +00:00
martin
903a5bce38 Make cdce depend on usbnet too 2019-07-31 10:19:55 +00:00
mrg
773ec77d3f introduce a library of common code / backends to share code between
USB ethernet drivers.

usbnet.h introduces a new set of APIs to provide common solutions
for these driver features:
 - USB endpoint pipe handling
 - rx and tx chain handling
 - generic handlers or support for several struct ifnet callbacks
 - MII bus locking
 - interrupt handling
 - partial autoconf handling: much of attach, and detach/activate
   can use common versions directly.

currently, only axen(4) and cdce(4) are converted.  the reductions
in these drivers are quite significant:  if_cdce.c is reduced from
1000 lines to 320 lines, and if_axen is reduced from 1902 lines
to 1021 lines.

add a "usbnet" module and make the if_axen module depend upon it.
2019-07-31 09:13:16 +00:00
skrll
ac2f821175 Whitespace 2019-07-30 06:35:03 +00:00
msaitoh
7f827af857 Avoid undefined behavior. Found by KUBSan. 2019-07-25 14:31:35 +00:00
msaitoh
dc6d79c511 Use unsigned (RAL_RF_BUSY). Found by KUBSan. 2019-07-25 11:10:38 +00:00
maxv
ec49b45e02 1) If the descriptor length is bigger than the USB string descriptor
itself, error out. Otherwise there is a small overflow (seen on KASAN,
    with bLength=255).
 2) Make sure we have a config descriptor header, otherwise there are small
    overflows (seen on KASAN, with wTotalLength=1).
 3) Once we have the complete config descriptor, make sure its size didn't
    change in the meantime. Otherwise there could be severe overflows.
 4) Make sure we have a bos descriptor header, otherwise overflow, same
    as 2).

ok mrg@ skrll@
2019-07-23 17:21:33 +00:00
skrll
c9e2a29280 KNF (from nhusb) 2019-07-22 06:24:57 +00:00
mrg
b2e4dc91f2 remove unused structure members. this brings most <foo>_chain and
<foo>_cdata structures into being identical for usb ethernet drivers.

upl(4) and url(4) need more work.
2019-07-21 10:27:56 +00:00
mrg
3cab9eef29 remove unused axe_accum and axe_idx members of struct axe_chain. 2019-07-21 09:38:28 +00:00
mrg
498e2674f8 revert previous. meant to delete that change... 2019-07-19 04:18:49 +00:00
mrg
3011319df8 call ure_stop_locked(), not ure_stop(), from ure_init_locked() to
avoid locking botch.  fixes assert reported by sc.dying.
2019-07-19 04:17:34 +00:00
mrg
d5d7d88468 adjust axe(4) similar to recent axen(4)/cdce(4)/ure(4) updates
(which were in turn partly based upon smsc(4) changes):
- mark network interface MPSAFE, and use MPSAFE calls
- convert to local tick task doing watchdog timeout
- add global, tx and rx locks
- add ratelimited tx error message
- split many functions into locked/unlocked version
- use more const
- fix some comments
- remove spl
- don't bother with OACTIVE and do it all internally (axe_tx_cnt)

additional changes here:
- use axe_stop() to abort pipes in detach

fixes a crash potential i only saw when almost finished debugging
these changes..
2019-07-15 06:40:21 +00:00
mrg
5c5367623b minor white space adjustments. 2019-07-15 03:14:22 +00:00
mrg
1fec062d90 move software parts out of the "reg" header. 2019-07-14 21:37:09 +00:00
maxv
40a1f4cc30 Revert previous, for now. 2019-07-06 08:00:19 +00:00
maxv
da12cb8442 Fix two length checks, otherwise a malicious USB key plugged in the
system could trigger overflows, seen with KASAN.
2019-07-06 05:05:53 +00:00
mrg
876d8a5d2c remove a few items that are done, and mark a few others as working
since i've personally tested.  most in the "drivers testing" i think
are working now since it's been a few releases and we've had minor
bug reports in them fixed, this list was rarely updated.
2019-06-30 22:19:55 +00:00
skrll
ad07d16c7a Remove an item that doesn't need to happen 2019-06-29 07:47:41 +00:00
skrll
fce290c58b Whitespace 2019-06-29 07:46:19 +00:00
mrg
05bd368781 more smp cleanup for ure(4)/axen(4)/cdce(4):
- convert IFF_ALLMULTI to ETHER_F_ALLMULTI, using ETHER_LOCK()
- remove IFF_OACTIVE use, and simply check the ring count in start
- assert/take more locks
- XXX: IFF_RUNNING is not properly protected (all driver problem)
- fix axen_timer setting so it actually runs
- document a locking issue in stop callback:
  stop is called with the softc lock held, but the lock order
  in all other places is ifnet -> softc -> rx -> tx, so taking
  ifnet lock when softc lock is held would be problematic
- in rxeof check for stopping/dying more often.  i managed to
  trigger a pagefault in cdce_rxeof() when yanking an active
  device as it attempted to usbd_setup_xfer() on closed pipes.
- add missing USBD_MPSAFE and cdce_stopping resetting for cdce(4)

between this and other recent clean ups increase performance of
these drivers mostly.  some numbers (in mbit/sec):

	old:				new:
driver	in	out	in+out		in	out	in+out
----	--	---     ------		--	---	------
cdce	39	32	44		38	33	54
axen	44	34	45		48	37	42
ure	36	34	35		36	38	38

i'm not sure why axen drops a little with in+out.  cdce is
helped quite a lot, and ure a little.  it is disappointing that
ure does not outperform cdce -- it's the same actual hardware,
and the device-specific (ure) should outperform the generic
cdce driver...
2019-06-28 01:57:43 +00:00
khorben
b326a3f950 Fix typos
Some were found by OpenBSD.
2019-06-26 22:58:58 +00:00
mrg
e1da3e4964 actually set ure_stopping, and don't follow it in init.
pointed out by sc.dying on source-changes-d.  thanks.
2019-06-24 04:42:06 +00:00
mrg
aefaaa77aa make cdce(4) and ure(4) usb and mpsafe:
- introduce locking ala smsc(4)/axen(4) style
- convert to mpsafe interfaces
- add tick task to cdce(4) to deal with missing watchdog, and
  actually make the watchdog do something
- convert DELAY() to usbd_delay_ms() in cdce(4) and don't increase
  the time in a potentially unbounded way
- remove spl calls

tested with network cable and usb adapter pullouts, reboots and
many many GBs of data transferred in either direction under load.
2019-06-23 02:14:14 +00:00
mrg
e914d846e5 wrap axen_iff() with axen_iff_locked().
add a missing lock exit in error path.
2019-06-22 10:58:39 +00:00
mrg
7c1f464615 mark this driver MPSAFE for usb tasks and pipes, if(4), and callouts.
remove remaining redundant spl calls.
2019-06-22 09:53:56 +00:00
mrg
ed56fb496f re-apply rev 1.44 with a minor bug fix in axen_tick_task().
it introduced a problem when there wasn't a reasonaly constant
stream of incoming packets, and i had a 'nttcp' running against
my test machine constantly, avoiding the bug.
2019-06-22 08:09:08 +00:00
mrg
d1e6396a98 revert the previous.
i'm fairly postive i tested it, as i tested enabing mpsafe version
on top of this successfully.  however, something happened mid-ssh
with a kernel with mpsafe and my session hung, and since then i've
been unable to boot kernels with the previous revision applied.
2019-06-22 07:17:13 +00:00
mrg
44e76680c9 s/Static/static/ 2019-06-22 04:45:04 +00:00
mrg
2ec2d544e1 move the software-only parts of cdce(4) out of if_cdcereg.h.
(if_cdcereg.h probably can go entirely.  it's almost empty,
but at least these definitions have some relationship with
the hardware bits.)
2019-06-22 04:35:46 +00:00
mrg
c2c0fad7d4 fix issues seen with transfers being reused before they are finished
being used.

adapt locking to the modern world.  some what inspired by if_smsc.c:
- add locks for softc, rx and tx
- add safe detach support
- safe detach vs mii lock requires 2 methods to lock the MII lock,
- check axen_dying and new axen_stopping more often
- consolidate checks to reduce the number of error paths that need
  to release a resource
- move axen_watchdog() out of if_timer into the tick task to
  prepare for MPSAFEification

TODO:
- remove spl usage
- enable mpsafe

special thanks to skrll and mlelstv for clearing up various
confusion and providing examples.
2019-06-21 14:19:46 +00:00
mrg
2fc98dfbe9 minor clean up, almost NFCI:
- use const, __func__, more
- axen_mii_lock is a normal mutex not rwlock, and make sure it's
  properly cleaned up for failed attach
- check axen_dying in axen_miibus_statchg()
- rename axen_ax88179_eeprom() to axen_get_eaddr() and move the code
  here into the support the current method.
- adjust some comments
2019-06-20 10:46:24 +00:00
jmcneill
dcbe944a80 HCSPARAMS2.SPR is bit 26, not 24 2019-06-19 15:10:17 +00:00
mrg
14c9b3f922 move struct axen_chain, struct axen_cdata, struct axen_softc,
struct axen_type, sc_if, GET_MII(), and GET_IFP() -- all the
software defined components from if_axenreg.h into if_axen.c.
2019-06-18 09:34:57 +00:00
christos
e591ea4973 Always increment, not just if we are queueing. 2019-06-16 21:04:08 +00:00
christos
c5af173f90 PR/54297: sc dying: opacket of ure(4) is always 0 2019-06-16 14:47:49 +00:00
msaitoh
21fb8e23a8 Add rnd(9) support. 2019-06-15 04:00:17 +00:00
maxv
ce2bdbd5cf Random style in ehci, also KM_SLEEP does not fail. 2019-06-13 17:20:25 +00:00
mrg
2e7079bce8 rearrange some parts of attach/detach to avoid partial-attach
leading to detach crash.
2019-06-09 13:35:47 +00:00
isaki
9ab905f56c Return correct properties.
It fixes PR kern/54264.
XXX I'm not sure all bidirectional uaudio devices support FULLDUPLEX
    or INDEPENDENT.
2019-06-06 12:59:33 +00:00
msaitoh
ae89e82305 Fix typo (s/recevie/receive/). 2019-06-04 10:15:22 +00:00
msaitoh
0f058a96bb Fix the detach path to prevent panic:
- Fix athn_usb_free_tx_list(). usc->usc_tx_bcn->xfer is freed in the above
   for () loop, so remove the if block. OK'd by skrll.
 - Add missing athn_usb_free_tx_msg().
 - Add missing athn_usb_stop().
2019-06-03 09:58:31 +00:00