2003-06-12 14:28:32 +00:00
|
|
|
.\" Copyright (c) 2003
|
|
|
|
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
2004-07-07 07:56:58 +00:00
|
|
|
.\" Author: Hartmut Brandt <harti@FreeBSD.org>
|
2003-06-12 14:28:32 +00:00
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
2004-07-07 07:56:58 +00:00
|
|
|
.\"
|
2003-06-12 14:28:32 +00:00
|
|
|
.Dd May 8, 2003
|
|
|
|
.Dt UTOPIA 9
|
2004-07-06 07:02:31 +00:00
|
|
|
.Os
|
2003-06-12 14:28:32 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm utopia
|
2004-07-07 07:56:58 +00:00
|
|
|
.Nd "driver module for ATM PHY chips"
|
2003-06-12 14:28:32 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In dev/utopia/utopia.h
|
|
|
|
.Ft int
|
2004-07-07 07:56:58 +00:00
|
|
|
.Fo utopia_attach
|
|
|
|
.Fa "struct utopia *utp" "struct ifatm *ifatm" "struct ifmedia *media"
|
|
|
|
.Fa "struct mtx *lock" "struct sysctl_ctx_list *ctx"
|
|
|
|
.Fa "struct sysctl_oid_list *tree" "const struct utopia_methods *vtab"
|
|
|
|
.Fc
|
2003-06-12 14:28:32 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn utopia_detach "struct utopia *utp"
|
|
|
|
.Ft int
|
|
|
|
.Fn utopia_start "struct utopia *utp"
|
|
|
|
.Ft void
|
|
|
|
.Fn utopia_stop "struct utopia *utp"
|
|
|
|
.Ft void
|
|
|
|
.Fn utopia_init_media "struct utopia *utp"
|
|
|
|
.Ft void
|
|
|
|
.Fn utopia_reset_media "struct utopia *utp"
|
|
|
|
.Ft int
|
|
|
|
.Fn utopia_reset "struct utopia *utp"
|
|
|
|
.Ft int
|
|
|
|
.Fn utopia_set_sdh "struct utopia *utp" "int sdh"
|
|
|
|
.Ft int
|
|
|
|
.Fn utopia_set_unass "struct utopia *utp" "int unass"
|
|
|
|
.Ft int
|
|
|
|
.Fn utopia_set_noscramb "struct utopia *utp" "int noscramb"
|
|
|
|
.Ft int
|
|
|
|
.Fn utopia_update_carrier "struct utopia *utp"
|
|
|
|
.Ft int
|
2004-07-03 18:29:24 +00:00
|
|
|
.Fn utopia_set_loopback "struct utopia *utp" "u_int mode"
|
2003-06-12 14:28:32 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn utopia_intr "struct utopia *utp"
|
2003-07-14 15:08:11 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn utopia_update_stats "struct utopia *utp"
|
2003-06-12 14:28:32 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
This module is used by all ATM drivers for cards that use a number of known
|
|
|
|
PHY chips to provide uniform functionality.
|
|
|
|
The module implements status monitoring in either interrupt or polling mode,
|
|
|
|
media option handling and application access to PHY registers.
|
|
|
|
.Pp
|
2004-07-07 07:56:58 +00:00
|
|
|
To use this interface, a driver must implement two functions for reading and
|
|
|
|
writing PHY registers, and initialize the following structure with pointers
|
2003-06-12 14:28:32 +00:00
|
|
|
to these functions:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct utopia_methods {
|
|
|
|
int (*readregs)(struct ifatm *, u_int reg,
|
|
|
|
uint8_t *val, u_int *n);
|
|
|
|
int (*writereg)(struct ifatm *, u_int reg,
|
|
|
|
u_int mask, u_int val);
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn readregs
|
|
|
|
function should read PHY registers starting at register
|
|
|
|
.Fa reg .
|
|
|
|
The maximum number of registers to read is given by the integer pointed
|
|
|
|
to by
|
|
|
|
.Fa n .
|
2004-07-07 07:56:58 +00:00
|
|
|
The function should either return 0 on success, or an error code.
|
|
|
|
In the first case,
|
2003-06-12 14:28:32 +00:00
|
|
|
.Fa *n
|
2004-07-07 07:56:58 +00:00
|
|
|
should be set to the actual number of registers read.
|
2003-06-12 14:28:32 +00:00
|
|
|
The
|
|
|
|
.Fn writereg
|
|
|
|
function should write one register.
|
|
|
|
It must change all bits for which the corresponding bit in
|
|
|
|
.Fa mask
|
|
|
|
is 1 to the value of the corresponding bit in
|
|
|
|
.Fa val .
|
2004-07-07 07:56:58 +00:00
|
|
|
It returns either 0 on success, or an error code.
|
2003-06-12 14:28:32 +00:00
|
|
|
.Pp
|
2004-07-07 07:56:58 +00:00
|
|
|
The ATM driver's private state block
|
|
|
|
.Pq Va softc
|
|
|
|
must begin with a
|
2003-06-12 14:28:32 +00:00
|
|
|
.Vt "struct ifatm" .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Vt "struct utopia"
|
|
|
|
holds the current state of the PHY chip and contains the following fields:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct utopia {
|
|
|
|
struct ifatm *ifatm; /* driver data */
|
|
|
|
struct ifmedia *media; /* driver supplied */
|
|
|
|
struct mtx *lock; /* driver supplied */
|
|
|
|
const struct utopia_methods *methods;
|
|
|
|
LIST_ENTRY(utopia) link; /* list of these structures */
|
|
|
|
u_int flags; /* flags set by the driver */
|
|
|
|
u_int state; /* current state */
|
|
|
|
u_int carrier; /* carrier state */
|
|
|
|
u_int loopback; /* loopback mode */
|
|
|
|
const struct utopia_chip *chip; /* chip operations */
|
2003-07-14 15:08:11 +00:00
|
|
|
struct utopia_stats1 stats; /* statistics */
|
2003-06-12 14:28:32 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
The public accessible fields have the following functions:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Va ifatm
|
2004-07-07 07:56:58 +00:00
|
|
|
Pointer to the driver's private data
|
|
|
|
.Pq Va softc .
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Va media
|
|
|
|
Pointer to the driver's media structure.
|
2004-07-07 07:56:58 +00:00
|
|
|
.It Va lock
|
2004-07-03 18:29:24 +00:00
|
|
|
Pointer to a mutex provided by the driver.
|
|
|
|
This mutex is used to synchronize
|
|
|
|
with the kernel thread that handles device polling.
|
|
|
|
It is locked in several
|
2003-06-12 14:28:32 +00:00
|
|
|
places:
|
|
|
|
.Bl -enum -offset indent
|
|
|
|
.It
|
|
|
|
In
|
|
|
|
.Fn utopia_detach
|
|
|
|
the mutex is locked to sleep and wait for the kernel thread to remove the
|
|
|
|
.Vt "struct utopia"
|
2004-07-07 07:56:58 +00:00
|
|
|
from the list of all
|
|
|
|
.Nm
|
|
|
|
devices.
|
2003-06-12 14:28:32 +00:00
|
|
|
Before returning to the caller the mutex is unlocked.
|
|
|
|
.It
|
|
|
|
In the
|
|
|
|
.Nm
|
2004-07-07 07:56:58 +00:00
|
|
|
kernel thread the mutex is locked, and the
|
2003-06-12 14:28:32 +00:00
|
|
|
.Fn utopia_carrier_update
|
|
|
|
function is called with this mutex locked.
|
|
|
|
This will result in the driver's
|
2004-07-03 18:29:24 +00:00
|
|
|
.Fn readregs
|
2004-06-21 14:11:45 +00:00
|
|
|
function being called with the mutex locked.
|
2003-06-12 14:28:32 +00:00
|
|
|
.It
|
|
|
|
In the sysctl handlers the mutex will be locked before calling into the driver's
|
|
|
|
.Fn readreg
|
|
|
|
or
|
|
|
|
.Fn writereg
|
|
|
|
functions.
|
|
|
|
.El
|
|
|
|
.It Va flags
|
2004-07-07 07:56:58 +00:00
|
|
|
Flags set by either the driver or the
|
|
|
|
.Nm
|
|
|
|
module.
|
2004-07-03 18:29:24 +00:00
|
|
|
The following flags are
|
2003-06-12 14:28:32 +00:00
|
|
|
defined:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_FL_NORESET
|
2004-07-07 07:56:58 +00:00
|
|
|
If this flag is set, the module will not try to write the
|
2004-07-03 18:29:24 +00:00
|
|
|
SUNI master reset register.
|
2004-07-07 07:56:58 +00:00
|
|
|
(Set by the driver.)
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_FL_POLL_CARRIER
|
2004-07-07 07:56:58 +00:00
|
|
|
If this flag is set, the module will periodically poll the carrier state
|
2004-07-03 18:29:24 +00:00
|
|
|
(as opposed to interrupt driven carrier state changes).
|
2004-07-07 07:56:58 +00:00
|
|
|
(Set by the driver.)
|
2003-06-12 14:28:32 +00:00
|
|
|
.El
|
|
|
|
.It Va state
|
2004-07-07 07:56:58 +00:00
|
|
|
Flags describing the current state of the PHY chip.
|
2004-07-03 18:29:24 +00:00
|
|
|
These are managed
|
2003-06-12 14:28:32 +00:00
|
|
|
by the module:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_ST_ACTIVE
|
2004-07-07 07:56:58 +00:00
|
|
|
The driver is active and the PHY registers can be accessed.
|
2003-06-12 14:28:32 +00:00
|
|
|
This is set by calling
|
|
|
|
.Fn utopia_start ,
|
|
|
|
which should be called either in the attach routine of the driver or
|
|
|
|
in the network interface initialisation routine (depending on whether the
|
|
|
|
registers are accessible all the time or only when the interface is up).
|
|
|
|
.It Dv UTP_ST_SDH
|
|
|
|
Interface is in SDH mode as opposed to SONET mode.
|
|
|
|
.It Dv UTP_ST_UNASS
|
|
|
|
Interface is producing unassigned cells instead of idle cells.
|
|
|
|
.It Dv UTP_ST_NOSCRAMB
|
|
|
|
Cell scrambling is switched off.
|
|
|
|
.It Dv UTP_ST_DETACH
|
2004-07-07 07:56:58 +00:00
|
|
|
(Internal use.)
|
|
|
|
Interface is currently detaching.
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_ST_ATTACHED
|
|
|
|
The attach routine has been run successfully.
|
|
|
|
.El
|
|
|
|
.It Va carrier
|
2004-07-03 18:29:24 +00:00
|
|
|
The carrier state of the interface.
|
|
|
|
This field can have one of three values:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_CARR_UNKNOWN
|
|
|
|
Carrier state is still unknown.
|
|
|
|
.It Dv UTP_CARR_OK
|
|
|
|
Carrier has been detected.
|
|
|
|
.It Dv UTP_CARR_LOST
|
|
|
|
Carrier has been lost.
|
|
|
|
.El
|
|
|
|
.It Va loopback
|
2004-07-03 18:29:24 +00:00
|
|
|
This is the current loopback mode of the interface.
|
2004-07-07 07:56:58 +00:00
|
|
|
Note that not all
|
2004-07-03 18:29:24 +00:00
|
|
|
chips support all loopback modes.
|
|
|
|
Refer to the chip documentation.
|
|
|
|
The
|
2003-06-12 14:28:32 +00:00
|
|
|
following modes may be supported:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_LOOP_NONE
|
|
|
|
No loopback, normal operation.
|
|
|
|
.It Dv UTP_LOOP_TIME
|
2004-07-03 18:29:24 +00:00
|
|
|
Timing source loopback.
|
|
|
|
The transmitter clock is driven by the receive clock.
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Dv UTP_LOOP_DIAG
|
|
|
|
Diagnostic loopback.
|
|
|
|
.It Dv UTP_LOOP_LINE
|
|
|
|
Serial line loopback.
|
|
|
|
.It Dv UTP_LOOP_PARAL
|
|
|
|
Parallel diagnostic loopback.
|
|
|
|
.It Dv UTP_LOOP_TWIST
|
|
|
|
Twisted pair diagnostic loopback.
|
|
|
|
.It Dv UTP_LOOP_PATH
|
|
|
|
Diagnostic path loopback.
|
|
|
|
.El
|
|
|
|
.It Va chip
|
2004-07-07 07:56:58 +00:00
|
|
|
This points to a function vector for chip specific functions.
|
2004-07-03 18:29:24 +00:00
|
|
|
Two fields
|
2004-07-03 22:53:50 +00:00
|
|
|
in this vector are publically available:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Va type
|
|
|
|
This is the type of the detected PHY chip.
|
|
|
|
One of:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -compact
|
|
|
|
.It Dv UTP_TYPE_UNKNOWN Pq No 0
|
|
|
|
.It Dv UTP_TYPE_SUNI_LITE Pq No 1
|
|
|
|
.It Dv UTP_TYPE_SUNI_ULTRA Pq No 2
|
|
|
|
.It Dv UTP_TYPE_SUNI_622 Pq No 3
|
|
|
|
.It Dv UTP_TYPE_IDT77105 Pq No 4
|
2003-06-12 14:28:32 +00:00
|
|
|
.El
|
|
|
|
.It Va name
|
|
|
|
This is a string with the name of the PHY chip.
|
|
|
|
.El
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following functions are used by the driver during attach/detach and/or
|
|
|
|
initialisation/stopping the interface:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Fn utopia_attach
|
2004-07-03 18:29:24 +00:00
|
|
|
Attach the PHY chip.
|
|
|
|
This is called with a preallocated
|
2003-06-12 14:28:32 +00:00
|
|
|
.Vt "struct utopia"
|
2004-07-07 07:56:58 +00:00
|
|
|
(which may be part of the driver's
|
|
|
|
.Va softc ) .
|
|
|
|
The module initializes all fields of the
|
|
|
|
.Nm
|
|
|
|
state and the media field.
|
2003-06-12 14:28:32 +00:00
|
|
|
User settable flags should be set after the call to
|
|
|
|
.Fn utopia_attach .
|
|
|
|
This function may fail due to the inability to install the sysctl handlers.
|
2004-07-07 07:56:58 +00:00
|
|
|
In this case it will return \-1.
|
|
|
|
On success, 0 is returned and the
|
2003-06-12 14:28:32 +00:00
|
|
|
.Dv UTP_ST_ATTACHED
|
|
|
|
flag is set.
|
|
|
|
.It Fn utopia_detach
|
2004-07-07 07:56:58 +00:00
|
|
|
Remove the
|
|
|
|
.Nm
|
|
|
|
attachment from the system.
|
2004-07-03 18:29:24 +00:00
|
|
|
This cancels all outstanding polling
|
2003-06-12 14:28:32 +00:00
|
|
|
timeouts.
|
|
|
|
.It Fn utopia_start
|
2004-07-03 18:29:24 +00:00
|
|
|
Start operation of that PHY.
|
|
|
|
This should be called at a time
|
|
|
|
when the PHY registers are known to be accessible.
|
|
|
|
This may be either in
|
2003-06-12 14:28:32 +00:00
|
|
|
the driver's attach function or when the interface is set running.
|
|
|
|
.It Fn utopia_stop
|
2004-07-03 18:29:24 +00:00
|
|
|
Stop operation of the PHY attachment.
|
|
|
|
This may be called either in the detach
|
2003-06-12 14:28:32 +00:00
|
|
|
function of the driver or when the interface is brought down.
|
|
|
|
.It Fn utopia_init_media
|
2004-07-03 18:29:24 +00:00
|
|
|
This must be called if the media field in the ATM MIB was changed.
|
|
|
|
The function
|
2003-06-12 14:28:32 +00:00
|
|
|
makes sure, that the ifmedia fields contain the same information as the
|
|
|
|
ATM MIB.
|
|
|
|
.It Fn utopia_reset_media
|
|
|
|
This may be called to remove all media information from the ifmedia field.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following functions can be used to modify the PHY state while the interface
|
|
|
|
is running:
|
2004-07-07 07:56:58 +00:00
|
|
|
.Bl -tag -width indent
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Fn utopia_reset
|
|
|
|
Reset the operational parameters to the default state (SONET, idle cells,
|
2004-07-03 18:29:24 +00:00
|
|
|
scrambling enabled).
|
2004-07-07 07:56:58 +00:00
|
|
|
Returns 0 on success, an error code otherwise, leaving
|
2003-06-12 14:28:32 +00:00
|
|
|
the state undefined.
|
|
|
|
.It Fn utopia_set_sdh
|
|
|
|
If the argument is zero the chip is switched to Sonet mode, if it is non-zero
|
2004-07-03 18:29:24 +00:00
|
|
|
the chip is switched to SDH mode.
|
2004-07-07 07:56:58 +00:00
|
|
|
Returns 0 on success, an error code otherwise,
|
2003-06-12 14:28:32 +00:00
|
|
|
leaving the previous state.
|
|
|
|
.It Fn utopia_set_unass
|
|
|
|
If the argument is zero the chip is switched to produce idle cells, if it is
|
2004-07-03 18:29:24 +00:00
|
|
|
non-zero the chip is switched to produce unassigned cells.
|
|
|
|
Returns 0 on success,
|
2004-07-07 07:56:58 +00:00
|
|
|
an error code otherwise, leaving the previous state.
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Fn utopia_set_noscramb
|
|
|
|
If the argument is zero enables scrambling, if it is
|
2004-07-03 18:29:24 +00:00
|
|
|
non-zero disables scrambling.
|
|
|
|
Returns 0 on success,
|
2004-07-07 07:56:58 +00:00
|
|
|
an error code otherwise, leaving the previous state.
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Fn utopia_update_carrier
|
|
|
|
Check the carrier state and update the carrier field in the state structure.
|
2004-07-07 07:56:58 +00:00
|
|
|
This will generate a message to the Netgraph stack if the carrier state changes.
|
2003-06-12 14:28:32 +00:00
|
|
|
For chips that are polled this is called automatically, for interrupt
|
|
|
|
driven attachments this must be called on interrupts from the PHY chip.
|
|
|
|
.It Fn utopia_set_loopback
|
2004-07-03 18:29:24 +00:00
|
|
|
Set the loopback mode of the chip.
|
|
|
|
Returns 0 on success, an error code
|
2004-07-07 07:56:58 +00:00
|
|
|
otherwise, leaving the previous state.
|
2003-06-12 14:28:32 +00:00
|
|
|
.It Fn utopia_intr
|
2004-07-03 18:29:24 +00:00
|
|
|
Called when an interrupt from the PHY chip is detected.
|
|
|
|
This resets the
|
2003-06-12 14:28:32 +00:00
|
|
|
interrupt state by reading all registers and, if the interrupt was from the
|
|
|
|
RSOP, checks the carrier state.
|
2003-07-14 15:08:11 +00:00
|
|
|
.It Fn utopia_update_stats
|
2004-07-07 07:56:58 +00:00
|
|
|
Update the statistics with counters read from the chip.
|
2003-06-12 14:28:32 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr utopia 4
|
2004-07-07 07:56:58 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An Harti Brandt Aq harti@FreeBSD.org
|