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 places:
In utopia_detach the mutex is locked to sleep and wait for the kernel thread to remove the .Vt "struct utopia" from the list of all utopia devices. Before returning to the caller the mutex is unlocked.
In the utopia kernel thread the mutex is locked, and the utopia_carrier_update function is called with this mutex locked. This will result in the drivers readregs function being called with the mutex locked.
In the sysctl handlers the mutex will be locked before calling into the drivers readreg or writereg functions.
flags
Flags set by either the driver or the utopia module. The following flags are defined:
UTP_FL_NORESET
If this flag is set, the module will not try to write the SUNI master reset register. (Set by the driver.)
UTP_FL_POLL_CARRIER
If this flag is set, the module will periodically poll the carrier state (as opposed to interrupt driven carrier state changes). (Set by the driver.)
state
Flags describing the current state of the PHY chip. These are managed by the module:
UTP_ST_ACTIVE
The driver is active and the PHY registers can be accessed. This is set by calling 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).
UTP_ST_SDH
Interface is in SDH mode as opposed to SONET mode.
UTP_ST_UNASS
Interface is producing unassigned cells instead of idle cells.
UTP_ST_NOSCRAMB
Cell scrambling is switched off.
UTP_ST_DETACH
(Internal use.) Interface is currently detaching.
UTP_ST_ATTACHED
The attach routine has been run successfully.
carrier
The carrier state of the interface. This field can have one of three values:
UTP_CARR_UNKNOWN
Carrier state is still unknown.
UTP_CARR_OK
Carrier has been detected.
UTP_CARR_LOST
Carrier has been lost.
loopback
This is the current loopback mode of the interface. Note that not all chips support all loopback modes. Refer to the chip documentation. The following modes may be supported:
UTP_LOOP_NONE
No loopback, normal operation.
UTP_LOOP_TIME
Timing source loopback. The transmitter clock is driven by the receive clock.
UTP_LOOP_DIAG
Diagnostic loopback.
UTP_LOOP_LINE
Serial line loopback.
UTP_LOOP_PARAL
Parallel diagnostic loopback.
UTP_LOOP_TWIST
Twisted pair diagnostic loopback.
UTP_LOOP_PATH
Diagnostic path loopback.
chip
This points to a function vector for chip specific functions. Two fields in this vector are publically available:
type
This is the type of the detected PHY chip. One of:
The following functions are used by the driver during attach/detach and/or initialisation/stopping the interface:
utopia_attach
Attach the PHY chip. This is called with a preallocated .Vt "struct utopia" (which may be part of the drivers softc). The module initializes all fields of the utopia state and the media field. User settable flags should be set after the call to utopia_attach. This function may fail due to the inability to install the sysctl handlers. In this case it will return -1. On success, 0 is returned and the UTP_ST_ATTACHED flag is set.
utopia_detach
Remove the utopia attachment from the system. This cancels all outstanding polling timeouts.
utopia_start
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 the drivers attach function or when the interface is set running.
utopia_stop
Stop operation of the PHY attachment. This may be called either in the detach function of the driver or when the interface is brought down.
utopia_init_media
This must be called if the media field in the ATM MIB was changed. The function makes sure, that the ifmedia fields contain the same information as the ATM MIB.
utopia_reset_media
This may be called to remove all media information from the ifmedia field.
The following functions can be used to modify the PHY state while the interface is running:
utopia_reset
Reset the operational parameters to the default state (SONET, idle cells, scrambling enabled). Returns 0 on success, an error code otherwise, leaving the state undefined.
utopia_set_sdh
If the argument is zero the chip is switched to Sonet mode, if it is non-zero the chip is switched to SDH mode. Returns 0 on success, an error code otherwise, leaving the previous state.
utopia_set_unass
If the argument is zero the chip is switched to produce idle cells, if it is non-zero the chip is switched to produce unassigned cells. Returns 0 on success, an error code otherwise, leaving the previous state.
utopia_set_noscramb
If the argument is zero enables scrambling, if it is non-zero disables scrambling. Returns 0 on success, an error code otherwise, leaving the previous state.
utopia_update_carrier
Check the carrier state and update the carrier field in the state structure. This will generate a message to the Netgraph stack if the carrier state changes. For chips that are polled this is called automatically, for interrupt driven attachments this must be called on interrupts from the PHY chip.
utopia_set_loopback
Set the loopback mode of the chip. Returns 0 on success, an error code otherwise, leaving the previous state.
utopia_intr
Called when an interrupt from the PHY chip is detected. This resets the interrupt state by reading all registers and, if the interrupt was from the RSOP, checks the carrier state.
utopia_update_stats
Update the statistics with counters read from the chip.