lib/vhost: add enum to differentiate the vhost backends
Each spdk_vhost_dev_backend is local to either SCSI or BLK backends, so its not possible to gauge which backend is used by the vdev on generic vhost layer. Added a `type` field with matching enums to differentiate between the two. Later patches will check that field in vhost.c. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I2a95961b9f9b5f070db7b22d44cf5114a24b1067 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12675 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
parent
0aa212bddb
commit
65bedb496f
@ -129,7 +129,7 @@ to_blk_dev(struct spdk_vhost_dev *vdev)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (vdev->backend != &vhost_blk_device_backend) {
|
||||
if (vdev->backend->type != VHOST_BACKEND_BLK) {
|
||||
SPDK_ERRLOG("%s: not a vhost-blk device\n", vdev->name);
|
||||
return NULL;
|
||||
}
|
||||
@ -140,7 +140,7 @@ to_blk_dev(struct spdk_vhost_dev *vdev)
|
||||
static struct spdk_vhost_blk_session *
|
||||
to_blk_session(struct spdk_vhost_session *vsession)
|
||||
{
|
||||
assert(vsession->vdev->backend == &vhost_blk_device_backend);
|
||||
assert(vsession->vdev->backend->type == VHOST_BACKEND_BLK);
|
||||
return (struct spdk_vhost_blk_session *)vsession;
|
||||
}
|
||||
|
||||
@ -1562,6 +1562,7 @@ static const struct spdk_vhost_user_dev_backend vhost_blk_user_device_backend =
|
||||
};
|
||||
|
||||
static const struct spdk_vhost_dev_backend vhost_blk_device_backend = {
|
||||
.type = VHOST_BACKEND_BLK,
|
||||
.vhost_get_config = vhost_blk_get_config,
|
||||
.dump_info_json = vhost_blk_dump_info_json,
|
||||
.write_config_json = vhost_blk_write_config_json,
|
||||
|
@ -248,7 +248,14 @@ struct spdk_vhost_user_dev_backend {
|
||||
int (*stop_session)(struct spdk_vhost_session *vsession);
|
||||
};
|
||||
|
||||
enum vhost_backend_type {
|
||||
VHOST_BACKEND_BLK = 0,
|
||||
VHOST_BACKEND_SCSI,
|
||||
};
|
||||
|
||||
struct spdk_vhost_dev_backend {
|
||||
enum vhost_backend_type type;
|
||||
|
||||
int (*vhost_get_config)(struct spdk_vhost_dev *vdev, uint8_t *config, uint32_t len);
|
||||
int (*vhost_set_config)(struct spdk_vhost_dev *vdev, uint8_t *config,
|
||||
uint32_t offset, uint32_t size, uint32_t flags);
|
||||
|
@ -157,6 +157,7 @@ static const struct spdk_vhost_user_dev_backend spdk_vhost_scsi_user_device_back
|
||||
};
|
||||
|
||||
static const struct spdk_vhost_dev_backend spdk_vhost_scsi_device_backend = {
|
||||
.type = VHOST_BACKEND_SCSI,
|
||||
.dump_info_json = vhost_scsi_dump_info_json,
|
||||
.write_config_json = vhost_scsi_write_config_json,
|
||||
.remove_device = vhost_scsi_dev_remove,
|
||||
@ -851,7 +852,7 @@ to_scsi_dev(struct spdk_vhost_dev *ctrlr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ctrlr->backend != &spdk_vhost_scsi_device_backend) {
|
||||
if (ctrlr->backend->type != VHOST_BACKEND_SCSI) {
|
||||
SPDK_ERRLOG("%s: not a vhost-scsi device.\n", ctrlr->name);
|
||||
return NULL;
|
||||
}
|
||||
@ -862,7 +863,7 @@ to_scsi_dev(struct spdk_vhost_dev *ctrlr)
|
||||
static struct spdk_vhost_scsi_session *
|
||||
to_scsi_session(struct spdk_vhost_session *vsession)
|
||||
{
|
||||
assert(vsession->vdev->backend == &spdk_vhost_scsi_device_backend);
|
||||
assert(vsession->vdev->backend->type == VHOST_BACKEND_SCSI);
|
||||
return (struct spdk_vhost_scsi_session *)vsession;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user