Commit 50f453de authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Jim Harris
Browse files

bdev_virtio: use pointers to process target scan



Temporary patch to reduce diffs of upcoming async target scan commits.

Change-Id: Idf82296bb30b36b3625c3f43d99c46ec2e40e168
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/375728


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent c5ff3d7d
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -230,7 +230,6 @@ bdev_virtio_io_cpl(struct virtio_req *req)
	spdk_bdev_io_complete_scsi_status(bdev_io, io_ctx->resp.status, sk, asc, ascq);
}


static void
bdev_virtio_poll(void *arg)
{
@@ -267,8 +266,10 @@ bdev_virtio_destroy_cb(void *io_device, void *ctx_buf)
static void
scan_target(struct virtio_hw *hw, uint8_t target)
{
	struct iovec iov;
	struct virtio_req vreq;
	struct iovec _iov;
	struct iovec *iov;
	struct virtio_req _vreq;
	struct virtio_req *vreq;
	struct virtio_scsi_cmd_req *req;
	struct virtio_scsi_cmd_resp *resp;
	struct spdk_scsi_cdb_inquiry *cdb;
@@ -277,21 +278,23 @@ scan_target(struct virtio_hw *hw, uint8_t target)
	struct virtio_scsi_disk *disk;
	struct spdk_bdev *bdev;

	vreq.iov = &iov;
	vreq.iovcnt = 1;
	vreq.is_write = 0;
	iov = &_iov;
	vreq = &_vreq;
	vreq->iov = iov;
	vreq->iovcnt = 1;
	vreq->is_write = 0;

	req = spdk_dma_zmalloc(sizeof(*req), 64, NULL);
	resp = spdk_dma_malloc(sizeof(*resp), 64, NULL);

	vreq.iov_req.iov_base = (void *)req;
	vreq.iov_req.iov_len = sizeof(*req);
	vreq->iov_req.iov_base = (void *)req;
	vreq->iov_req.iov_len = sizeof(*req);

	vreq.iov_resp.iov_base = (void *)resp;
	vreq.iov_resp.iov_len = sizeof(*resp);
	vreq->iov_resp.iov_base = (void *)resp;
	vreq->iov_resp.iov_len = sizeof(*resp);

	iov.iov_base = spdk_dma_malloc(4096, 64, NULL);
	iov.iov_len = 255;
	iov[0].iov_base = spdk_dma_malloc(4096, 64, NULL);
	iov[0].iov_len = 255;

	req->lun[0] = 1;
	req->lun[1] = target;
@@ -300,7 +303,7 @@ scan_target(struct virtio_hw *hw, uint8_t target)
	cdb->opcode = SPDK_SPC_INQUIRY;
	cdb->alloc_len[1] = 255;

	virtio_xmit_pkts(hw->vqs[2], &vreq);
	virtio_xmit_pkts(hw->vqs[2], vreq);

	do {
		cnt = virtio_recv_pkts(hw->vqs[2], &complete, 1);
@@ -317,10 +320,10 @@ scan_target(struct virtio_hw *hw, uint8_t target)
	req->cdb[0] = SPDK_SPC_SERVICE_ACTION_IN_16;
	req->cdb[1] = SPDK_SBC_SAI_READ_CAPACITY_16;

	iov.iov_len = 32;
	to_be32(&req->cdb[10], iov.iov_len);
	iov[0].iov_len = 32;
	to_be32(&req->cdb[10], iov[0].iov_len);

	virtio_xmit_pkts(hw->vqs[2], &vreq);
	virtio_xmit_pkts(hw->vqs[2], vreq);

	do {
		cnt = virtio_recv_pkts(hw->vqs[2], &complete, 1);
@@ -332,8 +335,8 @@ scan_target(struct virtio_hw *hw, uint8_t target)
		return;
	}

	disk->num_blocks = from_be64((uint64_t *)(iov.iov_base)) + 1;
	disk->block_size = from_be32((uint32_t *)(iov.iov_base + 8));
	disk->num_blocks = from_be64((uint64_t *)(iov[0].iov_base)) + 1;
	disk->block_size = from_be32((uint32_t *)(iov[0].iov_base + 8));

	disk->hw = hw;