blob: d7a25048a8af4be7e7f6c419df19e102044d03b0 [file] [log] [blame]
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +00001/*
2 * Copyright 2007-2012 Siemens AG
3 *
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.
7 *
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.
12 *
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000013 * Written by:
14 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
15 * Sergey Lapin <slapin@ossfans.org>
16 * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
17 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
18 */
19
20#include <linux/if_arp.h>
21
22#include <net/mac802154.h>
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +010023#include <net/ieee802154_netdev.h>
Alexander Aring5ad60d32014-10-25 09:41:02 +020024#include <net/cfg802154.h>
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000025
Alexander Aring0f1556b2014-10-25 09:41:00 +020026#include "ieee802154_i.h"
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000027
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +000028struct phy_chan_notify_work {
29 struct work_struct work;
30 struct net_device *dev;
31};
32
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000033struct hw_addr_filt_notify_work {
34 struct work_struct work;
35 struct net_device *dev;
36 unsigned long changed;
37};
38
Alexander Aringa5e1ec52014-10-25 17:16:35 +020039static struct ieee802154_local *mac802154_slave_get_priv(struct net_device *dev)
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000040{
Alexander Aring59d19cd2014-10-25 17:16:40 +020041 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000042
43 BUG_ON(dev->type != ARPHRD_IEEE802154);
44
Alexander Aring04e850f2014-10-25 17:16:37 +020045 return sdata->local;
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000046}
47
48static void hw_addr_notify(struct work_struct *work)
49{
50 struct hw_addr_filt_notify_work *nw = container_of(work,
51 struct hw_addr_filt_notify_work, work);
Alexander Aringa5e1ec52014-10-25 17:16:35 +020052 struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000053 int res;
54
Alexander Aringa5e1ec52014-10-25 17:16:35 +020055 res = local->ops->set_hw_addr_filt(&local->hw, &local->hw.hw_filt,
56 nw->changed);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000057 if (res)
58 pr_debug("failed changed mask %lx\n", nw->changed);
59
60 kfree(nw);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000061}
62
63static void set_hw_addr_filt(struct net_device *dev, unsigned long changed)
64{
Alexander Aring59d19cd2014-10-25 17:16:40 +020065 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000066 struct hw_addr_filt_notify_work *work;
67
68 work = kzalloc(sizeof(*work), GFP_ATOMIC);
69 if (!work)
70 return;
71
72 INIT_WORK(&work->work, hw_addr_notify);
73 work->dev = dev;
74 work->changed = changed;
Alexander Aring04e850f2014-10-25 17:16:37 +020075 queue_work(sdata->local->dev_workqueue, &work->work);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +000076}
77
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +010078void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val)
alex.bluesman.smirnov@gmail.com48e44d52012-06-25 23:24:50 +000079{
Alexander Aring59d19cd2014-10-25 17:16:40 +020080 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
alex.bluesman.smirnov@gmail.com48e44d52012-06-25 23:24:50 +000081
82 BUG_ON(dev->type != ARPHRD_IEEE802154);
83
Alexander Aring036562f2014-10-25 17:16:36 +020084 spin_lock_bh(&sdata->mib_lock);
85 sdata->short_addr = val;
86 spin_unlock_bh(&sdata->mib_lock);
alex.bluesman.smirnov@gmail.com48e44d52012-06-25 23:24:50 +000087
Alexander Aring04e850f2014-10-25 17:16:37 +020088 if ((sdata->local->ops->set_hw_addr_filt) &&
89 (sdata->local->hw.hw_filt.short_addr != sdata->short_addr)) {
90 sdata->local->hw.hw_filt.short_addr = sdata->short_addr;
Alexander Aring57205c12014-10-25 05:25:09 +020091 set_hw_addr_filt(dev, IEEE802154_AFILT_SADDR_CHANGED);
alex.bluesman.smirnov@gmail.com48e44d52012-06-25 23:24:50 +000092 }
93}
94
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +010095__le16 mac802154_dev_get_short_addr(const struct net_device *dev)
alex.bluesman.smirnov@gmail.come885a472012-07-10 21:22:44 +000096{
Alexander Aring59d19cd2014-10-25 17:16:40 +020097 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +010098 __le16 ret;
alex.bluesman.smirnov@gmail.come885a472012-07-10 21:22:44 +000099
100 BUG_ON(dev->type != ARPHRD_IEEE802154);
101
Alexander Aring036562f2014-10-25 17:16:36 +0200102 spin_lock_bh(&sdata->mib_lock);
103 ret = sdata->short_addr;
104 spin_unlock_bh(&sdata->mib_lock);
alex.bluesman.smirnov@gmail.come885a472012-07-10 21:22:44 +0000105
106 return ret;
107}
108
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +0000109void mac802154_dev_set_ieee_addr(struct net_device *dev)
110{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200111 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Alexander Aring04e850f2014-10-25 17:16:37 +0200112 struct ieee802154_local *local = sdata->local;
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +0000113
Alexander Aring036562f2014-10-25 17:16:36 +0200114 sdata->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr);
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +0100115
Alexander Aringa5e1ec52014-10-25 17:16:35 +0200116 if (local->ops->set_hw_addr_filt &&
Alexander Aring036562f2014-10-25 17:16:36 +0200117 local->hw.hw_filt.ieee_addr != sdata->extended_addr) {
118 local->hw.hw_filt.ieee_addr = sdata->extended_addr;
Alexander Aring57205c12014-10-25 05:25:09 +0200119 set_hw_addr_filt(dev, IEEE802154_AFILT_IEEEADDR_CHANGED);
alex.bluesman.smirnov@gmail.comef2486f2012-05-15 20:50:26 +0000120 }
121}
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000122
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +0100123__le16 mac802154_dev_get_pan_id(const struct net_device *dev)
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000124{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200125 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +0100126 __le16 ret;
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000127
128 BUG_ON(dev->type != ARPHRD_IEEE802154);
129
Alexander Aring036562f2014-10-25 17:16:36 +0200130 spin_lock_bh(&sdata->mib_lock);
131 ret = sdata->pan_id;
132 spin_unlock_bh(&sdata->mib_lock);
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000133
134 return ret;
135}
136
Phoebe Buckheisterb70ab2e2014-03-14 21:23:59 +0100137void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val)
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000138{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200139 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000140
141 BUG_ON(dev->type != ARPHRD_IEEE802154);
142
Alexander Aring036562f2014-10-25 17:16:36 +0200143 spin_lock_bh(&sdata->mib_lock);
144 sdata->pan_id = val;
145 spin_unlock_bh(&sdata->mib_lock);
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000146
Alexander Aring04e850f2014-10-25 17:16:37 +0200147 if ((sdata->local->ops->set_hw_addr_filt) &&
148 (sdata->local->hw.hw_filt.pan_id != sdata->pan_id)) {
149 sdata->local->hw.hw_filt.pan_id = sdata->pan_id;
Alexander Aring57205c12014-10-25 05:25:09 +0200150 set_hw_addr_filt(dev, IEEE802154_AFILT_PANID_CHANGED);
alex.bluesman.smirnov@gmail.comdcbe4f92012-06-25 23:24:49 +0000151 }
152}
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000153
Tony Cheneau04835462013-03-25 17:59:29 +0000154u8 mac802154_dev_get_dsn(const struct net_device *dev)
155{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200156 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Tony Cheneau04835462013-03-25 17:59:29 +0000157
158 BUG_ON(dev->type != ARPHRD_IEEE802154);
159
Alexander Aring036562f2014-10-25 17:16:36 +0200160 return sdata->dsn++;
Tony Cheneau04835462013-03-25 17:59:29 +0000161}
162
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000163static void phy_chan_notify(struct work_struct *work)
164{
165 struct phy_chan_notify_work *nw = container_of(work,
166 struct phy_chan_notify_work, work);
Alexander Aring59d19cd2014-10-25 17:16:40 +0200167 struct net_device *dev = nw->dev;
168 struct ieee802154_local *local = mac802154_slave_get_priv(dev);
169 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000170 int res;
171
Alexander Aring04e850f2014-10-25 17:16:37 +0200172 mutex_lock(&sdata->local->phy->pib_lock);
Alexander Aring036562f2014-10-25 17:16:36 +0200173 res = local->ops->set_channel(&local->hw, sdata->page, sdata->chan);
Varka Bhadram4710d802014-07-02 09:01:09 +0530174 if (res) {
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000175 pr_debug("set_channel failed\n");
Varka Bhadram4710d802014-07-02 09:01:09 +0530176 } else {
Alexander Aring04e850f2014-10-25 17:16:37 +0200177 sdata->local->phy->current_channel = sdata->chan;
178 sdata->local->phy->current_page = sdata->page;
Alan Ott9f7f78b2013-04-05 13:03:10 +0000179 }
Alexander Aring04e850f2014-10-25 17:16:37 +0200180 mutex_unlock(&sdata->local->phy->pib_lock);
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000181
182 kfree(nw);
183}
184
185void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
186{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200187 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000188 struct phy_chan_notify_work *work;
189
190 BUG_ON(dev->type != ARPHRD_IEEE802154);
191
Alexander Aring036562f2014-10-25 17:16:36 +0200192 spin_lock_bh(&sdata->mib_lock);
193 sdata->page = page;
194 sdata->chan = chan;
195 spin_unlock_bh(&sdata->mib_lock);
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000196
Alexander Aring04e850f2014-10-25 17:16:37 +0200197 mutex_lock(&sdata->local->phy->pib_lock);
198 if (sdata->local->phy->current_channel != sdata->chan ||
199 sdata->local->phy->current_page != sdata->page) {
200 mutex_unlock(&sdata->local->phy->pib_lock);
Alan Ott9f7f78b2013-04-05 13:03:10 +0000201
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000202 work = kzalloc(sizeof(*work), GFP_ATOMIC);
203 if (!work)
204 return;
205
206 INIT_WORK(&work->work, phy_chan_notify);
207 work->dev = dev;
Alexander Aring04e850f2014-10-25 17:16:37 +0200208 queue_work(sdata->local->dev_workqueue, &work->work);
Varka Bhadram4710d802014-07-02 09:01:09 +0530209 } else {
Alexander Aring04e850f2014-10-25 17:16:37 +0200210 mutex_unlock(&sdata->local->phy->pib_lock);
Varka Bhadram4710d802014-07-02 09:01:09 +0530211 }
alex.bluesman.smirnov@gmail.com66b69d42012-06-25 23:24:51 +0000212}
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200213
214
215int mac802154_get_params(struct net_device *dev,
216 struct ieee802154_llsec_params *params)
217{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200218 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200219 int res;
220
221 BUG_ON(dev->type != ARPHRD_IEEE802154);
222
Alexander Aring036562f2014-10-25 17:16:36 +0200223 mutex_lock(&sdata->sec_mtx);
224 res = mac802154_llsec_get_params(&sdata->sec, params);
225 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200226
227 return res;
228}
229
230int mac802154_set_params(struct net_device *dev,
231 const struct ieee802154_llsec_params *params,
232 int changed)
233{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200234 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200235 int res;
236
237 BUG_ON(dev->type != ARPHRD_IEEE802154);
238
Alexander Aring036562f2014-10-25 17:16:36 +0200239 mutex_lock(&sdata->sec_mtx);
240 res = mac802154_llsec_set_params(&sdata->sec, params, changed);
241 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200242
243 return res;
244}
245
246
247int mac802154_add_key(struct net_device *dev,
248 const struct ieee802154_llsec_key_id *id,
249 const struct ieee802154_llsec_key *key)
250{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200251 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200252 int res;
253
254 BUG_ON(dev->type != ARPHRD_IEEE802154);
255
Alexander Aring036562f2014-10-25 17:16:36 +0200256 mutex_lock(&sdata->sec_mtx);
257 res = mac802154_llsec_key_add(&sdata->sec, id, key);
258 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200259
260 return res;
261}
262
263int mac802154_del_key(struct net_device *dev,
264 const struct ieee802154_llsec_key_id *id)
265{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200266 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200267 int res;
268
269 BUG_ON(dev->type != ARPHRD_IEEE802154);
270
Alexander Aring036562f2014-10-25 17:16:36 +0200271 mutex_lock(&sdata->sec_mtx);
272 res = mac802154_llsec_key_del(&sdata->sec, id);
273 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200274
275 return res;
276}
277
278
279int mac802154_add_dev(struct net_device *dev,
280 const struct ieee802154_llsec_device *llsec_dev)
281{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200282 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200283 int res;
284
285 BUG_ON(dev->type != ARPHRD_IEEE802154);
286
Alexander Aring036562f2014-10-25 17:16:36 +0200287 mutex_lock(&sdata->sec_mtx);
288 res = mac802154_llsec_dev_add(&sdata->sec, llsec_dev);
289 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200290
291 return res;
292}
293
294int mac802154_del_dev(struct net_device *dev, __le64 dev_addr)
295{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200296 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200297 int res;
298
299 BUG_ON(dev->type != ARPHRD_IEEE802154);
300
Alexander Aring036562f2014-10-25 17:16:36 +0200301 mutex_lock(&sdata->sec_mtx);
302 res = mac802154_llsec_dev_del(&sdata->sec, dev_addr);
303 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200304
305 return res;
306}
307
308
309int mac802154_add_devkey(struct net_device *dev,
310 __le64 device_addr,
311 const struct ieee802154_llsec_device_key *key)
312{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200313 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200314 int res;
315
316 BUG_ON(dev->type != ARPHRD_IEEE802154);
317
Alexander Aring036562f2014-10-25 17:16:36 +0200318 mutex_lock(&sdata->sec_mtx);
319 res = mac802154_llsec_devkey_add(&sdata->sec, device_addr, key);
320 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200321
322 return res;
323}
324
325int mac802154_del_devkey(struct net_device *dev,
326 __le64 device_addr,
327 const struct ieee802154_llsec_device_key *key)
328{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200329 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200330 int res;
331
332 BUG_ON(dev->type != ARPHRD_IEEE802154);
333
Alexander Aring036562f2014-10-25 17:16:36 +0200334 mutex_lock(&sdata->sec_mtx);
335 res = mac802154_llsec_devkey_del(&sdata->sec, device_addr, key);
336 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200337
338 return res;
339}
340
341
342int mac802154_add_seclevel(struct net_device *dev,
343 const struct ieee802154_llsec_seclevel *sl)
344{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200345 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200346 int res;
347
348 BUG_ON(dev->type != ARPHRD_IEEE802154);
349
Alexander Aring036562f2014-10-25 17:16:36 +0200350 mutex_lock(&sdata->sec_mtx);
351 res = mac802154_llsec_seclevel_add(&sdata->sec, sl);
352 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200353
354 return res;
355}
356
357int mac802154_del_seclevel(struct net_device *dev,
358 const struct ieee802154_llsec_seclevel *sl)
359{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200360 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200361 int res;
362
363 BUG_ON(dev->type != ARPHRD_IEEE802154);
364
Alexander Aring036562f2014-10-25 17:16:36 +0200365 mutex_lock(&sdata->sec_mtx);
366 res = mac802154_llsec_seclevel_del(&sdata->sec, sl);
367 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200368
369 return res;
370}
371
372
373void mac802154_lock_table(struct net_device *dev)
374{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200375 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200376
377 BUG_ON(dev->type != ARPHRD_IEEE802154);
378
Alexander Aring036562f2014-10-25 17:16:36 +0200379 mutex_lock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200380}
381
382void mac802154_get_table(struct net_device *dev,
383 struct ieee802154_llsec_table **t)
384{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200385 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200386
387 BUG_ON(dev->type != ARPHRD_IEEE802154);
388
Alexander Aring036562f2014-10-25 17:16:36 +0200389 *t = &sdata->sec.table;
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200390}
391
392void mac802154_unlock_table(struct net_device *dev)
393{
Alexander Aring59d19cd2014-10-25 17:16:40 +0200394 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200395
396 BUG_ON(dev->type != ARPHRD_IEEE802154);
397
Alexander Aring036562f2014-10-25 17:16:36 +0200398 mutex_unlock(&sdata->sec_mtx);
Phoebe Buckheister29e02372014-05-16 17:46:42 +0200399}