vhost: allow allocating per-session context data
Sessions are allocated internally by the core vhost library whenever DPDK accepts a new connection, so the only reasonable way to store additional per-sesion data is to tell the core vhost library how much extra memory it needs to allocate. Hence, we add a new field to the vhost device backend struct. Change-Id: Id6c8285505b2e610e28e5d985aceb271ed232555 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/437778 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
This commit is contained in:
parent
aab242559d
commit
0e46c8f638
@ -1282,7 +1282,8 @@ new_connection(int vid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
vsession = spdk_dma_zmalloc(sizeof(struct spdk_vhost_session),
|
||||
vsession = spdk_dma_zmalloc(sizeof(struct spdk_vhost_session) +
|
||||
vdev->backend->session_ctx_size,
|
||||
SPDK_CACHE_LINE_SIZE, NULL);
|
||||
if (vsession == NULL) {
|
||||
SPDK_ERRLOG("spdk_dma_zmalloc failed\n");
|
||||
|
@ -832,6 +832,7 @@ static const struct spdk_vhost_dev_backend vhost_blk_device_backend = {
|
||||
(1ULL << VIRTIO_BLK_F_RO) | (1ULL << VIRTIO_BLK_F_FLUSH) | (1ULL << VIRTIO_BLK_F_CONFIG_WCE) |
|
||||
(1ULL << VIRTIO_BLK_F_BARRIER) | (1ULL << VIRTIO_BLK_F_SCSI) | (1ULL << VIRTIO_BLK_F_DISCARD) |
|
||||
(1ULL << VIRTIO_BLK_F_WRITE_ZEROES),
|
||||
.session_ctx_size = 0,
|
||||
.start_device = spdk_vhost_blk_start,
|
||||
.stop_device = spdk_vhost_blk_stop,
|
||||
.vhost_get_config = spdk_vhost_blk_get_config,
|
||||
|
@ -115,6 +115,12 @@ struct spdk_vhost_dev_backend {
|
||||
uint64_t virtio_features;
|
||||
uint64_t disabled_features;
|
||||
|
||||
/**
|
||||
* Size of additional per-session context data
|
||||
* allocated whenever a new client connects.
|
||||
*/
|
||||
size_t session_ctx_size;
|
||||
|
||||
/**
|
||||
* Callbacks for starting and pausing the device.
|
||||
* The first param is struct spdk_vhost_dev *.
|
||||
|
@ -1249,6 +1249,7 @@ spdk_vhost_nvme_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_
|
||||
}
|
||||
|
||||
static const struct spdk_vhost_dev_backend spdk_vhost_nvme_device_backend = {
|
||||
.session_ctx_size = 0,
|
||||
.start_device = spdk_vhost_nvme_start_device,
|
||||
.stop_device = spdk_vhost_nvme_stop_device,
|
||||
.dump_info_json = spdk_vhost_nvme_dump_info_json,
|
||||
|
@ -117,6 +117,7 @@ static int spdk_vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev);
|
||||
const struct spdk_vhost_dev_backend spdk_vhost_scsi_device_backend = {
|
||||
.virtio_features = SPDK_VHOST_SCSI_FEATURES,
|
||||
.disabled_features = SPDK_VHOST_SCSI_DISABLED_FEATURES,
|
||||
.session_ctx_size = 0,
|
||||
.start_device = spdk_vhost_scsi_start,
|
||||
.stop_device = spdk_vhost_scsi_stop,
|
||||
.dump_info_json = spdk_vhost_scsi_dump_info_json,
|
||||
|
Loading…
Reference in New Issue
Block a user