- document locking requirements more
- expand uno_foo() docs to include return type and parameters - expand uno_intr() docs - add uno_tick() - fix various typoes
This commit is contained in:
parent
cb47fa61ba
commit
d3025cbd35
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: usbnet.9,v 1.5 2019/08/12 00:01:23 mrg Exp $
|
.\" $NetBSD: usbnet.9,v 1.6 2019/08/15 08:33:14 mrg Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2019 Matthew R. Green
|
.\" Copyright (c) 2019 Matthew R. Green
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 11, 2019
|
.Dd August 14, 2019
|
||||||
.Dt USBNET 9
|
.Dt USBNET 9
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -346,6 +346,7 @@ on PHY number
|
||||||
.Fa phy
|
.Fa phy
|
||||||
and return the value in
|
and return the value in
|
||||||
.Fa valp .
|
.Fa valp .
|
||||||
|
Called with the MII lock held.
|
||||||
.It Fn usbnet_mii_writereg dev phy reg val
|
.It Fn usbnet_mii_writereg dev phy reg val
|
||||||
Write register
|
Write register
|
||||||
.Fa reg
|
.Fa reg
|
||||||
|
@ -353,9 +354,11 @@ on PHY number
|
||||||
.Fa phy
|
.Fa phy
|
||||||
with
|
with
|
||||||
.Fa val .
|
.Fa val .
|
||||||
|
Called with the MII lock held.
|
||||||
.It Fn usbnet_mii_statchg ifp
|
.It Fn usbnet_mii_statchg ifp
|
||||||
Trigger a status change update for interface
|
Trigger a status change update for interface
|
||||||
.Fa ifp
|
.Fa ifp .
|
||||||
|
Unlike register access, called with the MII lock not held.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Buffer enqueue handling for
|
Buffer enqueue handling for
|
||||||
|
@ -435,34 +438,36 @@ Points to a
|
||||||
.Va struct usbnet_ops
|
.Va struct usbnet_ops
|
||||||
structure which contains these members:
|
structure which contains these members:
|
||||||
.Bl -tag -width 4n
|
.Bl -tag -width 4n
|
||||||
.It uno_stop
|
.It Ft void Fn (*uno_stop) "struct ifnet *ifp" "int disable"
|
||||||
Stop interface (optional.)
|
Stop interface (optional.)
|
||||||
.It uno_ioctl
|
.It Ft int Fn (*uno_ioctl) "struct ifnet *ifp" "u_long cmd" "void *data"
|
||||||
Simple ioctl callback (optional.)
|
Simple ioctl callback (optional.)
|
||||||
.It uno_override_ioctl
|
.It Ft int Fn (*uno_override_ioctl "struct ifnet *ifp" "u_long cmd" "void *data"
|
||||||
Full ioctl callback (optional.)
|
Full ioctl callback (optional.)
|
||||||
.It uno_init
|
.It Ft int Fn (*uno_init) "struct ifnet *ifp"
|
||||||
Initialize (bring up) interface.
|
Initialize (bring up) interface.
|
||||||
Required.
|
Required.
|
||||||
Must call
|
Must call
|
||||||
.Fn usbnet_rx_tx_init .
|
.Fn usbnet_rx_tx_init .
|
||||||
.It uno_read_reg
|
.It Ft usbd_status Fn (*uno_read_reg) "struct usbnet *un" "int phy" "int reg" "uint16_t *val"
|
||||||
Read MII register.
|
Read MII register.
|
||||||
Required with MII.
|
Required with MII.
|
||||||
.It uno_write_reg
|
.It Ft usbd_status Fn (*uno_write_reg) "struct usbnet *un" "int phy" "int reg" "uint16_t val"
|
||||||
Write MII register.
|
Write MII register.
|
||||||
Required with MII.
|
Required with MII.
|
||||||
.It uno_statchg
|
.It Ft usbd_status Fn (*uno_statchg) "struct ifnet *ifp"
|
||||||
Handle MII status change.
|
Handle MII status change.
|
||||||
Required with MII.
|
Required with MII.
|
||||||
.It uno_tx_prepare
|
.It Ft usbd_status Fn (*uno_tx_prepare) "struct usbnet *un" "struct mbuf *m" "struct usbnet_chain *c"
|
||||||
Prepare an mbuf for transmit.
|
Prepare an mbuf for transmit.
|
||||||
Required.
|
Required.
|
||||||
.It uno_rx_loop
|
.It Ft usbd_status Fn (*uno_rx_loop) "struct usbnet *un" "struct usbnet_chain *c" "uint32_t total_len"
|
||||||
Prepare one or more chain for enqueue.
|
Prepare one or more chain for enqueue.
|
||||||
Required.
|
Required.
|
||||||
.It uno_intr
|
.It Ft void Fn (*uno_intr) "struct usbnet *un" "usbd_status status"
|
||||||
Process periodic interrupt (optional.)
|
Process periodic interrupt (optional.)
|
||||||
|
.It Ft void Fn (*uno_tick) "struct usbnet *un"
|
||||||
|
Called every second with USB task thread context (optional.)
|
||||||
.El
|
.El
|
||||||
.It un_intr
|
.It un_intr
|
||||||
Points to a
|
Points to a
|
||||||
|
@ -473,7 +478,7 @@ structure which should have these members set:
|
||||||
If
|
If
|
||||||
.Pf non- Dv NULL ,
|
.Pf non- Dv NULL ,
|
||||||
points to a buffer passed to
|
points to a buffer passed to
|
||||||
Fn usbd_open_pipe_intr
|
.Fn usbd_open_pipe_intr
|
||||||
in the device init callback, along with the size and interval.
|
in the device init callback, along with the size and interval.
|
||||||
.It uni_intr_bufsz
|
.It uni_intr_bufsz
|
||||||
Size of interrupt pipe buffer.
|
Size of interrupt pipe buffer.
|
||||||
|
@ -483,10 +488,10 @@ Frequency of the interrupt in milliseconds.
|
||||||
.It un_ed
|
.It un_ed
|
||||||
Array of endpoint descriptors.
|
Array of endpoint descriptors.
|
||||||
There indexes are provided:
|
There indexes are provided:
|
||||||
.Dq USBNET_ENDPT_RX ,
|
.Dv USBNET_ENDPT_RX ,
|
||||||
.Dq USBNET_ENDPT_TX ,
|
.Dv USBNET_ENDPT_TX ,
|
||||||
and
|
and
|
||||||
.Dq USBNET_ENDPT_INTR .
|
.Dv USBNET_ENDPT_INTR .
|
||||||
The Rx and Tx endpoints are required.
|
The Rx and Tx endpoints are required.
|
||||||
.It un_phyno
|
.It un_phyno
|
||||||
MII phy number.
|
MII phy number.
|
||||||
|
@ -567,6 +572,8 @@ The optional
|
||||||
.Fn uno_stop
|
.Fn uno_stop
|
||||||
callback performs device-specific operations to shutdown the
|
callback performs device-specific operations to shutdown the
|
||||||
transmit or receive handling.
|
transmit or receive handling.
|
||||||
|
.Fn uno_stop
|
||||||
|
will be called with the usbnet lock held.
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn uno_init
|
.Fn uno_init
|
||||||
|
@ -589,6 +596,10 @@ enqueued with the higher layers using either
|
||||||
.Fn usbnet_input
|
.Fn usbnet_input
|
||||||
for devices that currently use
|
for devices that currently use
|
||||||
.Fn if_input .
|
.Fn if_input .
|
||||||
|
The Rx lock will be held during this call, see
|
||||||
|
.Xr Fn usbnet_lock_rx
|
||||||
|
and
|
||||||
|
.Xr Fn usbnet_unlock_rx .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fn uno_tx_prepare
|
.Fn uno_tx_prepare
|
||||||
|
@ -603,6 +614,10 @@ more than the chain buffer size, as set in the
|
||||||
.Dq un_tx_bufsz
|
.Dq un_tx_bufsz
|
||||||
member.
|
member.
|
||||||
This callback is only called once per packet.
|
This callback is only called once per packet.
|
||||||
|
The Tx lock will be held during this call, see
|
||||||
|
.Xr Fn usbnet_lock_tx
|
||||||
|
and
|
||||||
|
.Xr Fn usbnet_unlock_tx .
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
.Fa struct usbnet_chain
|
.Fa struct usbnet_chain
|
||||||
|
@ -631,6 +646,11 @@ Returns
|
||||||
.It uno_statchg
|
.It uno_statchg
|
||||||
Handle a status change event for this interface.
|
Handle a status change event for this interface.
|
||||||
.El
|
.El
|
||||||
|
The read and write callbacks are called with the MII lock held.
|
||||||
|
See
|
||||||
|
.Xr usbnet_lock_mii
|
||||||
|
and
|
||||||
|
.Xr usbnet_unlock_mii .
|
||||||
.Sh INTERRUPT PIPE
|
.Sh INTERRUPT PIPE
|
||||||
The interrupt specific callback,
|
The interrupt specific callback,
|
||||||
.Dq uno_intr ,
|
.Dq uno_intr ,
|
||||||
|
@ -641,6 +661,10 @@ using the
|
||||||
function (instead of the
|
function (instead of the
|
||||||
.Fn usbd_open_pipe
|
.Fn usbd_open_pipe
|
||||||
function.)
|
function.)
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
framework provides most of the interrupt handling and the callback
|
||||||
|
simply inspects the returned buffer as necessary.
|
||||||
To enable the this callback point the
|
To enable the this callback point the
|
||||||
.Va struct usbnet
|
.Va struct usbnet
|
||||||
member
|
member
|
||||||
|
@ -809,6 +833,12 @@ into a
|
||||||
useful for this device that will be passed onto
|
useful for this device that will be passed onto
|
||||||
.Fn usbd_transfer .
|
.Fn usbd_transfer .
|
||||||
The framework's handling of the Tx interrupt is all internal.
|
The framework's handling of the Tx interrupt is all internal.
|
||||||
|
.It Interrupt pipe handling
|
||||||
|
For devices requiring special handling of the interrupt pipe (i.e.,
|
||||||
|
they use the
|
||||||
|
.Fn usbd_open_pipe_intr
|
||||||
|
method), most of the interrupt handler should be deleted, leaving
|
||||||
|
only code that inspects the result of the interrupt transfer.
|
||||||
.It Common errors
|
.It Common errors
|
||||||
It's common to forget to set link active on devices with MII.
|
It's common to forget to set link active on devices with MII.
|
||||||
Be sure to call
|
Be sure to call
|
||||||
|
|
Loading…
Reference in New Issue