02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VxWorks 5.5<br />

<strong>BSP</strong> Developer’s <strong>Guide</strong><br />

G.1.1 Structure of a 4.3 BSD Network Driver<br />

The network drivers currently shipped with VxWorks are based on those available<br />

in BSD UNIX version 4.3. These drivers define only one global (user-callable)<br />

routine, the driver’s attach( ) routine. Typically, the name of this routine contains<br />

the word, attach, prefixed with two letters from the device name. For example, the<br />

AMD Lance driver’s attach routine is called lnattach( ). The xxattach( ) routine<br />

hooks in five function pointers that are mapped into an ifnet structure. These<br />

functions, listed in Table G-1, are all called from various places in the IP protocol<br />

stack, which has intimate knowledge of the driver.<br />

Table G-1<br />

Network Interface Procedure Handles<br />

Function Function Pointer Driver-Specific Routine<br />

initialization if_init xxInit( )<br />

output if_output xxOutput( )<br />

control if_ioctl xxIoctl( )<br />

reset if_reset xxReset( )<br />

watchdog if_watchdog (optional) xxWatchdog( )<br />

Packet reception begins when the driver’s interrupt routine is invoked. The<br />

interrupt routine does the least work necessary to get the packet off the local<br />

hardware, schedules an input handler to run by calling netJobAdd( ), and then<br />

returns. The tNetTask calls the function that was added to its work queue. In the<br />

case of packet reception, this the driver’s xxReceive( ) function.<br />

The xxReceive( ) function eventually sends the packet up to a protocol by calling<br />

do_protocol_with_type( ). This routine is a switch statement that figures out<br />

which protocol to hand the packet off to. This calling sequence is shown in<br />

Figure G-1.<br />

Figure G-2 shows the call graph for packet transmission. After a protocol has<br />

picked an interface on which to send a packet, it calls the xxOutput( ) routine for<br />

that interface. The output routine calls the generic ether_output( ) function,<br />

passing it a pointer to addressing information (usually an arpcom structure) as<br />

well as the data to be sent. After the data is properly packed, it is placed on the<br />

output queue (using the IF_ENQUEUE macro), and the driver’s start routine is<br />

called. The xxTxStartup( ) routine dequeues as many packets as it can and<br />

transmits them on the physical medium.<br />

258

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!