Commit 6d7d56aa authored by Pawel Baldysiak's avatar Pawel Baldysiak Committed by Tomasz Zawadzki
Browse files

nvmf: Add support for get_supported_log_pages log page



This commit adds support for optional log page
SUPPORTED_LOG_PAGES that gathers all
log pages that are supported by subsystem.
Support is added for both discovery and IO subsystems.

Add public call to get just the stucture filled with what
is supported in SPDK for the controller - it can be used
in future in fixup for passthru get_log_page handling.

One of test_get_log_page()'s case expect LID 0x0 to fail
as not supported. Since it is supported now - change
LID in request to -1.

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


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
parent 605630ac
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -3455,6 +3455,21 @@ enum spdk_nvme_log_page {

#define spdk_nvme_log_page_is_vendor_specific(lid) ((lid) >= SPDK_NVME_LOG_VENDOR_SPECIFIC_START)

struct spdk_nvme_supported_log_pages {
	/* Log Page Identifier Supported 0-255 */
	struct {
		/* LID Supported - 0 */
		uint32_t lsupp		: 1;
		/* Index Offset Supported - 1 */
		uint32_t ios		: 1;
		/* Reserved - 2:15 */
		uint32_t reserved	: 14;
		/* LID Specific Parameter - 16:31 */
		uint32_t lidsp		: 16;
	} lids[256];
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_supported_log_pages) == 1024, "Incorrect size");

/**
 * Error information log page (\ref SPDK_NVME_LOG_ERROR)
 */
+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);

/**
 * Fill the log page struct with supported log pages for specified controller
 *
 * \param ctrlr The NVMe-oF controller
 * \param log_page target struct to be filled with log pages supported by the controller
 */
void spdk_nvmf_get_supported_log_pages(struct spdk_nvmf_ctrlr *ctrlr,
				       struct spdk_nvme_supported_log_pages *log_page);

/**
 * Fills the I/O Command Set specific Identify Namespace data structure (CNS
 * 05h)
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 21
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = ctrlr.c ctrlr_discovery.c ctrlr_bdev.c \
	 subsystem.c nvmf.c nvmf_rpc.c transport.c tcp.c \
+73 −5
Original line number Diff line number Diff line
@@ -2796,6 +2796,64 @@ is_log_page_ctrlr_nvm_scope(uint8_t lid)
	}
}

static const struct spdk_nvme_supported_log_pages g_supported_log_pages_discover = {
	.lids = {
		[SPDK_NVME_LOG_SUPPORTED_LOG_PAGES] = { .lsupp = 1 },
		[SPDK_NVME_LOG_DISCOVERY] =	      { .lsupp = 1 },
	}
};

static const struct spdk_nvme_supported_log_pages g_supported_log_pages = {
	.lids = {
		[SPDK_NVME_LOG_SUPPORTED_LOG_PAGES] =	      { .lsupp = 1 },
		[SPDK_NVME_LOG_ERROR] =			      { .lsupp = 1 },
		[SPDK_NVME_LOG_HEALTH_INFORMATION] =	      { .lsupp = 1 },
		[SPDK_NVME_LOG_FIRMWARE_SLOT] =		      { .lsupp = 1 },
		[SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS] = { .lsupp = 1 },
		[SPDK_NVME_LOG_COMMAND_EFFECTS_LOG] =	      { .lsupp = 1 },
		[SPDK_NVME_LOG_CHANGED_NS_LIST] =	      { .lsupp = 1 },
		[SPDK_NVME_LOG_RESERVATION_NOTIFICATION] =    { .lsupp = 1 },
	}
};

void
spdk_nvmf_get_supported_log_pages(struct spdk_nvmf_ctrlr *ctrlr,
				  struct spdk_nvme_supported_log_pages *log_page)
{
	if (spdk_nvmf_subsystem_is_discovery(ctrlr->subsys)) {
		*log_page = g_supported_log_pages_discover;
	} else {
		*log_page = g_supported_log_pages;
		if (ctrlr->subsys->flags.ana_reporting != 1) {
			log_page->lids[SPDK_NVME_LOG_ASYMMETRIC_NAMESPACE_ACCESS].lsupp = 0;
		}
	}
}

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

	spdk_nvmf_get_supported_log_pages(ctrlr, &supported_log_pages);

	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 *)(&supported_log_pages) + offset, copy_len);
	} else {
		SPDK_ERRLOG("Invalid Get supported log pages offset: (%" PRIu64 "), log page size (%" PRIu32")\n",
			    offset, page_size);
		return -EINVAL;
	}

	return 0;
}

static int
nvmf_ctrlr_get_log_page(struct spdk_nvmf_request *req)
{
@@ -2844,6 +2902,10 @@ nvmf_ctrlr_get_log_page(struct spdk_nvmf_request *req)

	if (spdk_nvmf_subsystem_is_discovery(subsystem)) {
		switch (lid) {
		/* If you are adding support for new log pages, please update g_supported_log_pages_discover[] to reflect it. */
		case SPDK_NVME_LOG_SUPPORTED_LOG_PAGES:
			rc = nvmf_get_supported_log_pages(ctrlr, req->iov, req->iovcnt, offset, len);
			break;
		case SPDK_NVME_LOG_DISCOVERY:
			if (spdk_nvmf_qpair_get_listen_trid(req->qpair, &cmd_source_trid)) {
				SPDK_ERRLOG("Failed to get LOG_DISCOVERY source trid\n");
@@ -2853,21 +2915,27 @@ nvmf_ctrlr_get_log_page(struct spdk_nvmf_request *req)
			}
			rc = nvmf_get_discovery_log_page(subsystem->tgt, ctrlr->hostnqn, req->iov, req->iovcnt,
							 offset, len, &cmd_source_trid);
			if (rc) {
				goto invalid_field_log_page;
			}

			if (!rae) {
			if (!rc && !rae) {
				nvmf_ctrlr_unmask_aen(ctrlr, SPDK_NVME_ASYNC_EVENT_DISCOVERY_LOG_CHANGE_MASK_BIT);
			}
			return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
			break;
		default:
			SPDK_INFOLOG(nvmf, "Unsupported Get Log Page Identifier for discovery subsystem 0x%02X\n", lid);
			goto invalid_field_log_page;
		}

		if (rc) {
			goto invalid_field_log_page;
		}
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
	}

	switch (lid) {
	/* If you are adding support for new log pages, please update g_supported_log_pages[] to reflect it. */
	case SPDK_NVME_LOG_SUPPORTED_LOG_PAGES:
		rc = nvmf_get_supported_log_pages(ctrlr, req->iov, req->iovcnt, offset, len);
		break;
	case SPDK_NVME_LOG_ERROR:
		nvmf_get_error_log_page(ctrlr, req->iov, req->iovcnt, offset, len, rae);
		break;
+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_supported_log_pages;
	spdk_nvmf_ctrlr_identify_iocs_specific;
	spdk_nvmf_ctrlr_identify_ns;
	spdk_nvmf_ctrlr_identify_ns_ext;
Loading