From patchwork Wed Jul 24 08:29:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 261345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5BBDB2C0096 for ; Wed, 24 Jul 2013 18:30:07 +1000 (EST) Received: from localhost ([::1]:59103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1uST-0003zO-8I for incoming@patchwork.ozlabs.org; Wed, 24 Jul 2013 04:30:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1uRs-0003qJ-Tc for qemu-devel@nongnu.org; Wed, 24 Jul 2013 04:29:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1uRr-0003fS-Jd for qemu-devel@nongnu.org; Wed, 24 Jul 2013 04:29:28 -0400 Received: from mail-oa0-f45.google.com ([209.85.219.45]:55097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1uRr-0003f7-Ek for qemu-devel@nongnu.org; Wed, 24 Jul 2013 04:29:27 -0400 Received: by mail-oa0-f45.google.com with SMTP id j1so266196oag.18 for ; Wed, 24 Jul 2013 01:29:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=AKoJrsx4UrlrZoDNqYPCxO/rXZVYR80AD4UmN1QX9KE=; b=YMzHxJrqJ3Vo4uilcYqE7DnA5fBmca2kzijO8OKumE2Wc1SjdpB1oDKZjr2IW5HD3Z //X8U+VcjnMFTsy928xZA8hQ+FSY3yvas+t7sxcnXkHc/IsF5DfdKeFqGdCiTGNnc7ts waJZ3XuqlIPiDouKIuhl0iVYDTYAPLvxOa7ZQrukNvVwmMjfUJtXD/23UPUBMVnjmpSK /Hu8+MNTAttFLbtD/FxGEVRGZtYMIE7rwLaQVjBRNbrcmAuDMOu5KRlqJYAaw+JrIIbI ojrkQA4jc8RS344HoZVHJlleh2fAOQFqQwEmftpbvYJF3IRw8tSavbvEFAFreNsVqxip Kfdw== X-Received: by 10.182.215.133 with SMTP id oi5mr29212491obc.83.1374654566931; Wed, 24 Jul 2013 01:29:26 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPSA id cp7sm6842521obb.0.2013.07.24.01.29.22 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Jul 2013 01:29:25 -0700 (PDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Wed, 24 Jul 2013 18:29:18 +1000 Message-Id: <1374654558-17815-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.3.2 X-Gm-Message-State: ALoCoQk1JiykBDImmhznmzSrVo9lRSNMPBHKJzffod2sGZgeLXXlvX2GYqQLPsdEB/wz5nvSqPOU X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.219.45 Cc: Anthony Liguori , Alexey Kardashevskiy , Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini Subject: [Qemu-devel] [PATCH v3] spapr-vscsi: add task management X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org At the moment the guest kernel issues two types of task management requests to the hypervisor - task about and lun reset. This adds handling for these tasks. As spapr-vscsi starts calling scsi_req_cancel(), free_request callback was implemented. As virtio-vscsi, spapr-vscsi does not handle CLEAR_ACA either as CDB control byte does not seem to be used at all so NACA bit is not set to the guest so the guest has no good reason to call CLEAR_ACA task. Signed-off-by: Alexey Kardashevskiy --- Changes: 2013/07/23: * remove unnecessary free_request callback 2013/07/22: * fixed LUN_RESET (it used to clear requests while it should reset a device) * added handling of ABORT_TASK_SET/CLEAR_TASK_SET Signed-off-by: Alexey Kardashevskiy --- hw/scsi/spapr_vscsi.c | 65 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 46f4455..50993fa 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -117,6 +117,20 @@ static struct vscsi_req *vscsi_get_req(VSCSIState *s) return NULL; } +static struct vscsi_req *vscsi_find_req(VSCSIState *s, uint64_t srp_tag) +{ + vscsi_req *req; + int i; + + for (i = 0; i < VSCSI_REQ_LIMIT; i++) { + req = &s->reqs[i]; + if (req->iu.srp.cmd.tag == srp_tag) { + return req; + } + } + return NULL; +} + static void vscsi_put_req(vscsi_req *req) { if (req->sreq != NULL) { @@ -753,40 +767,57 @@ static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req) static int vscsi_process_tsk_mgmt(VSCSIState *s, vscsi_req *req) { union viosrp_iu *iu = &req->iu; - int fn; + vscsi_req *tmpreq; + SCSIDevice *sdev; + int i, lun = 0, error = 0; fprintf(stderr, "vscsi_process_tsk_mgmt %02x\n", iu->srp.tsk_mgmt.tsk_mgmt_func); switch (iu->srp.tsk_mgmt.tsk_mgmt_func) { -#if 0 /* We really don't deal with these for now */ case SRP_TSK_ABORT_TASK: - fn = ABORT_TASK; + tmpreq = vscsi_find_req(s, req->iu.srp.tsk_mgmt.task_tag); + if (tmpreq && tmpreq->sreq) { + assert(tmpreq->sreq->hba_private); + scsi_req_cancel(tmpreq->sreq); + } break; + + case SRP_TSK_LUN_RESET: + sdev = vscsi_device_find(&s->bus, req->iu.srp.tsk_mgmt.lun, &lun); + if (sdev) { + qdev_reset_all(&sdev->qdev); + } + break; + case SRP_TSK_ABORT_TASK_SET: - fn = ABORT_TASK_SET; - break; case SRP_TSK_CLEAR_TASK_SET: - fn = CLEAR_TASK_SET; - break; - case SRP_TSK_LUN_RESET: - fn = LOGICAL_UNIT_RESET; + for (i = 0; i < VSCSI_REQ_LIMIT; i++) { + tmpreq = &s->reqs[i]; + if (tmpreq->iu.srp.cmd.lun != req->iu.srp.tsk_mgmt.lun) { + continue; + } + if (!tmpreq->active || !tmpreq->sreq) { + continue; + } + assert(tmpreq->sreq->hba_private); + scsi_req_cancel(tmpreq->sreq); + } break; + case SRP_TSK_CLEAR_ACA: - fn = CLEAR_ACA; - break; -#endif default: - fn = 0; + error = 1; } - if (fn) { - /* XXX Send/Handle target task management */ - ; + + if (!error) { + vscsi_send_rsp(s, req, GOOD, 0, 0); } else { vscsi_makeup_sense(s, req, ILLEGAL_REQUEST, 0x20, 0); vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0); } - return !fn; + + return 1; } static int vscsi_handle_srp_req(VSCSIState *s, vscsi_req *req)