Cansend function, Send function, Can-send function – Comtrol eCos User Manual

Page 606

Advertising
background image

Chapter 46. Generic Ethernet Device Driver

};

ETH_DRV_SET_MC_ALL

This entry instructs the device to receive all multicast packets, and delete any explicit filtering which had been
set up.

This function should return zero if the specified operation was completed successfully. It should return non-zero if
the operation could not be performed, for any reason.

Can-send function

static int HRDWR_can_send(struct eth_drv_sc *sc)

This function is called to determine if it is possible to start the transmission of a packet on the interface. Some
interfaces will allow multiple packets to be "queued" and this function allows for the highest possible utilization of
that mode.

Return the number of packets which could be accepted at this time, zero implies that the interface is saturated/busy.

Send function

struct eth_drv_sg {

CYG_ADDRESS

buf;

CYG_ADDRWORD len;

};

static void

HRDWR_send(

struct eth_drv_sc *sc,

struct eth_drv_sg *sg_list, int sg_len,

int total_len, unsigned long key)

This function is used to send a packet of data to the network. It is the responsibility of this function to somehow
hand the data over to the hardware interface. This will most likely require copying, but just the address/length
values could be used by smart hardware.

Note: All data in/out of the driver is specified via a “scatter-gather” list. This is just an array of address/length
pairs which describe sections of data to move (in the order given by the array), as in the struct eth_drv_sg
defined above and pointed to by

sg_list

.

Once the data has been successfully sent by the interface (or if an error occurs), the driver should call

(sc->funs-

>eth_drv->tx_done)()

(see

the Section called Callback Tx-Done function

) using the specified

key

. Only then

will the upper layers release the resources for that packet and start another transmission.

502

Advertising