Commit Graph

41 Commits

Author SHA1 Message Date
martin
89e3596f3d Better bounds checking for oversized packets, to avoid kernel memory
corruption. Pointed out by Ilja Van Sprundel.
2020-06-11 09:56:57 +00:00
gson
c2d905cb60 Conditionally enable the formerly #if'ed-out code to use the
WRITE_REGION_1 command for writing blocks of data to the device.
This is to address a performance issue where "ifconfig run0 up" would
take as long as 20-30 seconds when using a UHCI or OHCI host
controller due to the large number of control transfers performed by
the driver in combination with the inability of those host controllers
to perform multiple control transfers per USB frame.  Limit the
transfers to 64 bytes as in the corresponding #if'ed-out code in
FreeBSD.  Currently only enabled for mac_ver 0x5390 as it is the only
version tested so far.
2020-06-06 13:53:43 +00:00
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
mlelstv
90e85cec6c Avoid race condition. Patch from bouyer@ 2020-01-04 22:30:06 +00:00
gson
52f0ad4e7d Code that's #if'ed out still ought to compile. 2019-12-19 15:17:30 +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
26ee7ba1a4 KNF 2019-01-22 06:46:21 +00:00
jakllsch
1d5cb2a3a0 Correct abuses of aprint_error_dev(9). 2018-11-29 18:53:42 +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
080b2b0b4a Use callout_halt and usb_rem_task_wait in run(4) detach. 2018-07-29 02:01:22 +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
maxv
ef29464208 Replace ovbcopy -> memmove, same. 2018-02-01 16:49:34 +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
skrll
d42627d4ac Use a #define instead of a magic number 2017-11-17 13:08:48 +00:00
skrll
ff1dbb860a Trailing whitespace 2017-11-17 12:55:16 +00:00
hauke
2c1adfbe92 Recognize the Ralink RT5370 adapter. It has been in usbdevs for a while. 2017-05-04 14:07:34 +00:00
skrll
a7c71d30d6 +#include "opt_usb.h" 2016-11-25 12:56:29 +00:00
mlelstv
8f96d6f598 Ignore completed transfers when detaching. This avoids a race condition
where the detach code has already freed the xfer structures.
2016-10-01 11:09:12 +00:00
mlelstv
4420de0cb1 Use pointer passed as argument. This is not really a change as
data->xfer is supposed to be the same.
2016-10-01 11:07:30 +00:00
mlelstv
da8283ba36 Use splusb() like the other drivers instead of splnet(). 2016-10-01 07:23:40 +00:00
mlelstv
60767f1d18 mcs is a 16bit value. 2016-10-01 07:21:45 +00:00
mlelstv
faca41fb2b Merge enough FreeBSD code to make RT5592 work. 2016-09-16 09:25:30 +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
nonaka
b2901b1b91 Add pmf hooks. 2015-03-13 15:33:04 +00:00
martin
8317b16e13 Quell maybe-uninitialized false positives from gcc 4.8 2014-01-28 13:08:13 +00:00
christos
89f5489ab3 replace macro with inline function 2013-03-30 03:17:33 +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
christos
eadcae412c remove duplicated QoS definitions 2012-08-20 07:32:49 +00:00
nonaka
c9051a9fd6 Use /libdata/firmware/run instead of /libdata/firmware/rum for run(4) firmwares. 2012-06-01 13:19:38 +00:00
nonaka
6a9737b9fa Add a dependency on bpf module. 2012-06-01 12:38:25 +00:00
nonaka
9cdb1c70e5 Add a driver for Ralink Technology RT2700U/RT2800U/RT3000U USB IEEE
802.11a/b/g/n wireless network devices, ported from OpenBSD by FUKAUMI Naoki,
arranged by me.
2012-05-30 14:30:32 +00:00