History log of /freebsd-current/sys/dev/usb/net/if_smsc.c
Revision Date Author Comments
# 7ef6ce51 07-May-2024 Ed Maste <emaste@FreeBSD.org>

smsc(4): update to mention Microchip

Microchip Technology acquired SMSC in 2012, and all current products
and datasheets refer to the devices supported by this driver as
Microchip parts. Mention SMSC in a parenthetical comment to explain
the driver's name.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45115


# 8a0ee306 07-Dec-2023 Ronald Klop <ronald@FreeBSD.org>

if_smsc: fix build on armv6 & armv7

compile error was:
/usr/src/sys/dev/usb/net/if_smsc.c:1597:40: error: format specifies type 'unsigned long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
"failed alloc for bootargs (%lu)", len);
~~~ ^~~
%zd

PR: 274092
Approved by: karels
MFC after: 1 month


# 3878bbf1 04-Nov-2023 Ronald Klop <ronald@FreeBSD.org>

Teach if_smsc to get MAC from bootargs.

Some Raspberry Pi pass smsc95xx.macaddr=XX:XX:XX:XX:XX:XX as bootargs.
Use this if no ethernet address is found in an EEPROM.
As last resort fall back to ether_gen_addr() instead of random MAC.

PR: 274092
Reported by: Patrick M. Hausen (via ML)
Reviewed by: imp, karels, zlei
Tested by: Patrick M. Hausen
Approved by: karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42463


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 935b194d 07-Feb-2023 Justin Hibbits <jhibbits@FreeBSD.org>

Mechanically convert usb ethernet drivers to DrvAPI

Reviewed by: zlei
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37812


# 94466c43 04-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

Revert "usb: Remove a double words in a source code comments"

This reverts commit 8ca67bf1273a5168f8a3787183159c477632e582.

The original comment was correct; changing it loses a key part.

Reported by: jrtc27


# 8ca67bf1 04-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

usb: Remove a double words in a source code comments

- s/that that/that/

MFC after: 3 days


# d0ddb5aa 03-Sep-2022 Gordon Bergling <gbe@FreeBSD.org>

usb: Fix two typos in source code comments

- s/overriden/overridden/

MFC after: 3 days


# bc9372d7 06-May-2022 John Baldwin <jhb@FreeBSD.org>

usb: Remove unused devclass arguments to DRIVER_MODULE.


# 3e38757d 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

Remove unused miibus_devclass and miibus_fdt_devclass.


# c8c1c23a 09-Apr-2022 Gordon Bergling <gbe@FreeBSD.org>

usb(4): Fix two typos in source code comments

- s/negotation/negotiation/

MFC after: 3 days


# c6df6f53 09-Dec-2021 Warner Losh <imp@FreeBSD.org>

Create wrapper for Giant taken for newbus

Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D31831


# 9599d814 02-Oct-2021 Gordon Bergling <gbe@FreeBSD.org>

smsc(4): Fix a typo in a comment

- s/setings/settings/

MFC after: 3 days


# 5a3426f4 11-Apr-2021 Hans Petter Selasky <hselasky@FreeBSD.org>

if_smsc: Add the ability to disable "turbo_mode", also called RX frame batching,
similarly to the Linux driver, by a tunable read only sysctl.

Submitted by: Oleg Sidorkin <osidorkin@gmail.com>
PR: 254884
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking


# 9dd3156e 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

usb: clean up empty lines in .c and .h files


# 9c847ffd 11-Jun-2020 Hans Petter Selasky <hselasky@FreeBSD.org>

Add missing range checks when receiving USB ethernet packets.

Found by: Ilja Van Sprundel, IOActive
MFC after: 3 days
Sponsored by: Mellanox Technologies


# eea248ec 24-Feb-2020 Ed Maste <emaste@FreeBSD.org>

smsc: remove pre-FreeBSD-10 compat support

Sponsored by: The FreeBSD Foundation


# f8d2b1f3 15-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by: hselasky, kib
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D23632


# 74954211 04-Nov-2019 Eric Joyner <erj@FreeBSD.org>

net: add ETHER_IS_ZERO macro similar to ETHER_IS_BROADCAST

Some places in network code may need to verify that an ethernet address
is not the 'zero' address. Provide a standard macro ETHER_IS_ZERO for
this purpose, similar to the ETHER_IS_BROADCAST macro already available.

This patch also removes previous ETHER_IS_ZERO definitions in several
USB ethernet drivers, in favor of this centrally-located macro.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: erj@
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21240


# 0a738e4d 14-Oct-2019 Gleb Smirnoff <glebius@FreeBSD.org>

Convert to if_foreach_llmaddr() KPI.

Reviewed by: hselasky


# 31c484ad 20-Aug-2019 Justin Hibbits <jhibbits@FreeBSD.org>

Unbreak USB ethernet module builds

Sponsored by: Juniper Networks, Inc.


# bac5ec96 19-May-2019 Ian Lepore <ian@FreeBSD.org>

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


# d7c5a620 18-May-2018 Matt Macy <mmacy@FreeBSD.org>

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


# 361558a6 29-Apr-2018 Ed Maste <emaste@FreeBSD.org>

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


# 8c9b26c3 29-Apr-2018 Ed Maste <emaste@FreeBSD.org>

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


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

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.


# e1304351 27-Oct-2017 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

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.


# c5765d84 01-Oct-2017 Ian Lepore <ian@FreeBSD.org>

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


# 33299e3d 16-Nov-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

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


# a2696bf3 11-Nov-2016 Andrew Turner <andrew@FreeBSD.org>

Use ofw_bus_node_is_compatible in more drivers used on arm.

Sponsored by: ABT Systems Ltd


# 968d859d 12-Oct-2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

[fdt] Add one more heuristic to determine MAC address of the SMSC device

- 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


# 8cb15594 14-Feb-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix variable assignment inside if-clause in the smsc driver.
Found by D5245 / PVS.

MFC after: 1 week


# f809f280 10-Dec-2015 Warner Losh <imp@FreeBSD.org>

Create a USB_PNP_INFO and use it to export the existing PNP
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


# 4da9ba7e 07-Dec-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

When setting up VLANs on a Raspberry Pi ethernet port, the MTU drops
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


# ece4b0bd 05-Jan-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Make a bunch of USB debug SYSCTLs tunable, so that their value(s) can
be set before the USB device(s) are probed.


# 381fd761 23-Oct-2014 Luiz Otavio O Souza <loos@FreeBSD.org>

Fix a bug where some DTS layouts could cause the premature ending of the
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.


# cd8d304e 26-Sep-2014 Gavin Atkinson <gavin@FreeBSD.org>

Add new (untested) device IDs to smsc(4)

MFC after: 1 week


# ecc70d3f 18-Sep-2014 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanically convert to if_inc_counter().


# 5a1a4f75 05-May-2014 Michael Tuexen <tuexen@FreeBSD.org>

Fill in csum_data only for UDP or TCP packets. This fixes a bug where
SCTP were reported to have always a correct checksum if they don't
contain any ethernet padding.

MFC after: 3 days


# c3322cb9 28-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

Include necessary headers that now are available due to pollution
via if_var.h.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# ebe01023 13-Jun-2013 Kevin Lo <kevlo@FreeBSD.org>

- Use the consistenly PHY-specific reset routine PHY_RESET() rather than
generic mii_phy_reset().
- Return the result of mii_mediachg() rather than blindly returning 0.
- on smsc(4), driver lock should be held to get current
mii_media_active/mii_media_status value.

Reviewed by: yongari


# 74b50dd9 10-Feb-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix correct use of USB header files.


# 664413a1 01-Feb-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix for hardware checksum offloading in SMSC driver.
This also fixes IPv6 support for this particular hardware.

Submitted by: Daisuke Aoyama


# 61bfd867 30-Jan-2013 Sofian Brabez <sbz@FreeBSD.org>

Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays

Reviewed by: cognet
Approved by: cognet


# 82b036b9 22-Nov-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Look for MAC address in FDT tree nodes that are usb network devices and
have either "mac-address" or "local-mac-addrress" property.


# db702c59 21-Oct-2012 Eitan Adler <eadler@FreeBSD.org>

remove duplicate semicolons where possible.

Approved by: cperciva
MFC after: 1 week


# 2196d98e 28-Sep-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Make sure we don't leak a mbuf in a fail case.


# 66249c7c 28-Sep-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Remove some trailing bytes which are not part of the ethernet packet.

Discussed with: bgray @


# 9b42038b 22-Sep-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Apply some more casting.


# 8692ca36 22-Sep-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Apply correct casting.


# b011f8c4 14-Aug-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Merging of projects/armv6, part 5

- Driver for SMSC LAN95XX and LAN8710A ethernet controllers
- Driver for LAN8710A PHY

Submitted by: Ben Gray, Damjan Marion, Tim Kientzle