54 unsigned int align_log2;
65 padding = ( headroom + tailroom );
74 align_log2 =
fls ( align - 1 );
75 if ( align_log2 >= ( 8 *
sizeof ( align ) ) )
77 align = ( 1UL << align_log2 );
80 assert ( align >=
sizeof ( *iobuf ) );
81 threshold = ( align -
sizeof ( *iobuf ) );
87 if (
len <= threshold ) {
104 iobuf =
malloc (
sizeof ( *iobuf ) );
167 if ( iobuf->
end == iobuf ) {
270 if ( ! concatenated )
#define iob_pull(iobuf, len)
struct arbelprm_rc_send_wqe rc
#define iob_put(iobuf, len)
struct dma_mapping map
DMA mapping.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct io_buffer * alloc_iob_raw(size_t len, size_t align, size_t offset)
Allocate I/O buffer with specified alignment and offset.
#define PAGE_SIZE
Page size.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
A doubly-linked list entry (or list head)
Dynamic memory allocation.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
#define list_del(list)
Delete an entry from a list.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
static __always_inline void iob_unmap(struct io_buffer *iobuf)
Unmap I/O buffer for DMA.
void * malloc_phys_offset(size_t size, size_t phys_align, size_t offset)
Allocate memory with specified physical alignment and offset.
static __always_inline int dma_mapped(struct dma_mapping *map)
Check if DMA unmapping is required.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
struct io_buffer * iob_concatenate(struct list_head *list)
Concatenate I/O buffers into a single buffer.
static void(* free)(struct refcnt *refcnt))
struct io_buffer * alloc_rx_iob(size_t len, struct dma_device *dma)
Allocate and map I/O buffer for receive DMA.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
void * end
End of the buffer.
void * malloc(size_t size)
Allocate memory.
#define INIT_LIST_HEAD(list)
Initialise a list head.
static size_t iob_headroom(struct io_buffer *iobuf)
Calculate available space at start of an I/O buffer.
#define list_is_singular(list)
Test whether a list has just one entry.
struct list_head list
List of which this buffer is a member.
static __always_inline int iob_map_rx(struct io_buffer *iobuf, struct dma_device *dma)
Map empty I/O buffer for receive DMA.
void free_rx_iob(struct io_buffer *iobuf)
Unmap and free I/O buffer for receive DMA.
#define ENOBUFS
No buffer space available.
void * head
Start of the buffer.
struct io_buffer * iob_split(struct io_buffer *iobuf, size_t len)
Split I/O buffer.
#define IOB_ZLEN
Minimum I/O buffer length and alignment.
void * data
Start of data.
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
uint8_t data[48]
Additional event data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint16_t offset
Offset to command line.
#define fls(x)
Find last (i.e.
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
#define NULL
NULL pointer (VOID *)
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
void * memset(void *dest, int character, size_t len) __nonnull