Commit 008c1298 authored by Pawel Baldysiak's avatar Pawel Baldysiak Committed by Tomasz Zawadzki
Browse files

nvmf: Add public getter for cmds_and_effects log page struct



Add public call to get just the stucture filled data about
cmds supported by SPDK for target ctrlr  - it can be used
in future in fixup for passthru get_log_page handling.
It aligns the code with getters for supported log pages
and feature ids and effects log page.

Change-Id: Ia89f6505d8d1dd26b523b0d4e82f811c0b58e9b6
Signed-off-by: default avatarPawel Baldysiak <pawel.baldysiak@dell.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26454


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent ca2a1c36
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,15 @@ enum spdk_nvmf_request_exec_status {
int spdk_nvmf_ctrlr_identify_ctrlr(struct spdk_nvmf_ctrlr *ctrlr,
				   struct spdk_nvme_ctrlr_data *cdata);

/**
 * Fills log page struct with supported cmds and effects log page for specified controller
 *
 * \param ctrlr The NVMe-oF controller
 * \param log_page target structure to be filled with cmds and effects supported by the controller
 */
void spdk_nvmf_get_cmds_and_effects_log_page(struct spdk_nvmf_ctrlr *ctrlr,
		struct spdk_nvme_cmds_and_effect_log_page *log_page);

/**
 * Fills log page struct with feature identifiers effects log page for specified controller
 *
+32 −16
Original line number Diff line number Diff line
@@ -2681,40 +2681,56 @@ static const struct spdk_nvme_cmds_and_effect_log_page g_cmds_and_effect_log_pag
	},
};

static int
nvmf_get_cmds_and_effects_log_page(struct spdk_nvmf_ctrlr *ctrlr, struct iovec *iovs, int iovcnt,
				   uint64_t offset, uint32_t length)
void
spdk_nvmf_get_cmds_and_effects_log_page(struct spdk_nvmf_ctrlr *ctrlr,
					struct spdk_nvme_cmds_and_effect_log_page *log_page)
{
	uint32_t page_size = sizeof(struct spdk_nvme_cmds_and_effect_log_page);
	size_t copy_len = 0;
	struct spdk_nvme_cmds_and_effect_log_page cmds_and_effect_log_page = g_cmds_and_effect_log_page;
	struct spdk_nvme_cmds_and_effect_entry zero = {};
	struct spdk_iov_xfer ix;
	struct spdk_nvme_cmds_and_effect_entry *entry;

	*log_page = g_cmds_and_effect_log_page;
	if (!ctrlr->cdata.oncs.write_zeroes || !nvmf_ctrlr_write_zeroes_supported(ctrlr)) {
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_WRITE_ZEROES] = zero;
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_WRITE_ZEROES];
		memset(entry, 0, sizeof(*entry));
	}
	if (!ctrlr->cdata.oncs.dsm || !nvmf_ctrlr_dsm_supported(ctrlr)) {
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_DATASET_MANAGEMENT] = zero;
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_DATASET_MANAGEMENT];
		memset(entry, 0, sizeof(*entry));
	}
	if (!ctrlr->cdata.oncs.compare) {
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_COMPARE] = zero;
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_COMPARE];
		memset(entry, 0, sizeof(*entry));
	}
	if (!nvmf_subsystem_has_zns_iocs(ctrlr->subsys)) {
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_ZONE_MGMT_SEND] = zero;
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_ZONE_MGMT_RECV] = zero;
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_ZONE_MGMT_SEND];
		memset(entry, 0, sizeof(*entry));
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_ZONE_MGMT_RECV];
		memset(entry, 0, sizeof(*entry));
	}
	if (!nvmf_subsystem_zone_append_supported(ctrlr->subsys)) {
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_ZONE_APPEND] = zero;
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_ZONE_APPEND];
		memset(entry, 0, sizeof(*entry));
	}
	if (!ctrlr->cdata.oncs.copy) {
		cmds_and_effect_log_page.io_cmds_supported[SPDK_NVME_OPC_COPY] = zero;
		entry = &log_page->io_cmds_supported[SPDK_NVME_OPC_COPY];
		memset(entry, 0, sizeof(*entry));
	}
}

static int
nvmf_get_cmds_and_effects_log_page(struct spdk_nvmf_ctrlr *ctrlr, struct iovec *iovs, int iovcnt,
				   uint64_t offset, uint32_t length)
{
	uint32_t page_size = sizeof(struct spdk_nvme_cmds_and_effect_log_page);
	size_t copy_len = 0;
	struct spdk_iov_xfer ix;
	struct spdk_nvme_cmds_and_effect_log_page cmds_and_effects_log_page = {};

	spdk_nvmf_get_cmds_and_effects_log_page(ctrlr, &cmds_and_effects_log_page);

	spdk_iov_xfer_init(&ix, iovs, iovcnt);
	if (offset < page_size) {
		copy_len = spdk_min(page_size - offset, length);
		spdk_iov_xfer_from_buf(&ix, (char *)(&cmds_and_effect_log_page) + offset, copy_len);
		spdk_iov_xfer_from_buf(&ix, (char *)(&cmds_and_effects_log_page) + offset, copy_len);
	} else {
		SPDK_ERRLOG("Invalid Get log page cmds effects offset: (%" PRIu64 "), log page size (%" PRIu32")\n",
			    offset, page_size);
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@

	# public functions in nvmf_cmd.h
	spdk_nvmf_ctrlr_identify_ctrlr;
	spdk_nvmf_get_cmds_and_effects_log_page;
	spdk_nvmf_get_feature_ids_effects_log_page;
	spdk_nvmf_get_supported_log_pages;
	spdk_nvmf_ctrlr_identify_iocs_specific;