Skip to content

Commit 32bad7e

Browse files
alex-bluesmandavem330
authored andcommitted
mac802154: add wpan device-class support
Every real 802.15.4 transceiver, which works with software MAC layer, can be classified as a wpan device in this stack. So the wpan device implementation provides missing link in datapath between the device drivers and the Linux network queue. According to the IEEE 802.15.4 standard each packet can be one of the following types: - beacon - MAC layer command - ACK - data This patch adds support for the data packet-type only, but this is enough to perform data transmission and receiving over radio. Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5ac2497 commit 32bad7e

8 files changed

Lines changed: 583 additions & 13 deletions

File tree

‎include/linux/nl802154.h‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,8 @@ enum {
130130
enum {
131131
__IEEE802154_DEV_INVALID = -1,
132132

133-
/* TODO:
134-
* Nowadays three device types supported by this stack at linux-zigbee
135-
* project: WPAN = 0, MONITOR = 1 and SMAC = 2.
136-
*
137-
* Since this stack implementation exists many years, it's definitely
138-
* bad idea to change the assigned values due to they are already used
139-
* by third-party userspace software like: iz-tools, wireshark...
140-
*
141-
* Currently only monitor device is added and initialized by '1' for
142-
* compatibility.
143-
*/
144-
IEEE802154_DEV_MONITOR = 1,
133+
IEEE802154_DEV_WPAN,
134+
IEEE802154_DEV_MONITOR,
145135

146136
__IEEE802154_DEV_MAX,
147137
};

‎include/net/mac802154.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121

2222
#include <net/af_ieee802154.h>
2323

24+
/* General MAC frame format:
25+
* 2 bytes: Frame Control
26+
* 1 byte: Sequence Number
27+
* 20 bytes: Addressing fields
28+
* 14 bytes: Auxiliary Security Header
29+
*/
30+
#define MAC802154_FRAME_HARD_HEADER_LEN (2 + 1 + 20 + 14)
31+
2432
/* The following flags are used to indicate changed address settings from
2533
* the stack to the hardware.
2634
*/

‎net/mac802154/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
obj-$(CONFIG_MAC802154) += mac802154.o
2-
mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o monitor.o
2+
mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o monitor.o wpan.o

‎net/mac802154/ieee802154_dev.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
140140
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
141141
name, mac802154_monitor_setup);
142142
break;
143+
case IEEE802154_DEV_WPAN:
144+
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
145+
name, mac802154_wpan_setup);
146+
break;
143147
default:
144148
dev = NULL;
145149
err = -EINVAL;

‎net/mac802154/mac802154.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,17 @@ struct mac802154_sub_if_data {
9393
#define MAC802154_CHAN_NONE (~(u8)0) /* No channel is assigned */
9494

9595
extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
96+
extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
9697

9798
int mac802154_slave_open(struct net_device *dev);
9899
int mac802154_slave_close(struct net_device *dev);
99100

100101
void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb);
101102
void mac802154_monitor_setup(struct net_device *dev);
102103

104+
void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb);
105+
void mac802154_wpan_setup(struct net_device *dev);
106+
103107
netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
104108
u8 page, u8 chan);
105109

‎net/mac802154/mac_cmd.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
4343
struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = {
4444
.get_phy = mac802154_get_phy,
4545
};
46+
47+
struct ieee802154_mlme_ops mac802154_mlme_wpan = {
48+
.get_phy = mac802154_get_phy,
49+
};

‎net/mac802154/rx.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
7777
}
7878

7979
mac802154_monitors_rx(priv, skb);
80+
mac802154_wpans_rx(priv, skb);
8081
out:
8182
dev_kfree_skb(skb);
8283
return;

0 commit comments

Comments
 (0)