Commit cb883c5a authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Jim Harris
Browse files

lib/ftl: Dump FTL properties to the JSON request



Change-Id: I5176269a73a26afdd35a15719a57fd6862dcce68
Signed-off-by: default avatarMariusz Barczak <Mariusz.Barczak@solidigmtechnology.com>
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19007


Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent 309682ca
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "ftl_internal.h"
#include "ftl_nv_cache.h"
#include "ftl_debug.h"
#include "ftl_utils.h"

void
ftl_mngt_check_conf(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt)
@@ -182,6 +183,9 @@ ftl_mngt_finalize_startup(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mng
		dev->unmap_in_progress = true;
	}

	ftl_property_register(dev, "superblock_version", &dev->sb->header.version,
			      sizeof(dev->sb->header.version), ftl_property_dump_uint64);

	/* Clear the limit applications as they're incremented incorrectly by
	 * the initialization code.
	 */
+45 −3
Original line number Diff line number Diff line
@@ -20,6 +20,15 @@ struct ftl_property {
	/** Name of the property */
	const char *name;

	/* Pointer to the value of property */
	void *value;

	/* The value size of the property */
	size_t size;

	/* The function to dump the value of property into the specified JSON RPC request */
	ftl_property_dump_fn dump;

	/** Link to put the property to the list */
	LIST_ENTRY(ftl_property) entry;
};
@@ -40,7 +49,8 @@ get_property_item(struct ftl_properties *properties, const char *name)
}

void
ftl_property_register(struct spdk_ftl_dev *dev, const char *name)
ftl_property_register(struct spdk_ftl_dev *dev, const char *name, void *value, size_t size,
		      ftl_property_dump_fn dump)
{
	struct ftl_properties *properties = dev->properties;

@@ -55,6 +65,9 @@ ftl_property_register(struct spdk_ftl_dev *dev, const char *name)
		}

		prop->name = name;
		prop->value = value;
		prop->size = size;
		prop->dump = dump;
		LIST_INSERT_HEAD(&properties->list, prop, entry);
	}
}
@@ -103,11 +116,40 @@ ftl_property_dump(struct spdk_ftl_dev *dev, struct spdk_jsonrpc_request *request

	spdk_json_write_named_object_begin(w, "properties");
	LIST_FOREACH(prop, &properties->list, entry) {
		/* TODO dump the value as well */
		spdk_json_write_named_string(w, prop->name, "");
		prop->dump(prop, w);
	}
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
	spdk_jsonrpc_end_result(request, w);
}

void
ftl_property_dump_bool(const struct ftl_property *property,
		       struct spdk_json_write_ctx *w)
{
	bool *value = property->value;

	assert(property->size == sizeof(*value));
	spdk_json_write_named_bool(w, property->name, *value);
}

void
ftl_property_dump_uint64(const struct ftl_property *property,
			 struct spdk_json_write_ctx *w)
{
	uint64_t *value = property->value;

	assert(property->size == sizeof(*value));
	spdk_json_write_named_uint64(w, property->name, *value);
}

void
ftl_property_dump_uint32(const struct ftl_property *property,
			 struct spdk_json_write_ctx *w)
{
	uint32_t *value = property->value;

	assert(property->size == sizeof(*value));
	spdk_json_write_named_uint32(w, property->name, *value);
}
+30 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include "spdk/stdinc.h"

struct spdk_ftl_dev;
struct ftl_property;

/**
 * @brief Init the FTL properties system
@@ -22,13 +23,41 @@ int ftl_properties_init(struct spdk_ftl_dev *dev);
 */
void ftl_properties_deinit(struct spdk_ftl_dev *dev);

/**
 * @brief A function to dump the FTL property which type is bool
 */
void ftl_property_dump_bool(const struct ftl_property *property, struct spdk_json_write_ctx *w);

/**
 * @brief A function to dump the FTL property which type is uint64
 */
void ftl_property_dump_uint64(const struct ftl_property *property, struct spdk_json_write_ctx *w);

/**
 * @brief A function to dump the FTL property which type is uint32
 */
void ftl_property_dump_uint32(const struct ftl_property *property, struct spdk_json_write_ctx *w);

/**
 * @brief Dump the value of property into the specified JSON RPC request
 *
 * @param property The property to dump to the JSON RPC request
 * @param[out] w JSON RPC request
 */
typedef void (*ftl_property_dump_fn)(const struct ftl_property *property,
				     struct spdk_json_write_ctx *w);

/**
 * @brief Register a FTL property
 *
 * @param dev FTL device
 * @param name the FTL property name
 * @param value Pointer to the value of property
 * @param size The value size of the property
 * @param dump The function to dump the property to the JSON RPC request
 */
void ftl_property_register(struct spdk_ftl_dev *dev, const char *name);
void ftl_property_register(struct spdk_ftl_dev *dev, const char *name, void *value, size_t size,
			   ftl_property_dump_fn dump);

/**
 * @brief Dump FTL properties to the JSON request