7#include <netinet/sctp.h>
17#define OSMO_IO_DEFAULT_MSGB_SIZE 1024
18#define OSMO_IO_DEFAULT_MSGB_HEADROOM 128
21#define OSMO_IO_BACKEND_DEFAULT "POLL"
23#if defined(HAVE_URING)
39#define IOFD_FLAG_CLOSED (1<<0)
40#define IOFD_FLAG_IN_CALLBACK (1<<1)
41#define IOFD_FLAG_TO_FREE (1<<2)
42#define IOFD_FLAG_NOTIFY_CONNECTED (1<<3)
43#define IOFD_FLAG_FD_REGISTERED (1<<4)
45#define IOFD_FLAG_SET(iofd, flag) \
46 (iofd)->flags |= (flag)
48#define IOFD_FLAG_UNSET(iofd, flag) \
49 (iofd)->flags &= ~(flag)
51#define IOFD_FLAG_ISSET(iofd, flag) ((iofd)->flags & (flag))
53#define IOFD_MSGHDR_MAX_READ_SQES 32
129 struct io_uring *
ring;
147#define IOFD_MSGHDR_IO_BUFFERS 8
void iofd_txqueue_enqueue_front(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
Enqueue a message at the front.
Definition: osmo_io.c:234
osmo_io_fd_mode
The mode of an osmo_io_fd determines if read/write, recvfrom/sendmsg or recvmsg/sendmsg semantics are...
Definition: osmo_io.h:64
void iofd_msghdr_free(struct iofd_msghdr *msghdr)
Free the msghdr.
Definition: osmo_io.c:180
void iofd_handle_segmented_read(struct osmo_io_fd *iofd, struct msgb *msg, int rc)
Restore message boundaries on read() and pass individual messages to the read callback.
Definition: osmo_io.c:362
void iofd_handle_send_completion(struct osmo_io_fd *iofd, int rc, struct iofd_msghdr *msghdr)
completion handler: Internal function called by osmo_io_backend after a given I/O operation has compl...
Definition: osmo_io.c:449
struct iofd_msghdr * iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg, size_t cmsg_size)
Allocate the msghdr.
Definition: osmo_io.c:138
struct msgb * iofd_msgb_alloc2(struct osmo_io_fd *iofd, size_t size)
convenience wrapper to call msgb_alloc with parameters from osmo_io_fd (of given size)
Definition: osmo_io.c:188
struct msgb * iofd_msgb_alloc(struct osmo_io_fd *iofd)
convenience wrapper to call msgb_alloc with parameters from osmo_io_fd
Definition: osmo_io.c:197
int iofd_txqueue_enqueue(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
Enqueue a message to be sent.
Definition: osmo_io.c:210
struct iofd_msghdr * iofd_txqueue_dequeue(struct osmo_io_fd *iofd)
Dequeue a message from the front.
Definition: osmo_io.c:248
void iofd_handle_recv(struct osmo_io_fd *iofd, struct msgb *msg, int rc, struct iofd_msghdr *msghdr)
completion handler: Internal function called by osmo_io_backend after a given I/O operation has compl...
Definition: osmo_io.c:424
Simple doubly linked list implementation.
io(_uring) abstraction osmo fd compatibility
#define IOFD_MSGHDR_MAX_READ_SQES
Definition: osmo_io_internal.h:53
#define IOFD_MSGHDR_IO_BUFFERS
Definition: osmo_io_internal.h:147
iofd_msg_action
Definition: osmo_io_internal.h:138
@ IOFD_ACT_RECVFROM
Definition: osmo_io_internal.h:141
@ IOFD_ACT_RECVMSG
Definition: osmo_io_internal.h:143
@ IOFD_ACT_SENDTO
Definition: osmo_io_internal.h:142
@ IOFD_ACT_READ
Definition: osmo_io_internal.h:139
@ IOFD_ACT_WRITE
Definition: osmo_io_internal.h:140
@ IOFD_ACT_SENDMSG
Definition: osmo_io_internal.h:144
iofd_seg_act
Definition: osmo_io_internal.h:178
@ IOFD_SEG_ACT_DEFER
Definition: osmo_io_internal.h:181
@ IOFD_SEG_ACT_HANDLE_MORE
Definition: osmo_io_internal.h:180
@ IOFD_SEG_ACT_HANDLE_ONE
Definition: osmo_io_internal.h:179
const struct iofd_backend_ops iofd_poll_ops
Definition: osmo_io_poll.c:201
Osmocom socket convenience functions.
Definition: osmo_io_internal.h:27
void(* read_enable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:34
void(* write_enable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:32
void(* read_disable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:35
void(* write_disable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:33
int(* close)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:31
int(* setup)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:28
int(* register_fd)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:29
void(* notify_connected)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:36
int(* unregister_fd)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:30
serialized version of 'struct msghdr' employed by sendmsg/recvmsg
Definition: osmo_io_internal.h:150
char cmsg[0]
control message buffer for passing sctp_sndrcvinfo along
Definition: osmo_io_internal.h:175
struct osmo_io_fd * iofd
I/O file descriptor on which we perform this I/O operation.
Definition: osmo_io_internal.h:169
struct llist_head list
entry into osmo_io_fd.tx_queue.msg_queue
Definition: osmo_io_internal.h:152
int flags
flags we pass as argument to sendmsg / recvmsg
Definition: osmo_io_internal.h:162
enum iofd_msg_action action
Definition: osmo_io_internal.h:153
uint8_t io_len
current number of message-buffers that are stored
Definition: osmo_io_internal.h:165
struct msghdr hdr
the 'struct msghdr' we are wrapping/ecapsulating here
Definition: osmo_io_internal.h:155
struct osmo_sockaddr osa
socket address of the remote peer
Definition: osmo_io_internal.h:157
struct msgb * msg[IOFD_MSGHDR_IO_BUFFERS]
message-buffer containing data for this I/O operation
Definition: osmo_io_internal.h:167
bool in_cancel_queue
msghdr is in the cancel_queue list
Definition: osmo_io_internal.h:172
struct iovec iov[IOFD_MSGHDR_IO_BUFFERS]
io-vector we need to pass as argument to sendmsg/recvmsg; is set up to point into msg below
Definition: osmo_io_internal.h:160
(double) linked list header structure
Definition: linuxlist.h:46
Osmocom message buffer.
Definition: msgb.h:31
Structure representing a file dsecriptor.
Definition: select.h:31
Definition: osmo_io_internal.h:55
uint32_t flags
flags to guard closing/freeing of iofd
Definition: osmo_io_internal.h:64
unsigned int current_length
current length of write queue
Definition: osmo_io_internal.h:101
struct msgb * pending
Pending msgb to keep partial data during segmentation.
Definition: osmo_io_internal.h:72
struct osmo_io_fd::@39 tx_queue
uint8_t num_sqes
requested number of simultaniously submitted read SQEs
Definition: osmo_io_internal.h:115
bool enabled
read is enabled, due to registration of callback function
Definition: osmo_io_internal.h:113
struct llist_head msg_queue
actual linked list implementing the transmit queue
Definition: osmo_io_internal.h:103
struct osmo_io_fd::@40::@42::@43 read
struct osmo_io_fd::@40::@42::@44 write
struct io_uring * ring
ring the read SQEs have been submitted to
Definition: osmo_io_internal.h:119
enum osmo_io_fd_mode mode
type of read/write mode to use
Definition: osmo_io_internal.h:61
struct osmo_io_fd::@38 msgb_alloc
char * name
human-readable name to associte with fd
Definition: osmo_io_internal.h:67
struct llist_head list
linked list for internal management
Definition: osmo_io_internal.h:57
unsigned int max_length
maximum length of write queue
Definition: osmo_io_internal.h:99
size_t cmsg_size
size of iofd_msghdr.cmsg[] when allocated in recvmsg path
Definition: osmo_io_internal.h:80
uint8_t sqes_submitted
current number of simultaneously submitted read SQEs
Definition: osmo_io_internal.h:121
uint8_t io_write_buffers
maximum number of message-buffers per write operation
Definition: osmo_io_internal.h:86
struct osmo_fd connect_ofd
Definition: osmo_io_internal.h:133
struct osmo_io_fd::@40::@41 poll
struct osmo_io_fd::@40::@42 uring
unsigned int headroom
headroom to allocate when allocating msgb's
Definition: osmo_io_internal.h:94
struct osmo_fd ofd
Definition: osmo_io_internal.h:108
unsigned int size
size of msgb to allocate (excluding headroom)
Definition: osmo_io_internal.h:92
void * msghdr[IOFD_MSGHDR_MAX_READ_SQES]
array of simultaneously submitted read SQEs
Definition: osmo_io_internal.h:117
int fd
actual operating-system level file decriptor
Definition: osmo_io_internal.h:59
const void * ctx
talloc context from which to allocate msgb when reading
Definition: osmo_io_internal.h:90
uint8_t io_read_buffers
maximum number of message-buffers per read operation
Definition: osmo_io_internal.h:83
struct osmo_io_ops io_ops
send/recv (msg) callback functions
Definition: osmo_io_internal.h:70
void * data
data pointer passed through to call-back function
Definition: osmo_io_internal.h:75
unsigned int priv_nr
private number, extending data
Definition: osmo_io_internal.h:77
I/O operations (call-back functions) related to an osmo_io_fd.
Definition: osmo_io.h:103