public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Nicholas A. Bellinger" <nab@daterainc.com>,
	target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	kvm-devel <kvm@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>,
	Sagi Grimberg <sagig@mellanox.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Nicholas Bellinger <nab@linux-iscsi.org>,
	Sagi Grimberg <sagig@dev.mellanox.co.il>
Subject: Re: [RFCv2 5/7] vhost/scsi: Enable T10 PI IOV -> SGL memory mapping
Date: Mon, 17 Mar 2014 12:02:54 +0100	[thread overview]
Message-ID: <5326D65E.6060205@redhat.com> (raw)
In-Reply-To: <1395034381-656-6-git-send-email-nab@daterainc.com>

Il 17/03/2014 06:32, Nicholas A. Bellinger ha scritto:
> +		if (vq->iov[0].iov_len == sizeof(v_req_pi)) {
> +			req = (unsigned char *)&v_req_pi;
> +			target = &v_req_pi.lun[1];
> +			req_size = sizeof(v_req_pi);
> +			hdr_pi = true;
> +		} else if (vq->iov[0].iov_len == sizeof(v_req)) {
> +			req = (unsigned char *)&v_req;
> +			target = &v_req.lun[1];
> +			req_size = sizeof(v_req);
> +			hdr_pi = false;

The right check here is on the negotiated features.

You need a matching QEMU patch to enable the protection information
feature, like this (untested):

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 3983a5b..4c8d5cd 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -154,6 +154,9 @@ static uint32_t vhost_scsi_get_features(VirtIODevice *vdev,
     if (!(s->dev.features & (1 << VIRTIO_SCSI_F_HOTPLUG))) {
         features &= ~(1 << VIRTIO_SCSI_F_HOTPLUG);
     }
+    if (!(s->dev.features & (1 << VIRTIO_SCSI_F_T10_PI))) {
+        features &= ~(1 << VIRTIO_SCSI_F_T10_PI);
+    }
 
     return features;
 }
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 6610b3a..4a551e9 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -629,6 +629,9 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    /* Protection information is not supported yet.  */
+    dev->guest_features &= ~VIRTIO_SCSI_F_T10_PI;
+
     scsi_bus_new(&s->bus, sizeof(s->bus), dev,
                  &virtio_scsi_scsi_info, vdev->bus_name);
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 9010246..8621fbf 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -267,6 +267,16 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
             .value    = "no",\
         },\
         {\
+            .driver   = "virtio-scsi-pci",\
+            .property = "prot_info",\
+            .value    = "off",\
+        },\
+        {\
+            .driver   = "vhost-scsi-pci",\
+            .property = "prot_info",\
+            .value    = "off",\
+        },\
+        {\
             .driver   = "PIIX4_PM",\
             .property = "acpi-pci-hotplug-with-bridge-support",\
             .value    = "off",\
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
index 42b1024..a555f49 100644
--- a/include/hw/virtio/virtio-scsi.h
+++ b/include/hw/virtio/virtio-scsi.h
@@ -34,6 +34,7 @@
 #define VIRTIO_SCSI_F_INOUT                    0
 #define VIRTIO_SCSI_F_HOTPLUG                  1
 #define VIRTIO_SCSI_F_CHANGE                   2
+#define VIRTIO_SCSI_F_T10_PI                   3
 
 #define VIRTIO_SCSI_VQ_SIZE     128
 #define VIRTIO_SCSI_CDB_SIZE    32
@@ -184,7 +185,9 @@ typedef struct {
     DEFINE_PROP_BIT("hotplug", _state, _feature_field, VIRTIO_SCSI_F_HOTPLUG,  \
                                                        true),                  \
     DEFINE_PROP_BIT("param_change", _state, _feature_field,                    \
-                                            VIRTIO_SCSI_F_CHANGE, true)
+                                            VIRTIO_SCSI_F_CHANGE, true)        \
+    DEFINE_PROP_BIT("prot_info", _state, _feature_field,                       \
+                                            VIRTIO_SCSI_F_T10_PI, true)
 
 void virtio_scsi_common_realize(DeviceState *dev, Error **errp);
 void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp);


  reply	other threads:[~2014-03-17 11:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17  5:32 [RFCv2 0/7] vhost/scsi: Add T10 PI SGL passthrough support Nicholas A. Bellinger
2014-03-17  5:32 ` [RFCv2 1/7] virtio-scsi.h: Add virtio_scsi_cmd_req_pi header definition Nicholas A. Bellinger
2014-03-17  5:32 ` [RFCv2 2/7] vhost/scsi: Move sanity check into vhost_scsi_map_iov_to_sgl Nicholas A. Bellinger
2014-03-17  5:32 ` [RFCv2 3/7] vhost/scsi: Add preallocation of protection SGLs Nicholas A. Bellinger
2014-03-17  5:32 ` [RFCv2 4/7] vhost/scsi: Add T10 PI IOV -> SGL memory mapping logic Nicholas A. Bellinger
2014-03-17  5:32 ` [RFCv2 5/7] vhost/scsi: Enable T10 PI IOV -> SGL memory mapping Nicholas A. Bellinger
2014-03-17 11:02   ` Paolo Bonzini [this message]
2014-03-17 19:18     ` Nicholas A. Bellinger
2014-03-17  5:33 ` [RFCv2 6/7] vhost/scsi: Add new VIRTIO_SCSI_F_T10_PI feature bit Nicholas A. Bellinger
2014-03-17  5:33 ` [RFCv2 7/7] virtio-scsi: Enable DIF/DIX modes in SCSI host LLD Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5326D65E.6060205@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mst@redhat.com \
    --cc=nab@daterainc.com \
    --cc=nab@linux-iscsi.org \
    --cc=sagig@dev.mellanox.co.il \
    --cc=sagig@mellanox.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox