From patchwork Fri Oct 20 21:52:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Brace X-Patchwork-Id: 10021045 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 795D260234 for ; Fri, 20 Oct 2017 21:53:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B7EB28F67 for ; Fri, 20 Oct 2017 21:53:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FE4F28F6D; Fri, 20 Oct 2017 21:53:08 +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 AE7B728F6A for ; Fri, 20 Oct 2017 21:53:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753566AbdJTVxF (ORCPT ); Fri, 20 Oct 2017 17:53:05 -0400 Received: from mail-bl2nam02on0082.outbound.protection.outlook.com ([104.47.38.82]:61225 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753533AbdJTVws (ORCPT ); Fri, 20 Oct 2017 17:52:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mscc365.onmicrosoft.com; s=selector1-microsemi-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jKeTfZ8SC1o5fF923qkMJ52UW3bQD/nHJ/IHpIhZpew=; b=HxJBcyHp67JSZlAlYWzDrQ2e0pXDk3wX6yDbOnzEe3CdebQ8nBQ0e5LqDV9OznfVGfzvS40oXNYcwYGJSVLMl5pur0MXnLDvKv8ZppUM0qjYvQU+cCD2669gTpr2FfBUMLR0qxfClRX24Iu0Xt26VK1ekps/L/ZbHBAHatQMpvE= Received: from MWHPR02CA0010.namprd02.prod.outlook.com (10.168.209.148) by CY1PR0201MB1835.namprd02.prod.outlook.com (10.163.55.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Fri, 20 Oct 2017 21:52:45 +0000 Received: from BY2FFO11FD048.protection.gbl (2a01:111:f400:7c0c::191) by MWHPR02CA0010.outlook.office365.com (2603:10b6:300:4b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4 via Frontend Transport; Fri, 20 Oct 2017 21:52:45 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.100.21 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.21; helo=avsrvexchhts1.microsemi.net; Received: from avsrvexchhts1.microsemi.net (208.19.100.21) by BY2FFO11FD048.mail.protection.outlook.com (10.1.15.176) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.77.10 via Frontend Transport; Fri, 20 Oct 2017 21:52:45 +0000 Received: from [127.0.1.1] (10.238.32.34) by avsrvexchhts1.microsemi.net (10.100.34.105) with Microsoft SMTP Server id 14.3.361.1; Fri, 20 Oct 2017 14:52:12 -0700 Subject: [PATCH 11/12] hpsa: add enclosure logical identifier From: Don Brace To: , , , , , , , , , , CC: Date: Fri, 20 Oct 2017 16:52:10 -0500 Message-ID: <150853633028.28275.7539993197075273144.stgit@brunhilda> In-Reply-To: <150853443786.28275.17878578984391668998.stgit@brunhilda> References: <150853443786.28275.17878578984391668998.stgit@brunhilda> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916004)(39860400002)(346002)(376002)(2980300002)(438002)(189002)(199003)(106466001)(53936002)(2950100002)(76176999)(5660300001)(356003)(81166006)(54356999)(50986999)(81156014)(68736007)(103116003)(8676002)(97736004)(33716001)(83506002)(47776003)(478600001)(230700001)(23676002)(58126008)(2906002)(104016004)(86362001)(110136005)(50466002)(33646002)(69596002)(4326008)(106002)(77096006)(189998001)(9686003)(2201001)(8936002)(316002)(305945005)(16576012)(921003)(2101003)(83996005)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB1835; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD048; 1:vWrWhoBe5eIPriPxUic2IOPMcW0fB66z7s2TmfT3+G55/za1UNylcjVWP08SCMPhhxSUlNxl8jJNhNIJcLfe6a6G4J2bmo5c+OvA2xhxXWMYQwn5YQzsitOyxaBF/TEY X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 79a6da06-cc29-43e0-6585-08d51804e58e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:CY1PR0201MB1835; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1835; 3:GSMgeJRIMdsgIxcPXTtk9neNLZo1bvd8MjmqE0q9uu5k1qKzfhO1GN2RnvgLtjfZ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ZOuP/gpNBtaqtJBlZxtxqs5MD3GOWieIjtWbhnYcjJJie1CrywUi32vnS7oM6MT+BcN6Slshg6dGfZ3AjBv8FTz/9/SN1pAAhpr0XofqCmX2pFOR8WHe3AU8a2V2yM9esLjsuWIjhV+xW3dPRajrN7l0JUj1iT5VTJkfB85gQ2EIWkGzwxkcwO8cZB6NPU0U15URx/IvJQ5bozjM4QCxZQrtTHi7/X5ed9PNEjzkha4m0/Y86LDeOKBzkBJoI9pOUBDRfv0EgtQ2OUXznlcfJqtU0losSRe6mBCG1GBoN/+Lm6TKxy+6PES78GxS1Bh6YuY78wzgEsPrVfqcCYhDyt3j8OhQ3K5PIqi2p5pnwKNl9T0ByQ0tycJlf61oCZyhTgceWcX4+eEH X-Exchange-Antispam-Report-Test: UriScan:(72170198267865); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(93006095)(93004095)(10201501046)(3231020)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR0201MB1835; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR0201MB1835; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1835; 4:rr32SD+4mMkhXLEWy7CF7wCwXHuYmpShAha2uwjavN1xt4j6ZCaTKNJueoLjU00bvQ6vAXnzoRuGAPAW9iCdcLQ3MSjiBejpbKVoX3/ZfcHnUhRW7/ptF/pvrxYxnP1kVn/QX9pbJN9E+Fz/I12KflHjfPgOIkykseQJiGdt5pcDNVYQY4Leq0zZmVO0NMTc/caN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ics: 1; CY1PR0201MB1835; 6:tpB+t9XYCGRMihCQNX2ZPCGISe6UaLAHqslYo6tbQg/oiIpUIUx/YURBvP3Hq0kSs22SOv0bXotOC3ScFDCAZLb0drioJPhrO9w0lfJbokA+fg8eQBUCBSZA/d7nzVws6urs+vLHeXT1sWP0409rO2IAJJSBgmRbfMvoYRkLwEoBlwhpf1fVm3okIiNJgGGW/Am5wnY4Kq6uhSxMdma9aGNxVcovj5lymF01QcmBAaaVi2sTXkRJIunBRICIOpBQhx4nphHB2W4EJK3oJvm6kZT2bYZfmJFNID2LuyRp+26HhO1xmCgIAz0R9JkgwGIykBPsn9M6HpyAdSvaAwKxXQ==; 5:SGtx6iI5ULWH7HG5l63Tn1Eo+gbN2UnROAZLLkc0PBJYPz3arHW2nvl3Lz4Kbw4cGEwS2kjZ+33SB6YB6+k+BlSeg3HolJLTt35Q3fH/WUGE7D3EZtgdUv18rPrfQHQ2tRxfy4CaXwWHBJygj/CuGw==; 24:pAk2+eb/VKcbe5M/Qi4ZAx2/GgaqvRawpHUmG+bL8Ch1NE7FmgvSAs2zNR+mPcPqrYBI0si+7+4Zj0j6OB0fBR/KSvefefWPAwlEjdFMra8=; 7:+u+8ZgFwr+9elzVc+tlepud09xs/jv7e7jWlLHYlmQd/G/rACNDtVMkTh8TJslYopmw9GLkzh18vU6MSw7Fz5w3KKp4o4vqZbJvx4ZoQr/x+WxxRUrQIyzYN8iY95WsCVkbtRSn/NVPlSBaz3JEgR0ZRCLRiPOJcBTpUnG2BfW22vsdduJo4faGYbJGja55kHkwM77ndfP8wf2VHw+24n9HTH/a7lUMRws4htfyXOP8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2017 21:52:45.0703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79a6da06-cc29-43e0-6585-08d51804e58e X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad; Ip=[208.19.100.21]; Helo=[avsrvexchhts1.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1835 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 add support for enclosure logical identifier Reviewed-by: Scott Benesh Reviewed-by: Scott Teel Reviewed-by: Kevin Barnett Signed-off-by: Don Brace --- drivers/scsi/hpsa.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index a536ed6..5428a4c 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -2965,6 +2965,57 @@ static void hpsa_scsi_interpret_error(struct ctlr_info *h, } } +static int hpsa_do_receive_diagnostic(struct ctlr_info *h, u8 *scsi3addr, + u8 page, u8 *buf, size_t bufsize) +{ + int rc = IO_OK; + struct CommandList *c; + struct ErrorInfo *ei; + + c = cmd_alloc(h); + if (fill_cmd(c, RECEIVE_DIAGNOSTIC, h, buf, bufsize, + page, scsi3addr, TYPE_CMD)) { + rc = -1; + goto out; + } + rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, + PCI_DMA_FROMDEVICE, NO_TIMEOUT); + if (rc) + goto out; + ei = c->err_info; + if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { + hpsa_scsi_interpret_error(h, c); + rc = -1; + } +out: + cmd_free(h, c); + return rc; +} + +static u64 hpsa_get_enclosure_logical_identifier(struct ctlr_info *h, + u8 *scsi3addr) +{ + u8 *buf; + u64 sa = 0; + int rc = 0; + + buf = kzalloc(1024, GFP_KERNEL); + if (!buf) + return 0; + + rc = hpsa_do_receive_diagnostic(h, scsi3addr, RECEIVE_DIAGNOSTIC, + buf, 1024); + + if (rc) + goto out; + + sa = get_unaligned_be64(buf+12); + +out: + kfree(buf); + return sa; +} + static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr, u16 page, unsigned char *buf, unsigned char bufsize) @@ -3400,6 +3451,9 @@ static void hpsa_get_enclosure_info(struct ctlr_info *h, bmic_device_index = GET_BMIC_DRIVE_NUMBER(&rle->lunid[0]); + encl_dev->sas_address = + hpsa_get_enclosure_logical_identifier(h, scsi3addr); + if (encl_dev->target == -1 || encl_dev->lun == -1) { rc = IO_OK; goto out; @@ -6571,6 +6625,17 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, c->Request.CDB[0] = HPSA_INQUIRY; c->Request.CDB[4] = size & 0xFF; break; + case RECEIVE_DIAGNOSTIC: + c->Request.CDBLen = 6; + c->Request.type_attr_dir = + TYPE_ATTR_DIR(cmd_type, ATTR_SIMPLE, XFER_READ); + c->Request.Timeout = 0; + c->Request.CDB[0] = cmd; + c->Request.CDB[1] = 1; + c->Request.CDB[2] = 1; + c->Request.CDB[3] = (size >> 8) & 0xFF; + c->Request.CDB[4] = size & 0xFF; + break; case HPSA_REPORT_LOG: case HPSA_REPORT_PHYS: /* Talking to controller so It's a physical command @@ -9508,7 +9573,7 @@ static int hpsa_add_sas_host(struct ctlr_info *h) struct hpsa_sas_port *hpsa_sas_port; struct hpsa_sas_phy *hpsa_sas_phy; - parent_dev = &h->scsi_host->shost_gendev; + parent_dev = &h->scsi_host->shost_dev; hpsa_sas_node = hpsa_alloc_sas_node(parent_dev); if (!hpsa_sas_node) @@ -9599,7 +9664,7 @@ hpsa_sas_get_linkerrors(struct sas_phy *phy) static int hpsa_sas_get_enclosure_identifier(struct sas_rphy *rphy, u64 *identifier) { - *identifier = 0; + *identifier = rphy->identify.sas_address; return 0; }