Received: from eggs.gnu.org ([2001:4830:134:3::10]:42836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHTAZ-0000Bw-5w for qemu-devel@nongnu.org; Thu, 05 Sep 2013 02:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHTAT-0003rV-0t for qemu-devel@nongnu.org; Thu, 05 Sep 2013 02:35:55 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]:35900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHTAS-0003r6-Qr for qemu-devel@nongnu.org; Thu, 05 Sep 2013 02:35:48 -0400 Received: by mail-pb0-f51.google.com with SMTP id jt11so1365392pbb.38 for ; Wed, 04 Sep 2013 23:35:47 -0700 (PDT) Message-ID: <52282638.9000008@ozlabs.ru> Date: Thu, 05 Sep 2013 16:35:36 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <87r4d77r2t.fsf@abhimanyu.in.ibm.com> In-Reply-To: <87r4d77r2t.fsf@abhimanyu.in.ibm.com> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] spapr-vscsi: Adding VSCSI capabilities List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Nikunj A. Dadhania" Cc: Paolo Bonzini , "qemu-ppc@nongnu.org" , Alexander Graf , "qemu-devel@nongnu.org" On 09/02/2013 03:03 PM, Nikunj A. Dadhania wrote: > > This implements capabilities exchange between vscsi host and client. As > at the moment no capability is supported, put zero flags everywhere and > return. > > Signed-off-by: Nikunj A Dadhania Acked-by: Alexey Kardashevskiy > --- > hw/scsi/spapr_vscsi.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c > index e9090e5..030b775 100644 > --- a/hw/scsi/spapr_vscsi.c > +++ b/hw/scsi/spapr_vscsi.c > @@ -858,6 +858,57 @@ static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req) > return vscsi_send_iu(s, req, sizeof(*sinfo), VIOSRP_MAD_FORMAT); > } > > +static int vscsi_send_capabilities(VSCSIState *s, vscsi_req *req) > +{ > + struct viosrp_capabilities *vcap; > + struct capabilities cap = { }; > + uint16_t len, req_len; > + uint64_t buffer; > + int rc; > + > + vcap = &req->iu.mad.capabilities; > + req_len = len = be16_to_cpu(vcap->common.length); > + buffer = be64_to_cpu(vcap->buffer); > + if (len > sizeof(cap)) { > + fprintf(stderr, "vscsi_send_capabilities: capabilities size mismatch !\n"); > + > + /* > + * Just read and populate the structure that is known. > + * Zero rest of the structure. > + */ > + len = sizeof(cap); > + } > + rc = spapr_vio_dma_read(&s->vdev, buffer, &cap, len); > + if (rc) { > + fprintf(stderr, "vscsi_send_capabilities: DMA read failure !\n"); > + } > + > + /* > + * Current implementation does not suppport any migration or > + * reservation capabilities. Construct the response telling the > + * guest not to use them. > + */ > + cap.flags = 0; > + cap.migration.ecl = 0; > + cap.reserve.type = 0; > + cap.migration.common.server_support = 0; > + cap.reserve.common.server_support = 0; > + > + rc = spapr_vio_dma_write(&s->vdev, buffer, &cap, len); > + if (rc) { > + fprintf(stderr, "vscsi_send_capabilities: DMA write failure !\n"); > + } > + if (req_len > len) { > + /* > + * Being paranoid and lets not worry about the error code > + * here. Actual write of the cap is done above. > + */ > + spapr_vio_dma_set(&s->vdev, (buffer + len), 0, (req_len - len)); > + } > + vcap->common.status = rc ? cpu_to_be32(1) : 0; > + return vscsi_send_iu(s, req, sizeof(*vcap), VIOSRP_MAD_FORMAT); > +} > + > static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req) > { > union mad_iu *mad = &req->iu.mad; > @@ -878,6 +929,9 @@ static int vscsi_handle_mad_req(VSCSIState *s, vscsi_req *req) > mad->host_config.common.status = cpu_to_be16(1); > vscsi_send_iu(s, req, sizeof(mad->host_config), VIOSRP_MAD_FORMAT); > break; > + case VIOSRP_CAPABILITIES_TYPE: > + vscsi_send_capabilities(s, req); > + break; > default: > fprintf(stderr, "VSCSI: Unknown MAD type %02x\n", > be32_to_cpu(mad->empty_iu.common.type)); > -- Alexey