Commit 6153b4aa authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

nvme: Add a new parameter in spdk_nvme_poll_group_create



Purpose: To setup an accelerated function callback
for created spdk_nvme_poll_group. In this patch,
we just create the interface. The real usage of this
call back will be provided in the other patch.

Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: I0d936aa4eba4dbfcc0137942156b9f2919eb5b78
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6758


Community-CI: Broadcom CI
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 8f5e4bfe
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,13 @@

## v21.04: (Upcoming Release)


### nvme

Added an accelerated table pointer in spdk_nvme_poll_group
which can be used provide the accelerated functions by users with
hardware engine, such as crc32c accelerated function.

### bdev

For `bdev_ocssd_create` RPC, the optional parameter `range` was removed.
+1 −1
Original line number Diff line number Diff line
@@ -961,7 +961,7 @@ nvme_init_ns_worker_ctx(struct ns_worker_ctx *ns_ctx)
	opts.delay_cmd_submit = true;
	opts.create_only = true;

	ns_ctx->u.nvme.group = spdk_nvme_poll_group_create(NULL);
	ns_ctx->u.nvme.group = spdk_nvme_poll_group_create(NULL, NULL);
	if (ns_ctx->u.nvme.group == NULL) {
		goto poll_group_failed;
	}
+34 −1
Original line number Diff line number Diff line
@@ -258,6 +258,36 @@ struct spdk_nvme_ctrlr_opts {
	uint64_t fabrics_connect_timeout_us;
};

/**
 * NVMe acceleration operation callback.
 *
 * \param cb_arg The user provided arg which is passed to the corresponding accelerated function call
 * defined in struct spdk_nvme_accel_fn_table.
 * \param status 0 if it completed successfully, or negative errno if it failed.
 */
typedef void (*spdk_nvme_accel_completion_cb)(void *cb_arg, int status);

/**
 * Function table for the NVMe acccelerator device.
 *
 * This table provides a set of APIs to allow user to leverage
 * accelerator functions.
 */
struct spdk_nvme_accel_fn_table {
	/**
	 * The size of spdk_nvme_accel_fun_table according to the caller of
	 * this library is used for ABI compatibility.  The library uses this
	 * field to know how many fields in this structure are valid.
	 * And the library will populate any remaining fields with default values.
	 * Newly added fields should be put at the end of the struct.
	 */
	size_t table_size;

	/** The accelerated crc32c function. */
	void (*submit_accel_crc32c)(void *ctx, uint32_t *dst, struct iovec *iov,
				    uint32_t iov_cnt, uint32_t seed, spdk_nvme_accel_completion_cb cb_fn, void *cb_arg);
};

/**
 * Indicate whether a ctrlr handle is associated with a Discovery controller.
 *
@@ -2209,10 +2239,13 @@ typedef void (*spdk_nvme_disconnected_qpair_cb)(struct spdk_nvme_qpair *qpair,
 * Create a new poll group.
 *
 * \param ctx A user supplied context that can be retrieved later with spdk_nvme_poll_group_get_ctx
 * \param table The call back table defined by users which contains the accelerated functions
 * which can be used to accelerate some operations such as crc32c.
 *
 * \return Pointer to the new poll group, or NULL on error.
 */
struct spdk_nvme_poll_group *spdk_nvme_poll_group_create(void *ctx);
struct spdk_nvme_poll_group *spdk_nvme_poll_group_create(void *ctx,
		struct spdk_nvme_accel_fn_table *table);

/**
 * Get a optimal poll group.
+1 −0
Original line number Diff line number Diff line
@@ -454,6 +454,7 @@ struct spdk_nvme_qpair {

struct spdk_nvme_poll_group {
	void						*ctx;
	struct spdk_nvme_accel_fn_table			accel_fn_table;
	STAILQ_HEAD(, spdk_nvme_transport_poll_group)	tgroups;
};

+17 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
#include "nvme_internal.h"

struct spdk_nvme_poll_group *
spdk_nvme_poll_group_create(void *ctx)
spdk_nvme_poll_group_create(void *ctx, struct spdk_nvme_accel_fn_table *table)
{
	struct spdk_nvme_poll_group *group;

@@ -44,6 +44,22 @@ spdk_nvme_poll_group_create(void *ctx)
		return NULL;
	}

	group->accel_fn_table.table_size = sizeof(struct spdk_nvme_accel_fn_table);
	if (table && table->table_size != 0) {
		group->accel_fn_table.table_size = table->table_size;
#define SET_FIELD(field) \
	if (offsetof(struct spdk_nvme_accel_fn_table, field) + sizeof(table->field) <= table->table_size) { \
		group->accel_fn_table.field = table->field; \
	} \

		SET_FIELD(submit_accel_crc32c);
		/* Do not remove this statement, you should always update this statement when you adding a new field,
		 * and do not forget to add the SET_FIELD statement for your added field. */
		SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_accel_fn_table) == 16, "Incorrect size");

#undef SET_FIELD
	}

	group->ctx = ctx;
	STAILQ_INIT(&group->tgroups);

Loading