drm/omap: Fix error handling path in 'omap_dmm_probe()'
[linux/fpc-iii.git] / net / mac802154 / llsec.h
blob6f3b658e3279cc536859cbe4f36927eafaa5c19c
1 /*
2 * Copyright (C) 2014 Fraunhofer ITWM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * Written by:
14 * Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
17 #ifndef MAC802154_LLSEC_H
18 #define MAC802154_LLSEC_H
20 #include <linux/slab.h>
21 #include <linux/hashtable.h>
22 #include <linux/kref.h>
23 #include <linux/spinlock.h>
24 #include <net/af_ieee802154.h>
25 #include <net/ieee802154_netdev.h>
27 struct mac802154_llsec_key {
28 struct ieee802154_llsec_key key;
30 /* one tfm for each authsize (4/8/16) */
31 struct crypto_aead *tfm[3];
32 struct crypto_skcipher *tfm0;
34 struct kref ref;
37 struct mac802154_llsec_device_key {
38 struct ieee802154_llsec_device_key devkey;
40 struct rcu_head rcu;
43 struct mac802154_llsec_device {
44 struct ieee802154_llsec_device dev;
46 struct hlist_node bucket_s;
47 struct hlist_node bucket_hw;
49 /* protects dev.frame_counter and the elements of dev.keys */
50 spinlock_t lock;
52 struct rcu_head rcu;
55 struct mac802154_llsec_seclevel {
56 struct ieee802154_llsec_seclevel level;
58 struct rcu_head rcu;
61 struct mac802154_llsec {
62 struct ieee802154_llsec_params params;
63 struct ieee802154_llsec_table table;
65 DECLARE_HASHTABLE(devices_short, 6);
66 DECLARE_HASHTABLE(devices_hw, 6);
68 /* protects params, all other fields are fine with RCU */
69 rwlock_t lock;
72 void mac802154_llsec_init(struct mac802154_llsec *sec);
73 void mac802154_llsec_destroy(struct mac802154_llsec *sec);
75 int mac802154_llsec_get_params(struct mac802154_llsec *sec,
76 struct ieee802154_llsec_params *params);
77 int mac802154_llsec_set_params(struct mac802154_llsec *sec,
78 const struct ieee802154_llsec_params *params,
79 int changed);
81 int mac802154_llsec_key_add(struct mac802154_llsec *sec,
82 const struct ieee802154_llsec_key_id *id,
83 const struct ieee802154_llsec_key *key);
84 int mac802154_llsec_key_del(struct mac802154_llsec *sec,
85 const struct ieee802154_llsec_key_id *key);
87 int mac802154_llsec_dev_add(struct mac802154_llsec *sec,
88 const struct ieee802154_llsec_device *dev);
89 int mac802154_llsec_dev_del(struct mac802154_llsec *sec,
90 __le64 device_addr);
92 int mac802154_llsec_devkey_add(struct mac802154_llsec *sec,
93 __le64 dev_addr,
94 const struct ieee802154_llsec_device_key *key);
95 int mac802154_llsec_devkey_del(struct mac802154_llsec *sec,
96 __le64 dev_addr,
97 const struct ieee802154_llsec_device_key *key);
99 int mac802154_llsec_seclevel_add(struct mac802154_llsec *sec,
100 const struct ieee802154_llsec_seclevel *sl);
101 int mac802154_llsec_seclevel_del(struct mac802154_llsec *sec,
102 const struct ieee802154_llsec_seclevel *sl);
104 int mac802154_llsec_encrypt(struct mac802154_llsec *sec, struct sk_buff *skb);
105 int mac802154_llsec_decrypt(struct mac802154_llsec *sec, struct sk_buff *skb);
107 #endif /* MAC802154_LLSEC_H */