Blame view
net/mac802154/mib.c
5.11 KB
1802d0bee treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
ef2486f55 mac802154: basic ... |
2 3 4 |
/* * Copyright 2007-2012 Siemens AG * |
ef2486f55 mac802154: basic ... |
5 6 7 8 9 10 11 12 13 14 |
* Written by: * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> * Sergey Lapin <slapin@ossfans.org> * Maxim Gorbachyov <maxim.gorbachev@siemens.com> * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> */ #include <linux/if_arp.h> #include <net/mac802154.h> |
b70ab2e87 ieee802154: enfor... |
15 |
#include <net/ieee802154_netdev.h> |
5ad60d369 ieee802154: move ... |
16 |
#include <net/cfg802154.h> |
ef2486f55 mac802154: basic ... |
17 |
|
0f1556bc2 mac802154: move m... |
18 |
#include "ieee802154_i.h" |
59cb300f2 mac802154: use dr... |
19 |
#include "driver-ops.h" |
ef2486f55 mac802154: basic ... |
20 |
|
66b69d4d7 mac802154: page a... |
21 22 |
void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) { |
59d19cd70 mac802154: introd... |
23 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
12439a535 mac802154: remove... |
24 25 |
struct ieee802154_local *local = sdata->local; int res; |
66b69d4d7 mac802154: page a... |
26 |
|
4a3a8c0c3 mac802154: remove... |
27 |
ASSERT_RTNL(); |
66b69d4d7 mac802154: page a... |
28 |
BUG_ON(dev->type != ARPHRD_IEEE802154); |
12439a535 mac802154: remove... |
29 30 31 32 |
res = drv_set_channel(local, page, chan); if (res) { pr_debug("set_channel failed "); |
4710d806f 6lowpan: mac80215... |
33 |
} else { |
12439a535 mac802154: remove... |
34 35 |
local->phy->current_channel = chan; local->phy->current_page = page; |
4710d806f 6lowpan: mac80215... |
36 |
} |
66b69d4d7 mac802154: page a... |
37 |
} |
29e023746 mac802154: add ll... |
38 |
|
29e023746 mac802154: add ll... |
39 40 41 |
int mac802154_get_params(struct net_device *dev, struct ieee802154_llsec_params *params) { |
59d19cd70 mac802154: introd... |
42 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
43 44 45 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
46 47 48 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_get_params(&sdata->sec, params); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
49 50 51 52 53 54 55 56 |
return res; } int mac802154_set_params(struct net_device *dev, const struct ieee802154_llsec_params *params, int changed) { |
59d19cd70 mac802154: introd... |
57 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
58 59 60 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
61 62 63 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_set_params(&sdata->sec, params, changed); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
64 65 66 |
return res; } |
29e023746 mac802154: add ll... |
67 68 69 70 |
int mac802154_add_key(struct net_device *dev, const struct ieee802154_llsec_key_id *id, const struct ieee802154_llsec_key *key) { |
59d19cd70 mac802154: introd... |
71 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
72 73 74 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
75 76 77 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_key_add(&sdata->sec, id, key); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
78 79 80 81 82 83 84 |
return res; } int mac802154_del_key(struct net_device *dev, const struct ieee802154_llsec_key_id *id) { |
59d19cd70 mac802154: introd... |
85 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
86 87 88 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
89 90 91 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_key_del(&sdata->sec, id); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
92 93 94 |
return res; } |
29e023746 mac802154: add ll... |
95 96 97 |
int mac802154_add_dev(struct net_device *dev, const struct ieee802154_llsec_device *llsec_dev) { |
59d19cd70 mac802154: introd... |
98 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
99 100 101 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
102 103 104 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_dev_add(&sdata->sec, llsec_dev); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
105 106 107 108 109 110 |
return res; } int mac802154_del_dev(struct net_device *dev, __le64 dev_addr) { |
59d19cd70 mac802154: introd... |
111 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
112 113 114 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
115 116 117 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_dev_del(&sdata->sec, dev_addr); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
118 119 120 |
return res; } |
29e023746 mac802154: add ll... |
121 122 123 124 |
int mac802154_add_devkey(struct net_device *dev, __le64 device_addr, const struct ieee802154_llsec_device_key *key) { |
59d19cd70 mac802154: introd... |
125 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
126 127 128 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
129 130 131 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_devkey_add(&sdata->sec, device_addr, key); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
132 133 134 135 136 137 138 139 |
return res; } int mac802154_del_devkey(struct net_device *dev, __le64 device_addr, const struct ieee802154_llsec_device_key *key) { |
59d19cd70 mac802154: introd... |
140 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
141 142 143 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
144 145 146 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_devkey_del(&sdata->sec, device_addr, key); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
147 148 149 |
return res; } |
29e023746 mac802154: add ll... |
150 151 152 |
int mac802154_add_seclevel(struct net_device *dev, const struct ieee802154_llsec_seclevel *sl) { |
59d19cd70 mac802154: introd... |
153 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
154 155 156 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
157 158 159 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_seclevel_add(&sdata->sec, sl); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
160 161 162 163 164 165 166 |
return res; } int mac802154_del_seclevel(struct net_device *dev, const struct ieee802154_llsec_seclevel *sl) { |
59d19cd70 mac802154: introd... |
167 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
168 169 170 |
int res; BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
171 172 173 |
mutex_lock(&sdata->sec_mtx); res = mac802154_llsec_seclevel_del(&sdata->sec, sl); mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
174 175 176 |
return res; } |
29e023746 mac802154: add ll... |
177 178 |
void mac802154_lock_table(struct net_device *dev) { |
59d19cd70 mac802154: introd... |
179 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
180 181 |
BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
182 |
mutex_lock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
183 184 185 186 187 |
} void mac802154_get_table(struct net_device *dev, struct ieee802154_llsec_table **t) { |
59d19cd70 mac802154: introd... |
188 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
189 190 |
BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
191 |
*t = &sdata->sec.table; |
29e023746 mac802154: add ll... |
192 193 194 195 |
} void mac802154_unlock_table(struct net_device *dev) { |
59d19cd70 mac802154: introd... |
196 |
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
29e023746 mac802154: add ll... |
197 198 |
BUG_ON(dev->type != ARPHRD_IEEE802154); |
036562f9c mac802154: rename... |
199 |
mutex_unlock(&sdata->sec_mtx); |
29e023746 mac802154: add ll... |
200 |
} |