Commit 490c83c6 authored by Krishna Kanth Reddy's avatar Krishna Kanth Reddy Committed by Tomasz Zawadzki
Browse files

lib/nvme: NVMe ZNS - Zone Descriptor Extension support



Signed-off-by: default avatarKrishna Kanth Reddy <krish.reddy@samsung.com>
Change-Id: I11a72f48bf4e39e0547c29cb0213679ab24388b2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9494


Reviewed-by: default avatarKlaus Jensen <its@irrelevant.dk>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
parent 2d6736d1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ log level.

### nvme

Added new functions `spdk_nvme_zns_set_zone_desc_ext` and `spdk_nvme_zns_ext_report_zones`
to set zone descriptor extension and to get extended zone report respectively.

New API `spdk_nvme_ctrlr_get_memory_domain` has been added, it allows to get SPDK memory domain used by nvme controller.

New API functions `spdk_nvme_ns_cmd_readv_ext` and `spdk_nvme_ns_cmd_writev_ext`
+39 −0
Original line number Diff line number Diff line
@@ -359,6 +359,23 @@ int spdk_nvme_zns_offline_zone(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *
			       uint64_t slba, bool select_all,
			       spdk_nvme_cmd_cb cb_fn, void *cb_arg);

/**
 * Submit a Set Zone Descriptor Extension operation to the specified NVMe namespace.
 *
 * \param ns Namespace.
 * \param qpair I/O queue pair to submit the request.
 * \param slba starting LBA of the zone to operate on.
 * \param buffer Virtual address pointer to the data payload buffer.
 * \param payload_size Payload buffer size.
 * \param cb_fn Callback function invoked when the I/O command completes.
 * \param cb_arg Argument passed to callback function.
 *
 * \return 0 on success. Negated errno on failure.
 */
int spdk_nvme_zns_set_zone_desc_ext(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
				    uint64_t slba, void *buffer, uint32_t payload_size,
				    spdk_nvme_cmd_cb cb_fn, void *cb_arg);

/**
 * Get a zone report from the specified NVMe namespace.
 *
@@ -381,6 +398,28 @@ int spdk_nvme_zns_report_zones(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *
			       enum spdk_nvme_zns_zra_report_opts report_opts, bool partial_report,
			       spdk_nvme_cmd_cb cb_fn, void *cb_arg);

/**
 * Get a extended zone report from the specified NVMe namespace.
 *
 * \param ns Namespace.
 * \param qpair I/O queue pair to submit the request.
 * \param payload The pointer to the payload buffer.
 * \param payload_size The size of payload buffer.
 * \param slba starting LBA of the zone to operate on.
 * \param report_opts Filter on which zone states to include in the extended zone report.
 * \param partial_report If true, nr_zones field in the extended zone report indicates the number of zone
 * descriptors that were successfully written to the extended zone report. If false, nr_zones field in the
 * extended zone report indicates the number of zone descriptors that match the report_opts criteria.
 * \param cb_fn Callback function invoked when the I/O command completes.
 * \param cb_arg Argument passed to callback function.
 *
 * \return 0 on success. Negated errno on failure.
 */
int spdk_nvme_zns_ext_report_zones(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
				   void *payload, uint32_t payload_size, uint64_t slba,
				   enum spdk_nvme_zns_zra_report_opts report_opts, bool partial_report,
				   spdk_nvme_cmd_cb cb_fn, void *cb_arg);

#ifdef __cplusplus
}
#endif
+43 −0
Original line number Diff line number Diff line
@@ -170,6 +170,17 @@ spdk_nvme_zns_report_zones(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpai
				       cb_fn, cb_arg);
}

int
spdk_nvme_zns_ext_report_zones(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
			       void *payload, uint32_t payload_size, uint64_t slba,
			       enum spdk_nvme_zns_zra_report_opts report_opts, bool partial_report,
			       spdk_nvme_cmd_cb cb_fn, void *cb_arg)
{
	return nvme_zns_zone_mgmt_recv(ns, qpair, payload, payload_size, slba,
				       SPDK_NVME_ZONE_EXTENDED_REPORT, report_opts, partial_report,
				       cb_fn, cb_arg);
}

static int
nvme_zns_zone_mgmt_send(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
			uint64_t slba, bool select_all, uint8_t zone_send_action,
@@ -235,3 +246,35 @@ spdk_nvme_zns_offline_zone(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpai
	return nvme_zns_zone_mgmt_send(ns, qpair, slba, select_all, SPDK_NVME_ZONE_OFFLINE,
				       cb_fn, cb_arg);
}

int
spdk_nvme_zns_set_zone_desc_ext(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
				uint64_t slba, void *buffer, uint32_t payload_size,
				spdk_nvme_cmd_cb cb_fn, void *cb_arg)
{
	struct nvme_request *req;
	struct spdk_nvme_cmd *cmd;

	if (payload_size == 0) {
		return -EINVAL;
	}

	if (buffer == NULL) {
		return -EINVAL;
	}

	req = nvme_allocate_request_user_copy(qpair, buffer, payload_size, cb_fn, cb_arg, true);
	if (req == NULL) {
		return -ENOMEM;
	}

	cmd = &req->cmd;
	cmd->opc = SPDK_NVME_OPC_ZONE_MGMT_SEND;
	cmd->nsid = ns->id;

	*(uint64_t *)&cmd->cdw10 = slba;

	cmd->cdw13 = SPDK_NVME_ZONE_SET_ZDE;

	return nvme_qpair_submit_request(qpair, req);
}
+2 −0
Original line number Diff line number Diff line
@@ -207,7 +207,9 @@
	spdk_nvme_zns_open_zone;
	spdk_nvme_zns_reset_zone;
	spdk_nvme_zns_offline_zone;
	spdk_nvme_zns_set_zone_desc_ext;
	spdk_nvme_zns_report_zones;
	spdk_nvme_zns_ext_report_zones;

	# public functions from nvme_ocssd.h
	spdk_nvme_ctrlr_is_ocssd_supported;