iobuf.c File Reference

I/O buffers. More...

#include <stdint.h>
#include <errno.h>
#include <gpxe/malloc.h>
#include <gpxe/iobuf.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
struct io_bufferalloc_iob (size_t len)
 Allocate I/O buffer.
void free_iob (struct io_buffer *iobuf)
 Free I/O buffer.
int iob_ensure_headroom (struct io_buffer *iobuf, size_t len)
 Ensure I/O buffer has sufficient headroom.


Detailed Description

I/O buffers.

Definition in file iobuf.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

struct io_buffer* alloc_iob ( size_t  len  )  [read]

Allocate I/O buffer.

Parameters:
len Required length of buffer
Return values:
iobuf I/O buffer, or NULL if none available
The I/O buffer will be physically aligned to a multiple of IOBUF_SIZE.

Definition at line 41 of file iobuf.c.

References io_buffer::data, io_buffer::end, io_buffer::head, IOB_ALIGN, IOB_ZLEN, malloc_dma(), NULL, and io_buffer::tail.

Referenced by a3c90x_refill_rx_ring(), aoe_send_command(), arp_resolve(), ath5k_rx_iob_alloc(), atl1e_clean_rx_irq(), b44_init_rx_ring(), b44_rx_refill(), ccmp_decrypt(), ccmp_encrypt(), default_xfer_alloc_iob(), e1000_refill_rx_ring(), e1000e_refill_rx_ring(), efab_fill_rx_queue(), efi_snp_transmit(), gdbudp_send(), ib_mi_send(), ib_refill_recv(), icmp6_send_solicit(), ifec_get_rx_desc(), igb_refill_rx_ring(), ipv4_reassemble(), legacy_poll(), mtnic_alloc_iobuf(), myri10ge_net_open(), myri10ge_net_poll(), natsemi_open(), natsemi_poll(), net80211_accum_frags(), net80211_probe_start(), net80211_probe_step(), net80211_send_assoc(), net80211_send_auth(), net80211_send_disassoc(), phantom_refill_rx_ring(), pnic_poll(), pxenv_undi_transmit(), rtl8169_refill_rx_ring(), rtl818x_handle_rx(), rtl818x_init_rx_ring(), rtl_poll(), sis190_alloc_rx_iob(), skge_rx_refill(), sky2_rx_alloc(), tcp_xmit(), tcp_xmit_reset(), tkip_decrypt(), tkip_encrypt(), udp_alloc_iob(), undinet_poll(), vxge_hw_ring_replenish(), vxge_hw_vpath_poll_rx(), wep_decrypt(), wep_encrypt(), and wpa_alloc_frame().

00041                                             {
00042         struct io_buffer *iobuf = NULL;
00043         void *data;
00044 
00045         /* Pad to minimum length */
00046         if ( len < IOB_ZLEN )
00047                 len = IOB_ZLEN;
00048 
00049         /* Align buffer length */
00050         len = ( len + __alignof__( *iobuf ) - 1 ) &
00051                 ~( __alignof__( *iobuf ) - 1 );
00052         
00053         /* Allocate memory for buffer plus descriptor */
00054         data = malloc_dma ( len + sizeof ( *iobuf ), IOB_ALIGN );
00055         if ( ! data )
00056                 return NULL;
00057 
00058         iobuf = ( struct io_buffer * ) ( data + len );
00059         iobuf->head = iobuf->data = iobuf->tail = data;
00060         iobuf->end = iobuf;
00061         return iobuf;
00062 }

void free_iob ( struct io_buffer iobuf  ) 

Free I/O buffer.

Parameters:
iobuf I/O buffer

Definition at line 69 of file iobuf.c.

References assert, io_buffer::data, io_buffer::end, free_dma(), io_buffer::head, and io_buffer::tail.

Referenced by __vxge_hw_ring_delete(), a3c90x_free_rx_iobuf(), aoe_rx(), arp_rx(), ath5k_rxbuf_free(), b44_free_rx_ring(), ccmp_decrypt(), dhcp_deliver_iob(), dhcp_tx(), downloader_xfer_deliver_iob(), e1000_free_rx_resources(), e1000e_free_rx_resources(), eapol_key_rx(), eapol_rx(), efab_free_resources(), efab_receive(), efi_snp_receive(), efi_snp_transmit(), gdbudp_recv(), http_socket_deliver_iob(), ib_cmrc_complete_recv(), ib_cmrc_complete_send(), ib_cmrc_xfer_deliver_iob(), ib_complete_recv(), ib_complete_send(), ib_mi_complete_recv(), ib_mi_send(), ib_refill_recv(), icmp6_rx(), icmp_rx(), ifec_free(), igb_free_rx_resources(), ipv4_reassemble(), ipv4_rx(), ipv4_tx(), ipv6_rx(), ipv6_tx(), legacy_poll(), mtnic_free_io_buffers(), mtnic_process_rx_cq(), myri10ge_net_close(), myri10ge_net_open(), natsemi_close(), natsemi_open(), net80211_free_frags(), net80211_free_wlan(), net80211_handle_mgmt(), net80211_probe_finish_all(), net80211_probe_finish_best(), net80211_probe_step(), net80211_rx(), net80211_rx_frag(), net80211_tx_mgmt(), net_rx(), net_step(), net_tx(), netdev_rx_err(), netdev_tx_complete_err(), phantom_close(), posix_file_free(), posix_file_xfer_deliver_iob(), pxe_tftp_xfer_deliver_iob(), pxe_udp_deliver_iob(), pxenv_undi_isr(), pxenv_undi_transmit(), rarp_rx(), read_user(), rtl8169_free_rx_resources(), rtl818x_free_rx_ring(), sis190_free(), skge_rx_clean(), sky2_rx_clean(), slam_mc_socket_deliver(), slam_socket_deliver(), srp_login_rej(), srp_login_rsp(), srp_rsp(), srp_unrecognised(), tcp_close(), tcp_process_queue(), tcp_rx(), tcp_rx_data(), tcpip_rx(), tcpip_tx(), tftp_rx(), tftp_rx_data(), tkip_decrypt(), tls_send_plaintext(), udp_rx(), udp_tx(), vxge_hw_ring_replenish(), wep_decrypt(), and xfer_deliver_as_raw().

00069                                           {
00070         if ( iobuf ) {
00071                 assert ( iobuf->head <= iobuf->data );
00072                 assert ( iobuf->data <= iobuf->tail );
00073                 assert ( iobuf->tail <= iobuf->end );
00074                 free_dma ( iobuf->head,
00075                            ( iobuf->end - iobuf->head ) + sizeof ( *iobuf ) );
00076         }
00077 }

int iob_ensure_headroom ( struct io_buffer iobuf,
size_t  len 
)

Ensure I/O buffer has sufficient headroom.

Parameters:
iobuf I/O buffer
len Required headroom
This function currently only checks for the required headroom; it does not reallocate the I/O buffer if required. If we ever have a code path that requires this functionality, it's a fairly trivial change to make.

Definition at line 90 of file iobuf.c.

References ENOBUFS, and iob_headroom().

Referenced by udp_tx().

00090                                                                 {
00091 
00092         if ( iob_headroom ( iobuf ) >= len )
00093                 return 0;
00094         return -ENOBUFS;
00095 }


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