File descriptor group utility functions. More...
Data Structures | |
struct | spdk_event_handler_opts |
Macros | |
#define | SPDK_FD_GROUP_ADD(fgrp, efd, fn, arg) spdk_fd_group_add(fgrp, efd, fn, arg, #fn) |
#define | SPDK_FD_GROUP_ADD_EXT(fgrp, efd, fn, arg, opts) spdk_fd_group_add_ext(fgrp, efd, fn, arg, #fn, opts) |
Typedefs | |
typedef int(* | spdk_fd_fn) (void *ctx) |
Callback function registered for the event source file descriptor. | |
typedef int(* | spdk_fd_group_wrapper_fn) (void *wrapper_ctx, spdk_fd_fn cb_fn, void *cb_ctx) |
Enumerations | |
enum | spdk_fd_type { SPDK_FD_TYPE_DEFAULT = 0x0 , SPDK_FD_TYPE_EVENTFD = 0x1 } |
File descriptor type. More... | |
Functions | |
SPDK_STATIC_ASSERT (sizeof(struct spdk_event_handler_opts)==16, "Incorrect size") | |
void | spdk_fd_group_get_default_event_handler_opts (struct spdk_event_handler_opts *opts, size_t opts_size) |
Initialize a spdk_event_handler_opts structure to the default values. | |
int | spdk_fd_group_create (struct spdk_fd_group **fgrp) |
Initialize one fd_group. | |
void | spdk_fd_group_destroy (struct spdk_fd_group *fgrp) |
Release all resources associated with this fgrp. | |
int | spdk_fd_group_wait (struct spdk_fd_group *fgrp, int timeout) |
Wait for new events generated inside fgrp, and process them with their registered spdk_fd_fn. | |
int | spdk_fd_group_get_fd (struct spdk_fd_group *fgrp) |
Return the internal epoll_fd of specific fd_group. | |
int | spdk_fd_group_nest (struct spdk_fd_group *parent, struct spdk_fd_group *child) |
Nest the child fd_group in the parent fd_group. | |
int | spdk_fd_group_unnest (struct spdk_fd_group *parent, struct spdk_fd_group *child) |
Remove the nested child from the parent. | |
int | spdk_fd_group_add (struct spdk_fd_group *fgrp, int efd, spdk_fd_fn fn, void *arg, const char *name) |
Register SPDK_INTERRUPT_EVENT_IN event source to specified fgrp. | |
int | spdk_fd_group_add_for_events (struct spdk_fd_group *fgrp, int efd, uint32_t events, spdk_fd_fn fn, void *arg, const char *name) |
Register one event source to specified fgrp with specific event types. | |
int | spdk_fd_group_add_ext (struct spdk_fd_group *fgrp, int efd, spdk_fd_fn fn, void *arg, const char *name, struct spdk_event_handler_opts *opts) |
Register one event type stated in spdk_event_handler_opts agrument to the specified fgrp. | |
void | spdk_fd_group_remove (struct spdk_fd_group *fgrp, int efd) |
Unregister one event source from one fgrp. | |
int | spdk_fd_group_event_modify (struct spdk_fd_group *fgrp, int efd, int event_types) |
Change the event notification types associated with the event source. | |
int | spdk_fd_group_get_epoll_event (struct epoll_event *event) |
Copies the epoll(7) event that caused a callback function to execute. | |
int | spdk_fd_group_set_wrapper (struct spdk_fd_group *fgrp, spdk_fd_group_wrapper_fn cb_fn, void *cb_ctx) |
Set a wrapper function to be called when an epoll(7) event is received. | |
File descriptor group utility functions.
typedef int(* spdk_fd_fn) (void *ctx) |
Callback function registered for the event source file descriptor.
ctx | Context passed as arg to spdk_fd_group_add(). |
enum spdk_fd_type |
File descriptor type.
The event handler may have extra checks and can do extra processing based on this.
int spdk_fd_group_add | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
spdk_fd_fn | fn, | ||
void * | arg, | ||
const char * | name ) |
Register SPDK_INTERRUPT_EVENT_IN event source to specified fgrp.
Use spdk_fd_group_add_for_events() for other event types.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
fn | Called each time there are events in event source. |
arg | Function argument for fn. |
name | Name of the event source. |
int spdk_fd_group_add_ext | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
spdk_fd_fn | fn, | ||
void * | arg, | ||
const char * | name, | ||
struct spdk_event_handler_opts * | opts ) |
Register one event type stated in spdk_event_handler_opts agrument to the specified fgrp.
spdk_event_handler_opts argument consists of event which is a bit mask composed by ORing together enum spdk_interrupt_event_types values. It also consists of fd_type, which can be used by event handler to perform extra checks during the spdk_fd_group_wait call.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
fn | Called each time there are events in event source. |
arg | Function argument for fn. |
name | Name of the event source. |
opts | Extended event handler option. |
int spdk_fd_group_add_for_events | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
uint32_t | events, | ||
spdk_fd_fn | fn, | ||
void * | arg, | ||
const char * | name ) |
Register one event source to specified fgrp with specific event types.
Event types argument is a bit mask composed by ORing together enum spdk_interrupt_event_types values.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
events | Event notification types. |
fn | Called each time there are events in event source. |
arg | Function argument for fn. |
name | Name of the event source. |
int spdk_fd_group_create | ( | struct spdk_fd_group ** | fgrp | ) |
Initialize one fd_group.
fgrp | A pointer to return the initialized fgrp. |
void spdk_fd_group_destroy | ( | struct spdk_fd_group * | fgrp | ) |
Release all resources associated with this fgrp.
Users need to remove all event sources from the fgrp before destroying it.
fgrp | The fgrp to destroy. |
int spdk_fd_group_event_modify | ( | struct spdk_fd_group * | fgrp, |
int | efd, | ||
int | event_types ) |
Change the event notification types associated with the event source.
Modules like nbd, need this api to add EPOLLOUT when having data to send, and remove EPOLLOUT if no data to send.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
event_types | The event notification types. |
void spdk_fd_group_get_default_event_handler_opts | ( | struct spdk_event_handler_opts * | opts, |
size_t | opts_size ) |
Initialize a spdk_event_handler_opts structure to the default values.
[out] | opts | Will be filled with default option. |
opts_size | Must be the size of spdk_event_handler_opts structure. |
int spdk_fd_group_get_epoll_event | ( | struct epoll_event * | event | ) |
Copies the epoll(7) event that caused a callback function to execute.
This function can only be called by the callback function, doing otherwise results in undefined behavior.
event | pointer to an epoll(7) event to copy to. |
int spdk_fd_group_get_fd | ( | struct spdk_fd_group * | fgrp | ) |
Return the internal epoll_fd of specific fd_group.
fgrp | The pointer of specified fgrp. |
int spdk_fd_group_nest | ( | struct spdk_fd_group * | parent, |
struct spdk_fd_group * | child ) |
Nest the child fd_group in the parent fd_group.
After this operation completes, calling spdk_fd_group_wait() on the parent will include events from the child.
parent | The parent fd_group. |
child | The child fd_group. |
void spdk_fd_group_remove | ( | struct spdk_fd_group * | fgrp, |
int | efd ) |
Unregister one event source from one fgrp.
fgrp | The fgrp registered to. |
efd | File descriptor of the event source. |
int spdk_fd_group_set_wrapper | ( | struct spdk_fd_group * | fgrp, |
spdk_fd_group_wrapper_fn | cb_fn, | ||
void * | cb_ctx ) |
Set a wrapper function to be called when an epoll(7) event is received.
The callback associated with that event is passed to the wrapper, which is responsible for executing it. Only one wrapper can be assigned to an fd_group at a time.
fgrp | fd group. |
cb_fn | Wrapper callback. |
cb_ctx | Wrapper callback's context. |
int spdk_fd_group_unnest | ( | struct spdk_fd_group * | parent, |
struct spdk_fd_group * | child ) |
Remove the nested child from the parent.
parent | The parent fd_group. |
child | The child fd_group. |
int spdk_fd_group_wait | ( | struct spdk_fd_group * | fgrp, |
int | timeout ) |
Wait for new events generated inside fgrp, and process them with their registered spdk_fd_fn.
fgrp | The fgrp to wait and process. |
timeout | Specifies the number of milliseconds that will block. -1 causes indefinitely blocking; 0 causes immediately return. |