- 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.
- 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.
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().
in the usbnet_chain if needed. remove it
- usbnet media status change already set link to false, don't repeat
this in every driver
- don't clear link in stop, nothing was re-enabling it for non-MII
- add optional uno_tick_cb(struct usbnet *un) that is called from the
usbnet tick timer
- remove wrong debug sysctl prototype
rx_loop and timer are kernel versions changes, but hopefully this is
the last one for usbnet. working with 3 more drivers now (cue, mue
and url), leaving only aue, kue, upl and umb undone (aue may work
with previously supported devices, mine doesn't work with our driver,
kue and upl have patches for testing and umb is undone.)
bump version.
introduce USBNET_MODULE() that encompasses almost all the module
specific code for usbnet modules. they still need to include
the relevant ioconf.c, but everything else is now just, eg,
USBNET_MODULE(axen)
than can fit in the buffer. done at the driver and not usbnet
layer because the driver knows how much beyond the mbuf data needs
to be sent (headers and trailers.)
axen(4) had a KASSERT() for this condition, but there's no
invariant here we can check so it's best as an error return.
XXX: only tested on these drivers, needs to be copied to udav, smsc
and urndis after testing as well as the not commited conversions.
- move a large number of members internal to usbnet.c's new
"struct usbnet_private".
- provide accessors for a few of these
- move struct usbnet_cdata into usbnet.c as well, but move
bufsz, list count, and xfer flags back out into struct usbnet,
and have them set as part of the setup efore usbnet_attach()
- split the intr pipe parts into their own structure
- move all the main usbnet*lock* code into usbnet.c too
usbnet_attach() goes down to 2 args, and the inputs needed are
now the full contents of 'struct usbnet' besides the driver
owned 'un_flags' and usbnet owned 'un_pri'.
welcome netbsd 9.99.6.
- move rx/tx xfer flags into usbnet_cdata
- move the callbacks into usbnet_ops structure
- move rx/tx xfer flags arguments from usbnet_init_rx_tx()
and move them all into usbnet_attach() arguments
- s/miibus/mii/ in some places for consistency
other clean up:
- create wrapper functions for callbacks, move knowledge about
special handling (OK to be missing, error eating) there.
- use cdata pointer if already available
- provide some more macros (will be real functions later) for
accessing usbnet members, use existing ones more
bump kernel version.
- usbnet_enqueue() can set mbuf flags and csum_data
- usbnet_input() for non-ethernet based devices (upl, umb)
- allow a complete override for ioctl()
- remove converted list -- we have compiling and/or working patches for
all the devices except for umb(4), will be merged as testing happens
hopefully this is the last ABI change, though it may end up being
extended for additional smsc(4) support.
hello for real netbsd 9.99.3!
new comment:
* if un_intr_buf is not NULL, use usbd_open_pipe_intr() not
* usbd_open_pipe() for USBNET_ENDPT_INTR, with this buffer,
* size, and interval.
the standard handling is in usbnet.c, with a callback to deal with
the interrupt it self. not fully tested, designed for if_aue.c
and a few others not yet converted.
- make usbhist for usbnet.c work, thanks paulg
- usbnet_init_rx_tx() clears out all allocations upon failure now
- add usbnet_ec() to get a pointer to the struct ethercom
- add usbnet_{lock,unlock,owned}*() to lock/unlock the various locks
and *owned*() for asserting
welcome 9.99.3!
- change the read/write register callbacks to have the same phy/reg
order as the MII code.
- add "mii_flags" param to usbnet_attach_ifp(). axe(4) wants it.
also:
- add usbnet debug code, sysctl node support
- remove commented DPRINTF()s accidentally left in place
- add usbnet_softc()
- reorder some attach code to be consistent
- re-add USBD_FORCE_SHORT_XFER for axen rx chain
ride 9.99.2 bump.
USB ethernet drivers.
usbnet.h introduces a new set of APIs to provide common solutions
for these driver features:
- USB endpoint pipe handling
- rx and tx chain handling
- generic handlers or support for several struct ifnet callbacks
- MII bus locking
- interrupt handling
- partial autoconf handling: much of attach, and detach/activate
can use common versions directly.
currently, only axen(4) and cdce(4) are converted. the reductions
in these drivers are quite significant: if_cdce.c is reduced from
1000 lines to 320 lines, and if_axen is reduced from 1902 lines
to 1021 lines.
add a "usbnet" module and make the if_axen module depend upon it.
- convert IFF_ALLMULTI to ETHER_F_ALLMULTI, using ETHER_LOCK()
- remove IFF_OACTIVE use, and simply check the ring count in start
- assert/take more locks
- XXX: IFF_RUNNING is not properly protected (all driver problem)
- fix axen_timer setting so it actually runs
- document a locking issue in stop callback:
stop is called with the softc lock held, but the lock order
in all other places is ifnet -> softc -> rx -> tx, so taking
ifnet lock when softc lock is held would be problematic
- in rxeof check for stopping/dying more often. i managed to
trigger a pagefault in cdce_rxeof() when yanking an active
device as it attempted to usbd_setup_xfer() on closed pipes.
- add missing USBD_MPSAFE and cdce_stopping resetting for cdce(4)
between this and other recent clean ups increase performance of
these drivers mostly. some numbers (in mbit/sec):
old: new:
driver in out in+out in out in+out
---- -- --- ------ -- --- ------
cdce 39 32 44 38 33 54
axen 44 34 45 48 37 42
ure 36 34 35 36 38 38
i'm not sure why axen drops a little with in+out. cdce is
helped quite a lot, and ure a little. it is disappointing that
ure does not outperform cdce -- it's the same actual hardware,
and the device-specific (ure) should outperform the generic
cdce driver...
it introduced a problem when there wasn't a reasonaly constant
stream of incoming packets, and i had a 'nttcp' running against
my test machine constantly, avoiding the bug.
i'm fairly postive i tested it, as i tested enabing mpsafe version
on top of this successfully. however, something happened mid-ssh
with a kernel with mpsafe and my session hung, and since then i've
been unable to boot kernels with the previous revision applied.
being used.
adapt locking to the modern world. some what inspired by if_smsc.c:
- add locks for softc, rx and tx
- add safe detach support
- safe detach vs mii lock requires 2 methods to lock the MII lock,
- check axen_dying and new axen_stopping more often
- consolidate checks to reduce the number of error paths that need
to release a resource
- move axen_watchdog() out of if_timer into the tick task to
prepare for MPSAFEification
TODO:
- remove spl usage
- enable mpsafe
special thanks to skrll and mlelstv for clearing up various
confusion and providing examples.
- use const, __func__, more
- axen_mii_lock is a normal mutex not rwlock, and make sure it's
properly cleaned up for failed attach
- check axen_dying in axen_miibus_statchg()
- rename axen_ax88179_eeprom() to axen_get_eaddr() and move the code
here into the support the current method.
- adjust some comments
- Mitigate race conditions, that become critical when multiple outstanding
transfers are enabled.
- Drop link flags earlier in foo_stop() to make sure (paranoia).
- Update boundary length for SS mode, taken from OpenBSD.
- Make sure everything passed to the adapter is little endian.
- Specify padding bits in a similar manner to Linux.
XXX I wonder whether this is really necessary...