Home | History | Annotate | Download | only in usb
History log of /src/sys/dev/usb/if_mue.c
RevisionDateAuthorComments
 1.83  31-Oct-2022  andvar fix various typos in comments and one output message.
 1.82  20-Aug-2022  riastradh usbnet(9): New usbnet_ispromisc(un).

Replaces ifp->if_flags & IFF_PROMISC in multicast filter updates.
 1.81  03-Mar-2022  riastradh usbnet: Omit needless detachcv name parameter to usbnet_attach.
 1.80  03-Mar-2022  riastradh usbnet: Factor usbnet_init_rx_tx out into usbnet_if_init.

Make it private; no need for drivers to call it any more.
 1.79  03-Mar-2022  riastradh usbnet drivers: Prune dead IFF_RUNNING branches in *_uno_init.

usbnet(9) guarantees !IFF_RUNNING now before calling it.
 1.78  03-Mar-2022  riastradh usbnet drivers: Omit needless isdying tests in *_uno_init.

usbnet(9) already checks this immediately before calling *_uno_init.
 1.77  03-Mar-2022  riastradh usbnet drivers: Omit needless usbnet core lock and assertions.

During attach, the caller has exclusive access to the usbnet until
usbnet_attach_ifp. At other times, register access is serialized
either by the usbnet multicast lock or by IFNET_LOCK.
 1.76  03-Mar-2022  riastradh usbnet drivers: Avoid undefined behaviour if read reg fails.

Some callers don't check the error code, e.g. ~all the mii phy
drivers using PHY_READ. Just return zero if the device is gone or
the xfer fails for any other reason.
 1.75  03-Mar-2022  riastradh usbnet drivers: Assert IFNET_LOCKED in if ioctl routines.

These only happen either during the transition up or down (init or
stop), or while that transition is excluded (ioctl).

This may be called from ioctl or from init, which both hold the ifnet
lock.

XXX smsc_setoe_locked should maybe trigger reinit because the rx loop
behaves differently depending on whether checksumming is enabled.

XXX mue_sethwcsum_locked needs to exclude mcast updates.
 1.74  03-Mar-2022  riastradh usbnet drivers: Omit redundant multicast filter update on init.
 1.73  03-Mar-2022  riastradh usbnet drivers: Stop abusing ifp->if_flags & IFF_ALLMULTI.

This legacy flag is a figment of userland's imagination. The actual
kernel state is ec->ec_flags & ETHER_F_ALLMULTI, protected by the
ETHER_LOCK, so that multicast filter updates -- which run without
IFNET_LOCK -- need not attempt to write racily to ifp->if_flags.
 1.72  03-Mar-2022  riastradh usbnet drivers: Omit needless uno_mcast locked subroutines.

uno_mcast is now called with the core lock already held so there is
no need for a separate locked subroutine.
 1.71  03-Mar-2022  riastradh usbnet: Take the core lock around uno_mcast.

Every driver does this already. This will enable us to change the
lock that serializes access to the registers so we can go back to
doing this synchronously in SIOCADDMULTI/SIOCDELMULTI.
 1.70  03-Mar-2022  riastradh usbnet drivers: Omit needless uno_init locked subroutines.

uno_init is now called with the core lock already held so there is no
need for a separate locked subroutine.
 1.69  03-Mar-2022  riastradh usbnet drivers: No need for usbnet_busy in uno_ioctl.

This callback always runs with the IFNET_LOCK held, and the interface
cannot be detached until the IFNET_LOCK is released, so there is no
need to hang onto a reference count here. (None of the subnet
drivers touch the IFNET_LOCK except to verify it is held sometimes.)
 1.68  03-Mar-2022  riastradh usbnet drivers: No need for usbnet_busy in uno_mcast.

This callback always runs with IFNET_LOCK held, and during a task
that usbnet_detach prevents scheduling anew and waits for finishing
before completing the detach, so there is no need to hang onto a
reference count here.
 1.67  03-Mar-2022  riastradh usbnet drivers: No need for usbnet_busy in uno_init.

This callback always runs with the IFNET_LOCK held, and the interface
cannot be detached until the IFNET_LOCK is released, so there is no
need to hang onto a reference count here. (None of the usbnet
drivers touch the IFNET_LOCK except to verify it is held sometimes.)
 1.66  03-Mar-2022  riastradh usbnet: Split multicast filter reprogramming into separate operation.
 1.65  03-Mar-2022  riastradh usbnet drivers: Stop timeout loops early if device is detaching.
 1.64  03-Mar-2022  riastradh usbnet: Enter uno_init with the core lock held.

This reduces code in all drivers except urndis(4) and aue(4).

However, it's still safe for urndis to drop the core lock because the
ifnet is locked, and the ifnet lock covers the DOWN->UP (uno_init)
and UP->DOWN (uno_stop) transitions.
 1.63  03-Mar-2022  riastradh axen(4), mue(4), smsc(4): Omit irrelevant cases in ioctl.

SIOCSIFFLAGS and SIOCSETHERCAP always end up in ether_ioctl_reinit,
which triggers the same logic to reprogram the multicast filters
anyway.
 1.62  15-Jul-2021  nisimura back out the previous accidental commit
 1.61  15-Jul-2021  nisimura explanation typo
 1.60  27-Jun-2020  jmcneill branches: 1.60.6;
prop_data_data_nocopy -> prop_data_value
 1.59  15-Mar-2020  thorpej 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.
 1.58  13-Mar-2020  christos PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log
 1.57  29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.56  07-Jan-2020  maxv branches: 1.56.2;
Localify, constify.
 1.55  23-Aug-2019  mrg s/UBSNET_MII_DECL_DEFAULT/USBNET_MII_DECL_DEFAULT/. from sc.dying.
 1.54  20-Aug-2019  mrg couple more changes to usbnet(9):

- MII read/write reg return int instead of usbd_status (requested by skrll)
- usbnet_attach_ifp(9) changes arg, two mii-specific flags are placed by a
pointer to new struct usbnet_mii. if not NULL, then attach an MII to this
interface like previous have_mii parameter. use this to allow ure(4) to
properly pass PHY location to mii_attach().

welcome netbsd 9.99.10.
 1.53  19-Aug-2019  mrg move the check against un_phyno from usbnet back into the drivers
that do this (axe, axen, mue, smsc, ure.) it made mii scanning
only work for phy 0, and aue needs it for at least one device.

fix smsc to return usbd_status not -1 on failure. XXX smsc was
writing to '*val' even in error cases, it does not now.

remove a double call to IFQ_SET_READY() (noticed by chuq).

avoid unlock+instant relock by using usbnet_lock_mii_un_locked().
 1.52  15-Aug-2019  mrg port cue(4), mue(4) and url(4) to usbnet(9). diffstat says:

8 files changed, 911 insertions(+), 3087 deletions(-)
 1.51  01-Aug-2019  mrg remove unused code and use common ethernet media code where equivalent.
 1.50  29-May-2019  mlelstv branches: 1.50.2; 1.50.4;
don't use a spin lock, the USB host driver may need to take other locks.
stop watchdog timer early to prevent calling txeof twice.
allow more output after USB error by clearing OACTIVE in error path.
 1.49  29-May-2019  mlelstv mutexes are destroyed unconditionally in detach, so also init them
unconditionally.
 1.48  28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.47  26-May-2019  mlelstv Also destroy the mutex. Thanks chs@ for noticing.
 1.46  26-May-2019  mlelstv usbd_transfer may sleep, add a mutex to prevent a race in mue_start.
 1.45  23-May-2019  msaitoh Whitespace fix (mainly tabify).
 1.44  23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.43  05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.42  05-Mar-2019  martin Avoid unitialized use warning.
 1.41  06-Feb-2019  rin Fix sign compare differently; instead of casting from int to unsigned,
casting from sizeof (and friends) to int.

Suggested by joerg@.
 1.40  06-Feb-2019  rin We cannot use DPRINTF(sc, ...) when sc is not initialized.
 1.39  06-Feb-2019  rin Fix sign compare.
 1.38  06-Feb-2019  rin Add ratecheck for TX errors for axen(4) and mue(4).
 1.37  06-Feb-2019  rin Fix TSO support:
- Rename mue_tx_offload() to mue_tso_prepare().
- Take care of short mbuf's (paranoia).
 1.36  06-Feb-2019  rin Remove unused.
 1.35  06-Feb-2019  rin SIOC[GS]IFMEDIA are processed in ether_ioctl().
 1.34  06-Feb-2019  rin Fix NULL checks after dereference.
 1.33  06-Feb-2019  rin Cosmetic changes; no functional changes.
 1.32  06-Feb-2019  rin Fix panic when detach or "ifconfig down" for axen(4) and mue(4).
- Mitigate race conditions, that become critical when multiple outstanding
transfers are enabled.
- Drop link flags earlier in foo_stop() to make sure (paranoia).
 1.31  03-Feb-2019  mlelstv Make size of transmit/receive queues variable. Restrict queue size again
to 1 for LAN7500 as some chips fail.

Read Chip revision register and report value. Maybe we can identify
chisp better now.
 1.30  31-Jan-2019  rin Add missing callout_destroy() in mue_detach().
 1.29  30-Jan-2019  rin Fix mue_sethwcsum():
- Check appropriate flags to enable RX checksum offloading.
- We don't support ICMP/IGMP checksum offloading.

Tested both on LAN7800 and 7500.
 1.28  22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.27  05-Jan-2019  mlelstv Enable multiple outstanding transfers.

iperf3 now shows 250MBit/s for sending and 225MBit/s for receiving.
 1.26  28-Dec-2018  rin Define DPRINTF() as __nothing when !USB_DEBUG. Drop excess braces.

No functional changes intended.
 1.25  22-Dec-2018  rin Fix previous; We also need to turn off IFF_ALLMULTI bit when
it is disabled.
 1.24  20-Dec-2018  rin Set IFF_ALLMULTI bit appropriately when we fall back to "allmulti".
 1.23  11-Dec-2018  martin Avoid signed/unsigned comparision (if_mtu is uint64_t)
 1.22  11-Dec-2018  rin Determine the frame size as a function of MTU.

XXX Jumbo frame is not yet supported.
 1.21  11-Dec-2018  rin Stop assigning random MAC address when it cannot be obtained from H/W.
It was intended only for debugging.
 1.20  11-Dec-2018  rin Support checksum offloading for mue(4) by Robert Swindells
and adjusted by myself.
 1.19  04-Dec-2018  rin Remove duplicate ;'s. No binary changes intended.
 1.18  16-Sep-2018  rin Style. No functional changes.
 1.17  16-Sep-2018  rin Check range of EEPROM address rather truncate implicitly.
 1.16  16-Sep-2018  rin Correct nonsense message in KASSERTMSG.
 1.15  16-Sep-2018  rin - Style (total_len ---> totlen).
- Fix printf format (totlen is unsigned).
 1.14  16-Sep-2018  rin Do not turn on IFF_OACTIVE if transfer fails.
Remove redundant error message.
 1.13  16-Sep-2018  rin Drop wrong KASSERT; we don't need TCP headers here.
 1.12  16-Sep-2018  rin Rewrite mue_encap(); drop too long packets rather than panic.
 1.11  16-Sep-2018  rin Allow ethernet frame with VLAN tag.
 1.10  16-Sep-2018  rin Correct lower bound of RX packet length; don't forget FCS.
 1.9  16-Sep-2018  rin - Improve error messages.
- Switch from debug printf to normal printf for real errors.
 1.8  16-Sep-2018  rin Use proper integer types.
 1.7  16-Sep-2018  rin Style. No binary changes.
 1.6  01-Sep-2018  mlelstv branches: 1.6.2;
fix diagnostic build.
 1.5  31-Aug-2018  rin Convert debug printf to KASSERTMSG for check of RX buffer length.
Also turn KASSERT into KASSERTMSG for that of TX buffer.
 1.4  30-Aug-2018  rin Check buffer length before copy.
 1.3  30-Aug-2018  rin Support added for TCP segmentation offload (TSO).
Improve TX performance around 10% if enabled.
 1.2  27-Aug-2018  rin Check ifp->if_capenable, not ifp->if_capabilities, when enable some features.
Not a real problem since ifp->if_capabilities = 0 at the moment.
 1.1  25-Aug-2018  rin Add mue(4), driver for Microchip LAN75xx/LAN78xx known as internal NIC of
Raspberry Pi 3 B+, from OpenBSD.

Tested on Raspberry Pi 3 B+ (LAN7800) and Z-TEK ZE582 (LAN7500).

* BUGS/TODO

- If the media type is set to something other than 1000baseT-FDX, data
transmission becomes quite unstable. Also, ukphy(4) recognize 1000baseT as
a supported media type, but it is not in fact.

- Catch up with changes made to usmsc(4) in nick-nhusb branch, i.e.,
make the driver MP-safe.

- Support RX/VLAN/TX chekcsum offloading.
 1.6.2.6  26-Jan-2019  pgoyette Sync with HEAD
 1.6.2.5  18-Jan-2019  pgoyette Synch with HEAD
 1.6.2.4  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.6.2.3  30-Sep-2018  pgoyette Ssync with HEAD
 1.6.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.2.1  01-Sep-2018  pgoyette file if_mue.c was added on branch pgoyette-compat on 2018-09-06 06:56:04 +0000
 1.50.4.1  01-Sep-2019  martin Pull up following revision(s) (requested by mrg in ticket #135):

distrib/sets/lists/comp/mi 1.2279
distrib/sets/lists/modules/mi 1.123
share/man/man9/Makefile 1.438
share/man/man9/usbnet.9 1.1-1.9
sys/dev/ic/rndisreg.h 1.3
sys/dev/usb/TODO 1.47-1.52
sys/dev/usb/TODO.usbmp 1.15,1.16
sys/dev/usb/files.usb 1.157-1.167
sys/dev/usb/if_aue.c 1.155-1.161
sys/dev/usb/if_auereg.h 1.30-1.32
sys/dev/usb/if_axe.c 1.103-1.119
sys/dev/usb/if_axen.c 1.51-1.53,1.55-1.67
sys/dev/usb/if_axenreg.h 1.15
sys/dev/usb/if_cdce.c 1.54-1.67
sys/dev/usb/if_cue.c 1.85,1.86
sys/dev/usb/if_cuereg.h 1.23
sys/dev/usb/if_kue.c 1.97-1.100
sys/dev/usb/if_kuereg.h 1.23,1.24
sys/dev/usb/if_mue.c 1.51-1.55
sys/dev/usb/if_muereg.h 1.6
sys/dev/usb/if_muevar.h 1.9
sys/dev/usb/if_smsc.c 1.46-1.61
sys/dev/usb/if_smscreg.h 1.6
sys/dev/usb/if_smscvar.h delete
sys/dev/usb/if_udav.c 1.60-1.71
sys/dev/usb/if_udavreg.h 1.14,1.15
sys/dev/usb/if_upl.c 1.65,1.66
sys/dev/usb/if_ure.c 1.15-1.31
sys/dev/usb/if_urevar.h 1.4,1.5
sys/dev/usb/if_url.c 1.67-1.70
sys/dev/usb/if_urlreg.h 1.14
sys/dev/usb/if_urndis.c 1.22-1.33
sys/dev/usb/if_urtwn.c 1.72
sys/dev/usb/ohci.c 1.290
sys/dev/usb/uhub.c 1.143
sys/dev/usb/usb.c 1.180
sys/dev/usb/usb.h 1.118
sys/dev/usb/usb_mem.c 1.71
sys/dev/usb/usb_subr.c 1.238,1.239
sys/dev/usb/usbdevs 1.772
sys/dev/usb/usbdi.c 1.183,1.186
sys/dev/usb/usbdi.h 1.97
sys/dev/usb/usbdi_util.c 1.75
sys/dev/usb/usbhist.h 1.5,1.6
sys/dev/usb/usbnet.c 1.1-1.24
sys/dev/usb/usbnet.h 1.1-1.14
sys/dev/usb/usbroothub.c 1.9
sys/dev/usb/xhci.c 1.109,1.110
sys/modules/Makefile 1.223
sys/modules/usbnet/Makefile 1.1

usbnet(9): Add common framework for USB network devices.
This bring various safety fixes to all updated drivers,
and includes locking clean up, detach safety when being
used or not, separate rx/tx locks to improve performance,
porting to NET_MPSAFE, many edge/error case bugs in
drivers fixed, as well as resovling PRs 54303 and 54308.
These drivers are converted: axe(4), axen(4), aue(4),
cdce(4), cue(4), kue(4), mue(4), smsc(4), udav(4),
upl(4), ure(4), url(4), and urndis(4).
 1.50.2.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.2.2  10-Jun-2019  christos Sync with HEAD
 1.50.2.1  29-May-2019  christos file if_mue.c was added on branch phil-wifi on 2019-06-10 22:07:33 +0000
 1.56.2.1  29-Feb-2020  ad Sync with head.
 1.60.6.1  01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed