From patchwork Thu Dec 28 20:33:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10135849 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 1E69F60318 for ; Thu, 28 Dec 2017 20:34:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 103382AD58 for ; Thu, 28 Dec 2017 20:34:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 045692B3EB; Thu, 28 Dec 2017 20:34:01 +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 3913C2AD58 for ; Thu, 28 Dec 2017 20:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754704AbdL1Ud7 (ORCPT ); Thu, 28 Dec 2017 15:33:59 -0500 Received: from mail-by2nam01on0051.outbound.protection.outlook.com ([104.47.34.51]:37027 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754413AbdL1Ud5 (ORCPT ); Thu, 28 Dec 2017 15:33:57 -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=ROAGlMlOWP3dGcG+sk4Yo0OIuwFjkZiKDdcTPmyXGgU=; b=PaHY8d/B1C/NbUsMCpaUYLyMeyleDo1AoI3bJng95L3G6nqYs1Y1nQqweWe6mF+qhipt/Vwiw9CCcC/FSvT25XwjIfK9Z4YOHSCe0Ucilf0IwiBgwxebzKm/29F7xQQOs6ZamMuxzO9YQ/uYCdEysX51Jgb20kbrgxdv9nZoggc= Received: from BY2PR07CA0086.namprd07.prod.outlook.com (10.166.107.39) by CY1PR0701MB1948.namprd07.prod.outlook.com (10.163.141.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Thu, 28 Dec 2017 20:33:55 +0000 Received: from BN1BFFO11FD008.protection.gbl (2a01:111:f400:7c10::1:159) by BY2PR07CA0086.outlook.office365.com (2a01:111:e400:7bff::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Thu, 28 Dec 2017 20:33:55 +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 BN1BFFO11FD008.mail.protection.outlook.com (10.58.144.71) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Thu, 28 Dec 2017 20:33:34 +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; Thu, 28 Dec 2017 12:33: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 vBSKXk1d002769; Thu, 28 Dec 2017 12:33:46 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBSKXjXK002768; Thu, 28 Dec 2017 12:33:45 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 02/37] qla2xxx: Use IOCB path to submit Control VP MBX command Date: Thu, 28 Dec 2017 12:33:10 -0800 Message-ID: <20171228203345.2702-3-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171228203345.2702-1-himanshu.madhani@cavium.com> References: <20171228203345.2702-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)(39380400002)(376002)(346002)(39860400002)(396003)(2980300002)(448002)(199004)(189003)(8676002)(76176011)(2950100002)(5660300001)(356003)(50466002)(50226002)(54906003)(48376002)(6666003)(80596001)(36756003)(1076002)(2906002)(42186006)(47776003)(106466001)(86362001)(16586007)(575784001)(51416003)(316002)(69596002)(81156014)(305945005)(110136005)(8936002)(81166006)(59450400001)(85326001)(478600001)(72206003)(87636003)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1948; 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; BN1BFFO11FD008; 1:G6RlywPPAgIgrFziEBer4XSSsbOc2Tcr7sFf8HCsxunfDUAQ0nw2VufmTosrOQ5LHsxePfTpgbW8rYXWfaGgQT8/jn+7uK+YDmGVBN5K92X5S5vVpT/YIz0fYbvDosOe X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d18eb13-2d7e-4074-e3a4-08d54e324482 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY1PR0701MB1948; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 3:auEbv7ua7RntXQmdR0X1WqA3uy8/Zgvvi6dufMU7gJPaxxbzeueVWJt0V8/AS3tHWPJCa7tmEsRZxDx1RZMI0PWoqNVjBKCdjjcR29BaaWmH/G6/ah8lzmYT2BIsoB803TkbkAevHluznUdwsbjS0kliYDDD+uXXIIj5mZDHDUlib5Rzqvpgsb5rpX70nuBkHoTbYY2417x38K/cdvtnA0dFF9otKaBMDhO3QoQdZTq23722KC9aPikuV9Lmm7NZsp9a5B8eSN08P1tgJuLKxtkKzysn2mCLBhI5KZL56jw3e+3/R+buyPlkrReBiaJlVNc1Y84CyytqL+h5qP9U3w==; 25:1hmOs4uiuhbyUwWFRNz9DTcGlYqKqHc0wbfKrLv41JucQuUVYTNc/kW1MFZojDaEZJXL5q/djOfdx6+ebb3zgGaz9JnLpV6DK5smE9zbCSvKsh8FisNj8j7uF4r0LlvkqeXdMXkKaVG9UYa7CW//RTNWD9RyHgrC/RdiboH7w4UmaXX09fRxzEZpC+gw7bKzh6MkjYfpmYJlF2dav8k+RgpA+kohLJz5Z/N5JjnGj1vDWqTUJKDd+QhqweEyRJe8zHWcPwpMJhHNsNhg9dHCzerT1/PPcjGTYigkArq2UwTyXagXF6kQyGkXzpa7SUG4d3EvwPeEbf3T6E1moRybHg==; 31:Ty3eW5Uwh3Zp73qnDdNrHlBKwXlrtXh8o5g6rXLb3pe57fa6NKfjahw2Tu2RULBsg5zP3oKS3MwDwNJ8xywuMXJZuO9GqX/8WHR6g5WtsONxHepDltkXsdIziglTdzX+rRBISaT/ekcL5XL2DzkaCkxCVjRLWuCe/4Q5OETqPqv92IcFPWwoFnLriNsTsK2ro0/MUxIFDeWGmKMM0rd36yp2qWItZM5vyT1/uu7OlfM= X-MS-TrafficTypeDiagnostic: CY1PR0701MB1948: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 20:ghbTAXRRasqsik7wLZ2U9cwVLSupjk1g6brSRSijRYG6ci6a00EhOm7vkFINa2RBdDlQ8lFFp4stGiBHm48nvIzhQpjmixeHTZQyhlV0sjztfrsGpkPMNaxSGSHrXfP4Xjo+26UboY2vN7LFuuE6eI4fHAGw+qQkPt525UvPrHbFRDgjAqED6N2svmjeJeGMCazDzce1Gu3zCY+J7Khju28hyH5SBrtx/e1LhKMaCwup0pPlPfjKjkkXPKQFculDsm9SymQcs3/VrXlQjphpTeqsEGYiveLEKuqeaVlPwetvo/RhwYuCKiD/rYxN2Uv0eLRMj/A9Tsc7128VViqm/sHgS9cfWWlPklejNr+Cl6nxTEaD1/sNf69IsRG0gJLRMr8Aiw370F0Td/e0cO2j9Uz8In3eVMOy7y/TGauo+Py0abo4nh4mFLxVAAHBsHEW9ks2oEbBqaufBQ3u3IGV004ilxkSDTDAALIU77i4AaTrwMoGPPbTqizASYRV30K+; 4:D9oDI5TFlKa/58DcDG58TE8NyWI9KKGYfnYupAF4eEyzLLk47Omjtp26XeqCrizSZD6tCURFjgzOq9j2RiX2Gui73Yv6/NejkS3zcuhnUE955w8+oGBU9/QXsd5PPMTkQXpBia58pSn6IjxB+NlT5JIrXJSL0z0QTB9oGh6jdaOF5iQLwk65jyF8djnyagPye1p2qDw8QRXXoQFM+QyYdUtzpgl+wa5SBYaKoycDYpxlz3UMM9bSs0Lm5bwsZpL4gfblpqzkqP8FtZqmwdPLZA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231023)(944501075)(10201501046)(3002001)(6041268)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:CY1PR0701MB1948; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR0701MB1948; X-Forefront-PRVS: 05352A48BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0701MB1948; 23:BJR7K0CEmHif6stGW+Mw6I7y/0V99Vf1dNBGeO2?= =?us-ascii?Q?cmwBJV5eR7OxnkLq5oVCKeNyfvqPirIhu529T1jXbsV7VUKMQM4LmAEZlyOd?= =?us-ascii?Q?Ro0kAG2P3udfky2IE0HMZm9ame03WpiQSkHXWEd9WKdiXss4VCX4NG9OmzB1?= =?us-ascii?Q?p+HOLtyHA/xrYIpSjIjAXN4wPxUTuUykCU6rhlTAU+7XnezDzwA8JFhOB+hS?= =?us-ascii?Q?2xpVAwVIjtoCGoixUen60oK/v6uwPnIOHAuqB28XD57SZfio2QjU7TGct6J9?= =?us-ascii?Q?tvtSa7xwNEQvoiE9CfbdQ43Z5qr7vwfAANNUo/wwBtDTTGaLr0MubJJ6Wrm/?= =?us-ascii?Q?lnsINt1ftFIuqpLkU1l2RY5G85VfK5XzVnV1tjJbXd3FmEFGIgdezwIPuotc?= =?us-ascii?Q?Omuv0rj35SckwiVmq/Ae5jyTUSeTaEOY5CIeqRG0wV1NYAmWMYNOTOPddoxt?= =?us-ascii?Q?nQc4w6EJeNm5xm9kLbwxXuMuTlUk6bc5s5+YCpDU4S6UsKgWk9/JCC89mkpB?= =?us-ascii?Q?dPWhlcG9xIVPky17zomBWpT6AutQyig5jmGB5MXV6AlzA2+vLJ8OZki3ftU/?= =?us-ascii?Q?Z+2bH55iS4CSgse+wg9qp250lJd5m4iSrOf/dhgIbXzRjHdcUnIQfNeJOM8R?= =?us-ascii?Q?uD+F6q4ZYmOqFaNBW30kPn1ILyGpbSbn0IIusfp8HuXS+LLNpJvPKxAbWxd7?= =?us-ascii?Q?vxQBlMt/yRnFkej40PX3x838kAr11Vc2l6IkM/t/59wQ8wNvROdk8kphlzYJ?= =?us-ascii?Q?YzQXhTvBPiK5WX/AUY9dy3YHFzMSlIJMDcjZr5NrNELZhPtqGcETL3IBTV9i?= =?us-ascii?Q?OFhbw3W0QbTe8curKJLOebw/waWGiJv+wPYluac4NiC09YF3h9RzMOHN+vPC?= =?us-ascii?Q?fpyZNFD7kCeEoPMoCIrD571d1nO2ug9qBQKas4yRVm7jhsZGDPlIX75NVV9C?= =?us-ascii?Q?OJMLq0BzK0R3AoPWVdo80+1katqAYX/GK3wwdOdEQpUtp9L4DGNOevAc/6i9?= =?us-ascii?Q?5G7U5yM0P8y4op/KbcVcCMUBaDKUozgo73Aru+x/r4hhQyw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 6:mY4V3oqcJi1GstU2CBFOKUeYo4Sexjjn4VMw2gmFV0c0AK0RvUJanMRhzqlU9tX95xYlfuFky9aEdG89TuZYdahyKBFXDrb2182mbGeYR2tu43V0/Kf/QaUmw/zrMhXDDdpYkdOiejliBxXVMc/Gq3XcAitwdm0AolexA3nfpShLdIF8B7XM9b5yiaVXdjsI/T0brezszMbRBHH31s7S40XJkteYD+zbG+K/LCZnFAlU4SuFEBvGDMapJBWXecBfXWNuDAguusgiqlP3IfwuDQ7a1gVzV2CIuSDs5vIL2AhoWYOTiPju7gWbirslYT+WQ0AhzRxYyr0Zqz8zoU1tZw6CHoKOnyl2Xug/m3MVVZs=; 5:2tESJSKyuZ65Nt9cuLyTp1wOpxRjAHpQstQq8WxEPQ0MU2+q1sAoWfl87IUX9EQR0Ag79pavXpjFe0DdZpmb8Dxa2oZTVSHWhrZVaWMztp4ubyi18GjlkQtyoSuonf9KQiq1yO5JEVxNyfJGvp9t/0jJvVfflYiQnxbaBGrYQq4=; 24:i5FTa/F8DW6FAWL2RHVTSS7RAPI4zUmX+It1ktt1dheViGKZoVsix+xngtd8zRIz5DrpB2NmJWH+ki+Fm3vXJurzQ13AnJQpkqdfKmmXByo=; 7:Cuq8+i/MuIyBGG6TsnxEpO+UrcWUnVK0hYSE6VgzuHws544VgqtD6VSQDr2RW+mSW8EokiSi2iR2UaBPyJ+E1Uq2GsvzG3rCF2HzznIfCw0gj7Rgcsn8jImxGEKYd/jWosZuRCr/CGdarY69RKHeqjS5EuVyZ/OMBf2x5Km7VbFnvDE1rKnvNzu6ji4GBMNImsI1dW/mGbXGfEjcBMDsw2+EAEciUFK6J+3ZAnKZzT0V2xnbtOB/HUB5KQtzalmT SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:33:34.3185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d18eb13-2d7e-4074-e3a4-08d54e324482 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: CY1PR0701MB1948 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 Use IOCB patch to submit Control VP MBX command to reduce bottle-neck for mbx interface. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 7 ++++ drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_inline.h | 1 + drivers/scsi/qla2xxx/qla_iocb.c | 23 ++++++++++++ drivers/scsi/qla2xxx/qla_isr.c | 35 ++++++++++++++++++ drivers/scsi/qla2xxx/qla_mbx.c | 77 --------------------------------------- drivers/scsi/qla2xxx/qla_mid.c | 76 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 143 insertions(+), 77 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 93ff92e2363f..969a7dee9f72 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -472,6 +472,10 @@ struct srb_iocb { uint32_t timeout_sec; struct list_head entry; } nvme; + struct { + u16 cmd; + u16 vp_index; + } ctrlvp; } u; struct timer_list timer; @@ -500,6 +504,7 @@ struct srb_iocb { #define SRB_NVME_CMD 19 #define SRB_NVME_LS 20 #define SRB_PRLI_CMD 21 +#define SRB_CTRL_VP 22 enum { TYPE_SRB, @@ -526,6 +531,8 @@ typedef struct srb { struct list_head elem; u32 gen1; /* scratch */ u32 gen2; /* scratch */ + int rc; + struct completion comp; union { struct srb_iocb iocb_cmd; struct bsg_job *bsg_job; diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index b650ebec1b9d..5fef2bf55a9f 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -135,6 +135,7 @@ qla2x00_async_iocb_timeout(void *data) case SRB_NACK_PLOGI: case SRB_NACK_PRLI: case SRB_NACK_LOGO: + case SRB_CTRL_VP: sp->done(sp, QLA_FUNCTION_TIMEOUT); break; } diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 17d2c20f1f75..4d32426393c7 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -273,6 +273,7 @@ qla2x00_init_timer(srb_t *sp, unsigned long tmo) sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; add_timer(&sp->u.iocb_cmd.timer); sp->free = qla2x00_sp_free; + init_completion(&sp->comp); if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD)) init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); if (sp->type == SRB_ELS_DCMD) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 8ea59586f4f1..2d523b71cc1f 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -3368,6 +3368,26 @@ qla_nvme_ls(srb_t *sp, struct pt_ls4_request *cmd_pkt) return rval; } +static void +qla25xx_ctrlvp_iocb(srb_t *sp, struct vp_ctrl_entry_24xx *vce) +{ + int map, pos; + + vce->entry_type = VP_CTRL_IOCB_TYPE; + vce->handle = sp->handle; + vce->entry_count = 1; + vce->command = cpu_to_le16(sp->u.iocb_cmd.u.ctrlvp.cmd); + vce->vp_count = cpu_to_le16(1); + + /* + * index map in firmware starts with 1; decrement index + * this is ok as we never use index 0 + */ + map = (sp->u.iocb_cmd.u.ctrlvp.vp_index - 1) / 8; + pos = (sp->u.iocb_cmd.u.ctrlvp.vp_index - 1) & 7; + vce->vp_idx_map[map] |= 1 << pos; +} + int qla2x00_start_sp(srb_t *sp) { @@ -3446,6 +3466,9 @@ qla2x00_start_sp(srb_t *sp) case SRB_NACK_LOGO: qla2x00_send_notify_ack_iocb(sp, pkt); break; + case SRB_CTRL_VP: + qla25xx_ctrlvp_iocb(sp, pkt); + break; default: break; } diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index a55bfaa790a3..a265c2d8c9cc 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -1937,6 +1937,37 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) sp->done(sp, ret); } +static void qla_ctrlvp_completed(scsi_qla_host_t *vha, struct req_que *req, + struct vp_ctrl_entry_24xx *vce) +{ + const char func[] = "CTRLVP-IOCB"; + srb_t *sp; + int rval = QLA_SUCCESS; + + sp = qla2x00_get_sp_from_handle(vha, func, req, vce); + if (!sp) + return; + + if (vce->entry_status != 0) { + ql_dbg(ql_dbg_vport, vha, 0x10c4, + "%s: Failed to complete IOCB -- error status (%x)\n", + sp->name, vce->entry_status); + rval = QLA_FUNCTION_FAILED; + } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { + ql_dbg(ql_dbg_vport, vha, 0x10c5, + "%s: Failed to complete IOCB -- completion status (%x) vpidx %x\n", + sp->name, le16_to_cpu(vce->comp_status), + le16_to_cpu(vce->vp_idx_failed)); + rval = QLA_FUNCTION_FAILED; + } else { + ql_dbg(ql_dbg_vport, vha, 0x10c6, + "Done %s.\n", __func__); + } + + sp->rc = rval; + sp->done(sp, rval); +} + /** * qla2x00_process_response_queue() - Process response queue entries. * @ha: SCSI driver HA context @@ -3001,6 +3032,10 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha, qla24xx_mbx_iocb_entry(vha, rsp->req, (struct mbx_24xx_entry *)pkt); break; + case VP_CTRL_IOCB_TYPE: + qla_ctrlvp_completed(vha, rsp->req, + (struct vp_ctrl_entry_24xx *)pkt); + break; default: /* Type Not Supported. */ ql_dbg(ql_dbg_async, vha, 0x5042, diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index e2b5fa47bb57..dea2e66be0b1 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3945,83 +3945,6 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha) } /* - * qla24xx_control_vp - * Enable a virtual port for given host - * - * Input: - * ha = adapter block pointer. - * vhba = virtual adapter (unused) - * index = index number for enabled VP - * - * Returns: - * qla2xxx local function return status code. - * - * Context: - * Kernel context. - */ -int -qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) -{ - int rval; - int map, pos; - struct vp_ctrl_entry_24xx *vce; - dma_addr_t vce_dma; - struct qla_hw_data *ha = vha->hw; - int vp_index = vha->vp_idx; - struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); - - ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c1, - "Entered %s enabling index %d.\n", __func__, vp_index); - - if (vp_index == 0 || vp_index >= ha->max_npiv_vports) - return QLA_PARAMETER_ERROR; - - vce = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); - if (!vce) { - ql_log(ql_log_warn, vha, 0x10c2, - "Failed to allocate VP control IOCB.\n"); - return QLA_MEMORY_ALLOC_FAILED; - } - - vce->entry_type = VP_CTRL_IOCB_TYPE; - vce->entry_count = 1; - vce->command = cpu_to_le16(cmd); - vce->vp_count = cpu_to_le16(1); - - /* index map in firmware starts with 1; decrement index - * this is ok as we never use index 0 - */ - map = (vp_index - 1) / 8; - pos = (vp_index - 1) & 7; - mutex_lock(&ha->vport_lock); - vce->vp_idx_map[map] |= 1 << pos; - mutex_unlock(&ha->vport_lock); - - rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0); - if (rval != QLA_SUCCESS) { - ql_dbg(ql_dbg_mbx, vha, 0x10c3, - "Failed to issue VP control IOCB (%x).\n", rval); - } else if (vce->entry_status != 0) { - ql_dbg(ql_dbg_mbx, vha, 0x10c4, - "Failed to complete IOCB -- error status (%x).\n", - vce->entry_status); - rval = QLA_FUNCTION_FAILED; - } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { - ql_dbg(ql_dbg_mbx, vha, 0x10c5, - "Failed to complete IOCB -- completion status (%x).\n", - le16_to_cpu(vce->comp_status)); - rval = QLA_FUNCTION_FAILED; - } else { - ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c6, - "Done %s.\n", __func__); - } - - dma_pool_free(ha->s_dma_pool, vce, vce_dma); - - return rval; -} - -/* * qla2x00_send_change_request * Receive or disable RSCN request from fabric controller * diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 522d585a1a08..e6f3d2d62c61 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -894,3 +894,79 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, failed: return 0; } + +static void qla_ctrlvp_sp_done(void *s, int res) +{ + struct srb *sp = s; + + complete(&sp->comp); + /* don't free sp here. Let the caller do the free */ +} + +/** + * qla24xx_control_vp() - Enable a virtual port for given host + * @vha: adapter block pointer + * @cmd: command type to be sent for enable virtual port + * + * Return: qla2xxx local function return status code. + */ +int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) +{ + int rval = QLA_MEMORY_ALLOC_FAILED; + struct qla_hw_data *ha = vha->hw; + int vp_index = vha->vp_idx; + struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); + srb_t *sp; + + ql_dbg(ql_dbg_vport, vha, 0x10c1, + "Entered %s cmd %x index %d.\n", __func__, cmd, vp_index); + + if (vp_index == 0 || vp_index >= ha->max_npiv_vports) + return QLA_PARAMETER_ERROR; + + sp = qla2x00_get_sp(base_vha, NULL, GFP_KERNEL); + if (!sp) + goto done; + + sp->type = SRB_CTRL_VP; + sp->name = "ctrl_vp"; + sp->done = qla_ctrlvp_sp_done; + qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); + sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; + sp->u.iocb_cmd.u.ctrlvp.cmd = cmd; + sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index; + + rval = qla2x00_start_sp(sp); + if (rval != QLA_SUCCESS) { + ql_dbg(ql_dbg_async, vha, 0xffff, + "%s: %s Failed submission. %x.\n", + __func__, sp->name, rval); + goto done_free_sp; + } + + ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n", + sp->name, sp->handle); + + wait_for_completion(&sp->comp); + rval = sp->rc; + switch (rval) { + case QLA_FUNCTION_TIMEOUT: + ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Timeout. %x.\n", + __func__, sp->name, rval); + break; + case QLA_SUCCESS: + ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s done.\n", + __func__, sp->name); + goto done_free_sp; + default: + ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Failed. %x.\n", + __func__, sp->name, rval); + goto done_free_sp; + } +done: + return rval; + +done_free_sp: + sp->free(sp); + return rval; +}