Commit 3185d3c9 authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Tomasz Zawadzki
Browse files

bdev: Report memory domains in bdev_get_bdevs RPC



This change will simplify development/debugging.

Signed-off-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Change-Id: Ibde374089057a0684391f6519fa4e878d007408d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11049


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent d7ac3d92
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "spdk/string.h"
#include "spdk/base64.h"
#include "spdk/bdev_module.h"
#include "spdk/dma.h"

#include "spdk/log.h"

@@ -354,7 +355,8 @@ rpc_dump_bdev_info(struct spdk_json_write_ctx *w,
{
	struct spdk_bdev_alias *tmp;
	uint64_t qos_limits[SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES];
	int i;
	struct spdk_memory_domain **domains;
	int i, rc;

	spdk_json_write_object_begin(w);

@@ -433,6 +435,31 @@ rpc_dump_bdev_info(struct spdk_json_write_ctx *w,
				   spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_NVME_IO));
	spdk_json_write_object_end(w);

	rc = spdk_bdev_get_memory_domains(bdev, NULL, 0);
	if (rc > 0) {
		domains = calloc(rc, sizeof(struct spdk_memory_domain *));
		if (domains) {
			i = spdk_bdev_get_memory_domains(bdev, domains, rc);
			if (i == rc) {
				spdk_json_write_named_array_begin(w, "memory_domains");
				for (i = 0; i < rc; i++) {
					spdk_json_write_object_begin(w);
					spdk_json_write_named_string(w, "dma_device_id", spdk_memory_domain_get_dma_device_id(domains[i]));
					spdk_json_write_named_int32(w, "dma_device_type",
								    spdk_memory_domain_get_dma_device_type(domains[i]));
					spdk_json_write_object_end(w);
				}
				spdk_json_write_array_end(w);
			} else {
				SPDK_ERRLOG("Unexpected number of memory domains %d (should be %d)\n", i, rc);
			}

			free(domains);
		} else {
			SPDK_ERRLOG("Memory allocation failed\n");
		}
	}

	spdk_json_write_named_object_begin(w, "driver_specific");
	spdk_bdev_dump_info_json(bdev, w);
	spdk_json_write_object_end(w);