serial: imx: support RS-485 Rx disable on Tx
[linux-2.6-block.git] / include / net / lib80211.h
CommitLineData
7e272fcf
JL
1/*
2 * lib80211.h -- common bits for IEEE802.11 wireless drivers
3 *
4 * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com>
5 *
274bfb8d
JL
6 * Some bits copied from old ieee80211 component, w/ original copyright
7 * notices below:
8 *
9 * Original code based on Host AP (software wireless LAN access point) driver
10 * for Intersil Prism2/2.5/3.
11 *
12 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
13 * <j@w1.fi>
14 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
15 *
16 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
17 * <jketreno@linux.intel.com>
18 *
19 * Copyright (c) 2004, Intel Corporation
20 *
7e272fcf
JL
21 */
22
23#ifndef LIB80211_H
24#define LIB80211_H
25
274bfb8d
JL
26#include <linux/types.h>
27#include <linux/list.h>
60063497 28#include <linux/atomic.h>
274bfb8d
JL
29#include <linux/if.h>
30#include <linux/skbuff.h>
72118015 31#include <linux/ieee80211.h>
a1eb5fe3 32#include <linux/timer.h>
6bbefe86
DH
33#include <linux/seq_file.h>
34
274bfb8d
JL
35#define NUM_WEP_KEYS 4
36
37enum {
38 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
39};
40
de477254
PG
41struct module;
42
274bfb8d
JL
43struct lib80211_crypto_ops {
44 const char *name;
45 struct list_head list;
46
47 /* init new crypto context (e.g., allocate private data space,
48 * select IV, etc.); returns NULL on failure or pointer to allocated
49 * private data on success */
50 void *(*init) (int keyidx);
51
52 /* deinitialize crypto context and free allocated private data */
53 void (*deinit) (void *priv);
54
274bfb8d
JL
55 /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
56 * value from decrypt_mpdu is passed as the keyidx value for
57 * decrypt_msdu. skb must have enough head and tail room for the
58 * encryption; if not, error will be returned; these functions are
59 * called for all MPDUs (i.e., fragments).
60 */
61 int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
62 int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
63
64 /* These functions are called for full MSDUs, i.e. full frames.
65 * These can be NULL if full MSDU operations are not needed. */
66 int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
67 int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
68 void *priv);
69
70 int (*set_key) (void *key, int len, u8 * seq, void *priv);
71 int (*get_key) (void *key, int len, u8 * seq, void *priv);
72
73 /* procfs handler for printing out key information and possible
74 * statistics */
6bbefe86 75 void (*print_stats) (struct seq_file *m, void *priv);
274bfb8d
JL
76
77 /* Crypto specific flag get/set for configuration settings */
78 unsigned long (*get_flags) (void *priv);
79 unsigned long (*set_flags) (unsigned long flags, void *priv);
80
81 /* maximum number of bytes added by encryption; encrypt buf is
82 * allocated with extra_prefix_len bytes, copy of in_buf, and
83 * extra_postfix_len; encrypt need not use all this space, but
84 * the result must start at the beginning of the buffer and correct
85 * length must be returned */
86 int extra_mpdu_prefix_len, extra_mpdu_postfix_len;
87 int extra_msdu_prefix_len, extra_msdu_postfix_len;
88
89 struct module *owner;
90};
91
92struct lib80211_crypt_data {
93 struct list_head list; /* delayed deletion list */
94 struct lib80211_crypto_ops *ops;
95 void *priv;
96 atomic_t refcnt;
97};
98
99struct lib80211_crypt_info {
100 char *name;
101 /* Most clients will already have a lock,
102 so just point to that. */
103 spinlock_t *lock;
104
105 struct lib80211_crypt_data *crypt[NUM_WEP_KEYS];
106 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
107 struct list_head crypt_deinit_list;
108 struct timer_list crypt_deinit_timer;
109 int crypt_quiesced;
110};
111
2ba4b32e
JL
112int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name,
113 spinlock_t *lock);
114void lib80211_crypt_info_free(struct lib80211_crypt_info *info);
274bfb8d
JL
115int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops);
116int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops);
117struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name);
274bfb8d
JL
118void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info,
119 struct lib80211_crypt_data **crypt);
274bfb8d 120
7e272fcf 121#endif /* LIB80211_H */