NetDev_Tx() (Ethernet)

The next function in the device API structure is the transmit/Tx() function.

Files

Every device driver’s net_dev.c

Prototype

          static void NetDev_Tx (NET_IF     *pif,
                                 CPU_INT08U *p_data,
                                 CPU_INT16U  size,
                                 NET_ERR    *perr);


Note that since every device driver’s Tx() function is accessed only by function pointer via the device driver’s API structure, it doesn’t need to be globally available and should therefore be declared as ‘static’.

Arguments

pif

Pointer to the interface to start a network device.

p_data

Pointer to address of the data to transmit.

size

Size of the data to transmit.

perr

Pointer to variable that will receive the return error code from this function.

Returned Value

None.

Required Configuration

None.

Notes / Warnings

The transmit function should perform the following actions:

  1. For DMA-based hardware, the driver should select the next available transmit descriptor and set the pointer to the data area equal to the address pointer to by p_data.
  2. Non-DMA hardware should Mem_Copy() the data stored within the buffer pointed to by p_data to the device’s internal memory.
  3. Once completed, the driver must configure the device with the number of bytes to transmit. This is passed directly by value within the size argument. DMA-based devices generally have a size field within the transmit descriptor. Non-DMA devices generally have a transmit size register that needs to be configured.
  4. The driver should then take all necessary steps to initiate transmission of the data.
  5. Set perr to NET_DEV_ERR_NONE and return from the transmit function.