nvme: add support for ZNS zone management receive command
Add support for the ZNS zone management receive command. An internal nvme_zns_zone_mgmt_recv() function is created that matches the parameters of the zone management receive function in the ZNS specification. Convenience functions are provided for the following Zone Receive Action: Report Zones. Zone Receive Actions not implemented: Extended Report Zones. Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com> Change-Id: I23589a602336da5dffccec7230d07026a868e81b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4793 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
be3ff9c0b5
commit
6dec7623be
@ -3078,6 +3078,41 @@ enum spdk_nvme_zns_zone_send_action {
|
||||
SPDK_NVME_ZONE_OFFLINE = 0x5,
|
||||
};
|
||||
|
||||
/* ZNS Zone Receive Action (ZRA) cdw13 */
|
||||
enum spdk_nvme_zns_zone_receive_action {
|
||||
SPDK_NVME_ZONE_REPORT = 0x0,
|
||||
};
|
||||
|
||||
enum spdk_nvme_zns_zra_report_opts {
|
||||
SPDK_NVME_ZRA_LIST_ALL = 0x0,
|
||||
SPDK_NVME_ZRA_LIST_ZSE = 0x1,
|
||||
SPDK_NVME_ZRA_LIST_ZSIO = 0x2,
|
||||
SPDK_NVME_ZRA_LIST_ZSEO = 0x3,
|
||||
SPDK_NVME_ZRA_LIST_ZSC = 0x4,
|
||||
SPDK_NVME_ZRA_LIST_ZSF = 0x5,
|
||||
SPDK_NVME_ZRA_LIST_ZSRO = 0x6,
|
||||
SPDK_NVME_ZRA_LIST_ZSO = 0x7,
|
||||
};
|
||||
|
||||
struct spdk_nvme_zns_zone_desc {
|
||||
uint8_t zt;
|
||||
uint8_t zs;
|
||||
uint8_t za;
|
||||
uint8_t reserved3[5];
|
||||
uint64_t zcap;
|
||||
uint64_t zslba;
|
||||
uint64_t wp;
|
||||
uint8_t reserved32[32];
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_zns_zone_desc) == 64, "Incorrect size");
|
||||
|
||||
struct spdk_nvme_zns_zone_report {
|
||||
uint64_t nr_zones;
|
||||
uint8_t reserved8[56];
|
||||
struct spdk_nvme_zns_zone_desc descs[];
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_zns_zone_report) == 64, "Incorrect size");
|
||||
|
||||
#define spdk_nvme_cpl_is_error(cpl) \
|
||||
((cpl)->status.sc != SPDK_NVME_SC_SUCCESS || \
|
||||
(cpl)->status.sct != SPDK_NVME_SCT_GENERIC)
|
||||
|
@ -183,6 +183,28 @@ 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);
|
||||
|
||||
/**
|
||||
* Get a 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 zone report.
|
||||
* \param partial_report If true, nr_zones field in the zone report indicates the number of zone
|
||||
* descriptors that were successfully written to the zone report. If false, nr_zones field in the
|
||||
* 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_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
|
||||
|
@ -60,6 +60,42 @@ spdk_nvme_zns_ctrlr_get_data(struct spdk_nvme_ctrlr *ctrlr)
|
||||
return ctrlr->cdata_zns;
|
||||
}
|
||||
|
||||
static int
|
||||
nvme_zns_zone_mgmt_recv(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
void *payload, uint32_t payload_size, uint64_t slba,
|
||||
uint8_t zone_recv_action, uint8_t zra_spec_field, bool zra_spec_feats,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct spdk_nvme_cmd *cmd;
|
||||
|
||||
req = nvme_allocate_request_user_copy(qpair, payload, payload_size, cb_fn, cb_arg, false);
|
||||
if (req == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = SPDK_NVME_OPC_ZONE_MGMT_RECV;
|
||||
cmd->nsid = ns->id;
|
||||
|
||||
*(uint64_t *)&cmd->cdw10 = slba;
|
||||
cmd->cdw12 = payload_size / sizeof(uint32_t) - 1u;
|
||||
cmd->cdw13 = zone_recv_action | zra_spec_field << 8 | zra_spec_feats << 16;
|
||||
|
||||
return nvme_qpair_submit_request(qpair, req);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_zns_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_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,
|
||||
|
@ -168,6 +168,7 @@
|
||||
spdk_nvme_zns_open_zone;
|
||||
spdk_nvme_zns_reset_zone;
|
||||
spdk_nvme_zns_offline_zone;
|
||||
spdk_nvme_zns_report_zones;
|
||||
|
||||
# public functions from nvme_ocssd.h
|
||||
spdk_nvme_ctrlr_is_ocssd_supported;
|
||||
|
Loading…
x
Reference in New Issue
Block a user