From patchwork Wed Dec 27 04:34:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 10133415 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 DC68F6037D for ; Wed, 27 Dec 2017 04:35:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C54F72AB38 for ; Wed, 27 Dec 2017 04:35:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9F322AB6A; Wed, 27 Dec 2017 04:35:34 +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 499452AB38 for ; Wed, 27 Dec 2017 04:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751868AbdL0Efb (ORCPT ); Tue, 26 Dec 2017 23:35:31 -0500 Received: from mail-co1nam03on0046.outbound.protection.outlook.com ([104.47.40.46]:47936 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751539AbdL0EfP (ORCPT ); Tue, 26 Dec 2017 23:35:15 -0500 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=2QVu5v3MCvVy786qggoGyLCQC2f0lG40CIg/V3S5Y8A=; b=ckHP1jmhw4io5ZVgwVqR1eDOnz2nOwetsDueNre/K/0OGOG6MFlHCcH6wUZTl9/cFZtJ2pTO76mYn2qkk1V8P2BBv/dOWc/Xjzuj8hrmWovQxxA4AWYCCY4iIQlOsU82eqlmzbowATOliGHAHYq1KSBhRgv92YJzzQArjOcxDfM= Received: from MWHPR0201CA0047.namprd02.prod.outlook.com (10.167.160.24) by BY2PR0201MB1831.namprd02.prod.outlook.com (10.163.75.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Wed, 27 Dec 2017 04:35:11 +0000 Received: from BL2FFO11FD050.protection.gbl (2a01:111:f400:7c09::115) by MWHPR0201CA0047.outlook.office365.com (2603:10b6:301:73::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Wed, 27 Dec 2017 04:35:11 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.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 BL2FFO11FD050.mail.protection.outlook.com (10.173.161.212) 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; Wed, 27 Dec 2017 04:34:52 +0000 Received: from localhost (10.181.72.13) by avsrvexchhts1.microsemi.net (10.100.34.105) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 26 Dec 2017 20:34:57 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" , Bart Van Assche Subject: [PATCH v2 15/30] scsi: aacraid: Create helper functions to get lun info Date: Tue, 26 Dec 2017 20:34:36 -0800 Message-ID: <20171227043451.27813-16-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> 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)(39380400002)(346002)(39850400004)(376002)(396003)(2980300002)(438002)(199004)(189003)(16586007)(69596002)(76176011)(81166006)(68736007)(81156014)(8936002)(50466002)(97736004)(1076002)(86362001)(48376002)(356003)(305945005)(5660300001)(8676002)(106466001)(104016004)(53936002)(76506005)(316002)(36756003)(6666003)(57986006)(2950100002)(47776003)(54906003)(2201001)(72206003)(51416003)(77096006)(50226002)(478600001)(110136005)(4326008)(2906002)(106002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0201MB1831; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD050; 1:plXTM819A5kLP+1eymepp5Rf27L5PIG4NTJti8VoK4zwJENwwQmSOw7sXIvwNZmD0Mmr159xnfrcd+NtgPCacuAAZN0Vje59f1ZMcClahKiXGtSYgRlziHM2tZxMB5V4 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 223fd87f-a945-4907-3312-08d54ce32c20 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BY2PR0201MB1831; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0201MB1831; 3:slmVE/aVANpTvPb/ZA7Tp6Jh3fIV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iNqUrepGGx1MOyvLFLptNMK+nD0VBzgtpbG5ba9YXqTXwRME3QKajqIU5L0t/0yHsv7zTs9VmpSKRKkRb8UtvCpf4YBmWE2X3EcvAX78euvA8OcxcpeG6viFcR9Z0+kaI7+NfEV27iOb2wLRDNEfdL8Um7Qyu74b93s7lvsDvEFQr9NebkCJmG+28Jo/cg3T7wfCVlymPsqAddEizXyh7JgbN8BY4m3Nurk7KbXYm0fIF0Pi8ZybfAgTNrEKE6zhBNLqP0EBneNyj9ZsSRUi5WFTPAe+gDmoeUqWBngXOVBntX+/u6Jv+469NTOJ8CfncIH0MZnnmgkXIRUSAW/3emt+vOS3LM5S3qcEv4n4Zu4NGKo6R4enA6geV/F5qnNRqTZppB8sOq6uktLRu7uSkl5EFKkKZrTBcNfZQc5jhl8O5WmjSmQ55hrbjcuP8qWHWewRKqS0s3RDh8mW4HvJ+Y2NSgdW7b7ttdQMiu04LUgANkW02n+TbX2K4Qocj7w3K/hXeqprTEQbIDYw17lTyRNiLyguqo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170198267865); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(93006095)(93004095)(3002001)(10201501046)(6055026)(6041268)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:BY2PR0201MB1831; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BY2PR0201MB1831; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0201MB1831; 4:AjM4ZoSqkBKlX6laA3qGdM6F0lRp5SaQeRIGLQ56k8uD8yzzg2vdj9G41aKd29/NzJARSt+1DZKSPKtoT+tW7Tw1qF4ctndlelzrj9SFJGAYFPmerPJ2+ZCyvJuFZUyrdXD4LmTVqEP5atSpSd+hrMwzQIKkELenanlxUvz3MHJyziWOFNPzW/l8tfu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h6d8mDkQoQQsD7NGNb7OBZW1Dls5xmHdliX4anjb5wqQMnLI8AItS5uaPi1NNq21PhA6kPfdXau6Z3qyY=; 7:LbbhEZn41/vy+8bugQ+3EUGSL8KZwTCJqfc6q0lvUbQkIHAJ9hXP3PoroliTQTMDhIizWS5ftoNdGXbTX3isznIajgrFi8UbEP4nnNKCueuWyCw334Ud09bsHVHsWCS4wIgvbB0/YXO6Y5uDD/5Tggz5gO2Y/FkLTW0VbNEQZ48g29qgbl/QsPYR1j6U0aYio9LTOZgDoK1uILP/5dZ6Ozqbrmm1oTAvAvv6iX+2JoRvO9cN4PXZ8f+F/bkg9vqu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2017 04:34:52.1112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 223fd87f-a945-4907-3312-08d54ce32c20 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: BY2PR0201MB1831 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 Created inline function to retrieve lun info for each device from the phy luns structure. Signed-off-by: Raghava Aditya Renukunta --- Changes in V2: Use get_unaligned_be32 instead of open ended conversion drivers/scsi/aacraid/aachba.c | 54 +++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 43a3c11..fa0132b 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -42,6 +42,8 @@ #include /* For flush_kernel_dcache_page */ #include +#include + #include #include #include @@ -1844,7 +1846,41 @@ static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) mem_free_all: kfree(phys_luns); goto out; +} + +static inline u32 aac_get_safw_phys_lun_count(struct aac_dev *dev) +{ + return get_unaligned_be32(&dev->safw_phys_luns->list_length[0]); +} + +static inline u32 aac_get_safw_phys_bus(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].level2[1] & 0x3f; +} + +static inline u32 aac_get_safw_phys_target(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].level2[0]; +} +static inline u32 aac_get_safw_phys_expose_flag(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].bus >> 6; +} + +static inline u32 aac_get_safw_phys_attribs(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].node_ident[9]; +} + +static inline u32 aac_get_safw_phys_nexus(struct aac_dev *dev, int lun) +{ + return *((u32 *)&dev->safw_phys_luns->lun[lun].node_ident[12]); +} + +static inline u32 aac_get_safw_phys_device_type(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].node_ident[8]; } /** @@ -1862,22 +1898,16 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) u32 i, bus, target; u8 expose_flag, attribs; u8 devtype; - struct aac_ciss_phys_luns_resp *phys_luns; - - phys_luns = dev->safw_phys_luns; - lun_count = ((phys_luns->list_length[0] << 24) - + (phys_luns->list_length[1] << 16) - + (phys_luns->list_length[2] << 8) - + (phys_luns->list_length[3])) / 24; + lun_count = aac_get_safw_phys_lun_count(dev); for (i = 0; i < lun_count; ++i) { - bus = phys_luns->lun[i].level2[1] & 0x3f; - target = phys_luns->lun[i].level2[0]; - expose_flag = phys_luns->lun[i].bus >> 6; - attribs = phys_luns->lun[i].node_ident[9]; - nexus = *((u32 *) &phys_luns->lun[i].node_ident[12]); + bus = aac_get_safw_phys_bus(dev, i); + target = aac_get_safw_phys_target(dev, i); + expose_flag = aac_get_safw_phys_expose_flag(dev, i); + attribs = aac_get_safw_phys_attribs(dev, i); + nexus = aac_get_safw_phys_nexus(dev, i); if (bus >= AAC_MAX_BUSES || target >= AAC_MAX_TARGETS) continue;