To determine the mode, el_autosense_thread( ) tries to send a test data packet in each of the possible modes. When it successfully transmits the data packet, it sets the network interface to that mode. The lm_media_mode, lm_media, and lm_media_state members of the el_softc data structure keep track of the progress of the autosensing procedure, as follows:
•The value of the lm_media_mode member determines whether the el_autosense_thread( ) will automatically determine the network interface, or whether the user specified the type of media.
•The lm_media member specifies the current media. This member changes each time that the driver uses a different medium to try to transmit a packet. The if_el device driver can set this member to any of the following values:
LAN_MEDIA_UTP
LAN_MEDIA_BNC
LAN_MEDIA_AUI
The media is unshielded
The media is thin wire.
The media is the attachment unit interface (AUI).
•The lm_media_state member specifies the current state of the autosensing procedure, as follows:
LAN_MEDIA_STATE_SENSING | The driver is trying to determine |
| the media mode. |
LAN_MEDIA_STATE_DETERMINED | The media state has been determined. |
The el_autosense_thread( ) routine is implemented as a kernel thread. It performs the following tasks:
•Blocks until awakened (Section 5.3.2)
•Tests for the termination flag (Section 5.3.3)
•Starts up statistics (Section 5.3.4)
•Enters the packet transmit loop (Section 5.3.5)
•Saves counters prior to the transmit operation (Section 5.3.6)
•Allocates memory for a test packet (Section 5.3.7)
•Uses the default from the ROM (Section 5.3.8)
•Sets the media setting in the hardware (Section 5.3.9)
•Builds a test packet to transmit (Section 5.3.10)
•Transmits the test packet (Section 5.3.11)
•Sets a timer for the current kernel thread (Section 5.3.12)
•Tests for loss of carrier (Section 5.3.13)