powerpc: Relocatable system call no longer uses the LR
[linux/fpc-iii.git] / include / crypto / if_alg.h
blob018afb264ac261ea5dea2f3afa547cf9a8f7a202
1 /*
2 * if_alg: User-space algorithm interface
4 * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
13 #ifndef _CRYPTO_IF_ALG_H
14 #define _CRYPTO_IF_ALG_H
16 #include <linux/compiler.h>
17 #include <linux/completion.h>
18 #include <linux/if_alg.h>
19 #include <linux/scatterlist.h>
20 #include <linux/types.h>
21 #include <net/sock.h>
23 #define ALG_MAX_PAGES 16
25 struct crypto_async_request;
27 struct alg_sock {
28 /* struct sock must be the first member of struct alg_sock */
29 struct sock sk;
31 struct sock *parent;
33 const struct af_alg_type *type;
34 void *private;
37 struct af_alg_completion {
38 struct completion completion;
39 int err;
42 struct af_alg_control {
43 struct af_alg_iv *iv;
44 int op;
45 unsigned int aead_assoclen;
48 struct af_alg_type {
49 void *(*bind)(const char *name, u32 type, u32 mask);
50 void (*release)(void *private);
51 int (*setkey)(void *private, const u8 *key, unsigned int keylen);
52 int (*accept)(void *private, struct sock *sk);
53 int (*setauthsize)(void *private, unsigned int authsize);
55 struct proto_ops *ops;
56 struct module *owner;
57 char name[14];
60 struct af_alg_sgl {
61 struct scatterlist sg[ALG_MAX_PAGES + 1];
62 struct page *pages[ALG_MAX_PAGES];
63 unsigned int npages;
66 int af_alg_register_type(const struct af_alg_type *type);
67 int af_alg_unregister_type(const struct af_alg_type *type);
69 int af_alg_release(struct socket *sock);
70 int af_alg_accept(struct sock *sk, struct socket *newsock);
72 int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len);
73 void af_alg_free_sg(struct af_alg_sgl *sgl);
74 void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new);
76 int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con);
78 int af_alg_wait_for_completion(int err, struct af_alg_completion *completion);
79 void af_alg_complete(struct crypto_async_request *req, int err);
81 static inline struct alg_sock *alg_sk(struct sock *sk)
83 return (struct alg_sock *)sk;
86 static inline void af_alg_release_parent(struct sock *sk)
88 sock_put(alg_sk(sk)->parent);
91 static inline void af_alg_init_completion(struct af_alg_completion *completion)
93 init_completion(&completion->completion);
96 #endif /* _CRYPTO_IF_ALG_H */