Commit 9bb97528 authored by Jakub Radtke's avatar Jakub Radtke Committed by Changpeng Liu
Browse files

ocssd: add chunk notification log struct



This patch adds struct for "Chunk Notification Log".
New log page is used to report the state of chunk, lblk or pu.
Implementation is consistent with Open-Channel
specification (rev. 2.0)

Change-Id: I8aaf01c14d2f0faf8b8f8a6a773b6cb9bf97b38d
Signed-off-by: default avatarJakub Radtke <jakub.radtke@intel.com>
Reviewed-on: https://review.gerrithub.io/426233


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 713b4817
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static uint64_t g_discovery_page_numrec;

static struct spdk_ocssd_geometry_data geometry_data;

static struct spdk_ocssd_chunk_information g_ocssd_chunk_info_page[NUM_CHUNK_INFO_ENTRIES ];
static struct spdk_ocssd_chunk_information_entry g_ocssd_chunk_info_page[NUM_CHUNK_INFO_ENTRIES ];

static bool g_hex_dump = false;

@@ -580,7 +580,7 @@ print_ascii_string(const void *buf, size_t size)
}

static void
print_ocssd_chunk_info(struct spdk_ocssd_chunk_information *chk_info, int chk_num)
print_ocssd_chunk_info(struct spdk_ocssd_chunk_information_entry *chk_info, int chk_num)
{
	int i;
	char *cs_str, *ct_str;
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ int spdk_nvme_ocssd_ctrlr_cmd_geometry(struct spdk_nvme_ctrlr *ctrlr, uint32_t n
int spdk_nvme_ocssd_ns_cmd_vector_reset(struct spdk_nvme_ns *ns,
					struct spdk_nvme_qpair *qpair,
					uint64_t *lba_list, uint32_t num_lbas,
					struct spdk_ocssd_chunk_information *chunk_info,
					struct spdk_ocssd_chunk_information_entry *chunk_info,
					spdk_nvme_cmd_cb cb_fn, void *cb_arg);

/**
+104 −3
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ struct spdk_ocssd_geometry_data {
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_ocssd_geometry_data) == 4096, "Incorrect size");

struct spdk_ocssd_chunk_information {
struct spdk_ocssd_chunk_information_entry {
	/** Chunk State */
	struct {
		/** if set to 1 chunk is free */
@@ -208,7 +208,105 @@ struct spdk_ocssd_chunk_information {
	/** Write Pointer */
	uint64_t wp;
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_ocssd_chunk_information) == 32, "Incorrect size");
SPDK_STATIC_ASSERT(sizeof(struct spdk_ocssd_chunk_information_entry) == 32, "Incorrect size");

struct spdk_ocssd_chunk_notification_entry {

	/**
	 * This is a 64-bit incrementing notification count, indicating a
	 * unique identifier for this notification. The counter begins at 1h
	 * and is incremented for each unique event
	 */
	uint64_t		nc;

	/** This field points to the chunk that has its state updated */
	uint64_t		lba;

	/**
	 * This field indicates the namespace id that the event is associated
	 * with
	 */
	uint32_t		nsid;

	/** Field that indicate the state of the block */
	struct {

		/**
		 * If set to 1, then the error rate of the chunk has been
		 * changed to low
		 */
		uint8_t error_rate_low : 1;

		/**
		 * If set to 1, then the error rate of the chunk has been
		 * changed to medium
		 */
		uint8_t error_rate_medium : 1;

		/**
		 * If set to 1, then the error rate of the chunk has been
		 * changed to high
		 */
		uint8_t error_rate_high : 1;

		/**
		 * If set to 1, then the error rate of the chunk has been
		 * changed to unrecoverable
		 */
		uint8_t unrecoverable : 1;

		/**
		 * If set to 1, then the chunk has been refreshed by the
		 * device
		 */
		uint8_t refreshed : 1;

		uint8_t rsvd : 3;

		/**
		 * If set to 1 then the chunk's wear-level index is outside
		 * the average wear-level index threshold defined by the
		 * controller
		 */
		uint8_t wit_exceeded : 1;

		uint8_t rsvd2 : 7;
	} state;

	/**
	 * The address provided is covering either logical block, chunk, or
	 * parallel unit
	 */
	struct {

		/** If set to 1, the LBA covers the logical block */
		uint8_t lblk : 1;

		/** If set to 1, the LBA covers the respecting chunk */
		uint8_t chunk : 1;

		/**
		 * If set to 1, the LBA covers the respecting parallel unit
		 * including all chunks
		 */
		uint8_t pu : 1;

		uint8_t rsvd : 5;
	} mask;

	uint8_t			rsvd[9];

	/**
	 * This field indicates the number of logical chunks to be written.
	 * This is a 0's based value. This field is only valid if mask bit 0 is
	 * set. The number of blocks addressed shall not be outside the boundary
	 * of the specified chunk.
	 */
	uint16_t		nlb;

	uint8_t			rsvd2[30];
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_ocssd_chunk_notification_entry) == 64, "Incorrect size");

/**
 * Vector completion queue entry
@@ -250,6 +348,9 @@ enum spdk_ocssd_io_opcode {
enum spdk_ocssd_log_page {
	/** Chunk Information */
	SPDK_OCSSD_LOG_CHUNK_INFO		= 0xCA,

	/** Chunk Notification Log */
	SPDK_OCSSD_LOG_CHUNK_NOTIFICATION	= 0xD0,
};

/**
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ int
spdk_nvme_ocssd_ns_cmd_vector_reset(struct spdk_nvme_ns *ns,
				    struct spdk_nvme_qpair *qpair,
				    uint64_t *lba_list, uint32_t num_lbas,
				    struct spdk_ocssd_chunk_information *chunk_info,
				    struct spdk_ocssd_chunk_information_entry *chunk_info,
				    spdk_nvme_cmd_cb cb_fn, void *cb_arg)
{
	struct nvme_request	*req;