bdev_virtio/rpc: implement dump json config RPC
Change-Id: Ieb0e69743da893659538c37c37d6ee8802080b86 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/381986 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
cfa4cae06d
commit
17a302a138
@ -41,6 +41,7 @@
|
|||||||
#include "spdk/scsi_spec.h"
|
#include "spdk/scsi_spec.h"
|
||||||
#include "spdk/string.h"
|
#include "spdk/string.h"
|
||||||
#include "spdk/util.h"
|
#include "spdk/util.h"
|
||||||
|
#include "spdk/json.h"
|
||||||
|
|
||||||
#include "spdk_internal/bdev.h"
|
#include "spdk_internal/bdev.h"
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
@ -354,11 +355,21 @@ bdev_virtio_destruct(void *ctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bdev_virtio_dump_json_config(void *ctx, struct spdk_json_write_ctx *w)
|
||||||
|
{
|
||||||
|
struct virtio_scsi_disk *disk = ctx;
|
||||||
|
|
||||||
|
vtpci_dump_json_config(disk->vdev, w);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct spdk_bdev_fn_table virtio_fn_table = {
|
static const struct spdk_bdev_fn_table virtio_fn_table = {
|
||||||
.destruct = bdev_virtio_destruct,
|
.destruct = bdev_virtio_destruct,
|
||||||
.submit_request = bdev_virtio_submit_request,
|
.submit_request = bdev_virtio_submit_request,
|
||||||
.io_type_supported = bdev_virtio_io_type_supported,
|
.io_type_supported = bdev_virtio_io_type_supported,
|
||||||
.get_io_channel = bdev_virtio_get_io_channel,
|
.get_io_channel = bdev_virtio_get_io_channel,
|
||||||
|
.dump_config_json = bdev_virtio_dump_json_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -238,6 +238,25 @@ legacy_notify_queue(struct virtio_dev *dev, struct virtqueue *vq)
|
|||||||
VIRTIO_PCI_QUEUE_NOTIFY);
|
VIRTIO_PCI_QUEUE_NOTIFY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pci_dump_json_config(struct virtio_dev *dev, struct spdk_json_write_ctx *w)
|
||||||
|
{
|
||||||
|
struct virtio_hw *hw = virtio_dev_get_hw(dev);
|
||||||
|
struct spdk_pci_addr pci_addr = spdk_pci_device_get_addr((struct spdk_pci_device *)hw->pci_dev);
|
||||||
|
char addr[32];
|
||||||
|
|
||||||
|
spdk_json_write_name(w, "type");
|
||||||
|
if (dev->modern) {
|
||||||
|
spdk_json_write_string(w, "pci-modern");
|
||||||
|
} else {
|
||||||
|
spdk_json_write_string(w, "pci-legacy");
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_json_write_name(w, "pci_address");
|
||||||
|
spdk_pci_addr_fmt(addr, sizeof(addr), &pci_addr);
|
||||||
|
spdk_json_write_string(w, addr);
|
||||||
|
}
|
||||||
|
|
||||||
const struct virtio_pci_ops legacy_ops = {
|
const struct virtio_pci_ops legacy_ops = {
|
||||||
.read_dev_cfg = legacy_read_dev_config,
|
.read_dev_cfg = legacy_read_dev_config,
|
||||||
.write_dev_cfg = legacy_write_dev_config,
|
.write_dev_cfg = legacy_write_dev_config,
|
||||||
@ -253,6 +272,7 @@ const struct virtio_pci_ops legacy_ops = {
|
|||||||
.setup_queue = legacy_setup_queue,
|
.setup_queue = legacy_setup_queue,
|
||||||
.del_queue = legacy_del_queue,
|
.del_queue = legacy_del_queue,
|
||||||
.notify_queue = legacy_notify_queue,
|
.notify_queue = legacy_notify_queue,
|
||||||
|
.dump_json_config = pci_dump_json_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@ -461,6 +481,7 @@ const struct virtio_pci_ops modern_ops = {
|
|||||||
.setup_queue = modern_setup_queue,
|
.setup_queue = modern_setup_queue,
|
||||||
.del_queue = modern_del_queue,
|
.del_queue = modern_del_queue,
|
||||||
.notify_queue = modern_notify_queue,
|
.notify_queue = modern_notify_queue,
|
||||||
|
.dump_json_config = pci_dump_json_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -748,4 +769,21 @@ vtpci_deinit(uint32_t id)
|
|||||||
g_virtio_driver.internal[id].vtpci_ops = NULL;
|
g_virtio_driver.internal[id].vtpci_ops = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vtpci_dump_json_config(struct virtio_dev *hw, struct spdk_json_write_ctx *w)
|
||||||
|
{
|
||||||
|
spdk_json_write_name(w, "virtio");
|
||||||
|
spdk_json_write_object_begin(w);
|
||||||
|
|
||||||
|
spdk_json_write_name(w, "vq_count");
|
||||||
|
spdk_json_write_uint32(w, hw->max_queues);
|
||||||
|
|
||||||
|
spdk_json_write_name(w, "vq_size");
|
||||||
|
spdk_json_write_uint32(w, vtpci_ops(hw)->get_queue_num(hw, 0));
|
||||||
|
|
||||||
|
vtpci_ops(hw)->dump_json_config(hw, w);
|
||||||
|
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
}
|
||||||
|
|
||||||
SPDK_LOG_REGISTER_TRACE_FLAG("virtio_pci", SPDK_TRACE_VIRTIO_PCI)
|
SPDK_LOG_REGISTER_TRACE_FLAG("virtio_pci", SPDK_TRACE_VIRTIO_PCI)
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <rte_pci.h>
|
#include <rte_pci.h>
|
||||||
|
|
||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
|
#include "spdk/json.h"
|
||||||
#include "virtio_dev.h"
|
#include "virtio_dev.h"
|
||||||
|
|
||||||
struct virtqueue;
|
struct virtqueue;
|
||||||
@ -87,6 +88,8 @@ struct virtio_pci_ops {
|
|||||||
int (*setup_queue)(struct virtio_dev *hw, struct virtqueue *vq);
|
int (*setup_queue)(struct virtio_dev *hw, struct virtqueue *vq);
|
||||||
void (*del_queue)(struct virtio_dev *hw, struct virtqueue *vq);
|
void (*del_queue)(struct virtio_dev *hw, struct virtqueue *vq);
|
||||||
void (*notify_queue)(struct virtio_dev *hw, struct virtqueue *vq);
|
void (*notify_queue)(struct virtio_dev *hw, struct virtqueue *vq);
|
||||||
|
|
||||||
|
void (*dump_json_config)(struct virtio_dev *hw, struct spdk_json_write_ctx *w);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct virtio_hw {
|
struct virtio_hw {
|
||||||
@ -163,6 +166,8 @@ const struct virtio_pci_ops *vtpci_ops(struct virtio_dev *dev);
|
|||||||
|
|
||||||
void vtpci_deinit(uint32_t id);
|
void vtpci_deinit(uint32_t id);
|
||||||
|
|
||||||
|
void vtpci_dump_json_config(struct virtio_dev *hw, struct spdk_json_write_ctx *w);
|
||||||
|
|
||||||
extern const struct virtio_pci_ops virtio_user_ops;
|
extern const struct virtio_pci_ops virtio_user_ops;
|
||||||
|
|
||||||
#endif /* _VIRTIO_PCI_H_ */
|
#endif /* _VIRTIO_PCI_H_ */
|
||||||
|
@ -253,6 +253,18 @@ virtio_user_free(struct virtio_dev *vdev)
|
|||||||
virtio_user_dev_uninit(dev);
|
virtio_user_dev_uninit(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
virtio_user_dump_json_config(struct virtio_dev *vdev, struct spdk_json_write_ctx *w)
|
||||||
|
{
|
||||||
|
struct virtio_user_dev *dev = virtio_dev_get_user_dev(vdev);
|
||||||
|
|
||||||
|
spdk_json_write_name(w, "type");
|
||||||
|
spdk_json_write_string(w, "user");
|
||||||
|
|
||||||
|
spdk_json_write_name(w, "socket");
|
||||||
|
spdk_json_write_string(w, dev->path);
|
||||||
|
}
|
||||||
|
|
||||||
const struct virtio_pci_ops virtio_user_ops = {
|
const struct virtio_pci_ops virtio_user_ops = {
|
||||||
.read_dev_cfg = virtio_user_read_dev_config,
|
.read_dev_cfg = virtio_user_read_dev_config,
|
||||||
.write_dev_cfg = virtio_user_write_dev_config,
|
.write_dev_cfg = virtio_user_write_dev_config,
|
||||||
@ -268,4 +280,5 @@ const struct virtio_pci_ops virtio_user_ops = {
|
|||||||
.setup_queue = virtio_user_setup_queue,
|
.setup_queue = virtio_user_setup_queue,
|
||||||
.del_queue = virtio_user_del_queue,
|
.del_queue = virtio_user_del_queue,
|
||||||
.notify_queue = virtio_user_notify_queue,
|
.notify_queue = virtio_user_notify_queue,
|
||||||
|
.dump_json_config = virtio_user_dump_json_config,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user