From patchwork Thu Dec 21 17:34:06 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: 10128115 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 9049D60318 for ; Thu, 21 Dec 2017 17:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E4B529CE3 for ; Thu, 21 Dec 2017 17:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7327F29D1B; Thu, 21 Dec 2017 17:35:16 +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 EE59B29CE3 for ; Thu, 21 Dec 2017 17:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753535AbdLURfO (ORCPT ); Thu, 21 Dec 2017 12:35:14 -0500 Received: from mail-bl2nam02on0079.outbound.protection.outlook.com ([104.47.38.79]:32896 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754124AbdLUReo (ORCPT ); Thu, 21 Dec 2017 12:34:44 -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=rVFSeuA3INfVn3alhV0Vzr9qOMPCqWDd6gHrG1ekYHc=; b=Wr0TPQ7iJc2gm7dgotOBSf0ziImgKtyKKlBoSkxX3rZyy0q60NRusLIL5jZyjUKeru+AHR7culKMcbWLEo3qr7g2JmygvdrVclJOVqbiTg6s/Zuxp8VjD0Ma0MG6JotsLoPtmPlFZGQWKcNtvPt/KJ0nK905FJuDNt1xREpIl6g= Received: from MWHPR02CA0036.namprd02.prod.outlook.com (2603:10b6:301:60::25) by CO1PR02MB144.namprd02.prod.outlook.com (2a01:111:e400:101e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Thu, 21 Dec 2017 17:34:41 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:126) by MWHPR02CA0036.outlook.office365.com (2603:10b6:301:60::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Thu, 21 Dec 2017 17:34:41 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; linux.vnet.ibm.com; dkim=none (message not signed) header.d=none; linux.vnet.ibm.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 BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) 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; Thu, 21 Dec 2017 17:34:26 +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; Thu, 21 Dec 2017 09:34:25 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" Subject: [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info Date: Thu, 21 Dec 2017 09:34:06 -0800 Message-ID: <20171221173420.8213-16-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171221173420.8213-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171221173420.8213-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)(376002)(346002)(396003)(39860400002)(39380400002)(2980300002)(438002)(189003)(199004)(305945005)(76506005)(97736004)(48376002)(76176011)(36756003)(356003)(2950100002)(81166006)(81156014)(6666003)(51416003)(68736007)(5660300001)(8676002)(50226002)(69596002)(8936002)(72206003)(47776003)(86362001)(104016004)(2201001)(478600001)(53936002)(106002)(57986006)(4326008)(2906002)(50466002)(16586007)(1076002)(54906003)(106466001)(316002)(110136005)(77096006); DIR:OUT; SFP:1101; SCL:1; SRVR:CO1PR02MB144; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:U1i00t3pKJI3CrYkUSbPFWl6S+KryXv3CyStkAzzC8gmh700uBMpyZbLwT/eneUdHA9BA4TN4qRTMXRVv+EhN+9khUWCTJ9oHfHEor076wzfWjkprI8Q4eIihZhJrVqd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e5de5de-2417-44f2-5eac-08d54899157e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4608076)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:CO1PR02MB144; X-Microsoft-Exchange-Diagnostics: 1; CO1PR02MB144; 3:dLwQWH2V/RoYx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CXVdByDFG77Z/JHviX88Qv+XWxPOgv34mBljmzWtRkyjZUF0LYQCX98qEp0MDi66jugYtFB26JQGv53ILIwsqVjAOMGmihvYdJMTXMA/dn/UJ0mkQOB9wew7/ATcYC+maAVAKJS+B62Z6ao9+AOu6NvDXgxEiP1QXj+jvx4g7YvoJrrtwP5+w5cMbkqSJPCmIzPkjfn9hAOL8Lig+Oux9h2YIWjCOsAnmJ6O5IM2EhkPpiLeFYIXcsi66Ey7ukNOp00kb74AJ7B0GaBFJZ2mWNXjuOhwofFHkv+hGoprCXaFhvbqOqlOpaISLVzKau//49MWEDa/vcrAToAWA4Fc49wLYG3nRpfxr1oYNaFhiyxQ+K9DpoMzXyAsbx6F7GavYl8UkAk6u4x9pfp1Y3PNgAMflStA+7pujQpY2tLiLLEYSF2OFkoJa7lhPOqszVC4rhVg1rs8woDPPVkg86hgy3xBtJm7UL/y7Qa7kWu8WPs6/QxaFytO/SZ6pIZO186YVbPxxLHANiJdi18x4dJbNxmdAI5svvDrRHax3sPbbFhh72P4+UVz0D0dNAhxqwc7OQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170198267865); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(93006095)(93004095)(3231023)(10201501046)(6055026)(6041268)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:CO1PR02MB144; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CO1PR02MB144; X-Microsoft-Exchange-Diagnostics: 1; CO1PR02MB144; 4:oGeTGzIJ9vT3CH2YaB1mNkadpR3zM7Q+VtjtWeeEZXLvUgtr+xMmHSWTG3iXAKVR1SekcBn4Fj4D92WGyU7550ocFh71B3ixph0pMgi+3htFnV8nIZr3saAUsXTXG0nZXW5/UZ53c+xarPbDO8DxJ7l4PdO0zgMtGSbOfolpEgvPvY2y699jsni6dZjfe35FSNnRfWB/UxrEdip0sON8Ed+Z1pev+px4kEqEFDGUbGnizo9d/gP7S98v6AUKSjlzNqSUPtNTgg1DpFezGexBU/DwP9jYy51Bju1YZ74b6B+4nsa5QfCc2px0Wk5ZmArH X-Forefront-PRVS: 0528942FD8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO1PR02MB144; 23:qSNePsr+fAX+jCKQdJn4DwW7BI4KFBOZGqqeTI4GgV?= =?us-ascii?Q?NEsnpYtUm65Z5Oe98MunmY9oEFxxxdKDPzy/9ex6dNVT4vo0tgm8VNb4wjUX?= =?us-ascii?Q?uNhryThHwpGL+xjvqENNlot2qIdnaE58LHe0c0oc6zrGK5pyAdCqJd8WUX1P?= =?us-ascii?Q?iTo5dY7GzqVN56WUtRbixQRB+QaIcXXmu574jV5s2AjK5Ep1fzvyeTuP85CN?= =?us-ascii?Q?C+5BjqklOdGak0HpPFgqg01aQkALmv9fvCU7et5iW1WPlr4EkveESNiXGv9P?= =?us-ascii?Q?YkYXuSKcdlgUIzEu3gOAO7GdhKZO82D1YybguwA+6xp/eroz4aqOEEI/z3f/?= =?us-ascii?Q?wP1+aEEanQEQaFWY0/kIC/l7VgHBNLQGMXaQHQqr3oNsz2BuWGQqHke4KLd8?= =?us-ascii?Q?7p+LTEZj6aplh4qoioLcJKsCzXeLC8qi8S+zCynWkzVeKjhyM0uuenp18u/p?= =?us-ascii?Q?OMfoj6A10VX4wUyAwYrTcqbsaPZk7aNXVQphCqqduUdAW+zJoQ2xe40+rdAU?= =?us-ascii?Q?y/K839uNZDOMWWRYeGZb3ly4VszVnFjbrBbX39d7D1/Et8zmlbVs58JtTP1h?= =?us-ascii?Q?4ZfsIp/cl/QLkW8wZ186T1w+qhWl0AwIDU5GaF2Ly9NLJDzGESLL1ODjN5p0?= =?us-ascii?Q?1Kd9OJt+1AA6JBtpiQUmTQNvxBmAsCTbqQjSnROSualdPweqGHUknDG6jsdL?= =?us-ascii?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M9usOSUBFEnCLXsv8HqL15DbS5hVzVqzym7vn8/60bKuBS1YbCPZhLWgDxrySlXYU8IAGwNCiakInEh+V3UbhlILmI5u+Dro=; 7:ZfmooNS6E07aWtvSyryVDlQkNFbWGTNf/VEpK8qs74rF4uTMzWvFqJGXqi8ZVwclLgZ4SDsDUp6BVQqoh22dZu+1OE9la8AAcYj+Whx7evRqGIM0IWLFniRF43I75P/pltM0nbVV09gVY17MO+vVXPUekLQEc+zDj+1IwAiLgVnrpfEEOCJQGqnvUsQV/8S1+QdbYeMsVBf/t69suZPYDijMIH5umQIOejZzINElJU/FkPW/Nvb8u+x3U/lu3NkC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 17:34:26.7316 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e5de5de-2417-44f2-5eac-08d54899157e 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: CO1PR02MB144 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 --- drivers/scsi/aacraid/aachba.c | 59 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index affa2f1..83d2576 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1847,7 +1847,48 @@ 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) +{ + struct aac_ciss_phys_luns_resp *phys_luns; + + phys_luns = dev->safw_phys_luns; + + return ((phys_luns->list_length[0]<<24) + + (phys_luns->list_length[1]<<16) + + (phys_luns->list_length[2]<<8) + + (phys_luns->list_length[3])) / 24; +} +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]; } /** @@ -1865,22 +1906,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;