Skip to content

Commit

Permalink
mac802154: add wpan device-class support
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
alex-bluesman authored and davem330 committed Jun 27, 2012
1 parent 5ac2497 commit 32bad7e
Show file tree
Hide file tree
Showing 8 changed files with 583 additions and 13 deletions.
14 changes: 2 additions & 12 deletions include/linux/nl802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,8 @@ enum {
enum {
__IEEE802154_DEV_INVALID = -1,

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

__IEEE802154_DEV_MAX,
};
Expand Down
8 changes: 8 additions & 0 deletions include/net/mac802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@

#include <net/af_ieee802154.h>

/* General MAC frame format:
* 2 bytes: Frame Control
* 1 byte: Sequence Number
* 20 bytes: Addressing fields
* 14 bytes: Auxiliary Security Header
*/
#define MAC802154_FRAME_HARD_HEADER_LEN (2 + 1 + 20 + 14)

/* The following flags are used to indicate changed address settings from
* the stack to the hardware.
*/
Expand Down
2 changes: 1 addition & 1 deletion net/mac802154/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
obj-$(CONFIG_MAC802154) += mac802154.o
mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o monitor.o
mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o monitor.o wpan.o
4 changes: 4 additions & 0 deletions net/mac802154/ieee802154_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
name, mac802154_monitor_setup);
break;
case IEEE802154_DEV_WPAN:
dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
name, mac802154_wpan_setup);
break;
default:
dev = NULL;
err = -EINVAL;
Expand Down
4 changes: 4 additions & 0 deletions net/mac802154/mac802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ struct mac802154_sub_if_data {
#define MAC802154_CHAN_NONE (~(u8)0) /* No channel is assigned */

extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
extern struct ieee802154_mlme_ops mac802154_mlme_wpan;

int mac802154_slave_open(struct net_device *dev);
int mac802154_slave_close(struct net_device *dev);

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

void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb);
void mac802154_wpan_setup(struct net_device *dev);

netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
u8 page, u8 chan);

Expand Down
4 changes: 4 additions & 0 deletions net/mac802154/mac_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = {
.get_phy = mac802154_get_phy,
};

struct ieee802154_mlme_ops mac802154_mlme_wpan = {
.get_phy = mac802154_get_phy,
};
1 change: 1 addition & 0 deletions net/mac802154/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
}

mac802154_monitors_rx(priv, skb);
mac802154_wpans_rx(priv, skb);
out:
dev_kfree_skb(skb);
return;
Expand Down
Loading

0 comments on commit 32bad7e

Please sign in to comment.