Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6] / drivers / staging / rtl8187se / ieee80211 / internal.h
1 /*
2  * Cryptographic API.
3  *
4  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5  *
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.
10  *
11  */
12 #ifndef _CRYPTO_INTERNAL_H
13 #define _CRYPTO_INTERNAL_H
14
15
16 //#include <linux/crypto.h>
17 #include "rtl_crypto.h"
18 #include <linux/mm.h>
19 #include <linux/highmem.h>
20 #include <linux/init.h>
21 #include <asm/hardirq.h>
22 #include <asm/softirq.h>
23 #include <asm/kmap_types.h>
24
25 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
26 #define list_for_each_entry(pos, head, member)                          \
27         for (pos = list_entry((head)->next, typeof(*pos), member),      \
28                      prefetch(pos->member.next);                        \
29              &pos->member != (head);                                    \
30              pos = list_entry(pos->member.next, typeof(*pos), member),  \
31                      prefetch(pos->member.next))
32
33 static inline void cond_resched(void)
34 {
35         if (need_resched()) {
36                 set_current_state(TASK_RUNNING);
37                 schedule();
38         }
39 }
40 #endif
41
42 extern enum km_type crypto_km_types[];
43
44 static inline enum km_type crypto_kmap_type(int out)
45 {
46         return crypto_km_types[(in_softirq() ? 2 : 0) + out];
47 }
48
49 static inline void *crypto_kmap(struct page *page, int out)
50 {
51         return kmap_atomic(page, crypto_kmap_type(out));
52 }
53
54 static inline void crypto_kunmap(void *vaddr, int out)
55 {
56         kunmap_atomic(vaddr, crypto_kmap_type(out));
57 }
58
59 static inline void crypto_yield(struct crypto_tfm *tfm)
60 {
61         if (!in_softirq())
62                 cond_resched();
63 }
64
65 static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
66 {
67         return (void *)&tfm[1];
68 }
69
70 struct crypto_alg *crypto_alg_lookup(const char *name);
71
72 #ifdef CONFIG_KMOD
73 void crypto_alg_autoload(const char *name);
74 struct crypto_alg *crypto_alg_mod_lookup(const char *name);
75 #else
76 static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
77 {
78         return crypto_alg_lookup(name);
79 }
80 #endif
81
82 #ifdef CONFIG_CRYPTO_HMAC
83 int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
84 void crypto_free_hmac_block(struct crypto_tfm *tfm);
85 #else
86 static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
87 {
88         return 0;
89 }
90
91 static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
92 { }
93 #endif
94
95 #ifdef CONFIG_PROC_FS
96 void __init crypto_init_proc(void);
97 #else
98 static inline void crypto_init_proc(void)
99 { }
100 #endif
101
102 int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
103 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
104 int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
105
106 int crypto_init_digest_ops(struct crypto_tfm *tfm);
107 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
108 int crypto_init_compress_ops(struct crypto_tfm *tfm);
109
110 void crypto_exit_digest_ops(struct crypto_tfm *tfm);
111 void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
112 void crypto_exit_compress_ops(struct crypto_tfm *tfm);
113
114 #endif  /* _CRYPTO_INTERNAL_H */
115