Commit Graph

242 Commits

Author SHA1 Message Date
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
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
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
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
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
Ganbold Tsagaankhuu
cef38d45bb In some cases like NanoPI R1, its second USB ethernet
RTL8152 (chip version URE_CHIP_VER_4C10) doesn't
have hardwired MAC address, in other words, it is all zeros.
This commit fixes it by setting random MAC address
when MAC address is all zeros.

Reviewed by:	kevlo
Differential Revision:	https://reviews.freebsd.org/D19856
2019-04-09 13:54:08 +00:00
Ganbold Tsagaankhuu
ab0280c4d0 Fix URE_WDT6_SET_MODE value in the register definition.
Both linux and u-boot sources for RTL8152 driver has this value.
RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet.
This fixes for me RTL8152 USB ethernet not detected problem after
reboot on NanoPI R1 board.

Both NetBSD and OpenBSD have a wrong value so far.
2019-04-08 13:40:46 +00:00
Ed Maste
fea616de3e if_muge: use NULL not 0 for DRIVER_MODULE pointer args
Sponsored by:	The FreeBSD Foundation
2019-04-04 19:59:31 +00:00
Gavin Atkinson
afa9b0368f Support the Lenovo OneLink in ure(4).
MFC after:	1 week
2019-02-06 20:18:22 +00:00
Gleb Smirnoff
32c4f3bb78 Use mbufq instead of ifqueue to queue mbufs. 2018-12-18 19:38:13 +00:00
Poul-Henning Kamp
146ebc766c Recognize LAN in Lenovo USB-C and TB3 docks 2018-10-21 09:36:12 +00:00
Allan Jude
72851e8598 Use PNP metadata to allow devmatch to autoload ure(4)
Reviewed by:	manu imp
Approved by:	re (kib)
X-MFC-with:	devmatch
Sponsored by:	Klara Systems
2018-09-30 21:23:31 +00:00
Michal Meloun
23242e7a9c Add USB ID for rebranded RTL8153 found on NVIDIA Jetson TX1 board.
MFC after:	3 days
2018-08-13 07:28:25 +00:00
Kevin Lo
a99020fbf3 - Fix hash calculation by MAC address
- Since rx_cmd_c is an uint16_t, use le16toh() instead of le32toh()

Reviewed by:	emaste
2018-08-08 01:20:02 +00:00
Ed Maste
515a5d0239 muge(4): remove DTB MAC addr from TODO list after r335925
Also replace numbered list with - bulleted so the list entries do not
need to be renumbered as tasks are completed.

Sponsored by:	The FreeBSD Foundation
2018-07-04 13:38:02 +00:00
Oleksandr Tymoshenko
b4872d675e muge(4): add DTB blob as one more possible source of MAC address
On FDT-enabled platforms check if DTB blob has MAC address configured by
a boot loader. This information passed as a "local-mac-address" or
"mac-address" property of the device node. For USB NICs node
can be found by looking for compatibility string "usbVVV,PPP" where
VVV - vendor id (hex) and PPP - product id (hex)

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D16117
2018-07-04 03:02:53 +00:00
Ed Maste
2c8cf0c505 if_muge: retire lan78xx_eeprom_read
lan78xx_eeprom_read just checked for EEPROM presence then called
lan78xx_eeprom_read_raw if present, and had only one caller.  Introduce
lan78xx_eeprom_present to check for EEPROM presence, and use it in the
one place it is needed.

This is used by r334964, which was accidentally committed out-of-order
from my work tree.

Reported by:	markj
Sponsored by:	The FreeBSD Foundation
2018-06-11 19:34:47 +00:00
Ed Maste
2d14fb8bec if_muge: add LAN7850 support
Differences between LAN7800 and LAN7850 from the driver's perspective:

* The LAN7800 muxes EEPROM signals with LEDs, so LED mode needs to be
  disabled when reading/writing EEPROM.  The EEPROM is not muxed on the
  LAN7850.

* The Linux driver enables automatic duplex and speed detection when
  there is no EEPROM, for the LAN7800 only.  With this FreeBSD driver
  LAN7850-based adapters without a configuration EEPROM fail to link
  (with or without the automatic duplex and speed detection code), so
  I have just followed the example of the Linux driver for now.

Sponsored by:	The FreeBSD Foundation
Sponsored by:	Microchip (hardware)
2018-06-11 18:44:56 +00:00
Ed Maste
cfa989aa34 if_muge: Add GMII enable (vs RGMII) bit
The GMII control bit ETH_MAC_CR_GMII_EN_ is not documented in
LAN78xx datasheets, but from the permissively licensed header provided
by Microchip it is:

 #define ETH_MAC_CR_GMII_EN (0x00080000UL ) // GMII/RGMII Selection
2018-05-28 20:06:40 +00:00
Ed Maste
097f721b80 if_muge: Use lock assertion instead of broken locking in lan78xx_chip_init
Previously lan78xx_chip_init locked the driver's mutex if not already
locked, but unlocked it only in the case of error.  This provided a
fairly clear indication that the function is already called with the
lock held, so just replace it with a lock assertion.

Sponsored by:	The FreeBSD Foundation
2018-05-25 17:31:43 +00:00
Ed Maste
49b2a5fede if_muge: Add LAN78xx family USB ids but attach only to LAN7800
This driver was developed for the LAN7800 and the register-compatible
LAN7515 and has only been tested on those devices.  Adding support for
other members of the family should be straightforward, once we have
devices to test.

With this change the driver will probe but fail to attach due to the
Chip ID check, but will leave a hint leading to the driver that needs
work.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D15537
2018-05-24 16:34:06 +00:00
Hans Petter Selasky
0c89167c76 Add function to wait for USB ethernet attach to complete.
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-05-24 15:24:42 +00:00
Ed Maste
03ba5353ce if_muge: only attach to LAN7800 Chip ID
This driver was developed for the LAN7800 and the register-compatible
LAN7515 (found on Raspberry Pi 3B+) and has only been tested on those
devices.

Sponsored by:	The FreeBSD Foundation
2018-05-22 20:00:56 +00:00
Ed Maste
0842ea9bb9 muge(4): chase r333813 if_addr_lock rwlock to epoch + mutex
muge was committed to the tree in r333713 but not yet connected to the
tree, and it crossed paths with the migration to using ck.

Sponsored by:	The FreeBSD Foundation
2018-05-19 18:44:29 +00:00
Matt Macy
d7c5a620e2 ifnet: Replace if_addr_lock rwlock with epoch + mutex
Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
4.98   0.00   4.42   0.00 4235592     33   83.80 4720653 2149771   1235 247.32
4.73   0.00   4.20   0.00 4025260     33   82.99 4724900 2139833   1204 247.32
4.72   0.00   4.20   0.00 4035252     33   82.14 4719162 2132023   1264 247.32
4.71   0.00   4.21   0.00 4073206     33   83.68 4744973 2123317   1347 247.32
4.72   0.00   4.21   0.00 4061118     33   80.82 4713615 2188091   1490 247.32
4.72   0.00   4.21   0.00 4051675     33   85.29 4727399 2109011   1205 247.32
4.73   0.00   4.21   0.00 4039056     33   84.65 4724735 2102603   1053 247.32

After the patch

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
5.43   0.00   4.20   0.00 3313143     33   84.96 5434214 1900162   2656 245.51
5.43   0.00   4.20   0.00 3308527     33   85.24 5439695 1809382   2521 245.51
5.42   0.00   4.19   0.00 3316778     33   87.54 5416028 1805835   2256 245.51
5.42   0.00   4.19   0.00 3317673     33   90.44 5426044 1763056   2332 245.51
5.42   0.00   4.19   0.00 3314839     33   88.11 5435732 1792218   2499 245.52
5.44   0.00   4.19   0.00 3293228     33   91.84 5426301 1668597   2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by:	gallatin
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D15366
2018-05-18 20:13:34 +00:00
Ed Maste
e5151258c8 muge(4): style and comment cleanup
And tag some spots to revisit with XXX.

Sponsored by:	The FreeBSD Foundation
2018-05-18 17:07:59 +00:00
Ed Maste
48bc175842 muge(4): sync register names with Microchip's lan7800.h
Microchip provided a permissively-licensed lan78xx header, which has
an 'ETH_' prefix on most definitions.  Follow suit in our driver.

Sponsored by:	The FreeBSD Foundation
2018-05-18 14:30:45 +00:00
Andreas Tobler
087522b840 Fix build if USB_DEBUG is defined. 2018-05-17 17:57:41 +00:00
Ed Maste
d30c739c90 Add driver for Microchip LAN78xx USB3-GigE controller
This driver supports two Microchip USB-Ethernet controllers:

LAN7800 USB 3.1 to 10/100/1000 Mbps Ethernet
LAN7515 USB 2 to 10/100/1000 Mbps Ethernet with built-in USB hub

The LAN7515 is the Ethernet controller on the Raspberry Pi 3B+.
At present there is no datasheet for the LAN7515, but it is effectively
a USB 2 hub combined with a LAN7800 controller.  A comprehensive LAN7800
datasheet is at http://www.microchip.com/wwwproducts/en/LAN7800.

This driver is based on the structure of the smsc(4) driver which
supports Microchip/SMSC's LAN95xx family.  (Microchip acquired SMSC
in May 2012.)  The Linux lan78xx driver served as a reference for some
functionality and registers.

The 'muge' driver name comes from "Microchip USB Gigabit Ethernet".
I made some style adjustments and minor edits to Arshan's submission.
It will be connected to the build after additional review and testing.

Thanks to Microchip for providing a number of Evaluation Boards (EVBs)
for development and testing.

Submitted by:	Arshan Khanifar
Reviewed by:	hselasky (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D15168
2018-05-17 14:04:59 +00:00
Ed Maste
361558a60f if_smsc: set MII BUSY bit to read/write PHY regs
Per the datasheet, the BUSY bit must be set when reading or writing PHY
registers.  From Linux commit 80928805babf.

Submitted by:	Arshan Khanifar
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D15217
2018-04-30 02:18:19 +00:00
Ed Maste
8c9b26c3c4 if_smsc: fix reset check
In smsc_phy_init function, when the driver was trying to reset PHY, it
didn't poll for the correct bit (BMCR_RESET) to be cleared.  Instead, it
anded it with MII_BMCR (which is 0), so it just exited the loop.

This issue was fixed in Linux in commit d94609200069.

Submitted by:	Arshan Khanifar
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-04-30 01:58:24 +00:00
Hans Petter Selasky
7ef4e76f74 Fix race when detach is called right after attach in if_axge, that the
network device pointer might be NULL. Wait for any pending tasks to
complete before calling axge_stop().

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-02-24 08:44:51 +00:00
Hans Petter Selasky
cdadbbb03d Improve support for USB based 3G/4G/5G dongles from Huawei.
PR:		192345
Sponsored by:	Mellanox Technologies
2018-01-19 12:59:14 +00:00
Pedro F. Giffuni
9b10f59a10 SPDX: mostly fixes to previous changes.
Introduce the recently approved BSD-1-Clause and replace 0BSD which
never did fit well our use cases.
2017-12-13 16:13:17 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Pedro F. Giffuni
7282444b10 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:36:21 +00:00
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Kevin Lo
ccaf7ad472 Add TP-LINK UE300.
Submitted by:	Kris G <netsick@gmail.com>
2017-11-14 01:57:54 +00:00
Oleksandr Tymoshenko
e130435139 Fix MAC address detection regression introduced by r324184
To accomodate all variaties of Pi DTS files floating around
we look for MAC address property either in DTS node for
USB ethernet (if it exists) or at predefined path
".../usb/hub/ethernet".

After r324184 smsc_fdt_find_eth_node started to return node
with compatibility string "usb424,ec00" as an eth node.
In imported GNU dts files this node still does not have
MAC address related property, and therefor following check for
"mac-address" and "local-mac-address" fails.

To make this logic more robust do not just search for the node
but also make sure it has required property, so if node with
accepted compatibility string exists but doesn't have the
property we fall back to looking for hardoded path mentioned above.
2017-10-27 21:22:38 +00:00
Ian Lepore
c5765d84ac Allow Raspberry Pi platform and drivers to be configured with upstream DTBs.
- Added more compatibility strings to drivers not yet converted
 - Added new RPI platform code compatibility string to match the ones used
   upstream
 - Adapted RPI and RPI2 DTS to match the new platform code compatibility
   string

The goal is to use the upstream DTBs as a replacement for our custom one.
This is now possible with these changes.

Additionally, as the RPI firmware automatically chooses the right DTB for
us, this would allow to have one common armv6 kernel for RPI0 and RPI1
(BCM2835-based), and one common armv7 kernel for RPI2 v1.1 (BCM2836-based),
and RPI2 v1.2 / RPI3 (BCM2837-based).

Submitted by:	Sylvain Garrigues <sylgar@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D12360
2017-10-02 00:49:33 +00:00
Kevin Lo
21d36c9620 Add ThinkPad USB 3.0 Ethernet Adapter.
Submitted by:	jh
2017-09-29 01:19:22 +00:00
Hans Petter Selasky
33299e3d96 Make sure MAC address is reprogrammed when if_init() callback is
invoked. Else promiscious mode must be used to pass traffic. While at
it fix a debug print macro.

MFC after:	1 week
2016-11-16 14:39:03 +00:00
Andrew Turner
a2696bf3c0 Use ofw_bus_node_is_compatible in more drivers used on arm.
Sponsored by:	ABT Systems Ltd
2016-11-11 15:42:12 +00:00