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
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
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
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)
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
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
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
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
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
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
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
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
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
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
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.
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.
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
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.
- 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
The directly following m_defrag() call can wait, so there is no reason this
call can't as well.
Reported by: Coverity
CID: 1353551
Sponsored by: Dell EMC Isilon
- If check for net,ethernet/usb,device compatible node fails, try to find
.../usb/hub/ethernet, where ... is bus path that can depend on actual HW.
net,ethernet/usb,device compatibity strings are FreeBSD custom invention
that is used only in RPi DTBs and since there is no other way to tie USB
device to FDT node we just do our best effort here to work with upstream
device tree
- Use -1 value to indicate invalid phandle_t, 0 is valid phandle value and
shouldn't be used as error signal
So that Hyper-V can leverage them instead of rolling its own definition.
Discussed with: hps
Reviewed by: hps
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7592
axge_setmulti()/axge_setpromisc() with axge_rxfilter().
Multicast filter programming and promiscuous mode requires
access to a common RX configuration register so there is no need to
use separate functions with added complexity. axge_rxfilter() does
not read back AXGE_RCR register since accessing a register in USB
is too slow and we already have all knowledge of required
configuration. Rebuilding RX filter configuration is simpler and
faster than manipulating every bits after reading back the
register.
Note, axge_rxfilter() does not set RCR_IPE(IP header alignment on
32bit boundary) to disable extra padding bytes insertion. The
extra padding wastes ethernet to USB host bandwidth as well as
complicating RX handling logic. Current USB framework requires
copying RX frames to mbufs so there is no need to worry about
alignment. Previously axge_rx_frame() performed wrong bound check
due to the extra padding and it was broken when RX checksum
offloading is disabled. See added comment in axge_rx_frame () for
actual RX packet layout.
In axge_init(), disable WOL. It's meaningless to enable WOL in
normal operation.
In axge_rxeof(), use properly sized mbuf rather than blindly
allocating a mbuf cluster.
Use RX H/W checksum offloading only when administrator requested RX
checksum offloading. Previously it always used RX H/W checksum
offloading result regardless of RX checksum offloading state.
Separate L4 checksum offloading validation from L3 one and properly
set required offloading bits for each layer. This is to fix setting
L4 checksum offloading bits for L3 packets.
There are still lots of RX errors(probably RX FIFO overflows) under
moderate load. Users are strongly recommended to enable ethernet
flow control.
Reviewed by: kevlo (initial version), hselasky
structures. This simplifies mbuf copy operation to USB buffers as
well as improving readability. The controller supports Microsoft
LSOv1(aka TSO) but this change set does not include the support due
to copying overhead to USB buffers and large amount of memory waste.
Remove useless ZLP padding which seems to come from Linux. Required
bits the code tried to set was not copied into USB buffer so it had
no effect. Unlike Linux, FreeBSD USB stack automatically generates
ZLP so no explicit padding is required in driver.[1]
Micro-optimize updating IFCOUNTER_OPACKETS counter by moving it out
of TX loop since updating counter is not cheap operation as it did
long time ago and we already know how many number of packets were
queued after exiting the loop.
While here, fix a checksum offloading bug which will happen when
upper stack computes checksum while H/W checksum offloading is
active. The controller should be notified to not recompute the
checksum in this case.
Reviewed by: kevlo (initial version), hselasky
Pointed out by: hselasky [1]
than removing the network interfaces first. This change is rather larger
and convoluted as the ordering requirements cannot be separated.
Move the pfil(9) framework to SI_SUB_PROTO_PFIL, move Firewalls and
related modules to their own SI_SUB_PROTO_FIREWALL.
Move initialization of "physical" interfaces to SI_SUB_DRIVERS,
move virtual (cloned) interfaces to SI_SUB_PSEUDO.
Move Multicast to SI_SUB_PROTO_MC.
Re-work parts of multicast initialisation and teardown, not taking the
huge amount of memory into account if used as a module yet.
For interface teardown we try to do as many of them as we can on
SI_SUB_INIT_IF, but for some this makes no sense, e.g., when tunnelling
over a higher layer protocol such as IP. In that case the interface
has to go along (or before) the higher layer protocol is shutdown.
Kernel hhooks need to go last on teardown as they may be used at various
higher layers and we cannot remove them before we cleaned up the higher
layers.
For interface teardown there are multiple paths:
(a) a cloned interface is destroyed (inside a VIMAGE or in the base system),
(b) any interface is moved from a virtual network stack to a different
network stack ("vmove"), or (c) a virtual network stack is being shut down.
All code paths go through if_detach_internal() where we, depending on the
vmove flag or the vnet state, make a decision on how much to shut down;
in case we are destroying a VNET the individual protocol layers will
cleanup their own parts thus we cannot do so again for each interface as
we end up with, e.g., double-frees, destroying locks twice or acquiring
already destroyed locks.
When calling into protocol cleanups we equally have to tell them
whether they need to detach upper layer protocols ("ulp") or not
(e.g., in6_ifdetach()).
Provide or enahnce helper functions to do proper cleanup at a protocol
rather than at an interface level.
Approved by: re (hrs)
Obtained from: projects/vnet
Reviewed by: gnn, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D6747
tables. Some drivers needed some slight re-arrangement of declarations
to accommodate this. Change the USB pnp tables slightly to allow
better compatibility with the system by moving linux driver info from
start of each entry to the end. All other PNP tables in the system
have the per-device flags and such at the end of the elements rather
that at the beginning.
Differential Review: https://reviews.freebsd.org/D3458
from 1500 to 1496 bytes. The MTU should remain at 1500, extending the
frame size as per IEEE 802.3. Adding IFCAP_VLAN_MTU to the
if_capabilities field in the smsc driver solves the problem. The
datasheet for the LAN9512 chip, section 3.2.3 states that the chip
supports the extended frame.
Submitted by: rpp@ci.com.au
MFC after: 1 week
PR: 205050
IPv4/IPv6 checksum offloading and VLAN tag insertion/stripping.
Since uether doesn't provide a way to announce driver specific offload
capabilities to upper stack, checksum offloading support needs more work
and will be done in the future.
Special thanks to Hayes Wang from RealTek who gave input.
The mbuf length fields must be set before m_adj() is called else
m_adj() will not always adjust the mbuf and an unaligned read
exception can trigger inside the network stack. This can happen on
platforms where unaligned reads are not supported. Adjust a length
check to include the 2-byte ethernet alignment while at it.
MFC after: 3 days
variant of Microsoft RNDIS, i. e. their unofficial version of CDC ACM,
has been disabled in r261544 for resolving a conflict with umodem(4).
Eventually, in r275790 that problem was dealt with in the right way.
However, r275790 failed to put probing of RNDIS devices in question
back.
- Initialize the device prior to querying it, as required by the RNDIS
specification. Otherwise already determining the MAC address may fail
rightfully.
- On detach, halt the device again.
- Use UCDC_SEND_ENCAPSULATED_{COMMAND,RESPONSE}. While these macros are
resolving to the same values as UR_{CLEAR_FEATURE,GET_STATUS}, the
former set is way more appropriate in this context.
- Report unknown - rather: unimplemented - events unconditionally and
not just in debug mode. This ensures that we'll get some hint of what
is going wrong instead of the driver silently failing.
- Deal with the Microsoft ActiveSync requirement of using an input buffer
the size of the expected reply or larger - except for variably sized
replies - when querying a device.
- Fix some pointless NULL checks, style bugs etc.
This changes allow urndis(4) to communicate with a Microsoft-certified
USB RNDIS test token.
MFC after: 3 days
Sponsored by: genua mbh
This makes Mac OS X happy when it returns back from suspending.
o Switch notify state after data is transferred, but not before.
o Consider there is also Super Speed mode.
o Do not set stall bit on any pipes in device mode as Mac OS X seems
don't support it.
In collaboration with: hselasky@
Required when communicating to Mac OS X USB host stack.
o Also don't set stall bit to TX pipe in device mode as seems Mac OS X
don't clears it as it should.
Discussed with: hselasky@
search (i.e. without returning any result) and you would end up with a
random MAC address.
Change the search algorithm to a recursive one to ensure that all the nodes
on DTS will be verified.
The previous algorithm could not keep up if the DTS has too many sub-nodes.
While here, fix the punctuation on comments.
E5372 with different product IDs.
Interestingly, the standard E5372 IDs (12d1:1506) are currently listed in
u3g.c and are the same as the E3131. However, the R215/E5372 is an NCM
device and works well with cdce(4) whereas the E3131 isn't. More work
may be needed to better identify the other device IDs.
MFC after: 1 week
ethernet class.
Note: This is untested as I do not have a device like this. That is
reflected in the MFC timeout.
PR: 192345
Submitted by: rozhuk.im gmail.com
MFC after: 4 weeks
- Remove 4 extra bytes from the ethernet payload.
- The maximum RX buffer was incorrectly set. Increase it to 64K for
now, until the exact limit is understood.
- Enable hardware checksumming again.
- Make hardware data structure packed.
MFC after: 3 days
- Don't discard frames if the dropped or error flag is set.
- Don't remove the last 4-bytes of every packet.
- Add extra range check for data position offset when receiving data.
MFC after: 1 day
PR: 191432
While I'm here, remove aue_eeprom_getword() as its only usage is to
read station address and make it more readable. This change is
inspired by NetBSD.
With this change, aue(4) should work on big endian architectures.
PR: 188177
Before this patch, curvnet was NULL.
When the VIMAGE kernel option is enabled, this eliminates
kernel panics when USB ethernet devices are plugged in.
PR: 183835
Submitted by: Hiroo Oono <hiroo.ono at gmail dot com>
Useful for so-called USB tethering.
- Imported code from OpenBSD
- Adapted code to FreeBSD
- Removed some unused functions
- Fixed some buffer encoding and decoding issues
- Optimised data transport path a bit, by sending multiple packets at a time
- Increased receive buffer to 16K
Obtained from: OpenBSD
Requested by: eadler @
MFC after: 2 weeks
adapters. Both devices support Gigabit Ethernet and USB 2.0, and the AX88179
supports USB 3.0. The driver was written by kevlo@ and lwhsu@, with a few
bug fixes from me.
MFC after: 2 months
interface. Make MII drivers forget about 'struct ifnet'.
Later plan is to provide an administrative downcall from ifnet
layer into drivers, to inform them about administrative status
change. If someone thinks that processing MII events for an
administratively down interface is a big problem, then drivers
would turn MII processing off.
The following MII drivers do evil things, like strcmp() on
driver name, so they still need knowledge of ifnet and thus
include if_var.h. They all need to be fixed:
sys/dev/mii/brgphy.c
sys/dev/mii/e1000phy.c
sys/dev/mii/ip1000phy.c
sys/dev/mii/jmphy.c
sys/dev/mii/nsphy.c
sys/dev/mii/rgephy.c
sys/dev/mii/truephy.c
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
extremely outdated, and I doubt that it was ever used for ifnet drivers.
It was used for AF_INET sockets in pre-FreeBSD time.
Approved by: re (hrs)
Sponsored by: Nginx, Inc.
and protocol 1 are USB ethernet adapters. This avoids keeping and updating
the product list every now and then. This patch will add support for the
USB ethernet interface found in the IPAD.
MFC after: 1 week
checksum header. The header contains a received frame length but
the defined length for AX88772B is different with other ASIX
controllers. When the RX checksum is off, AX88772B controller does
not prepend a checksum header so driver has to use normal header
length mask.
This change should fix RX errors when RX checksum offloading is
off.
Tested by: kevlo
MFC After: 1 week