iPXE
iobpad.c File Reference

I/O buffer padding. More...

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

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ iob_pad()

void iob_pad ( struct io_buffer * iobuf,
size_t min_len )

Pad I/O buffer.

Parameters
iobufI/O buffer
min_lenMinimum 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 50 of file iobpad.c.

50 {
51 void *data;
52 size_t len;
53 size_t headroom;
54 signed int pad_len;
55
56 assert ( min_len <= IOB_ZLEN );
57
58 /* Move packet data to start of I/O buffer. This will both
59 * align the data (since I/O buffers are aligned to
60 * IOB_ALIGN) and give us sufficient space for the
61 * zero-padding
62 */
63 data = iobuf->data;
64 len = iob_len ( iobuf );
65 headroom = iob_headroom ( iobuf );
66 iob_push ( iobuf, headroom );
67 memmove ( iobuf->data, data, len );
68 iob_unput ( iobuf, headroom );
69
70 /* Pad to minimum packet length */
71 pad_len = ( min_len - iob_len ( iobuf ) );
72 if ( pad_len > 0 )
73 memset ( iob_put ( iobuf, pad_len ), 0, pad_len );
74}
long pad_len
Definition bigint.h:31
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
void * memset(void *dest, int character, size_t len) __nonnull
void * memmove(void *dest, const void *src, size_t len) __nonnull
static size_t iob_headroom(struct io_buffer *iobuf)
Calculate available space at start of an I/O buffer.
Definition iobuf.h:170
#define iob_push(iobuf, len)
Definition iobuf.h:89
#define IOB_ZLEN
Minimum I/O buffer length and alignment.
Definition iobuf.h:29
#define iob_put(iobuf, len)
Definition iobuf.h:125
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define iob_unput(iobuf, len)
Definition iobuf.h:140
void * data
Start of data.
Definition iobuf.h:53

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

Referenced by cgem_transmit(), eoib_transmit(), forcedeth_transmit(), legacy_transmit(), myri10ge_net_transmit(), nii_transmit(), pnic_transmit(), rdc_transmit(), realtek_transmit(), rhine_transmit(), sis190_transmit(), snpnet_transmit(), tg3_transmit(), and velocity_transmit().