Commit 0db7a0dc authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

vhost: add (set|get)_coalescing to virtio_blk transport



This fixes the behavior of spdk_vhost_(set|get)_coalescing() on
non-vhost-user devices.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ia17cd4c0ed4bad262090e05f83727c1516c21f92
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15772


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 25d55f48
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -1544,6 +1544,24 @@ vhost_blk_get_config(struct spdk_vhost_dev *vdev, uint8_t *config,
	return 0;
}

static int
vhost_blk_set_coalescing(struct spdk_vhost_dev *vdev, uint32_t delay_base_us,
			 uint32_t iops_threshold)
{
	struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev);

	return bvdev->ops->set_coalescing(vdev, delay_base_us, iops_threshold);
}

static void
vhost_blk_get_coalescing(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us,
			 uint32_t *iops_threshold)
{
	struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev);

	bvdev->ops->get_coalescing(vdev, delay_base_us, iops_threshold);
}

static const struct spdk_vhost_user_dev_backend vhost_blk_user_device_backend = {
	.session_ctx_size = sizeof(struct spdk_vhost_blk_session) - sizeof(struct spdk_vhost_session),
	.start_session =  vhost_blk_start,
@@ -1557,8 +1575,8 @@ static const struct spdk_vhost_dev_backend vhost_blk_device_backend = {
	.dump_info_json = vhost_blk_dump_info_json,
	.write_config_json = vhost_blk_write_config_json,
	.remove_device = vhost_blk_destroy,
	.set_coalescing = vhost_user_set_coalescing,
	.get_coalescing = vhost_user_get_coalescing,
	.set_coalescing = vhost_blk_set_coalescing,
	.get_coalescing = vhost_blk_get_coalescing,
};

int
@@ -1792,6 +1810,8 @@ static const struct spdk_virtio_blk_transport_ops vhost_user_blk = {
	.destroy_ctrlr = vhost_user_blk_destroy_ctrlr,

	.bdev_event = vhost_user_bdev_event_cb,
	.set_coalescing = vhost_user_set_coalescing,
	.get_coalescing = vhost_user_get_coalescing,
};

SPDK_VIRTIO_BLK_TRANSPORT_REGISTER(vhost_user_blk, &vhost_user_blk);
+12 −0
Original line number Diff line number Diff line
@@ -587,6 +587,18 @@ struct spdk_virtio_blk_transport_ops {
	 */
	void (*bdev_event)(enum spdk_bdev_event_type type, struct spdk_vhost_dev *vdev,
			   bdev_event_cb_complete cb, void *cb_arg);

	/**
	 * Set coalescing parameters.
	 */
	int (*set_coalescing)(struct spdk_vhost_dev *vdev, uint32_t delay_base_us,
			      uint32_t iops_threshold);

	/**
	 * Get coalescing parameters.
	 */
	void (*get_coalescing)(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us,
			       uint32_t *iops_threshold);
};

struct spdk_virtio_blk_transport {