From patchwork Wed Dec 20 06:56:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1EC6A6019C for ; Wed, 20 Dec 2017 06:57:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1506629649 for ; Wed, 20 Dec 2017 06:57:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037D92964F; Wed, 20 Dec 2017 06:57:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4343B29649 for ; Wed, 20 Dec 2017 06:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932513AbdLTG5j (ORCPT ); Wed, 20 Dec 2017 01:57:39 -0500 Received: from mail-sn1nam02on0078.outbound.protection.outlook.com ([104.47.36.78]:10320 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932462AbdLTG5R (ORCPT ); Wed, 20 Dec 2017 01:57:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DooAtf9h3HpAJiG9MvUcHf8sz8lTMv9/RKDwQZOHWOs=; b=CCv0hfauWQjzzdVRaYqGRf3NYXwcBgRbm7pC630HtuzVRQx6SSqL+lm2fmpHwPjgg8qQQll6B9csKWOU6lMFmePAx64UDtbLmDrsryKfRjU8RcN6d2P6WuLjo8t5N5TzCo2NWRSKXEbEtLmlgwZol+9yC+lsm8XPD5yjODb9Y+U= Received: from CO2PR07CA0078.namprd07.prod.outlook.com (2603:10b6:100::46) by MWHPR0701MB3818.namprd07.prod.outlook.com (2603:10b6:301:7f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 06:57:15 +0000 Received: from BN1AFFO11FD043.protection.gbl (2a01:111:f400:7c10::161) by CO2PR07CA0078.outlook.office365.com (2603:10b6:100::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Wed, 20 Dec 2017 06:57:15 +0000 Authentication-Results: spf=permerror (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD043.mail.protection.outlook.com (10.58.52.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 06:57:01 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 19 Dec 2017 22:56:49 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id vBK6uoZv021642; Tue, 19 Dec 2017 22:56:50 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6uobk021641; Tue, 19 Dec 2017 22:56:50 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 24/43] qla2xxx: Reduce the use of terminate exchange Date: Tue, 19 Dec 2017 22:56:25 -0800 Message-ID: <20171220065644.21511-25-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com> References: <20171220065644.21511-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(396003)(346002)(2980300002)(448002)(199004)(189003)(59450400001)(76176011)(8936002)(54906003)(50466002)(110136005)(48376002)(50226002)(87636003)(80596001)(36756003)(81166006)(8676002)(81156014)(72206003)(86362001)(316002)(85326001)(16586007)(69596002)(4326008)(42186006)(51416003)(5660300001)(2950100002)(478600001)(6666003)(2906002)(356003)(1076002)(47776003)(106466001)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR0701MB3818; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD043; 1:1bKl4/HuP/Sv8yKYMJ6CLB6Al9BKdPQuRHvYdeCs4dF0rQfouHoQ4TIh/dBGlJ7w8Jug0WX610CrRYoPW8CEz2h8EFY7OEMdZLZzXqThinf9W9dISxNmevnfGM3aY9MJ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dbd69864-3625-4852-682a-08d54776df6b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR0701MB3818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1an7OOWe/S9LcUuhGhLYueUJuwui1k844q9jzWFOE8oF7hX9w0RKCYA2DDe3qgRDwglkWMX2o+nkGkWu1CC+0ypeo69vOalb/su3hMtetb2Y+18uPH7A94tG18KUyQc7lkzKvCwDE48KBpbP+s3UGW9iPOXCF/XMz77PrMg060mItm+tn5j+Jaotybn86uovwoDAebLKgdnQUgzDcPinc5wPFS4hY0MiD9p+WsDJafDcwhJDrYmCJ/iSDGE6CfDg57QSqFo67hWdLY9Baf7HHY2rK8o8NtLMspVvYwy7FcBj2a8EAP9COtyy9oLw4OF9Yjk5kEdrUI0+c6sbRM6Td05pm4g5316a2TZ58bQmqw/OkDD1l6Np5dT9xir5MCKgYs3ueDcArnWyo3BlAHhGBoGUDeAY/t52ywVXz0mQk4su87YVNQod9NP2jDnlq8RLxtJSuz7JEbbD3M410vsNGYdVUX9zfn77ED3byl8yq/S7SsK0fJFRo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231023)(10201501046)(3002001)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR0701MB3818; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR0701MB3818; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3818; 4:9ZxnlHVYtPWivfRk1a2UpMTsUbcoye+hCE6zij52PpLRgp40F2D5/eigam59YMiuYUS6BFj/iCDt+EZEf54xp3Fzl6g98s80SBiVdZ5CXcVa0miH3QBuSVGcBTt5bHXgTJTK0G+2r2qYs8NcoB/dksg7j7v2BywRV32OLZcZYb3AfBV5gyDaHuJ+NPJEtQY9yINvrimiOreAvfH2DvXnhQ8nJ4xXVQJgirKYi1zRbf6MhFSwMl3bYw9WQU2/9LafY1l+XnMqNyz/pUURE/Hw2g== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR0701MB3818; 23:IJlH9SDwxuKRDW59xRGVJktgxnAUATVXX06Dken?= =?us-ascii?Q?CCjP7cTpvkNfeJEUdEFEdWAaSYcq4+j55xf/yVLMohwKfF5o63e3EQEynP+b?= =?us-ascii?Q?03x6y+6jIWh+ZtuMDgWEpCJHHfJ4lIHO+2Ig4+1b5TUE01gwEohCJcrkLoZ4?= =?us-ascii?Q?k4GdTnswJ+s04Jk9XR5GijxU+mnpXNjhfnqQ8joN5xTtG2f3hWWVaBiYm5bS?= =?us-ascii?Q?fDpidVxJKvchgS4fUtXXV3aLCL6XAt/teWthgkEYjv1bGIgYungWEPHrqlsy?= =?us-ascii?Q?BBUEfLgis7kLYKNedCLpFJw6Om72Mkt165hwSNzgDtL8bpcw0QWZhJsPRuuP?= =?us-ascii?Q?NOy+sW5Ti3gk1wJwbL1rhSnp1hG8b/+bxjYwq/dAdXwbYNV+p+TsOfU5wFVB?= =?us-ascii?Q?Hh743434gcv/gKaRYM2v+htC4grLfyEFfo/G+3EVBDnHEJ1GUmnBxYOeNF3H?= =?us-ascii?Q?/WZAeNo1oJaWXGPlHcgOYPY1nV6YG6ojG+8jewTX13d1/vgomT7MLdjFMvbT?= =?us-ascii?Q?L+AnwWOqVHqHeKBL48FvGnYOLbamO6RDlcr3EbwmwKbcFyR7LC169dC87VJA?= =?us-ascii?Q?fChrdLBq2j0bDVxVkOGWi/M6w7biMqsf/W3BsQrXsWmbxU+jF3mYamzqHNQH?= =?us-ascii?Q?ljWEvVkOSOey9bp+59c8Et2LvdGN3o2kBFZmU3CcyzRyqwGVbcRvac+HEZFA?= =?us-ascii?Q?76V8v6o0i98ssShWmRGsSTaa4UW/QQ1Gs2b8FabjuQtOAtxJUEFf5kmI5JNC?= =?us-ascii?Q?3YLj8+iOfdicRbedbjT84PS7kHBfWkmdiQibteSZJFfMGgCR7AzaPQzHJ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NCUL4FF4QlK2vTfMuw4MjsQKxTob5axFgt/Ar2IEf4Rolys1NVz+r9YdIDiiyAvgF4l6VpBcVKktF+Z9qSsjUArKxyAyVcBlPR8/8HI2iHRtQp2jE6JhggvMr0WFzsek6tNzv398AgL0D SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:57:01.9276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbd69864-3625-4852-682a-08d54776df6b X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0701MB3818 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran reduce usage of terminate exchange when command encounter resource bottle neck. Remote initiator view it as command drop. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_target.c | 140 ++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 66 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index c7c81d5cf69c..e7e0689d9ca5 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -75,7 +75,8 @@ MODULE_PARM_DESC(ql2xuctrlirq, int ql2x_ini_mode = QLA2XXX_INI_MODE_EXCLUSIVE; -static int temp_sam_status = SAM_STAT_BUSY; +static int qla_sam_status = SAM_STAT_BUSY; +static int tc_sam_status = SAM_STAT_TASK_SET_FULL; /* target core */ /* * From scsi/fc/fc_fcp.h @@ -4294,14 +4295,14 @@ static void qlt_create_sess_from_atio(struct work_struct *work) if (op->atio.u.raw.entry_count > 1) { ql_dbg(ql_dbg_tgt_mgt, vha, 0xf023, "Dropping multy entry atio %p\n", &op->atio); - goto out_term; + goto out_busy; } sess = qlt_make_local_sess(vha, s_id); /* sess has an extra creation ref. */ if (!sess) - goto out_term; + goto out_busy; /* * Now obtain a pre-allocated session tag using the original op->atio * packet header, and dispatch into __qlt_do_work() using the existing @@ -4312,7 +4313,7 @@ static void qlt_create_sess_from_atio(struct work_struct *work) struct qla_qpair *qpair = ha->base_qpair; spin_lock_irqsave(qpair->qp_lock_ptr, flags); - qlt_send_busy(qpair, &op->atio, SAM_STAT_BUSY); + qlt_send_busy(qpair, &op->atio, tc_sam_status); spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); spin_lock_irqsave(&ha->tgt.sess_lock, flags); @@ -4332,6 +4333,17 @@ static void qlt_create_sess_from_atio(struct work_struct *work) out_term: qlt_send_term_exchange(vha->hw->base_qpair, NULL, &op->atio, 0, 0); kfree(op); + return; +out_busy: + { + struct qla_qpair *qpair = ha->base_qpair; + + spin_lock_irqsave(qpair->qp_lock_ptr, flags); + qlt_send_busy(qpair, &op->atio, qla_sam_status); + spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); + kfree(op); + } + return; } /* ha->hardware_lock supposed to be held on entry */ @@ -4348,7 +4360,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, if (unlikely(tgt->tgt_stop)) { ql_dbg(ql_dbg_io, vha, 0x3061, "New command while device %p is shutting down\n", tgt); - return -EFAULT; + return -ENODEV; } id.b.al_pa = atio->u.isp24.fcp_hdr.s_id[2]; @@ -4403,7 +4415,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha, spin_lock_irqsave(&ha->tgt.sess_lock, flags); ha->tgt.tgt_ops->put_sess(sess); spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); - return -ENOMEM; + return -EBUSY; } cmd->cmd_in_wq = 1; @@ -5504,7 +5516,6 @@ qlt_chk_qfull_thresh_hold(struct scsi_qla_host *vha, struct qla_qpair *qpair, struct atio_from_isp *atio, uint8_t ha_locked) { struct qla_hw_data *ha = vha->hw; - uint16_t status; unsigned long flags; if (ha->tgt.num_pend_cmds < Q_FULL_THRESH_HOLD(ha)) @@ -5512,8 +5523,7 @@ qlt_chk_qfull_thresh_hold(struct scsi_qla_host *vha, struct qla_qpair *qpair, if (!ha_locked) spin_lock_irqsave(&ha->hardware_lock, flags); - status = temp_sam_status; - qlt_send_busy(qpair, atio, status); + qlt_send_busy(qpair, atio, qla_sam_status); if (!ha_locked) spin_unlock_irqrestore(&ha->hardware_lock, flags); @@ -5528,7 +5538,7 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha, struct qla_hw_data *ha = vha->hw; struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; int rc; - unsigned long flags; + unsigned long flags = 0; if (unlikely(tgt == NULL)) { ql_dbg(ql_dbg_tgt, vha, 0x3064, @@ -5552,8 +5562,7 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha, "sending QUEUE_FULL\n", vha->vp_idx); if (!ha_locked) spin_lock_irqsave(&ha->hardware_lock, flags); - qlt_send_busy(ha->base_qpair, atio, - SAM_STAT_TASK_SET_FULL); + qlt_send_busy(ha->base_qpair, atio, qla_sam_status); if (!ha_locked) spin_unlock_irqrestore(&ha->hardware_lock, flags); @@ -5572,42 +5581,37 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha, rc = qlt_handle_task_mgmt(vha, atio); } if (unlikely(rc != 0)) { - if (rc == -ESRCH) { - if (!ha_locked) - spin_lock_irqsave(&ha->hardware_lock, - flags); - -#if 1 /* With TERM EXCHANGE some FC cards refuse to boot */ - qlt_send_busy(ha->base_qpair, atio, - SAM_STAT_BUSY); -#else + if (!ha_locked) + spin_lock_irqsave(&ha->hardware_lock, flags); + switch (rc) { + case -ENODEV: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target\n"); + break; + case -EBADF: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target, sending TERM EXCHANGE for rsp\n"); qlt_send_term_exchange(ha->base_qpair, NULL, atio, 1, 0); -#endif - if (!ha_locked) - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - } else { - if (tgt->tgt_stop) { - ql_dbg(ql_dbg_tgt, vha, 0xe059, - "qla_target: Unable to send " - "command to target for req, " - "ignoring.\n"); - } else { - ql_dbg(ql_dbg_tgt, vha, 0xe05a, - "qla_target(%d): Unable to send " - "command to target, sending BUSY " - "status.\n", vha->vp_idx); - if (!ha_locked) - spin_lock_irqsave( - &ha->hardware_lock, flags); - qlt_send_busy(ha->base_qpair, - atio, SAM_STAT_BUSY); - if (!ha_locked) - spin_unlock_irqrestore( - &ha->hardware_lock, flags); - } + break; + case -EBUSY: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(ha->base_qpair, atio, + tc_sam_status); + break; + default: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(ha->base_qpair, atio, + qla_sam_status); + break; } + if (!ha_locked) + spin_unlock_irqrestore(&ha->hardware_lock, + flags); } break; @@ -5690,27 +5694,31 @@ static void qlt_response_pkt(struct scsi_qla_host *vha, rc = qlt_handle_cmd_for_atio(vha, atio); if (unlikely(rc != 0)) { - if (rc == -ESRCH) { -#if 1 /* With TERM EXCHANGE some FC cards refuse to boot */ - qlt_send_busy(rsp->qpair, atio, 0); -#else - qlt_send_term_exchange(rsp->qpair, NULL, atio, 1, 0); -#endif - } else { - if (tgt->tgt_stop) { - ql_dbg(ql_dbg_tgt, vha, 0xe05f, - "qla_target: Unable to send " - "command to target, sending TERM " - "EXCHANGE for rsp\n"); - qlt_send_term_exchange(rsp->qpair, NULL, - atio, 1, 0); - } else { - ql_dbg(ql_dbg_tgt, vha, 0xe060, - "qla_target(%d): Unable to send " - "command to target, sending BUSY " - "status\n", vha->vp_idx); - qlt_send_busy(rsp->qpair, atio, 0); - } + switch (rc) { + case -ENODEV: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target\n"); + break; + case -EBADF: + ql_dbg(ql_dbg_tgt, vha, 0xe05f, + "qla_target: Unable to send command to target, sending TERM EXCHANGE for rsp\n"); + qlt_send_term_exchange(rsp->qpair, NULL, + atio, 1, 0); + break; + case -EBUSY: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(rsp->qpair, atio, + tc_sam_status); + break; + default: + ql_dbg(ql_dbg_tgt, vha, 0xe060, + "qla_target(%d): Unable to send command to target, sending BUSY status\n", + vha->vp_idx); + qlt_send_busy(rsp->qpair, atio, + qla_sam_status); + break; } } }