* [PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request [not found] <1426266882-31626-1-git-send-email-horia.geanta@freescale.com> @ 2015-03-13 17:15 ` Horia Geanta 2015-03-13 19:46 ` David Miller 0 siblings, 1 reply; 4+ messages in thread From: Horia Geanta @ 2015-03-13 17:15 UTC (permalink / raw) To: linux-crypto, netdev, Herbert Xu, David S. Miller; +Cc: Kim Phillips Some crypto backends might require the requests' private contexts to be allocated in DMA-able memory. Signed-off-by: Horia Geanta <horia.geanta@freescale.com> --- 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) -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request 2015-03-13 17:15 ` [PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request Horia Geanta @ 2015-03-13 19:46 ` David Miller 2015-03-14 12:16 ` Horia Geantă 0 siblings, 1 reply; 4+ messages in thread From: David Miller @ 2015-03-13 19:46 UTC (permalink / raw) To: horia.geanta; +Cc: linux-crypto, netdev, herbert, kim.phillips From: Horia Geanta <horia.geanta@freescale.com> Date: Fri, 13 Mar 2015 19:15:22 +0200 > Some crypto backends might require the requests' private contexts > to be allocated in DMA-able memory. > > Signed-off-by: Horia Geanta <horia.geanta@freescale.com> No way. Upper layers should be absolutely not required to know about such requirements. Such details _must_ be hidden inside of the crypto layer and drivers and not leak out into the users of the crypto interfaces. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request 2015-03-13 19:46 ` David Miller @ 2015-03-14 12:16 ` Horia Geantă 2015-03-14 18:27 ` David Miller 0 siblings, 1 reply; 4+ messages in thread From: Horia Geantă @ 2015-03-14 12:16 UTC (permalink / raw) To: David Miller, herbert; +Cc: linux-crypto, netdev, kim.phillips On 3/13/2015 9:46 PM, David Miller wrote: > From: Horia Geanta <horia.geanta@freescale.com> > Date: Fri, 13 Mar 2015 19:15:22 +0200 > >> Some crypto backends might require the requests' private contexts >> to be allocated in DMA-able memory. >> >> Signed-off-by: Horia Geanta <horia.geanta@freescale.com> > > No way. > > Upper layers should be absolutely not required to know about such > requirements. > > Such details _must_ be hidden inside of the crypto layer and drivers > and not leak out into the users of the crypto interfaces. If you look at patch 1/4: http://www.mail-archive.com/linux-crypto@vger.kernel.org/msg13428.html that's what's done for {aead,ablkcipher,ahash}_request_alloc(). Thus users (upper layers) that allocate the crypto requests using the crypto API are unaware of the requirement. However, ESP is not using aead_request_alloc(). This breaks the interface and thus some crypto implementation details are not transparent. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request 2015-03-14 12:16 ` Horia Geantă @ 2015-03-14 18:27 ` David Miller 0 siblings, 0 replies; 4+ messages in thread From: David Miller @ 2015-03-14 18:27 UTC (permalink / raw) To: horia.geanta; +Cc: herbert, linux-crypto, netdev, kim.phillips From: Horia Geantă <horia.geanta@freescale.com> Date: Sat, 14 Mar 2015 14:16:37 +0200 > However, ESP is not using aead_request_alloc(). Then find a way to adjust it to do so. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-14 18:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1426266882-31626-1-git-send-email-horia.geanta@freescale.com>
2015-03-13 17:15 ` [PATCH 2/4] net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request Horia Geanta
2015-03-13 19:46 ` David Miller
2015-03-14 12:16 ` Horia Geantă
2015-03-14 18:27 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).