Commit fb5650ce authored by Abhineet Pandey's avatar Abhineet Pandey Committed by Tomasz Zawadzki
Browse files

lib/nvmf: Make set ANA state API public



This change adds public APIs 'spdk_nvmf_subsystem_get_ana_reporting' and
'spdk_nvmf_subsystem_set_ana_state', replacing the internal functions
'nvmf_subsystem_get_ana_reporting' and 'nvmf_subsystem_set_ana_state'
respectively. No changes have been done to the implementation of the mentioned
functions.

Change-Id: I6435d2fc524565c047871996c50ef6bccae48003
Signed-off-by: default avatarAbhineet Pandey <abhineet.pandey@nutanix.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21404


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent dde1b149
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -129,6 +129,10 @@ Added `spdk_nvmf_subsystem_is_discovery()` API to check whether a given susbyste

Added new optional `--ana-state` (or shortly `-n`) parameter to nvmf_subsystem_add_listener RPC call.

Added public APIs 'spdk_nvmf_subsystem_get_ana_reporting' and 'spdk_nvmf_subsystem_set_ana_state',
replacing the internal functions 'nvmf_subsystem_get_ana_reporting' and 'nvmf_subsystem_set_ana_state'
respectively.

### scripts

`setup.sh` now supports interactive mode for device selection and hugepage reservation.
+28 −0
Original line number Diff line number Diff line
@@ -837,6 +837,34 @@ bool spdk_nvmf_subsystem_any_listener_allowed(
int spdk_nvmf_subsystem_set_ana_reporting(struct spdk_nvmf_subsystem *subsystem,
		bool ana_reporting);

/**
 * Get whether a subsystem supports Asymmetric Namespace Access (ANA)
 * reporting.
 *
 * \param subsystem Subsystem to check
 *
 * \return true if subsystem supports ANA reporting, false otherwise.
 */
bool spdk_nvmf_subsystem_get_ana_reporting(struct spdk_nvmf_subsystem *subsystem);

/**
 * Set Asymmetric Namespace Access (ANA) state for the specified ANA group id.
 *
 * May only be performed on subsystems in the INACTIVE or PAUSED state.
 *
 * \param subsystem Subsystem to operate on
 * \param trid Address for which the new state will apply
 * \param ana_state The ANA state which is to be set
 * \param anagrpid The ANA group ID to operate on
 * \param cb_fn The function to call on completion
 * \param cb_arg The argument to pass to the cb_fn
 *
 */
void spdk_nvmf_subsystem_set_ana_state(struct spdk_nvmf_subsystem *subsystem,
				       const struct spdk_nvme_transport_id *trid,
				       enum spdk_nvme_ana_state ana_state, uint32_t anagrpid,
				       spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn, void *cb_arg);

/** NVMe-oF target namespace creation options */
struct spdk_nvmf_ns_opts {
	/**
+2 −2
Original line number Diff line number Diff line
@@ -578,7 +578,7 @@ nvmf_write_nvme_subsystem_config(struct spdk_json_write_ctx *w,

	spdk_json_write_named_uint32(w, "min_cntlid", spdk_nvmf_subsystem_get_min_cntlid(subsystem));
	spdk_json_write_named_uint32(w, "max_cntlid", spdk_nvmf_subsystem_get_max_cntlid(subsystem));
	spdk_json_write_named_bool(w, "ana_reporting", nvmf_subsystem_get_ana_reporting(subsystem));
	spdk_json_write_named_bool(w, "ana_reporting", spdk_nvmf_subsystem_get_ana_reporting(subsystem));

	/*     } "params" */
	spdk_json_write_object_end(w);
@@ -648,7 +648,7 @@ nvmf_write_nvme_subsystem_config(struct spdk_json_write_ctx *w,
			spdk_json_write_named_uuid(w, "uuid",  &ns_opts.uuid);
		}

		if (nvmf_subsystem_get_ana_reporting(subsystem)) {
		if (spdk_nvmf_subsystem_get_ana_reporting(subsystem)) {
			spdk_json_write_named_uint32(w, "anagrpid", ns_opts.anagrpid);
		}

+0 −5
Original line number Diff line number Diff line
@@ -411,11 +411,6 @@ void nvmf_transport_dump_opts(struct spdk_nvmf_transport *transport, struct spdk
			      bool named);
void nvmf_transport_listen_dump_trid(const struct spdk_nvme_transport_id *trid,
				     struct spdk_json_write_ctx *w);
void nvmf_subsystem_set_ana_state(struct spdk_nvmf_subsystem *subsystem,
				  const struct spdk_nvme_transport_id *trid,
				  enum spdk_nvme_ana_state ana_state, uint32_t anagrpid,
				  spdk_nvmf_tgt_subsystem_listen_done_fn cb_fn, void *cb_arg);
bool nvmf_subsystem_get_ana_reporting(struct spdk_nvmf_subsystem *subsystem);

/**
 * Sets the controller ID range for a subsystem.
+4 −4
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ dump_nvmf_subsystem(struct spdk_json_write_ctx *w, struct spdk_nvmf_subsystem *s
				spdk_json_write_named_uuid(w, "uuid", &ns_opts.uuid);
			}

			if (nvmf_subsystem_get_ana_reporting(subsystem)) {
			if (spdk_nvmf_subsystem_get_ana_reporting(subsystem)) {
				spdk_json_write_named_uint32(w, "anagrpid", ns_opts.anagrpid);
			}

@@ -785,7 +785,7 @@ nvmf_rpc_listen_paused(struct spdk_nvmf_subsystem *subsystem,
						 "Invalid parameters");
		ctx->response_sent = true;
	} else if (ctx->op == NVMF_RPC_LISTEN_SET_ANA_STATE) {
		nvmf_subsystem_set_ana_state(subsystem, &ctx->trid, ctx->ana_state, ctx->anagrpid,
		spdk_nvmf_subsystem_set_ana_state(subsystem, &ctx->trid, ctx->ana_state, ctx->anagrpid,
						  nvmf_rpc_set_ana_state_done, ctx);
		return;
	} else {
@@ -2549,7 +2549,7 @@ dump_nvmf_subsystem_listener(struct spdk_json_write_ctx *w,
	nvmf_transport_listen_dump_trid(trid, w);
	spdk_json_write_object_end(w);

	if (nvmf_subsystem_get_ana_reporting(listener->subsystem)) {
	if (spdk_nvmf_subsystem_get_ana_reporting(listener->subsystem)) {
		spdk_json_write_named_array_begin(w, "ana_states");
		for (i = 0; i < listener->subsystem->max_nsid; i++) {
			spdk_json_write_object_begin(w);
Loading