From patchwork Mon May 18 11:27:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 6428311 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B2F8E9F3D1 for ; Mon, 18 May 2015 11:27:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F82720602 for ; Mon, 18 May 2015 11:27:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34FF62060B for ; Mon, 18 May 2015 11:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753696AbbERL1Y (ORCPT ); Mon, 18 May 2015 07:27:24 -0400 Received: from mail-bn1bon0074.outbound.protection.outlook.com ([157.56.111.74]:59824 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753555AbbERL1W (ORCPT ); Mon, 18 May 2015 07:27:22 -0400 Received: from BY1PR0201CA0008.namprd02.prod.outlook.com (25.160.191.146) by BN3PR0201MB1027.namprd02.prod.outlook.com (25.161.207.149) with Microsoft SMTP Server (TLS) id 15.1.160.19; Mon, 18 May 2015 11:27:19 +0000 Received: from BY2FFO11OLC007.protection.gbl (2a01:111:f400:7c0c::152) by BY1PR0201CA0008.outlook.office365.com (2a01:111:e400:4814::18) with Microsoft SMTP Server (TLS) id 15.1.166.22 via Frontend Transport; Mon, 18 May 2015 11:27:19 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=sandisk.com; opteya.com; dkim=none (message not signed) header.d=none; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.173 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.173; helo=milsmgep12.sandisk.com; Received: from milsmgep12.sandisk.com (63.163.107.173) by BY2FFO11OLC007.mail.protection.outlook.com (10.1.14.254) with Microsoft SMTP Server id 15.1.172.14 via Frontend Transport; Mon, 18 May 2015 11:27:17 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep12.sandisk.com (Symantec Messaging Gateway) with SMTP id 2E.27.06265.59CC9555; Mon, 18 May 2015 04:27:17 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.224.2; Mon, 18 May 2015 04:27:17 -0700 X-AuditID: ac160a69-f790f6d000001879-3f-5559cc957de0 Received: from [10.50.231.56] ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id EC.E7.03643.29CC9555; Mon, 18 May 2015 04:27:17 -0700 (PDT) Message-ID: <5559CC92.7020202@sandisk.com> Date: Mon, 18 May 2015 13:27:14 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Doug Ledford CC: James Bottomley , Sagi Grimberg , Sebastian Parschauer , linux-rdma , "linux-scsi@vger.kernel.org" , Yann Droneaud , "Brian King" , Nathan Fontenot , Tyrel Datwyler Subject: [PATCH v2 12/12] IB/srp: Add 64-bit LUN support References: <5559CB3A.6060102@sandisk.com> In-Reply-To: <5559CB3A.6060102@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsWyRoxnke7UM5GhBp1TlS26ZrFbvDz/gdXi //rbLBbPDvWyWHRf38FmcXv3GhaLG20P2CxO3ua3WN+0jdWiaf8qdgcujweHNrN4PJt+mMnj 8I8fzB7XV99n8/jz5zOzx/t9V9k8Pm+SC2CP4rJJSc3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Z7lYEM5BbQldny4BxZnFlCX+DPvEjOELS+x/e0c5gmM/LOQ7JiFpGwW krIFjMyrGMVyM3OKc9MzCwwN9YoT81Iyi7P1kvNzNzGCg58zcgfj04nmhxiZODilGhhXanut umKQe8+KT8/xyn7NPx+//jdkm80bv8zZjJVDd1HwnYcNUkc/dgV76EZGvZix6H7/Fk/xr5xV C2fWnpDnWlJ873GWa3D7DafsU+zT9Xdy/PuRlcRS881m4dZTq/ME3DiPb+j32xu9ZBGf7Osp Tbtca9pvMKXOOWcQpboroCkjM58/e68SS3FGoqEWc1FxIgD1KKPGLgIAAA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC007; 1:CK0WJe2sM0H30YmQFMAQPW2P3he7Xiz/pTwrIhTMPHLbWOjiGz4tVgt+pDS2xFnyOipEBTAC2lU71sW0bJBScoJ3CfWOXeJzbgttoFvXiUj+nGZaVheD7p0QpskjrNPl0AIgwMa1FL92F/6TXZU6CjHkLUKwWCdyx2r1y5f5bkpFlWbxFdKbuy7Eqw18fxbKzImKPlChJtJXebXkj7o8Xgm0J7otnQCC2uFS216agXoWRGDn4Ix6HBy4Rs81s0DuoMRbEFxfDP6z27ILz88eYvBZX1XwjDkixqOgkukcD1xWzCyOdrpBQ+lD7t44qapKM830TuQNB/bVTGh1sWktUA== X-Forefront-Antispam-Report: CIP:63.163.107.173; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(438002)(199003)(189002)(87936001)(92566002)(33656002)(229853001)(46102003)(83506001)(59896002)(64126003)(23676002)(106466001)(86362001)(575784001)(110136002)(4001350100001)(189998001)(5001830100001)(5001960100002)(5001920100001)(50986999)(76176999)(64706001)(87266999)(54356999)(47776003)(65956001)(65816999)(65806001)(5001860100001)(77096005)(4001540100001)(19580395003)(19580405001)(80316001)(77156002)(62966003)(69596002)(50466002)(68736005)(81156007)(97736004)(36756003)(2950100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0201MB1027; H:milsmgep12.sandisk.com; FPR:; SPF:Pass; PTR:ErrorRetry; A:1; MX:1; LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0201MB1027; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BN3PR0201MB1027; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0201MB1027; X-Forefront-PRVS: 058043A388 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2015 11:27:17.6775 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.173]; Helo=[milsmgep12.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0201MB1027 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The SCSI standard defines 64-bit values for LUNs. Large arrays employing large or hierarchical LUN numbers become more and more common. So update the SRP initiator to use 64-bit LUN numbers. See also Hannes Reinecke, commit 9cb78c16f5da ("scsi: use 64-bit LUNs"), June 2014. The largest LUN number that has been tested is 0xd2003fff00000000. Checked the following structure sizes with gdb: * sizeof(struct srp_cmd) = 48 * sizeof(struct srp_tsk_mgmt) = 48 * sizeof(struct srp_aer_req) = 36 The ibmvscsi changes have been compile tested only (on a PPC system). Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Sagi Grimberg Reviewed-by: Yann Droneaud Cc: Sebastian Parschauer Cc: Brian King Cc: Nathan Fontenot Cc: Tyrel Datwyler --- drivers/infiniband/ulp/srp/ib_srp.c | 12 ++++++------ drivers/infiniband/ulp/srp/ib_srp.h | 1 - drivers/scsi/ibmvscsi/ibmvscsi.c | 6 +++--- include/scsi/srp.h | 7 ++++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index a0a2348..6b6f6e3 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1848,7 +1848,7 @@ static void srp_process_aer_req(struct srp_rdma_ch *ch, s32 delta = be32_to_cpu(req->req_lim_delta); shost_printk(KERN_ERR, target->scsi_host, PFX - "ignoring AER for LUN %llu\n", be64_to_cpu(req->lun)); + "ignoring AER for LUN %llu\n", scsilun_to_int(&req->lun)); if (srp_response_common(ch, delta, &rsp, sizeof(rsp))) shost_printk(KERN_ERR, target->scsi_host, PFX @@ -2040,7 +2040,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) memset(cmd, 0, sizeof *cmd); cmd->opcode = SRP_CMD; - cmd->lun = cpu_to_be64((u64) scmnd->device->lun << 48); + int_to_scsilun(scmnd->device->lun, &cmd->lun); cmd->tag = tag; memcpy(cmd->cdb, scmnd->cmnd, scmnd->cmd_len); @@ -2420,8 +2420,8 @@ srp_change_queue_depth(struct scsi_device *sdev, int qdepth) return scsi_change_queue_depth(sdev, qdepth); } -static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, - unsigned int lun, u8 func) +static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, u64 lun, + u8 func) { struct srp_target_port *target = ch->target; struct srp_rport *rport = target->rport; @@ -2455,7 +2455,7 @@ static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, memset(tsk_mgmt, 0, sizeof *tsk_mgmt); tsk_mgmt->opcode = SRP_TSK_MGMT; - tsk_mgmt->lun = cpu_to_be64((u64) lun << 48); + int_to_scsilun(lun, &tsk_mgmt->lun); tsk_mgmt->tag = req_tag | SRP_TAG_TSK_MGMT; tsk_mgmt->tsk_mgmt_func = func; tsk_mgmt->task_tag = req_tag; @@ -3150,7 +3150,7 @@ static ssize_t srp_create_target(struct device *dev, target_host->transportt = ib_srp_transport_template; target_host->max_channel = 0; target_host->max_id = 1; - target_host->max_lun = SRP_MAX_LUN; + target_host->max_lun = -1LL; target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; target = host_to_target(target_host); diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index e690847..17ee3f8 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h @@ -54,7 +54,6 @@ enum { SRP_DLID_REDIRECT = 2, SRP_STALE_CONN = 3, - SRP_MAX_LUN = 512, SRP_DEF_SG_TABLESIZE = 12, SRP_DEFAULT_QUEUE_SIZE = 1 << 6, diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index acea5d6..6a41c36 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -1053,7 +1053,7 @@ static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd, memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); srp_cmd->opcode = SRP_CMD; memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb)); - srp_cmd->lun = cpu_to_be64(((u64)lun) << 48); + int_to_scsilun(lun, &srp_cmd->lun); if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { if (!firmware_has_feature(FW_FEATURE_CMO)) @@ -1529,7 +1529,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) /* Set up an abort SRP command */ memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); tsk_mgmt->opcode = SRP_TSK_MGMT; - tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48); + int_to_scsilun(lun, &tsk_mgmt->lun); tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK; tsk_mgmt->task_tag = (u64) found_evt; @@ -1652,7 +1652,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) /* Set up a lun reset SRP command */ memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); tsk_mgmt->opcode = SRP_TSK_MGMT; - tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48); + int_to_scsilun(lun, &tsk_mgmt->lun); tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET; evt->sync_srp = &srp_rsp; diff --git a/include/scsi/srp.h b/include/scsi/srp.h index 1ae84db..5be834d 100644 --- a/include/scsi/srp.h +++ b/include/scsi/srp.h @@ -42,6 +42,7 @@ */ #include +#include enum { SRP_LOGIN_REQ = 0x00, @@ -179,7 +180,7 @@ struct srp_tsk_mgmt { u8 reserved1[6]; u64 tag; u8 reserved2[4]; - __be64 lun __attribute__((packed)); + struct scsi_lun lun; u8 reserved3[2]; u8 tsk_mgmt_func; u8 reserved4; @@ -200,7 +201,7 @@ struct srp_cmd { u8 data_in_desc_cnt; u64 tag; u8 reserved2[4]; - __be64 lun __attribute__((packed)); + struct scsi_lun lun; u8 reserved3; u8 task_attr; u8 reserved4; @@ -265,7 +266,7 @@ struct srp_aer_req { __be32 req_lim_delta; u64 tag; u32 reserved2; - __be64 lun; + struct scsi_lun lun; __be32 sense_data_len; u32 reserved3; u8 sense_data[0];