•
Determines whether packets were transmitted successfully
(Section 5.3.14)
•
Prints debug information (Section 5.3.15)
•
Sets up new media to try if transmit was unsuccessful (Section 5.3.16)
•
Establishes media if transmit was successful (Section 5.3.17)
5.3.1 Setting Up the el_autosense_thread Routine
The following code shows how to set up the el_autosense_thread( )
routine:
unsigned char el_junk_msg[] = {
0xaa, 0x00, 0x04, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x60, 0x06,
't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 'j', 'u', 'n', 'k',
' ', 'a', 'u', 't', 'o', 's', 'e', 'n', 's', 'e', ' ', 'm',
'e', 's', 's', 'a', 'g', 'e', '.'
};
#define EL_JUNK_SIZE 46
#define EL_AUTOSENSE_PASSES 3*10
static void el_autosense_thread(struct el_softc *sc)
{
struct ifnet *ifp = &sc->is_if;
unsigned long prev_tint, prev_tmo, prev_err;
struct mbuf *m;
int good_xmits, wait, s, i, link_beat, passes;
unsigned long wait_flag=0;
Defines the message to transmit when trying to determine the mode of
1
the device.
Declares a pointer to the el_softc data structure and calls it sc.
2
Declares a pointer to an ifnet data structure and calls it ifp. This line
3
also initializes ifp to the address of the ifnet data structure for this
3Com 3C5x9 device. The ifnet data structure is referenced through
the is_if member of the el_softc data structure pointer. The is_if
name is an alternate name for the ac_if member of the arpcom data
structure. The ac_if member is referred to as the network-visible
interface and is actually the instance of the ifnet data structure for
this 3Com 3C5x9 device.
5.3.2 Blocking Until Awakened
The following code shows how the el_autosense_thread( ) routine blocks
until awakened:
while(1) {
assert_wait((vm_offset_t)&sc->autosense_flag, TRUE);
thread_block();
Waits for some process to indicate when to proceed with the autosense
1
test.
1
3
Implementing the Autoconfiguration Support Section (probe) 5–19
2
1