Upper Layer Functions

Upper layer functions are called by drivers to deliver received packets or transmission completion status back up into the network stack.

These functions are defined by the hardware independent upper layers of the networking driver support. They are present to hide the interfaces to the actual networking stack so that the hardware drivers may be used by different network stack implementations without change.

These functions require a pointer to a struct eth_drv_sc which describes the interface at a logical level. It is assumed that the low level hardware driver will keep track of this pointer so it may be passed “up” as appropriate.

Callback Init function

void (sc->funs->eth_drv->init)(
		struct eth_drv_sc *sc, unsigned char *enaddr)
This function establishes the device at initialization time. It should be called once per device instance only, from the initialization function, if all is well (see the Section called Init function). The hardware should be totally initialized (not “started”) when this function is called.

Callback Tx-Done function

void (sc->funs->eth_drv->tx_done)(
		struct eth_drv_sc *sc,
		unsigned long key, int status)
This function is called when a packet completes transmission on the interface. The key value must be one of the keys provided to HRDWR_send() above. The value status should be non-zero (details currently undefined) to indicate that an error occurred during the transmission, and zero if all was well.

It should be called from the deliver function (see the Section called Deliver function) or poll function (see the Section called Poll function).

Callback Receive function

void (sc->funs->eth_drv->recv)(struct eth_drv_sc *sc, int len)
This function is called to indicate that a packet of length len has arrived at the interface. The callback HRDWR_recv() function described above will be used to actually unload the data from the interface into buffers used by the device independent layers.

It should be called from the deliver function (see the Section called Deliver function) or poll function (see the Section called Poll function).