#include <stdint.h>
#include <assert.h>
#include <gpxe/list.h>
Go to the source code of this file.
Data Structures | |
| struct | io_buffer |
| A persistent I/O buffer. More... | |
Defines | |
| #define | IOB_ALIGN 2048 |
| I/O buffer alignment. | |
| #define | IOB_ZLEN 64 |
| Minimum I/O buffer length. | |
| #define | iob_reserve(iobuf, len) |
| #define | iob_push(iobuf, len) |
| #define | iob_pull(iobuf, len) |
| #define | iob_put(iobuf, len) |
| #define | iob_unput(iobuf, len) |
| #define | iob_disown(iobuf) |
| Disown an I/O buffer. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void * | iob_reserve (struct io_buffer *iobuf, size_t len) |
| Reserve space at start of I/O buffer. | |
| static void * | iob_push (struct io_buffer *iobuf, size_t len) |
| Add data to start of I/O buffer. | |
| static void * | iob_pull (struct io_buffer *iobuf, size_t len) |
| Remove data from start of I/O buffer. | |
| static void * | iob_put (struct io_buffer *iobuf, size_t len) |
| Add data to end of I/O buffer. | |
| static void | iob_unput (struct io_buffer *iobuf, size_t len) |
| Remove data from end of I/O buffer. | |
| static void | iob_empty (struct io_buffer *iobuf) |
| Empty an I/O buffer. | |
| static size_t | iob_len (struct io_buffer *iobuf) |
| Calculate length of data in an I/O buffer. | |
| static size_t | iob_headroom (struct io_buffer *iobuf) |
| Calculate available space at start of an I/O buffer. | |
| static size_t | iob_tailroom (struct io_buffer *iobuf) |
| Calculate available space at end of an I/O buffer. | |
| static void | iob_populate (struct io_buffer *iobuf, void *data, size_t len, size_t max_len) |
| Create a temporary I/O buffer. | |
| struct io_buffer *__malloc | alloc_iob (size_t len) |
| Allocate I/O buffer. | |
| void | free_iob (struct io_buffer *iobuf) |
| Free I/O buffer. | |
| void | iob_pad (struct io_buffer *iobuf, size_t min_len) |
| Pad I/O buffer. | |
| int | iob_ensure_headroom (struct io_buffer *iobuf, size_t len) |
| Ensure I/O buffer has sufficient headroom. | |
Definition in file iobuf.h.
| #define IOB_ALIGN 2048 |
I/O buffer alignment.
I/O buffers allocated via alloc_iob() are guaranteed to be physically aligned to this boundary. Some cards cannot DMA across a 4kB boundary. With a standard Ethernet MTU, aligning to a 2kB boundary is sufficient to guarantee no 4kB boundary crossings. For a jumbo Ethernet MTU, a packet may be larger than 4kB anyway.
Definition at line 25 of file iobuf.h.
Referenced by alloc_iob().
| #define IOB_ZLEN 64 |
Minimum I/O buffer length.
alloc_iob() will round up the allocated length to this size if necessary. This is used on behalf of hardware that is not capable of auto-padding.
Definition at line 34 of file iobuf.h.
Referenced by alloc_iob(), and iob_pad().
| #define iob_reserve | ( | iobuf, | |||
| len | ) |
Value:
( { \
void *__result; \
__result = iob_reserve ( (iobuf), (len) ); \
assert ( (iobuf)->tail <= (iobuf)->end ); \
__result; } )
Definition at line 74 of file iobuf.h.
Referenced by aoe_send_command(), arp_resolve(), ath5k_rx_iob_alloc(), atl1e_clean_rx_irq(), b44_process_rx_packets(), gdbudp_send(), hermon_fill_mlx_send_wqe(), icmp6_send_solicit(), ifec_get_rx_desc(), linda_post_send(), myri10ge_net_open(), myri10ge_net_poll(), net80211_probe_start(), net80211_probe_step(), net80211_send_assoc(), net80211_send_auth(), net80211_send_disassoc(), pxenv_undi_transmit(), sky2_rx_alloc(), tcp_xmit(), tcp_xmit_reset(), udp_alloc_iob(), and wpa_alloc_frame().
| #define iob_push | ( | iobuf, | |||
| len | ) |
Value:
( { \
void *__result; \
__result = iob_push ( (iobuf), (len) ); \
assert ( (iobuf)->data >= (iobuf)->head ); \
__result; } )
Definition at line 91 of file iobuf.h.
Referenced by eth_push(), gdbudp_recv(), gdbudp_send(), ib_push(), iob_pad(), ipoib_push(), ipv4_tx(), ipv6_tx(), net80211_ll_push(), net80211_tx_mgmt(), tcp_xmit(), tcp_xmit_reset(), udp_tx(), and wpa_send_eapol().
| #define iob_pull | ( | iobuf, | |||
| len | ) |
Value:
( { \
void *__result; \
__result = iob_pull ( (iobuf), (len) ); \
assert ( (iobuf)->data <= (iobuf)->tail ); \
__result; } )
Definition at line 109 of file iobuf.h.
Referenced by aoe_rx(), arbel_complete(), eapol_rx(), efi_snp_transmit(), eth_pull(), gdbudp_recv(), hermon_complete(), http_socket_deliver_iob(), ib_pull(), ipoib_pull(), ipv4_reassemble(), ipv4_rx(), ipv6_rx(), legacy_transmit(), net80211_ll_pull(), phantom_poll(), read_user(), slam_pull_header(), slam_pull_value(), tcp_process_queue(), tcp_rx(), tcp_rx_data(), tftp_rx_data(), and udp_rx().
| #define iob_put | ( | iobuf, | |||
| len | ) |
Value:
( { \
void *__result; \
__result = iob_put ( (iobuf), (len) ); \
assert ( (iobuf)->tail <= (iobuf)->end ); \
__result; } )
Definition at line 127 of file iobuf.h.
Referenced by a3c90x_process_rx_packets(), aoe_send_command(), arbel_complete(), arp_resolve(), ath5k_handle_rx(), atl1e_clean_rx_irq(), b44_process_rx_packets(), ccmp_decrypt(), ccmp_encrypt(), dhcp_tx(), e1000_process_rx_packets(), e1000e_process_rx_packets(), efab_receive(), efi_snp_transmit(), gdbudp_send(), hermon_complete(), ib_mi_send(), icmp6_send_solicit(), ifec_rx_process(), igb_process_rx_packets(), iob_pad(), ipv4_reassemble(), iscsi_tx_data_out(), iscsi_tx_login_request(), legacy_poll(), linda_complete_recv(), mtnic_process_rx_cq(), myri10ge_net_poll(), natsemi_poll(), net80211_accum_frags(), net80211_probe_start(), net80211_probe_step(), net80211_send_assoc(), net80211_send_auth(), net80211_send_disassoc(), phantom_poll(), pnic_poll(), pxenv_udp_write(), pxenv_undi_transmit(), receive_new(), rtl8169_process_rx_packets(), rtl818x_handle_rx(), rtl_poll(), sis190_process_rx(), skge_rx_done(), slam_put_value(), slam_tx_nack(), srp_cmd(), srp_login(), tcp_process_queue(), tftp_send_ack(), tftp_send_error(), tftp_send_rrq(), tkip_decrypt(), tkip_encrypt(), tls_send_plaintext(), undinet_poll(), vxge_hw_vpath_poll_rx(), wep_decrypt(), wep_encrypt(), wpa_alloc_frame(), wpa_send_2_of_4(), and xfer_deliver_as_iob().
| #define iob_unput | ( | iobuf, | |||
| len | ) |
| #define iob_disown | ( | iobuf | ) |
Value:
Disown an I/O buffer.
| iobuf | I/O buffer |
xfer_deliver_iob ( xfer, iob_disown ( iobuf ) );
This will ensure that iobuf is set to NULL for any code after the call to xfer_deliver_iob().
Definition at line 219 of file iobuf.h.
Referenced by arp_rx(), dhcp_tx(), efi_snp_transmit(), http_socket_deliver_iob(), ib_cmrc_xfer_deliver_iob(), icmp_rx(), net80211_probe_step(), tftp_rx(), tftp_rx_data(), udp_rx(), and undinet_poll().
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
Reserve space at start of I/O buffer.
| iobuf | I/O buffer | |
| len | Length to reserve |
| data | Pointer to new start of buffer |
Definition at line 69 of file iobuf.h.
References io_buffer::data, and io_buffer::tail.
Add data to start of I/O buffer.
| iobuf | I/O buffer | |
| len | Length to add |
| data | Pointer to new start of buffer |
Definition at line 87 of file iobuf.h.
References io_buffer::data.
Remove data from start of I/O buffer.
| iobuf | I/O buffer | |
| len | Length to remove |
| data | Pointer to new start of buffer |
Definition at line 104 of file iobuf.h.
References assert, io_buffer::data, and io_buffer::tail.
00104 { 00105 iobuf->data += len; 00106 assert ( iobuf->data <= iobuf->tail ); 00107 return iobuf->data; 00108 }
Add data to end of I/O buffer.
| iobuf | I/O buffer | |
| len | Length to add |
| data | Pointer to newly added space |
Definition at line 122 of file iobuf.h.
References io_buffer::tail.
00122 { 00123 void *old_tail = iobuf->tail; 00124 iobuf->tail += len; 00125 return old_tail; 00126 }
Remove data from end of I/O buffer.
| iobuf | I/O buffer | |
| len | Length to remove |
Definition at line 139 of file iobuf.h.
References io_buffer::tail.
00139 { 00140 iobuf->tail -= len; 00141 }
| static void iob_empty | ( | struct io_buffer * | iobuf | ) | [inline, static] |
Empty an I/O buffer.
| iobuf | I/O buffer |
Definition at line 152 of file iobuf.h.
References io_buffer::data, and io_buffer::tail.
Calculate length of data in an I/O buffer.
| iobuf | I/O buffer |
| len | Length of data in buffer |
Definition at line 162 of file iobuf.h.
References io_buffer::data, and io_buffer::tail.
Referenced by a3c90x_process_tx_packets(), a3c90x_transmit(), aoe_rx(), arbel_complete(), arbel_post_send(), ath5k_tx_processq(), ath5k_txbuf_setup(), atl1e_tx_map(), b44_transmit(), ccmp_decrypt(), ccmp_encrypt(), dhcp_deliver_iob(), downloader_xfer_deliver_iob(), e1000_transmit(), e1000e_transmit(), eapol_rx(), efab_transmit(), efi_snp_receive(), eth_pull(), falcon_build_tx_desc(), gdbudp_recv(), gdbudp_send(), hermon_complete(), hermon_fill_mlx_send_wqe(), hermon_fill_rc_send_wqe(), hermon_fill_ud_send_wqe(), http_rx_data(), http_socket_deliver_iob(), ib_cmrc_complete_recv(), ib_cmrc_xfer_deliver_iob(), ib_mi_complete_recv(), ib_pull(), ib_push(), icmp6_rx(), icmp_rx(), ifec_net_transmit(), igb_transmit(), iob_pad(), ipoib_complete_recv(), ipoib_pull(), ipoib_transmit(), ipv4_pshdr_chksum(), ipv4_reassemble(), ipv4_rx(), ipv4_tx(), ipv6_rx(), ipv6_tx(), ipv6_tx_csum(), legacy_transmit(), linda_post_send(), mtnic_transmit(), myri10ge_net_transmit(), natsemi_transmit(), ndp_process_advert(), net80211_accum_frags(), net80211_ll_pull(), net80211_probe_step(), net80211_rx_frag(), net_step(), netdev_rx(), netdev_tx(), phantom_refill_rx_ring(), phantom_transmit(), pnic_transmit(), posix_file_xfer_deliver_iob(), pxe_tftp_xfer_deliver_iob(), pxe_udp_deliver_iob(), pxenv_undi_isr(), read_user(), rtl8169_transmit(), rtl818x_tx(), rtl_transmit(), sis190_transmit(), skge_xmit_frame(), sky2_xmit_frame(), slam_mc_socket_deliver(), slam_pull_header(), slam_pull_value(), slam_socket_deliver(), srp_cmd(), srp_login(), srp_login_rej(), srp_login_rsp(), srp_rsp(), tcp_process_queue(), tcp_rx(), tcp_rx_data(), tcp_xmit(), tcp_xmit_reset(), tftp_rx(), tftp_rx_data(), tkip_decrypt(), tkip_encrypt(), udp_rx(), udp_tx(), undinet_poll(), undinet_transmit(), vxge_hw_fifo_txdl_buffer_set(), wep_decrypt(), wep_encrypt(), xfer_deliver_as_raw(), and xfer_deliver_iob_meta().
Calculate available space at start of an I/O buffer.
| iobuf | I/O buffer |
| len | Length of data available at start of buffer |
Definition at line 172 of file iobuf.h.
References io_buffer::data, and io_buffer::head.
Referenced by iob_ensure_headroom(), iob_pad(), and net80211_probe_step().
Calculate available space at end of an I/O buffer.
| iobuf | I/O buffer |
| len | Length of data available at end of buffer |
Definition at line 182 of file iobuf.h.
References io_buffer::end, and io_buffer::tail.
Referenced by arbel_complete(), arbel_post_recv(), ath5k_rxbuf_setup(), dhcp_tx(), hermon_complete(), hermon_post_recv(), ib_post_recv(), linda_post_recv(), slam_put_value(), tftp_send_rrq(), and undinet_poll().
| static void iob_populate | ( | struct io_buffer * | iobuf, | |
| void * | data, | |||
| size_t | len, | |||
| size_t | max_len | |||
| ) | [inline, static] |
Create a temporary I/O buffer.
| iobuf | I/O buffer | |
| data | Data buffer | |
| len | Length of data | |
| max_len | Length of buffer |
Definition at line 197 of file iobuf.h.
References io_buffer::data, io_buffer::end, io_buffer::head, and io_buffer::tail.
Referenced by hermon_fill_mlx_send_wqe(), linda_complete_recv(), and linda_post_send().
00198 { 00199 iobuf->head = iobuf->data = data; 00200 iobuf->tail = ( data + len ); 00201 iobuf->end = ( data + max_len ); 00202 }
Allocate I/O buffer.
| len | Required length of buffer |
| iobuf | I/O buffer, or NULL if none available |
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.
| 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 }
Pad I/O buffer.
| iobuf | I/O buffer | |
| min_len | Minimum length |
IOB_ALIGN.
min_len must not exceed
| 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 }
Ensure I/O buffer has sufficient headroom.
| iobuf | I/O buffer | |
| len | Required headroom |
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 }
1.5.7.1