From patchwork Tue Jan 5 14:22:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 7955301 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 826D4BEEE5 for ; Tue, 5 Jan 2016 14:22:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99B4F20384 for ; Tue, 5 Jan 2016 14:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6AD12037E for ; Tue, 5 Jan 2016 14:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbcAEOW1 (ORCPT ); Tue, 5 Jan 2016 09:22:27 -0500 Received: from mail-by2on0057.outbound.protection.outlook.com ([207.46.100.57]:8125 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751614AbcAEOWZ (ORCPT ); Tue, 5 Jan 2016 09:22:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oVebprrlg2tX1UBRI6Px57WX9L5/rQB7YrxmBvgMxKw=; b=lKPjnc4+fNIulUq3fh6HDSqJwjGH6x6alS8huFL/eicUSOyZ2pKsqXZL5EoeYEMvIlAg4S+6+3XonUg9HXvFJ9ST70H6XpF8A8gNKL9PRsoOwSIjUUCeF4eS/84KRaXcwnV05gTnCZQZ/1aA3IFjCqJEH3BUxt66KJm00yCTcFo= Received: from BLUPR0201CA0042.namprd02.prod.outlook.com (10.163.116.52) by DM2PR0201MB0830.namprd02.prod.outlook.com (10.160.95.151) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 5 Jan 2016 14:22:24 +0000 Received: from BY2FFO11FD040.protection.gbl (2a01:111:f400:7c0c::196) by BLUPR0201CA0042.outlook.office365.com (2a01:111:e400:52e7::52) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Tue, 5 Jan 2016 14:22:23 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=sandisk.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=bestguesspass action=none header.from=sandisk.com; 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 BY2FFO11FD040.mail.protection.outlook.com (10.1.14.225) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Tue, 5 Jan 2016 14:22:22 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep12.sandisk.com (Symantec Messaging Gateway) with SMTP id BC.FD.02821.E91DB865; Tue, 5 Jan 2016 06:22:22 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.248.2; Tue, 5 Jan 2016 06:22:22 -0800 X-AuditID: ac160a69-f797e6d000000b05-97-568bd19e95b0 Received: from [10.50.231.71] ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id 12.FD.08831.D91DB865; Tue, 5 Jan 2016 06:22:22 -0800 (PST) Subject: [PATCH 04/15] IB/srpt: Introduce target_reverse_dma_direction() To: Doug Ledford References: <568BD0FC.70207@sandisk.com> CC: Christoph Hellwig , "linux-rdma@vger.kernel.org" From: Bart Van Assche Message-ID: <568BD19C.6060404@sandisk.com> Date: Tue, 5 Jan 2016 15:22:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <568BD0FC.70207@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsWyRoxnke68i91hBnMmWVq8PP+B1WLl6qNM Fs8O9bI4MHvsvtnA5vF+31U2j8+b5AKYo7hsUlJzMstSi/TtErgy+r9fYS2YwVex/Gl5A+M3 7i5GTg4JAROJ63fPsEPYYhIX7q1n62Lk4hASOMEocWvnfFYIZzujxIsrnYwwHZNf9TJDJDYz Ssy41cwGkhAW8JB4tWgNK4gtIqAmsenVIqCxHEBFGhLvtmaBhJkF4iXWfXoDNodNwEji2/uZ LCAlvAJaEid2V4GYLAIqEt8fOIBUiApESPzYsASsmldAUOLkzCcsIDangKbE/9ZdYMOZgez1 u/QhhstLbH87B+wwCYFVrBJ/Jy4AO0xIQF3i5JL5TBMYRWYhGTULoX0WkvYFjMyrGMVyM3OK c9NTCwyN9IoT81Iyi7P1kvNzNzGCo4ArcwfjiknmhxgFOBiVeHg5XnaFCbEmlhVX5h5ilOBg VhLhfX2kO0yINyWxsiq1KD++qDQntfgQozQHi5I4r3WLWpiQQHpiSWp2ampBahFMlomDU6qB ceILU53j16ceE3gg9OzwsqWTa6r+XeV9Kq+xaUprsHNK6dafouU650/MXXVV4u/fkOlsF2oZ hSp7cwR1tBoOiqUtXnOSb4qvlyZ7j8a7qTkCb5mzeU/eWbbQW9xwXrDMpCtdRaJsIUsfWMW3 mPlyPDteNHXXsa6i5e8/rFx+vbSucrPqgq12NkosxRmJhlrMRcWJAMbr/71+AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIJMWRmVeSWpSXmKPExsXCtZEjRXfexe4wgycf1C1env/AarFy9VEm i2eHelkcmD1232xg83i/7yqbx+dNcgHMUVw2Kak5mWWpRfp2CVwZ/d+vsBbM4KtY/rS8gfEb dxcjJ4eEgInE5Fe9zBC2mMSFe+vZuhi5OIQENjJK7D9xgAUkISzgIfFq0RpWEFtEQE1i06tF 7F2MHEBFGhLvtmaBmMwC8RJ3O5lAKtgEjCS+vZ/JAhLmFdCSOLG7CsRkEVCR+P7AAaRCVCBC 4seGJYwgNq+AoMTJmU/A9nAKaEr8b93FDmIzC6hL/Jl3iRnClpfY/nYO8wRG/llIWmYhKZuF pGwBI/MqRrHczJzi3PTMAkNDveLEvJTM4my95PzcTYzgQOSM3MH4dKL5IUYmDk6pBsaHz7vm yh0NU3ewPlE/8zdbvJXCnq+l+42WbVPrmjw3rWSVukre0Y4adVXGI0teb3o3R5phz7YwWVFj xTfrs/q5kiWLC+PDTjUlVWx12sz+2iFq9st/d1b5L1yXPtE1fbnFXyF157MSrybMPjVB1Pq1 s9szXem1PsoW28TCnqqWG028pybBdVmJpTgj0VCLuag4EQCxVMBf9AEAAA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD040; 1:MKRVMNdNvSq8J5Wtal3A/HpkTAAIMgFna9W87b8HxLdBexiXxNjcqDxmLQ5i2C60Kq8P6hpe3cpjG3HJOegYmC1+rAGDyFXqRVUzO7fMfyWna6VdOQ+/aXsGkO7N6oFdIHwjznKQjJ81YgdU2qwbRNrWjT9t4tHTg/LEGUXAegO/rKd1nclR2DNm0v4x+4XKG6fh7LWyWZ1t4eYxGfN9/hj94Krj3LHoENxipHjKN3O3WR9BCxR5zg2lo4OrOF9xBq13y9cwL1M7HIyxELMC6huUkp+66Njl1fq4CTwOLxOWVG5SvYxbKq4rJQuXozX8CtNNANyKLjaACcifl6MVKQ== X-Forefront-Antispam-Report: CIP:63.163.107.173; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(76176999)(2950100001)(50466002)(19580405001)(59896002)(65816999)(87266999)(110136002)(50986999)(64126003)(77096005)(83506001)(229853001)(5001960100002)(87936001)(230700001)(23676002)(5008740100001)(19580395003)(69596002)(80316001)(106466001)(189998001)(86362001)(54356999)(4326007)(65956001)(65806001)(47776003)(33656002)(586003)(81156007)(92566002)(36756003)(1220700001)(1096002)(4001350100001)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0201MB0830; H:milsmgep12.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0830; 2:XzVZlJX3K/Bf7scMTcqERrS2czy1BKRHUJDa0QVpzgkArQynG8+AUEkTEy4c0E1eCG9EyXZyIFhi56uJzCxQKyyyvKiG3HOgIl9cHiF1Rwv1JkgGUyk2BlCfA1WYeGKEig1W0jjRQocEatbs3bNsqg==; 3:wfnTNwUdZF3GdYrPBa0Qc+oM1Yk2xeW8zd6+VlFpnA6aakUJiQbW7XOP5dgPRcgcXLWooWPhsD+KG9l6iTflfo5YQ8jm7oYj3o69TTHVkryxPMbUdf4pUe1Q3TguQeRFZAHQk1DoxJA/hXNgbVZwfUM6nx4RGxwFAYNGCoOuEw1HdBrxyT0qbKtwRtXlO1KwL6n3quw1KrNxr5JQ4v4swD68/9KF5pzqetfHXyGU6CvICOlakI0da46/5YU5gXbRMbFLlhOSooFpS6osM9tJmA==; 25:QRq6gKnfgeNl1CFUCy9C/V3YqJC4tFqzMHREFlTEmk9pW977F8tQnaExU3BGtWHa+xRF/Rz7k8CzeySzKUp54O9hQW3CN0fH1bsPanZEq32aDkO31nrI5QLMTkp53Z6n2FMwOngcrKpEh7GNSIqcQzEoLqBFJSTKqiD6b+p+jZ2NsEdz2DW9hHbU4ZotO4v06p15R+CcIIuFoROV0xcusxCls4IWJyY2H23WlFLkVsh5IRPTrZGHJz/M+soVR0m/A+44VFUobJALrq9p2/n6zg== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:DM2PR0201MB0830; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0830; 20:EDS507WO7wE/3CGRV3b980zkDnsUN/WBULjiTk/7vYohhBtWXHVlu/f5E6QZZdmz7JkHHG9hjU+if0a8/xMZ0hGLVjJkgdWFZYFRmqPxT5w7TkmpS/kr4P4kiCc6neLw01rp6L7YNsua929tvDIDCj9u12CTAxn+9fSXL0hniDG6egYplsYO2DQUWs/BjbLhwMRb6a3UrnOfYSE+moP1wsUieSJJoif62jvUwJpE9IM6nO5wzvnqg0/7QsLNVZ6Z8xlAB28L69kAZEjNLFatqLO5e6DOh6dLMGFsKyNqj6EEVM69WpNhIoZR4hSZjWvy1WWkCRM3xRC2D7ZvM+tCPrZ5Z4wqtqcuI/CpZN/NnilJNm0LvB02IgOqSikhWxLitV9XUSRGg82gKglyH807DcXGvYmQLx34lykT87F9mwz3pSXpOvUPHV2yuVZeLK2J0LjgSSS1UU3d73gbHp+ZH8ZQb7FgrOGbCpXkBcOMqQnSFY3K9kuW2yAxTfqRoai/; 4:3Q5mZDObBXEbXVnEQaKrBUXrqPcAJdcvEGI1wCweK8C8+UCYyA60Q2WWS19PIs6bmf/HBLQZhypwVi4rN5/LTFilbCj5yO31h4GC57572DrUT4bFTMQP1YYq5RmlByMAq8Jb6s0kLtREueQcUHsSIyvtq57ny1aa3r6hgBrcdtp0K0GghVKLr+MzUzaUdBYS/GViNM84gXx6gHp6NWSZx+/zMrRULy5u8V77LvGpjtoUFFBFZYw6jFUP8lT+sCQWsdK/JQVTkn4c6+7gbNXGFMqK/J+6qXQ5tumDIGTWYXkyxpq+z0NJfU1UPLy9jSxW7Q8mXQB1mFa8itH8OSpBwT37bXv5kxPvHrmpZM0YsgjQa3z+RYJvLp8vrp/BqeSojDgBwVmCKRXwTxo+07y7xFkyej6iL4VJe240 i6F5tdW4vp/RkYlkIPZhsu6aGpiN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121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z7gIzWKwEIurNUoztSN1hmM/rUOuBr0FL3vSvEv7jA==; 24:wZt2JRZhgl1fIgo3qgrT8XDG9KXRkIyOlMmPQ8Ho395xHVK3X7AsnuglwDjbOj0VDxIEJbUdF0xiiyE5nqa7EBVucylhT4EZQKldj2W7i5g=; 20:MVemrQYXWA22KxunFNf098fFpdtJ6bh2zWtARhT2ZlAPvp1j8GPIpdWw53xy9BreD+pHinYAMpo+Dj59+hnelTU9bCfgRkNd/uXxDrsv3htb2+oGtDGI9bWEACQXFOOXvt/nQ5H8NnGiDCfK94WjF/GilFkrJ5wOqfrWj9SDR3xFHd0uL8p7iL0G7t2AA2dH4PIMAA5cl2O9Wzau5YXB1jC21jgNTvNpPX5otwto7sgY0Musvcm0Rnswoq4EHszp SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2016 14:22:22.9983 (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: DM2PR0201MB0830 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 Use the function target_reverse_dma_direction() instead of reimplementing it. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- drivers/infiniband/ulp/srpt/ib_srpt.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index cbcc73e..fd94780 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -96,19 +96,6 @@ static int srpt_queue_status(struct se_cmd *cmd); static void srpt_recv_done(struct ib_cq *cq, struct ib_wc *wc); static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc); -/** - * opposite_dma_dir() - Swap DMA_TO_DEVICE and DMA_FROM_DEVICE. - */ -static inline -enum dma_data_direction opposite_dma_dir(enum dma_data_direction dir) -{ - switch (dir) { - case DMA_TO_DEVICE: return DMA_FROM_DEVICE; - case DMA_FROM_DEVICE: return DMA_TO_DEVICE; - default: return dir; - } -} - static enum rdma_ch_state srpt_set_ch_state(struct srpt_rdma_ch *ch, enum rdma_ch_state new_state) { @@ -1048,7 +1035,7 @@ static void srpt_unmap_sg_to_ib_sge(struct srpt_rdma_ch *ch, dir = ioctx->cmd.data_direction; BUG_ON(dir == DMA_NONE); ib_dma_unmap_sg(ch->sport->sdev->device, sg, ioctx->sg_cnt, - opposite_dma_dir(dir)); + target_reverse_dma_direction(&ioctx->cmd)); ioctx->mapped_sg_count = 0; } } @@ -1085,7 +1072,7 @@ static int srpt_map_sg_to_ib_sge(struct srpt_rdma_ch *ch, ioctx->sg_cnt = sg_cnt = cmd->t_data_nents; count = ib_dma_map_sg(ch->sport->sdev->device, sg, sg_cnt, - opposite_dma_dir(dir)); + target_reverse_dma_direction(cmd)); if (unlikely(!count)) return -EAGAIN;