Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp210141pxu; Wed, 25 Nov 2020 17:52:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxieYmiV4CqhKINENaecrvlLM/M+FyHKRrTcfGf6LTo2iPfj84Jrhzx7ixgunu8wWsG3uCP X-Received: by 2002:a17:906:68c4:: with SMTP id y4mr711751ejr.332.1606355563584; Wed, 25 Nov 2020 17:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606355563; cv=none; d=google.com; s=arc-20160816; b=UEx6CCKgyWtA39FsKEbdf1TE39TOXaj17pM39UOk9z51AumQtPT/VcaWfmn/NK/BY2 dfAuD/TwGjezKFsrlO0bIQMVPIANTwUuG8ZbGf1KXmqlKj0RWzYx7USnSRI63u/6f2xO WvrzB3RQIHKm3vYwmUxEPKex1kzcoDyQBm9xmWzeFifFnA5YQkghTXtcjBbUFe92EmyT IgyeY4GJni0L+VXzZunILG8epz9rHxM/CdXQmAxGUziLok9zKYtAuvPaRuDAfwfiLwhJ 3AvVXna84RCfMqO02zYHuPFf0mwsxsWfLBZt8vOgQeYHfUV/VOZweE7Y2eBV5NkrVanT uJ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O0G8BwhdQmHy6fVo4M3OvwXIv+BaNLlbt0XQMATqVqI=; b=YP0rNFakxSzckPqH4KNlx2GL1TbdE5i25Wi7brMLc04jCTHS6zNFA9dgfbKcyDdR+c zorCCVPxz7ZBCCk29eLJhgs+Ui71LYn7qryPDvm26XxfDZ2oDxeE/0/bnQm6gzbIT/Yb WgBD9ZREoP3sCrwJKSnBsRZjS5+1/EgvIrTMqMFMBOGPYhPMFj1Pvb18M9h69CNtEaKi mVP4PP/x0KsXfc9JgJNMrNGt/pQiyBy8EX0uX+f1OKYZAne56eWx1QegnH5aKG3fQEo5 yQembKIxgf1FA3qQazvWegahq2FM7CSNoscdtm1zJKXYu2C0KPmCBlaNtqpYV20cxuY3 uTig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=YJxvE7jV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z23si2206709ejn.209.2020.11.25.17.52.21; Wed, 25 Nov 2020 17:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=YJxvE7jV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732663AbgKZBtK (ORCPT + 99 others); Wed, 25 Nov 2020 20:49:10 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36098 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731223AbgKZBsl (ORCPT ); Wed, 25 Nov 2020 20:48:41 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AQ1WJJp079089; Wed, 25 Nov 2020 20:48:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=O0G8BwhdQmHy6fVo4M3OvwXIv+BaNLlbt0XQMATqVqI=; b=YJxvE7jVsDbgEuGNQoQ6IfyKqQWJqdD/rWYte0HbyDJcYYx+a4VJGKX3G8wQI1+/AH0y NgD3jAWGvls/Xe4lYkYSj6XtwCYE6/YPcts0rhG0sj3vVOyndyKEWQSNP/yyirMH79Zf YP9Qhe0jVO3aIPEDlwZd1UEPIVcSrX+/vJQ/wqPRXpzFDhmejhjJ9OkOT7jAPqV7q0fr 0wP1FG2g50B7jQRtA4H4PZDjydcnyyNiHP4K6TB0s0ckAgTV6z87K/eH8HQukuwTTvFI hQRL79ssnaAQuzn/FiRc4EuyxoR/W1zl8U1xL+SmTz4Fs/c9V+Q08ktQKSLJaH8DVxPo TA== Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 3520vd2gv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Nov 2020 20:48:34 -0500 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AQ1lHES010471; Thu, 26 Nov 2020 01:48:33 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma03wdc.us.ibm.com with ESMTP id 35133p438b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Nov 2020 01:48:33 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AQ1mPtR38535498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Nov 2020 01:48:25 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 062696E050; Thu, 26 Nov 2020 01:48:32 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2F696E04E; Thu, 26 Nov 2020 01:48:31 +0000 (GMT) Received: from vios4361.aus.stglabs.ibm.com (unknown [9.3.43.61]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 26 Nov 2020 01:48:31 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, Tyrel Datwyler Subject: [PATCH 06/13] ibmvfc: add handlers to drain and complete Sub-CRQ responses Date: Wed, 25 Nov 2020 19:48:17 -0600 Message-Id: <20201126014824.123831-7-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201126014824.123831-1-tyreld@linux.ibm.com> References: <20201126014824.123831-1-tyreld@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-25_14:2020-11-25,2020-11-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 mlxscore=0 adultscore=0 clxscore=1015 suspectscore=3 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011260005 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The logic for iterating over the Sub-CRQ responses is similiar to that of the primary CRQ. Add the necessary handlers for processing those responses. Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc.c | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 6eaedda4917a..a8730522920e 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -3371,6 +3371,78 @@ static int ibmvfc_toggle_scrq_irq(struct ibmvfc_sub_queue *scrq, int enable) return rc; } +static void ibmvfc_handle_scrq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost) +{ + struct ibmvfc_event *evt = (struct ibmvfc_event *)be64_to_cpu(crq->ioba); + + switch (crq->valid) { + case IBMVFC_CRQ_CMD_RSP: + break; + default: + dev_err(vhost->dev, "Got and invalid message type 0x%02x\n", crq->valid); + return; + } + + /* The only kind of payload CRQs we should get are responses to + * things we send. Make sure this response is to something we + * actually sent + */ + if (unlikely(!ibmvfc_valid_event(&vhost->pool, evt))) { + dev_err(vhost->dev, "Returned correlation_token 0x%08llx is invalid!\n", + crq->ioba); + return; + } + + if (unlikely(atomic_read(&evt->free))) { + dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n", + crq->ioba); + return; + } + + del_timer(&evt->timer); + list_del(&evt->queue); + ibmvfc_trc_end(evt); + evt->done(evt); +} + +static struct ibmvfc_crq *ibmvfc_next_scrq(struct ibmvfc_sub_queue *scrq) +{ + struct ibmvfc_crq *crq; + + crq = &scrq->msgs[scrq->cur].crq; + if (crq->valid & 0x80) { + if (++scrq->cur == scrq->size) + scrq->cur = 0; + rmb(); + } else + crq = NULL; + + return crq; +} + +static void ibmvfc_drain_sub_crq(struct ibmvfc_sub_queue *scrq) +{ + struct ibmvfc_crq *crq; + int done = 0; + + while (!done) { + while ((crq = ibmvfc_next_scrq(scrq)) != NULL) { + ibmvfc_handle_scrq(crq, scrq->vhost); + crq->valid = 0; + wmb(); + } + + ibmvfc_toggle_scrq_irq(scrq, 1); + if ((crq = ibmvfc_next_scrq(scrq)) != NULL) { + ibmvfc_toggle_scrq_irq(scrq, 0); + ibmvfc_handle_scrq(crq, scrq->vhost); + crq->valid = 0; + wmb(); + } else + done = 1; + } +} + /** * ibmvfc_init_tgt - Set the next init job step for the target * @tgt: ibmvfc target struct -- 2.27.0