iobpad.c File Reference

I/O buffer padding. More...

#include <string.h>
#include <gpxe/iobuf.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
void iob_pad (struct io_buffer *iobuf, size_t min_len)
 Pad I/O buffer.


Detailed Description

I/O buffer padding.

Definition in file iobpad.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

void iob_pad ( struct io_buffer iobuf,
size_t  min_len 
)

Pad I/O buffer.

Parameters:
iobuf I/O buffer
min_len Minimum length
This function pads and aligns I/O buffers, for devices that aren't capable of padding in hardware, or that require specific alignment in TX buffers. The packet data will end up aligned to a multiple of IOB_ALIGN.

min_len must not exceed

Parameters:
IOB_ZLEN. 

Definition at line 44 of file iobpad.c.

References assert, io_buffer::data, iob_headroom(), iob_len(), iob_push, iob_put, iob_unput, IOB_ZLEN, memmove(), and memset().

Referenced by legacy_transmit(), myri10ge_net_transmit(), pnic_transmit(), rtl_transmit(), and sis190_transmit().

00044                                                          {
00045         void *data;
00046         size_t len;
00047         size_t headroom;
00048         signed int pad_len;
00049 
00050         assert ( min_len <= IOB_ZLEN );
00051 
00052         /* Move packet data to start of I/O buffer.  This will both
00053          * align the data (since I/O buffers are aligned to
00054          * IOB_ALIGN) and give us sufficient space for the
00055          * zero-padding
00056          */
00057         data = iobuf->data;
00058         len = iob_len ( iobuf );
00059         headroom = iob_headroom ( iobuf );
00060         iob_push ( iobuf, headroom );
00061         memmove ( iobuf->data, data, len );
00062         iob_unput ( iobuf, headroom );
00063 
00064         /* Pad to minimum packet length */
00065         pad_len = ( min_len - iob_len ( iobuf ) );
00066         if ( pad_len > 0 )
00067                 memset ( iob_put ( iobuf, pad_len ), 0, pad_len );
00068 }


Generated on Tue Apr 6 20:01:55 2010 for gPXE by  doxygen 1.5.7.1