simple_unlock(&sc->el_softc_lock);
splx(s);
thread_halt_self();
}
1
Enters a loop for transmitting a packet and determining if it succeeds.
A packet must go out twice successfully for media selection to succeed.
This algorithm probably will not work in all cases.
5.3.6 Saving Counters Prior to the Transmit Operation
The following code shows how the
el_autosense_thread( )
routine saves
counters prior to the transmit operation:
prev_tint= sc->tint;
prev_err = ifp->if_oerrors;
prev_tmo = sc->xmit_tmo;
5.3.7 Allocating Memory for a Test Packet
The following code shows how the
el_autosense_thread( )
routine
allocates memory for a test packet:
MGETHDR(m, M_WAIT, MT_DATA);
if ((+ > EL_AUTOSENSE_PASSES) || (m == NULL)) {
if (m) {
m_freem(m);
printf("el%d: Autosense thread cannot determine media\n",
ifp->if_unit);
printf("el%d: Use lan_config to configure if necessary\n",
ifp->if_unit);
} else {
printf("el%d: Autosense thread cannot get xmit buffer\n",
ifp->if_unit);
}
5.3.8 Using the Default from the ROM
The following code shows how the
el_autosense_thread( )
routine uses
the default media setting from ROM. This code sequence signifies a last
resort if the driver is unable to determine the media.
switch (sc->eeprom.addrconf & 0xc) {
1
case ACR_10B5:
if (sc->lm_media_mode == LAN_MODE_AUTOSENSE)
sc->lm_media = LAN_MEDIA_AUI;
break;
case ACR_10B2:
if (sc->lm_media_mode == LAN_MODE_AUTOSENSE)
sc->lm_media = LAN_MEDIA_BNC;
break;
case ACR_10BT:
default:
if (sc->lm_media_mode == LAN_MODE_AUTOSENSE)
sc->lm_media = LAN_MEDIA_UTP;
break;
}
printf("el%d: Used %s setting from eeprom\n",
Implementing the Autoconfiguration Support Section (probe) 5–21