summaryrefslogtreecommitdiffstats
path: root/crypto/scatterwalk.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2005-07-06 22:52:09 +0200
committerDavid S. Miller <davem@davemloft.net>2005-07-06 22:52:09 +0200
commit95477377995aefa2ec1654a9a3777bd57ea99146 (patch)
tree7aa4d6173de13c81c2fa0e4d2f9e0de22e141b6a /crypto/scatterwalk.h
parent[CRYPTO] Add support for low-level multi-block operations (diff)
downloadlinux-95477377995aefa2ec1654a9a3777bd57ea99146.tar.xz
linux-95477377995aefa2ec1654a9a3777bd57ea99146.zip
[CRYPTO] Add alignmask for low-level cipher implementations
The VIA Padlock device requires the input and output buffers to be aligned on 16-byte boundaries. This patch adds the alignmask attribute for low-level cipher implementations to indicate their alignment requirements. The mid-level crypt() function will copy the input/output buffers if they are not aligned correctly before they are passed to the low-level implementation. Strictly speaking, some of the software implementations require the buffers to be aligned on 4-byte boundaries as they do 32-bit loads. However, it is not clear whether it is better to copy the buffers or pay the penalty for unaligned loads/stores. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto/scatterwalk.h')
-rw-r--r--crypto/scatterwalk.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/scatterwalk.h b/crypto/scatterwalk.h
index 5495bb970816..e79925c474a3 100644
--- a/crypto/scatterwalk.h
+++ b/crypto/scatterwalk.h
@@ -55,6 +55,12 @@ static inline void scatterwalk_advance(struct scatter_walk *walk,
walk->len_this_segment -= nbytes;
}
+static inline unsigned int scatterwalk_aligned(struct scatter_walk *walk,
+ unsigned int alignmask)
+{
+ return !(walk->offset & alignmask);
+}
+
void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
int scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out);
void scatterwalk_map(struct scatter_walk *walk, int out);