Commit 3f50defd authored by Ankit Kumar's avatar Ankit Kumar Committed by Konrad Sztyber
Browse files

thread: Extended options for spdk_interrupt_register



Added a new API spdk_interrupt_register_ext(), which is an extension of
spdk_interrupt_register() and accepts an extended options for event
handler i.e. spdk_event_handler_opts.

Change-Id: Ic20e5e9647127546eb8299a411e6181131c6f128
Signed-off-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25079


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 28b353a5
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ change notice to client.

Add `spdk_reduce_vol_get_info()` to get the information for the compressed volume.

### thread

Added `spdk_interrupt_register_ext()` API which can receive `spdk_event_handler_opts` structure.
This is to prevent any further expansion of `spdk_interrupt_register()` API.

### util

Added `spdk_fd_group_add_ext()` API which can receive `spdk_event_handler_opts` structure. This is
+29 −0
Original line number Diff line number Diff line
@@ -881,6 +881,28 @@ struct spdk_interrupt *spdk_interrupt_register(int efd, spdk_interrupt_fn fn,
struct spdk_interrupt *spdk_interrupt_register_for_events(int efd, uint32_t events,
		spdk_interrupt_fn fn, void *arg, const char *name);

/**
 * Register an spdk_interrupt with specific event type stated in spdk_event_handler_opts argument
 * on the current thread.
 *
 * The provided function will be called any time one of specified event types from
 * spdk_event_handler_opts argument triggers on the associated file descriptor.
 * Event types argument in spdk_event_handler_opts is a bit mask composed by ORing together
 * enum spdk_interrupt_event_types values.
 *
 * \param efd File descriptor of the spdk_interrupt.
 * \param fn Called each time there are events in spdk_interrupt.
 * \param arg Function argument for fn.
 * \param name Human readable name for the spdk_interrupt. Pointer of the spdk_interrupt
 * name is set if NULL.
 * \param opts Extended event handler option.
 *
 * \return a pointer to the spdk_interrupt registered on the current thread on success
 * or NULL on failure.
 */
struct spdk_interrupt *spdk_interrupt_register_ext(int efd, spdk_interrupt_fn fn, void *arg,
		const char *name, struct spdk_event_handler_opts *opts);

/*
 * \brief Register an spdk_interrupt on the current thread with setting its name
 * to the string of the spdk_interrupt function name.
@@ -895,6 +917,13 @@ struct spdk_interrupt *spdk_interrupt_register_for_events(int efd, uint32_t even
#define SPDK_INTERRUPT_REGISTER_FOR_EVENTS(efd, events, fn, arg)	\
	spdk_interrupt_register_for_events(efd, events, fn, arg, #fn)

/*
 * \brief Register an spdk_interrupt on the current thread with specific event types provided
 * in opts and with setting its name to the string of the spdk_interrupt function name.
 */
#define SPDK_INTERRUPT_REGISTER_EXT(efd, fn, arg, opts)	\
	spdk_interrupt_register_ext(efd, fn, arg, #fn, opts)

/**
 * Unregister an spdk_interrupt on the current thread.
 *
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
	spdk_for_each_channel_continue;
	spdk_interrupt_register;
	spdk_interrupt_register_for_events;
	spdk_interrupt_register_ext;
	spdk_interrupt_unregister;
	spdk_interrupt_set_event_types;
	spdk_thread_get_interrupt_fd;
+14 −1
Original line number Diff line number Diff line
@@ -2842,6 +2842,19 @@ spdk_interrupt_register(int efd, spdk_interrupt_fn fn,
struct spdk_interrupt *
spdk_interrupt_register_for_events(int efd, uint32_t events, spdk_interrupt_fn fn, void *arg,
				   const char *name)
{
	struct spdk_event_handler_opts opts = {};

	spdk_fd_group_get_default_event_handler_opts(&opts, sizeof(opts));
	opts.events = events;
	opts.fd_type = SPDK_FD_TYPE_DEFAULT;

	return spdk_interrupt_register_ext(efd, fn, arg, name, &opts);
}

struct spdk_interrupt *
spdk_interrupt_register_ext(int efd, spdk_interrupt_fn fn, void *arg, const char *name,
			    struct spdk_event_handler_opts *opts)
{
	struct spdk_thread *thread;
	struct spdk_interrupt *intr;
@@ -2875,7 +2888,7 @@ spdk_interrupt_register_for_events(int efd, uint32_t events, spdk_interrupt_fn f
	intr->fn = fn;
	intr->arg = arg;

	ret = spdk_fd_group_add_for_events(thread->fgrp, efd, events, _interrupt_wrapper, intr, intr->name);
	ret = spdk_fd_group_add_ext(thread->fgrp, efd, _interrupt_wrapper, intr, intr->name, opts);

	if (ret != 0) {
		SPDK_ERRLOG("thread %s: failed to add fd %d: %s\n",