Loading...
Searching...
No Matches
event.h File Reference

Event framework public API. More...

Data Structures

struct  spdk_app_opts
 Event framework initialization options. More...
 

Macros

#define SPDK_APP_GETOPT_STRING   "c:de:ghi:m:n:p:r:s:uvA:B:L:RW:"
 

Typedefs

typedef void(* spdk_event_fn) (void *arg1, void *arg2)
 Event handler function.
 
typedef void(* spdk_app_shutdown_cb) (void)
 Callback function for customized shutdown handling of application.
 
typedef void(* spdk_sighandler_t) (int signal)
 Signal handler function.
 
typedef enum spdk_app_parse_args_rvals spdk_app_parse_args_rvals_t
 

Enumerations

enum  spdk_app_parse_args_rvals { SPDK_APP_PARSE_ARGS_HELP = 0 , SPDK_APP_PARSE_ARGS_SUCCESS = 1 , SPDK_APP_PARSE_ARGS_FAIL = 2 }
 

Functions

 SPDK_STATIC_ASSERT (sizeof(struct spdk_app_opts)==253, "Incorrect size")
 
void spdk_app_opts_init (struct spdk_app_opts *opts, size_t opts_size)
 Initialize the default value of opts.
 
int spdk_app_start (struct spdk_app_opts *opts_user, spdk_msg_fn start_fn, void *ctx)
 Start the framework.
 
void spdk_app_fini (void)
 Perform final shutdown operations on an application using the event framework.
 
void spdk_app_start_shutdown (void)
 Start shutting down the framework.
 
void spdk_app_stop (int rc)
 Stop the framework.
 
int spdk_app_get_shm_id (void)
 Return the shared memory id for this application.
 
int spdk_app_parse_core_mask (const char *mask, struct spdk_cpuset *cpumask)
 Convert a string containing a CPU core mask into a bitmask.
 
const struct spdk_cpusetspdk_app_get_core_mask (void)
 Get the mask of the CPU cores active for this application.
 
spdk_app_parse_args_rvals_t spdk_app_parse_args (int argc, char **argv, struct spdk_app_opts *opts, const char *getopt_str, const struct option *app_long_opts, int(*parse)(int ch, char *arg), void(*usage)(void))
 Helper function for parsing arguments and printing usage messages.
 
void spdk_app_usage (void)
 Print usage strings for common SPDK command line options.
 
struct spdk_event * spdk_event_allocate (uint32_t lcore, spdk_event_fn fn, void *arg1, void *arg2)
 Allocate an event to be passed to spdk_event_call().
 
void spdk_event_call (struct spdk_event *event)
 Pass the given event to the associated lcore and call the function.
 
void spdk_framework_enable_context_switch_monitor (bool enabled)
 Enable or disable monitoring of context switches.
 
bool spdk_framework_context_switch_monitor_enabled (void)
 Return whether context switch monitoring is enabled.
 

Detailed Description

Event framework public API.

See SPDK Event Framework Components for an overview of the SPDK event framework API.

Typedef Documentation

◆ spdk_event_fn

typedef void(* spdk_event_fn) (void *arg1, void *arg2)

Event handler function.

Parameters
arg1Argument 1.
arg2Argument 2.

◆ spdk_sighandler_t

typedef void(* spdk_sighandler_t) (int signal)

Signal handler function.

Parameters
signalSignal number.

Function Documentation

◆ spdk_app_get_core_mask()

const struct spdk_cpuset * spdk_app_get_core_mask ( void )

Get the mask of the CPU cores active for this application.

Returns
the bitmask of the active CPU cores.

◆ spdk_app_get_shm_id()

int spdk_app_get_shm_id ( void )

Return the shared memory id for this application.

Returns
shared memory id.

◆ spdk_app_opts_init()

void spdk_app_opts_init ( struct spdk_app_opts * opts,
size_t opts_size )

Initialize the default value of opts.

Parameters
optsData structure where SPDK will initialize the default options.
opts_sizeMust be set to sizeof(struct spdk_app_opts).

◆ spdk_app_parse_args()

spdk_app_parse_args_rvals_t spdk_app_parse_args ( int argc,
char ** argv,
struct spdk_app_opts * opts,
const char * getopt_str,
const struct option * app_long_opts,
int(* parse )(int ch, char *arg),
void(* usage )(void) )

Helper function for parsing arguments and printing usage messages.

Parameters
argcCount of arguments in argv parameter array.
argvArray of command line arguments.
optsDefault options for the application.
getopt_strString representing the app-specific command line parameters. Characters in this string must not conflict with characters in SPDK_APP_GETOPT_STRING. This argument is optional.
app_long_optsArray of full-name parameters. This argument is optional.
parseFunction pointer to call if an argument in getopt_str is found. This argument is optional but only if getopt_str is not provided.
usageFunction pointer to print usage messages for app-specific command line parameters. This argument is optional.
Returns
SPDK_APP_PARSE_ARGS_FAIL on failure, SPDK_APP_PARSE_ARGS_SUCCESS on success, SPDK_APP_PARSE_ARGS_HELP if '-h' passed as an option.

◆ spdk_app_parse_core_mask()

int spdk_app_parse_core_mask ( const char * mask,
struct spdk_cpuset * cpumask )

Convert a string containing a CPU core mask into a bitmask.

Parameters
maskString containing a CPU core mask.
cpumaskBitmask of CPU cores.
Returns
0 on success, -1 on failure.

◆ spdk_app_start()

int spdk_app_start ( struct spdk_app_opts * opts_user,
spdk_msg_fn start_fn,
void * ctx )

Start the framework.

Before calling this function, opts must be initialized by spdk_app_opts_init(). Once started, the framework will call start_fn on an spdk_thread running on the current system thread with the argument provided.

If opts->delay_subsystem_init is set (e.g. through –wait-for-rpc flag in spdk_app_parse_args()) this function will only start a limited RPC server accepting only a few RPC commands - mostly related to pre-initialization. With this option, the framework won't be started and start_fn won't be called until the user sends an rpc_framework_start_init RPC command, which marks the pre-initialization complete and allows start_fn to be finally called.

This call will block until spdk_app_stop() is called. If an error condition occurs during the initialization code within spdk_app_start(), this function will immediately return before invoking start_fn.

Parameters
opts_userInitialization options used for this application. It should not be NULL. And the opts_size value inside the opts structure should not be zero.
start_fnEntry point that will execute on an internally created thread once the framework has been started.
ctxArgument passed to function start_fn.
Returns
0 on success or non-zero on failure.

◆ spdk_app_start_shutdown()

void spdk_app_start_shutdown ( void )

Start shutting down the framework.

Typically this function is not called directly, and the shutdown process is started implicitly by a process signal. But in applications that are using SPDK for a subset of its process threads, this function can be called in lieu of a signal.

◆ spdk_app_stop()

void spdk_app_stop ( int rc)

Stop the framework.

This does not wait for all threads to exit. Instead, it kicks off the shutdown process and returns. Once the shutdown process is complete, spdk_app_start() will return.

Parameters
rcThe rc value specified here will be returned to caller of spdk_app_start().

◆ spdk_app_usage()

void spdk_app_usage ( void )

Print usage strings for common SPDK command line options.

May only be called after spdk_app_parse_args().

◆ spdk_event_allocate()

struct spdk_event * spdk_event_allocate ( uint32_t lcore,
spdk_event_fn fn,
void * arg1,
void * arg2 )

Allocate an event to be passed to spdk_event_call().

Parameters
lcoreLcore to run this event.
fnFunction used to execute event.
arg1Argument passed to function fn.
arg2Argument passed to function fn.
Returns
a pointer to the allocated event.

◆ spdk_event_call()

void spdk_event_call ( struct spdk_event * event)

Pass the given event to the associated lcore and call the function.

Parameters
eventEvent to execute.

◆ spdk_framework_context_switch_monitor_enabled()

bool spdk_framework_context_switch_monitor_enabled ( void )

Return whether context switch monitoring is enabled.

Returns
true if enabled or false otherwise.

◆ spdk_framework_enable_context_switch_monitor()

void spdk_framework_enable_context_switch_monitor ( bool enabled)

Enable or disable monitoring of context switches.

Parameters
enabledTrue to enable, false to disable.