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 />

H.3.2 Swapping Buffers Between Protocol and Driver<br />

To pass a buffer up to the MUX, a driver calls muxReceive( ), which, in turn, calls<br />

the protocol’s stackRcvRtn( ) routine (see Passing a Packet Up to the Protocol:<br />

stackRcvRtn( ), p.307). When control returns from muxReceive( ), the driver can<br />

consider the data delivered and can forget about the buffers it handed up to the<br />

MUX. When the upper layers are done with the data, they free the buffers back to<br />

the driver’s memory pool.<br />

This system is implicitly a buffer loaning system. If a device cannot receive data<br />

directly into clusters, it must first allocate its own memory (apart from a network<br />

buffer pool) and explicitly copy the data from its private memory into a cluster<br />

before passing it in an mBlk up to the MUX.<br />

H.3.3 Using Private Memory Management Routines<br />

If your device does not allow you to use the MUX memory-management utilities,<br />

you can write replacements for the ones provided by netBufLib. However, your<br />

replacements must conform to the API for these routines.<br />

H.3.4 Supporting Scatter-Gather in Your Driver<br />

Some devices support breaking up a single network packet into separate chunks<br />

of memory. This makes it possible to pass a packet (such as a list of mbufs from a<br />

Berkeley-type TCP/IP protocol) as a chain of mBlk/clBlk/cluster constructs.<br />

When a driver gets a chain of mBlks, it can decide at that point to transmit the<br />

clusters in the chain in any way it likes. If it can do a gather-write, then it need not<br />

do any data copying. If it cannot, then it has to put all of the data from the chain<br />

into a single memory area before transmitting it. This decision is driven by the type<br />

of network device for which the driver is implemented.<br />

H.4 Indicating Error Conditions<br />

Sometimes an END encounters errors or other events that are of interest to the<br />

protocols using that END. For example, the device could have gone down, or the<br />

280

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

Saved successfully!

Ooh no, something went wrong!