From patchwork Fri Mar 13 17:38:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: horia.geanta@freescale.com X-Patchwork-Id: 449997 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D7D86140119 for ; Sat, 14 Mar 2015 04:38:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752943AbbCMRiW (ORCPT ); Fri, 13 Mar 2015 13:38:22 -0400 Received: from mail-by2on0129.outbound.protection.outlook.com ([207.46.100.129]:5632 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751799AbbCMRiV (ORCPT ); Fri, 13 Mar 2015 13:38:21 -0400 Received: from DM2PR03CA0034.namprd03.prod.outlook.com (10.141.96.33) by BY2PR03MB393.namprd03.prod.outlook.com (10.141.141.12) with Microsoft SMTP Server (TLS) id 15.1.112.13; Fri, 13 Mar 2015 17:38:19 +0000 Received: from BY2FFO11FD002.protection.gbl (2a01:111:f400:7c0c::199) by DM2PR03CA0034.outlook.office365.com (2a01:111:e400:2428::33) with Microsoft SMTP Server (TLS) id 15.1.112.19 via Frontend Transport; Fri, 13 Mar 2015 17:38:19 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD002.mail.protection.outlook.com (10.1.14.124) with Microsoft SMTP Server (TLS) id 15.1.112.13 via Frontend Transport; Fri, 13 Mar 2015 17:38:18 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t2DHcGBf009770; Fri, 13 Mar 2015 10:38:16 -0700 From: Horia Geanta To: , , Herbert Xu , "David S. Miller" CC: Kim Phillips , Horia Geanta Subject: [PATCH v2 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request Date: Fri, 13 Mar 2015 19:38:11 +0200 Message-ID: <1426268291-21507-1-git-send-email-horia.geanta@freescale.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1426268260-20824-1-git-send-email-horia.geanta@freescale.com> References: <1426268260-20824-1-git-send-email-horia.geanta@freescale.com> X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=horia.geanta@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(575784001)(86362001)(48376002)(46102003)(229853001)(36756003)(50226001)(62966003)(77156002)(47776003)(2950100001)(92566002)(77096005)(87936001)(19580395003)(19580405001)(6806004)(106466001)(50986999)(76176999)(33646002)(85426001)(50466002)(104016003)(105606002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB393; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB393; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002009)(5005006); SRVR:BY2PR03MB393; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB393; X-Forefront-PRVS: 05143A8241 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2015 17:38:18.6645 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB393 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some crypto backends might require the requests' private contexts to be allocated in DMA-able memory. Signed-off-by: Horia Geanta --- Depends on patch 1/4 (sent only on crypto list) that adds the CRYPTO_TFM_REQ_DMA flag. net/ipv4/esp4.c | 7 ++++++- net/ipv6/esp6.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 60173d4d3a0e..3e6ddece0cbe 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -38,6 +38,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu); static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqhilen) { unsigned int len; + gfp_t gfp = GFP_ATOMIC; len = seqhilen; @@ -54,7 +55,11 @@ static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqhilen) len += sizeof(struct scatterlist) * nfrags; - return kmalloc(len, GFP_ATOMIC); + if (crypto_aead_reqsize(aead) && + (crypto_aead_get_flags(aead) & CRYPTO_TFM_REQ_DMA)) + gfp |= GFP_DMA; + + return kmalloc(len, gfp); } static inline __be32 *esp_tmp_seqhi(void *tmp) diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index e48f2c7c5c59..0d173eedad4e 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -65,6 +65,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu); static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqihlen) { unsigned int len; + gfp_t gfp = GFP_ATOMIC; len = seqihlen; @@ -81,7 +82,11 @@ static void *esp_alloc_tmp(struct crypto_aead *aead, int nfrags, int seqihlen) len += sizeof(struct scatterlist) * nfrags; - return kmalloc(len, GFP_ATOMIC); + if (crypto_aead_reqsize(aead) && + (crypto_aead_get_flags(aead) & CRYPTO_TFM_REQ_DMA)) + gfp |= GFP_DMA; + + return kmalloc(len, gfp); } static inline __be32 *esp_tmp_seqhi(void *tmp)