Commit 2eabc715 authored by Jin Yu's avatar Jin Yu Committed by Changpeng Liu
Browse files

vhost: add packed ring support



Update vhost blk contruct rpc, make it enable to
support packed ring feature.

Change-Id: Ia1f75e72e8441e8d82fad89073e4875f89e5b9cd
Signed-off-by: default avatarJin Yu <jin.yu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1567


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent cbfc8b2d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -313,11 +313,12 @@ int spdk_vhost_scsi_dev_remove_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tg
 * \param dev_name bdev name to associate with this vhost device
 * \param readonly if set, all writes to the device will fail with
 * \c VIRTIO_BLK_S_IOERR error code.
 * \param packed_ring this controller supports packed ring if set.
 *
 * \return 0 on success, negative errno on error.
 */
int spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_name,
			     bool readonly);
			     bool readonly, bool packed_ring);

/**
 * Remove a vhost device. The device must not have any open connections on it's socket.
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 2
SO_VER := 3
SO_MINOR := 0
SO_SUFFIX := $(SO_VER).$(SO_MINOR)

+8 −2
Original line number Diff line number Diff line
@@ -1158,6 +1158,7 @@ vhost_blk_controller_construct(void)
	char *cpumask;
	char *name;
	bool readonly;
	bool packed_ring;

	for (sp = spdk_conf_first_section(NULL); sp != NULL; sp = spdk_conf_next_section(sp)) {
		if (!spdk_conf_section_match_prefix(sp, "VhostBlk")) {
@@ -1178,13 +1179,15 @@ vhost_blk_controller_construct(void)

		cpumask = spdk_conf_section_get_val(sp, "Cpumask");
		readonly = spdk_conf_section_get_boolval(sp, "ReadOnly", false);
		packed_ring = spdk_conf_section_get_boolval(sp, "PackedRing", false);

		bdev_name = spdk_conf_section_get_val(sp, "Dev");
		if (bdev_name == NULL) {
			continue;
		}

		if (spdk_vhost_blk_construct(name, cpumask, bdev_name, readonly) < 0) {
		if (spdk_vhost_blk_construct(name, cpumask, bdev_name,
					     readonly, packed_ring) < 0) {
			return -1;
		}
	}
@@ -1193,7 +1196,8 @@ vhost_blk_controller_construct(void)
}

int
spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_name, bool readonly)
spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_name,
			 bool readonly, bool packed_ring)
{
	struct spdk_vhost_blk_dev *bvdev = NULL;
	struct spdk_vhost_dev *vdev;
@@ -1220,6 +1224,8 @@ spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_
	vdev->disabled_features = SPDK_VHOST_BLK_DISABLED_FEATURES;
	vdev->protocol_features = SPDK_VHOST_BLK_PROTOCOL_FEATURES;

	vdev->virtio_features |= (uint64_t)packed_ring << VIRTIO_F_RING_PACKED;

	if (spdk_bdev_io_type_supported(bdev, SPDK_BDEV_IO_TYPE_UNMAP)) {
		vdev->virtio_features |= (1ULL << VIRTIO_BLK_F_DISCARD);
	}
+4 −1
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ struct rpc_vhost_blk_ctrlr {
	char *dev_name;
	char *cpumask;
	bool readonly;
	bool packed_ring;
};

static const struct spdk_json_object_decoder rpc_construct_vhost_blk_ctrlr[] = {
@@ -249,6 +250,7 @@ static const struct spdk_json_object_decoder rpc_construct_vhost_blk_ctrlr[] = {
	{"dev_name", offsetof(struct rpc_vhost_blk_ctrlr, dev_name), spdk_json_decode_string },
	{"cpumask", offsetof(struct rpc_vhost_blk_ctrlr, cpumask), spdk_json_decode_string, true},
	{"readonly", offsetof(struct rpc_vhost_blk_ctrlr, readonly), spdk_json_decode_bool, true},
	{"packed_ring", offsetof(struct rpc_vhost_blk_ctrlr, packed_ring), spdk_json_decode_bool, true},
};

static void
@@ -275,7 +277,8 @@ spdk_rpc_vhost_create_blk_controller(struct spdk_jsonrpc_request *request,
		goto invalid;
	}

	rc = spdk_vhost_blk_construct(req.ctrlr, req.cpumask, req.dev_name, req.readonly);
	rc = spdk_vhost_blk_construct(req.ctrlr, req.cpumask, req.dev_name,
				      req.readonly, req.packed_ring);
	if (rc < 0) {
		goto invalid;
	}
+3 −1
Original line number Diff line number Diff line
@@ -1993,7 +1993,8 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
                                              ctrlr=args.ctrlr,
                                              dev_name=args.dev_name,
                                              cpumask=args.cpumask,
                                              readonly=args.readonly)
                                              readonly=args.readonly,
                                              packed_ring=args.packed_ring)

    p = subparsers.add_parser('vhost_create_blk_controller',
                              aliases=['construct_vhost_blk_controller'],
@@ -2002,6 +2003,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
    p.add_argument('dev_name', help='device name')
    p.add_argument('--cpumask', help='cpu mask for this controller')
    p.add_argument("-r", "--readonly", action='store_true', help='Set controller as read-only')
    p.add_argument("-p", "--packed_ring", action='store_true', help='Set controller as packed ring supported')
    p.set_defaults(func=vhost_create_blk_controller)

    def vhost_create_nvme_controller(args):
Loading