diff options
author | alex.bluesman.smirnov@gmail.com <alex.bluesman.smirnov@gmail.com> | 2012-05-15 16:50:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-16 15:17:08 -0400 |
commit | ef2486f5538b886ad4f0d1ac0857b518291b48f7 (patch) | |
tree | 2ca4e7f9f7ca50af3dec881942ee14cf7ae115fa /net/mac802154 | |
parent | 6e2128d42af43906d8bcbed7cf2207244fa4301e (diff) |
mac802154: basic mib support
Basic support for IEEE 802.15.4 management information base.
Current implementation contains a command to set HW address only.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac802154')
-rw-r--r-- | net/mac802154/Makefile | 2 | ||||
-rw-r--r-- | net/mac802154/mac802154.h | 3 | ||||
-rw-r--r-- | net/mac802154/mib.c | 93 |
3 files changed, 97 insertions, 1 deletions
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile index 4d9dd0f3b969..6b348b07a765 100644 --- a/net/mac802154/Makefile +++ b/net/mac802154/Makefile | |||
@@ -1,2 +1,2 @@ | |||
1 | obj-$(CONFIG_MAC802154) += mac802154.o | 1 | obj-$(CONFIG_MAC802154) += mac802154.o |
2 | mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o | 2 | mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o |
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h index 7ec2821c574b..7d9a0d4a99fd 100644 --- a/net/mac802154/mac802154.h +++ b/net/mac802154/mac802154.h | |||
@@ -95,4 +95,7 @@ extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced; | |||
95 | netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb, | 95 | netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb, |
96 | u8 page, u8 chan); | 96 | u8 page, u8 chan); |
97 | 97 | ||
98 | /* MIB callbacks */ | ||
99 | void mac802154_dev_set_ieee_addr(struct net_device *dev); | ||
100 | |||
98 | #endif /* MAC802154_H */ | 101 | #endif /* MAC802154_H */ |
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c new file mode 100644 index 000000000000..ab59821ec729 --- /dev/null +++ b/net/mac802154/mib.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
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 | * | ||
13 | * You should have received a copy of the GNU General Public License along | ||
14 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
16 | * | ||
17 | * Written by: | ||
18 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | ||
19 | * Sergey Lapin <slapin@ossfans.org> | ||
20 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> | ||
21 | * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> | ||
22 | */ | ||
23 | |||
24 | #include <linux/if_arp.h> | ||
25 | |||
26 | #include <net/mac802154.h> | ||
27 | #include <net/wpan-phy.h> | ||
28 | |||
29 | #include "mac802154.h" | ||
30 | |||
31 | struct hw_addr_filt_notify_work { | ||
32 | struct work_struct work; | ||
33 | struct net_device *dev; | ||
34 | unsigned long changed; | ||
35 | }; | ||
36 | |||
37 | struct mac802154_priv *mac802154_slave_get_priv(struct net_device *dev) | ||
38 | { | ||
39 | struct mac802154_sub_if_data *priv = netdev_priv(dev); | ||
40 | |||
41 | BUG_ON(dev->type != ARPHRD_IEEE802154); | ||
42 | |||
43 | return priv->hw; | ||
44 | } | ||
45 | |||
46 | static void hw_addr_notify(struct work_struct *work) | ||
47 | { | ||
48 | struct hw_addr_filt_notify_work *nw = container_of(work, | ||
49 | struct hw_addr_filt_notify_work, work); | ||
50 | struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev); | ||
51 | int res; | ||
52 | |||
53 | res = hw->ops->set_hw_addr_filt(&hw->hw, | ||
54 | &hw->hw.hw_filt, | ||
55 | nw->changed); | ||
56 | if (res) | ||
57 | pr_debug("failed changed mask %lx\n", nw->changed); | ||
58 | |||
59 | kfree(nw); | ||
60 | |||
61 | return; | ||
62 | } | ||
63 | |||
64 | static void set_hw_addr_filt(struct net_device *dev, unsigned long changed) | ||
65 | { | ||
66 | struct mac802154_sub_if_data *priv = netdev_priv(dev); | ||
67 | struct hw_addr_filt_notify_work *work; | ||
68 | |||
69 | work = kzalloc(sizeof(*work), GFP_ATOMIC); | ||
70 | if (!work) | ||
71 | return; | ||
72 | |||
73 | INIT_WORK(&work->work, hw_addr_notify); | ||
74 | work->dev = dev; | ||
75 | work->changed = changed; | ||
76 | queue_work(priv->hw->dev_workqueue, &work->work); | ||
77 | |||
78 | return; | ||
79 | } | ||
80 | |||
81 | void mac802154_dev_set_ieee_addr(struct net_device *dev) | ||
82 | { | ||
83 | struct mac802154_sub_if_data *priv = netdev_priv(dev); | ||
84 | struct mac802154_priv *mac = priv->hw; | ||
85 | |||
86 | if (mac->ops->set_hw_addr_filt && | ||
87 | memcmp(mac->hw.hw_filt.ieee_addr, | ||
88 | dev->dev_addr, IEEE802154_ADDR_LEN)) { | ||
89 | memcpy(mac->hw.hw_filt.ieee_addr, | ||
90 | dev->dev_addr, IEEE802154_ADDR_LEN); | ||
91 | set_hw_addr_filt(dev, IEEE802515_AFILT_IEEEADDR_CHANGED); | ||
92 | } | ||
93 | } | ||