Commit Graph

4097 Commits

Author SHA1 Message Date
Gleb Smirnoff
41840e2dab Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:30:30 +00:00
Gleb Smirnoff
100ad729c5 Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:30:06 +00:00
Gleb Smirnoff
0a738e4d65 Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:29:50 +00:00
Gleb Smirnoff
ae928424f1 Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:29:32 +00:00
Gleb Smirnoff
a433f711bb Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:29:14 +00:00
Gleb Smirnoff
9c601934f6 Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:26:53 +00:00
Gleb Smirnoff
3e7e87441c Convert to if_foreach_llmaddr() KPI.
Reviewed by:	hselasky
2019-10-14 20:26:17 +00:00
Gleb Smirnoff
b8a6e03fac Widen NET_EPOCH coverage.
When epoch(9) was introduced to network stack, it was basically
dropped in place of existing locking, which was mutexes and
rwlocks. For the sake of performance mutex covered areas were
as small as possible, so became epoch covered areas.

However, epoch doesn't introduce any contention, it just delays
memory reclaim. So, there is no point to minimise epoch covered
areas in sense of performance. Meanwhile entering/exiting epoch
also has non-zero CPU usage, so doing this less often is a win.

Not the least is also code maintainability. In the new paradigm
we can assume that at any stage of processing a packet, we are
inside network epoch. This makes coding both input and output
path way easier.

On output path we already enter epoch quite early - in the
ip_output(), in the ip6_output().

This patch does the same for the input path. All ISR processing,
network related callouts, other ways of packet injection to the
network stack shall be performed in net_epoch. Any leaf function
that walks network configuration now asserts epoch.

Tricky part is configuration code paths - ioctls, sysctls. They
also call into leaf functions, so some need to be changed.

This patch would introduce more epoch recursions (see EPOCH_TRACE)
than we had before. They will be cleaned up separately, as several
of them aren't trivial. Note, that unlike a lock recursion the
epoch recursion is safe and just wastes a bit of resources.

Reviewed by:	gallatin, hselasky, cy, adrian, kristof
Differential Revision:	https://reviews.freebsd.org/D19111
2019-10-07 22:40:05 +00:00
Hans Petter Selasky
ac66be4122 Make control endpoint quirk for xhci(4) configurable.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-10-07 13:40:29 +00:00
Emmanuel Vadot
7a58744fd0 Split out the attachment from the generic-ehci driver
Create an attachment file for the existing ACPI attachment, and create a
new FDT attachment for the generic-ehci driver.

Submitted by:	andrew (Original version)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D19389
2019-10-03 18:53:03 +00:00
Emmanuel Vadot
150c95edfe generic_ehci: Enable all phys and resets
The number of phys and resets is not defined and it controller dependent
so enable/disable every one of them.
2019-10-01 22:20:03 +00:00
Emmanuel Vadot
4dbb3f478b generic_ohci: Look for the phy based on the id
phy-names was never in the bindings schema even if it was present
in some DTS. Get the optional phy based on its ID.
2019-10-01 20:21:49 +00:00
Hans Petter Selasky
7fca0e69f6 Add quirk for XHCI(4) controllers to support USB control transfers
above 1Kbyte.  It might look like some XHCI(4) controllers do not
support when the USB control transfer is split using a link TRB. The
next NORMAL TRB after the link TRB is simply failing with XHCI error
code 4. The quirk ensures we allocate a 64Kbyte buffer so that the
data stage TRB is not broken with a link TRB.

Found at:	EuroBSDcon 2019
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-20 11:28:45 +00:00
Hans Petter Selasky
4631d7f717 Increase the maximum user-space buffer size from 256kBytes to 32MBytes for
libusb. This is useful for speeding up large data transfers while reducing
the interrupt rate.

Found at:	EuroBSDcon 2019
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-20 11:00:02 +00:00
Hans Petter Selasky
4e792e431a The maximum TD size is 31 and not 15.
Found at:	EuroBSDcon 2019
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-20 10:56:13 +00:00
Warner Losh
1af51473bc Some newer HID devices have descriptors that are larger than 1k. Bump
this to 2k to prevent them from being truncated and ignored. It
appears to be a sanity check only, but bumping it to 2k allows both of
my iic hid devices to be parsed and the second one to work...
2019-09-07 03:51:26 +00:00
Hans Petter Selasky
f6549df685 Fix regression issue after r351616. Make sure the mbuf queue gets initialized.
Found by:	gonzo@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-02 08:31:18 +00:00
Jung-uk Kim
1c9c1f5903 Add support for TP-Link Archer T2U Nano.
MFC after:	2 weeks
2019-09-01 06:40:58 +00:00
Gleb Smirnoff
35d3dd8b12 Use mbuf queue instead of ifqueue in USB network drivers.
Reviewed by:	stevek
2019-08-30 00:05:04 +00:00
Bjoern A. Zeeb
c982e56f4b usb: fix usb_fdt_support.c when altq enabled (usb_ehernet.h changes)
After r351243 when ALTQ was enabled in the kernel, the inline functions
in ifq.h would not have full type information as if_var.h was not
included.

Given usb_ethernet.h already includes all the various headers (which)
is the cause of the problem here, add if_var.h to it.  This fixes the
builds again.

Reported by:	CI system, e.g. FreeBSD-head-aarch64-LINT
2019-08-22 09:24:43 +00:00
Justin Hibbits
31c484ad31 Unbreak USB ethernet module builds
Sponsored by:	Juniper Networks, Inc.
2019-08-20 15:14:32 +00:00
Stephen J. Kiernan
df845c0f86 usb_ethernet.h includes a number of mii headers, but only does so in
order to have struct mii_data available. However, it only really needs
a forward declaration of struct mii_data for use in pointer form for
the return type of a function prototype.

Custom kernel configuration that have usb and fdt enabled, but no miibus,
end up with compilation failures because miibus_if.h will not get
generated.

Due to the above, the following changes have been made to usb_ethernet.h:
 * remove the inclusion of mii headers
 * forward-declare struct mii_data
 * include net/ifq.h to satify the need for complete struct ifqueue

Reviewed by:	ian
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D21293
2019-08-20 01:06:43 +00:00
Edward Tomasz Napierala
63722e5212 Add cdceem(4) driver, for virtual ethernet devices compliant
with Communication Device Class Ethernet Emulation Model (CDC EEM).
The driver supports both the device, and host side operation; there
is a new USB template (#11) for the former.

This enables communication with virtual USB NIC provided by iLO 5,
as found in new HPE Proliant servers.

Reviewed by:	hselasky
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Hewlett Packard Enterprise
2019-08-07 18:14:45 +00:00
Hans Petter Selasky
3194b27014 Correct PCI device ID for XHCI USB controller.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-08-07 13:35:13 +00:00
Konstantin Belousov
83b506939a Fix format spec for ILP32.
Sponsored by:	The FreeBSD Foundation
2019-08-03 18:26:16 +00:00
Takanori Watanabe
5f0099fcc1 Add per hub sysctl to expose port information for phyisical form etc.
Reviewed by:hselasky
Differential Revision:	https://reviews.freebsd.org/D20865
2019-08-03 16:13:44 +00:00
Hans Petter Selasky
f9e3413a3c Add support for tethering with Nokia 7 plus and the alike.
PR:		239495
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-07-28 21:47:04 +00:00
Poul-Henning Kamp
ccbb355988 Support multiple serial ports per device.
Enable this for the NovAtel OEMv2 GPS receiver.

Not fixed:  The receiver shows up as "<Interface 0>" in the device
tree, because that is literally what the descriptor-string is.

Reviewed by:	hselasky@
2019-07-12 09:02:12 +00:00
Hiroki Sato
2625e51956 Add support for RTL8156, 2.5GbE USB network controller, to if_cdce(4).
This chip can be found in Planex USB-LAN2500R.
2019-07-10 05:45:50 +00:00
Hans Petter Selasky
7fe671dc9b Put USB ACPI code into own module, uacpi.ko.
The code needs more testing before being enabled by default.

Sponsored by:	Mellanox Technologies
2019-07-08 20:53:25 +00:00
Hans Petter Selasky
74d565fd96 Minor code cleanup of USB ACPI code after r349161.
While at it fix an invalid memory access issue when attaching external
USB HUBs, which are not mapped by ACPI, due to missing status check
when calling AcpiGetObjectInfo() from acpi_usb_hub_port_probe_cb().

Sponsored by:	Mellanox Technologies
2019-07-08 19:26:05 +00:00
Ed Maste
91c33ba3a3 if_muge: set IFCAP_VLAN_MTU to maintain 1500 MTU with vlan use
PR:		238665
Submitted by:	Ralf <iz-rpi03@hs-karlsruhe.de>
MFC after:	1 week
2019-07-02 16:44:04 +00:00
Takanori Watanabe
a809abd44a Fix the case where no root hub object while host controller object exist in ACPI namespace.
Also you can disable ACPI support for USB by setting
debug.acpi.disabled="usb"

PR:	238711
2019-06-20 23:52:33 +00:00
Takanori Watanabe
e68fcc8875 Add ACPI support for USB driver.
This adds ACPI device path on devinfo(8) output and
show  value of _UPC(usb port capabilities), _PLD (physical location of device)
when hw.usb.debug >= 1 .

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D20630
2019-06-17 23:03:30 +00:00
Xin LI
f89d207279 Separate kernel crc32() implementation to its own header (gsb_crc32.h) and
rename the source to gsb_crc32.c.

This is a prerequisite of unifying kernel zlib instances.

PR:		229763
Submitted by:	Yoshihiro Ota <ota at j.email.ne.jp>
Differential Revision:	https://reviews.freebsd.org/D20193
2019-06-17 19:49:08 +00:00
Stephen Hurd
705aad98c6 Some devices take undesired actions when RTS and DTR are
asserted. Some development boards for example will reset on DTR,
and some radio interfaces will transmit on RTS.

This patch allows "stty -f /dev/ttyu9.init -rtsdtr" to prevent
RTS and DTR from being asserted on open(), allowing these devices
to be used without problems.

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D20031
2019-06-12 18:07:04 +00:00
Hans Petter Selasky
9ccaf2215a In usb(4) fix a lost completion event issue towards libusb(3). It may happen
if a USB transfer is cancelled that we need to fake a completion event.
Implement missing support in ugen_fs_copy_out() to handle this.

This fixes issues with webcamd(8) and firefox.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
2019-06-04 16:40:18 +00:00
Hans Petter Selasky
253c93f26b In xhci(4) there is no stream ID in the completion TRB.
Instead iterate all the stream IDs in stream mode to find
the matching USB transfer.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
2019-06-04 09:01:02 +00:00
Andriy Gapon
70b152cb3c Add USB ID for CP2112
This is a curious small widget for which I might write a driver.
It is bridge between USB HID interface and I2C interface plus some
GPIO pins.

MFC after:	 2 weeks
2019-05-23 11:06:38 +00:00
Ian Lepore
2c597054b4 Reverse the bit logic of sc_led_modes_mask. Instead of initializing it to
all-ones then carving out blocks of zeroes where specified values go, init
it to all-zeroes, put in ones where values need to be masked, then use it
as value &= ~sc_led_modes_mask.  In addition to being more idiomatic, this
means everything related to FDT data is initialized to zero along with the
rest of the softc, and that allows removing some #ifdef FDT sections and
wrapping the whole muge_set_leds() function in a single ifdef block.

This also deletes the early-out from muge_set_leds() when an eeprom exists.
Even if there is an eeprom with led config in it, the fdt data (if present)
should override that, because the user is in control of the fdt data.
2019-05-20 22:32:31 +00:00
Ian Lepore
a58040e746 A MAC adddress from FDT data should override anything stored in eeprom or
OTP registers (because the user is in control of the fdt data).  Remove the
early returns from the code that tries to find a good mac address, so that
the execution always flows through the routine to get an address from FDT
data last, when on FDT-enabled systems.
2019-05-20 22:21:47 +00:00
Ian Lepore
d736b52757 Don't detour through sc->sc_ue when we have a direct pointer to ue in hand
already.  Also, shorten a variable name for nicer line-wrapping.

No functional changes.
2019-05-20 22:04:01 +00:00
Ian Lepore
18dc4538b1 Use the new usb fdt support functions to locate the proper fdt node for
the device instance, and to get the MAC address for the device instance.
The ad-hoc code this replaces could find the wrong instance if multiple
devices were present.
2019-05-20 21:45:00 +00:00
Ed Maste
03dec17347 muge: update FDT LED configuration
Also use LED mode settings from the FDT to set the PHY.
From v3 of the patch submitted in the PR.

I moved the sc_led_modes and sc_led_modes_mask default setting outside
of the #ifdef FDT case.

PR:		237325
Submitted by:	Ralf <iz-rpi03@hs-karlsruhe.de>
Reviewed by:	ian
MFC after:	2 weeks
MFC with:	r348001
Event:		Waterloo Hackathon 2019
Differential Revision:	https://reviews.freebsd.org/D20325
2019-05-20 19:31:49 +00:00
Ed Maste
60ce15ed06 muge: configure LEDs per dtb (for Raspberry Pi 3B+)
Also apply some style(9) and remove the message about EEPROM configuration
(if there's an EEPROM the hardware handles LED configuration itself).

PR:		237325
Reviewed by:	ian
MFC after:	2 weeks
Submitted by:	Ralf <iz-rpi03@hs-karlsruhe.de>
2019-05-20 18:41:07 +00:00
Conrad Meyer
e2e050c8ef Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.

EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).

As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions.  The remainder of the patch addresses
adding appropriate includes to fix those files.

LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).

No functional change (intended).  Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.
2019-05-20 00:38:23 +00:00
Ian Lepore
bac5ec96f4 Add common support functions for USB devices configured via FDT data.
FDT data is sometimes used to configure usb devices which are hardwired into
an embedded system. Because the devices are instantiated by the usb
enumeration process rather than by ofwbus iterating through the fdt data, it
is somewhat difficult for a usb driver to locate fdt data that belongs to
it. In the past, various ad-hoc methods have been used, which can lead to
errors such applying configuration that should apply only to a hardwired
device onto a similar device attached by the user at runtime. For example,
if the user adds an ethernet device that uses the same driver as the builtin
ethernet, both devices might end up with the same MAC address.

These changes add a new usb_fdt_get_node() helper function that a driver can
use to locate FDT data that belongs to a single unique instance of the
device. This function locates the proper FDT data using the mechanism
detailed in the standard "usb-device.txt" binding document [1].

There is also a new usb_fdt_get_mac_addr() function, used to retrieve the
mac address for a given device instance from the fdt data. It uses
usb_fdt_get_node() to locate the right node in the FDT data, and attempts to
obtain the mac-address or local-mac-address property (in that order, the
same as linux does it).

The existing if_smsc driver is modified to use the new functions, both as an
example and for testing the new functions. Rpi and rpi2 boards use this
driver and provide the mac address via the fdt data.

[1] https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/usb/usb-device.txt

Differential Revision:	https://reviews.freebsd.org/D20262
2019-05-19 16:56:59 +00:00
Emmanuel Vadot
052073c382 Add support for USB 3.0 XHCI via ACPI
Ampere eMAG systems have XHCI just described in ACPI, not on PCI.

Submitted by:	Greg V <greg@unrelenting.technology>
Reviewed by:	andrew
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D19986
2019-05-08 15:42:39 +00:00
Hans Petter Selasky
16fba2f38a Remove superfluous USB keyword.
Discussed with:		danfe@
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2019-04-15 17:32:38 +00:00
Hans Petter Selasky
1175aabdef Fix spelling.
Submitted by:		Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2019-04-15 14:32:19 +00:00