DRAFT: IEEE 802.15.4 MAC layer basic implementation
Subsystems (3)
Hello all,
The IEEE 802.15.4 Working Group focuses on the standardization of the bottom two layers of ISO/OSI protocol stack: Physical (PHY) and MAC. The MAC layer provides access control to a shared channel and reliable data delivery. The main functions performed by the MAC sublayer are:
association and disassociation, security control, optional star network topology functions, such as beacon generation and Guaranteed Time Slots (GTSs) management, generation of ACK frames (if used), and, finally, application support for the two possible network topologies described in the standard.
This stack has working implementation in 'linux-zigbee.sourceforge.net' project, but unfortunately all the development was freezed according to unknown issue and it hasn't been merged to mailnline.
Currently I'm the one engineer who continue working on them. So the following patch series is based on the project mentioned above, and I just cut code into roudimentary pieces with minor fixes.
The code in the following patches was tested by 6LowPAN module. I took at230 transciever driver from 'linux-zigbee' and brought up IPv6 network, it worked.
Could please anyone review patches and let me know what do you think?
With best regards,
Alexander Smirnov
PATCH 1/12 mac802154: basic ieee802.15.4 device structures
The IEEE 802.15.4 Working Group focuses on the standardization of the bottom two layers of ISO/OSI protocol stack: Physical (PHY) and MAC. The MAC layer provides access control to a shared channel and reliable data delivery. The main functions performed by the MAC sublayer are:
association and disassociation, security control, optional star network topology functions, such as beacon generation and Guaranteed Time Slots (GTSs) management, generation of ACK frames (if used), and, finally, application support for the two possible network topologies described in the standard.
This is initial commit describes main data structure for ieee802.15.4 compatible devices representation for MAC layer and callbacks for communication with PHY and upper layers.
--- include/net/mac802154.h | 146 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 146 insertions(+), 0 deletions(-) create mode 100644 include/net/mac802154.h
include/net/mac802154.h new file +146 -0
@@ -0,0 +1,146 @@ +/* +* IEEE802.15.4-2003 specification +* +* Copyright (C) 2007-2011 Siemens AG +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#ifndef NET_MAC802154_H +#define NET_MAC802154_H + +/* size of ieee802.15.4 address in octets */ +#define IEEE802154_ALEN 8 + +/** +* enum ieee802154_hw_addr_filt_flags - hardware flags +* +* These flags are used to indicate changed address settings from +* the stack to the hardware. +* +* @IEEE802515_SADDR_CHANGED: +* Indicates that the Short Address changed +* +* @IEEE802515_IEEEADDR_CHANGED: +* Indicates that the IEEE Address changed +* +* @IEEE802515_PANID_CHANGED: +* Indicates that the PAN ID changed +* +* @IEEE802515_PANC_CHANGED: +* Indicates that PAN Coordinator status changed +*/ +enum ieee802154_hw_addr_filt_flags { +IEEE802515_SADDR_CHANGED =1 <<0 , +IEEE802515_IEEEADDR_CHANGED =1 <<1 , +IEEE802515_PANID_CHANGED =1 <<2 , +IEEE802515_PANC_CHANGED =1 <<3 , +}; + +struct ieee802154_hw_addr_filt { +u16 pan_id; +u16 short_addr; +u8 ieee_addr[IEEE802154_ALEN ]; +u8 pan_coord; +}; + +struct ieee802154_dev { +/* filled by the driver */ +int extra_tx_headroom;/* headroom to reserve for tx skb */ +u32 flags;/* Flags for device to set */ +struct device *parent; + +/* filled by mac802154 core */ +struct ieee802154_hw_addr_filt hw_filt; +void *priv;/* driver-specific data */ +struct wpan_phy *phy; +}; + +/* Checksum is in hardware and is omitted from packet */ +/** +* enum ieee802154_hw_flags - hardware flags +* +* These flags are used to indicate hardware capabilities to +* the stack. Generally, flags here should have their meaning +* done in a way that the simplest hardware doesn't need setting +* any particular flags. There are some exceptions to this rule, +* however, so you are advised to review these flags carefully. +* +* @IEEE802154_HW_OMIT_CKSUM: +* Indicates that receiver omits FCS and transmitter will add +* FCS on it's own. +* +* @IEEE802154_HW_AACK: +* Indicates that receiver will autorespond with ACK frames. +*/ +enum ieee802154_hw_flags { +IEEE802154_HW_OMIT_CKSUM =1 <<0 , +IEEE802154_HW_AACK =1 <<1 , +}; + +/** +* struct ieee802154_ops - callbacks from mac802154 to the driver +* +* This structure contains various callbacks that the driver may +* handle or, in some cases, must handle, for example to transmit +* a frame. +* +* @start: Handler that 802.15.4 module calls for device initialisation. +* This function is called before the first interface is attached. +* +* @stop: Handler that 802.15.4 module calls for device cleanup +* This function is called after the last interface is removed. +* +* @xmit: Handler that 802.15.4 module calls for each transmitted frame. +* skb cntains the buffer starting from the IEEE 802.15.4 header. +* The low-level driver should send the frame based on available +* configuration. +* This function should return zero or negative errno. +* Called with pib_lock held. +* +* @ed: Handler that 802.15.4 module calls for Energy Detection. +* This function should place the value for detected energy +* (usually device-dependant) in the level pointer and return +* either zero or negative errno. +* Called with pib_lock held. +* +* @set_channel: Set radio for listening on specific channel. +* Set the device for listening on specified channel. +* Returns either zero, or negative errno. +* Called with pib_lock held. +* +* @set_hw_addr_filt: Set radio for listening on specific address. +* Set the device for listening on specified address. +* Returns either zero, or negative errno. +*/ +struct ieee802154_ops { +struct module *owner; +int (*start)(struct ieee802154_dev *dev); +void (*stop)(struct ieee802154_dev *dev); +int (*xmit)(struct ieee802154_dev *dev, +struct sk_buff *skb); +int (*ed)(struct ieee802154_dev *dev,u8 *level); +int (*set_channel)(struct ieee802154_dev *dev, +int page, +int channel); +int (*set_hw_addr_filt)(struct ieee802154_dev *dev, +struct ieee802154_hw_addr_filt *filt, +unsigned long changed); +int (*ieee_addr)(struct ieee802154_dev *dev, +u8 addr[IEEE802154_ALEN ]); +}; + +int ieee802154_register_device (struct ieee802154_dev *dev); +void ieee802154_unregister_device (struct ieee802154_dev *dev); + +#endif /* NET_MAC802154_H */
Signature · 1 line
1.7.2.3
PATCH 2/12 mac802154: allocation of ieee802154 device
In reply to Alexander SmirnovInterface for device drivers to allocate and register ieee802154 compatible devices and bind callbacks.
--- net/Kconfig | 1 + net/Makefile | 1 + net/mac802154/Kconfig | 16 +++++ net/mac802154/Makefile | 2 + net/mac802154/ieee802154_dev.c | 121 ++++++++++++++++++++++++++++++++++++++++ net/mac802154/mac802154.h | 56 ++++++++++++++++++ 6 files changed, 197 insertions(+), 0 deletions(-) create mode 100644 net/mac802154/Kconfig create mode 100644 net/mac802154/Makefile create mode 100644 net/mac802154/ieee802154_dev.c create mode 100644 net/mac802154/mac802154.h
net/Kconfig +1 -0
@@ -211,6 +211,7 @@ source "net/econet/Kconfig" source "net/wanrouter/Kconfig" source "net/phonet/Kconfig" source "net/ieee802154/Kconfig" +source "net/mac802154/Kconfig" source "net/sched/Kconfig" source "net/dcb/Kconfig" source "net/dns_resolver/Kconfig"
net/Makefile +1 -0
@@ -60,6 +60,7 @@ ifneq ($(CONFIG_DCB),) obj-y += dcb/ endif obj-$(CONFIG_IEEE802154) += ieee802154/ +obj-$(CONFIG_MAC802154) += mac802154/ ifeq ($(CONFIG_NET),y) obj-$(CONFIG_SYSCTL) += sysctl_net.o
net/mac802154/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +config MAC802154 + tristate "Generic IEEE 802.15.4 Soft Networking Stack (mac802154)" + depends on IEEE802154 && EXPERIMENTAL + select CRC_CCITT + ---help--- + This option enables the hardware independent IEEE 802.15.4 + networking stack for SoftMAC devices (the ones implementing + only PHY level of IEEE 802.15.4 standard). + + Note: this implementation is neither certified, nor feature + complete! Compatibility with other implementations isn't + tested! + + If you plan to use HardMAC IEEE 802.15.4 devices, you can + say N here. Alternatievly you can say M to compile it as + module.
net/mac802154/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_MAC802154) += mac802154.o +mac802154-objs := ieee802154_dev.o
net/mac802154/ieee802154_dev.c new file +121 -0
121 lines not on this page · raw message
net/mac802154/mac802154.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 4/12 mac802154: TX data path
In reply to Alexander SmirnovMain TX data path implementation between upper and physical layers.
--- net/mac802154/Makefile | 2 +- net/mac802154/ieee802154_dev.c | 3 +- net/mac802154/tx.c | 102 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 net/mac802154/tx.c
net/mac802154/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_MAC802154) += mac802154.o -mac802154-objs := ieee802154_dev.o rx.o +mac802154-objs := ieee802154_dev.o rx.o tx.o
net/mac802154/ieee802154_dev.c +2 -1
@@ -31,7 +31,8 @@ struct ieee802154_dev *ieee802154_alloc_device(size_t priv_size,struct wpan_phy *phy;struct mac802154_priv *priv; -if (!ops || !ops->xmit || !ops->ed || !ops->start || !ops->stop) { +if (!ops || !ops->xmit || !ops->ed || !ops->start || !ops->stop || + !ops->set_channel) {printk (KERN_ERR "Undefined IEEE802.15.4 device operations\n" );return NULL ;
net/mac802154/tx.c new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 6/12 mac802154: MIB support
In reply to Alexander SmirnovSupport for IEEE 802.15.4 management information base, routine like setting of HW address, PAN id, channel etc...
--- include/linux/if.h | 3 + net/mac802154/Makefile | 2 +- net/mac802154/mac802154.h | 22 ++++ net/mac802154/mib.c | 247 +++++++++++++++++++++++++++++++++++++++++++++ net/mac802154/mib.h | 35 +++++++ 5 files changed, 308 insertions(+), 1 deletions(-) create mode 100644 net/mac802154/mib.c create mode 100644 net/mac802154/mib.h
include/linux/if.h +3 -0
@@ -76,6 +76,9 @@#define IFF_BRIDGE_PORT 0x4000/* device used as bridge port */ #define IFF_OVS_DATAPATH 0x8000/* device used as Open vSwitch * datapath port */ + +#define IFF_IEEE802154_COORD 0x400/* IEEE802.15.4 PAN coordinator */ +#define IFF_TX_SKB_SHARING 0x10000/* The interface supports sharing * skbs on transmit */ #define IFF_UNICAST_FLT 0x20000/* Supports unicast filtering */
net/mac802154/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_MAC802154) += mac802154.o -mac802154-objs := ieee802154_dev.o rx.o tx.o +mac802154-objs := ieee802154_dev.o rx.o tx.o mib.o
net/mac802154/mac802154.h +22 -0
@@ -53,4 +53,26 @@ struct mac802154_priv {#define mac802154_to_priv (_hw) container_of(_hw, struct mac802154_priv, hw) +struct mac802154_sub_if_data { +struct list_head list;/* the ieee802154_priv->slaves list */ + +struct mac802154_priv *hw; +struct net_device *dev; + +int type; + +spinlock_t mib_lock; + +u16 pan_id; +u16 short_addr; + +u8 chan; +u8 page; + +/* MAC BSN field */ +u8 bsn; +/* MAC DSN field */ +u8 dsn; +}; +#endif /* MAC802154_H */
net/mac802154/mib.c new file +247 -0
247 lines not on this page · raw message
net/mac802154/mib.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright 2008 Siemens AG +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +*/ + +#ifndef MIB802154_H +#define MIB802154_H + +/* MIB API */ +u8 mac802154_dev_get_dsn (const struct net_device *dev); +u8 mac802154_dev_get_bsn (const struct net_device *dev); +u16 mac802154_dev_get_pan_id (const struct net_device *dev); +u16 mac802154_dev_get_short_addr (const struct net_device *dev); +void mac802154_dev_set_pan_id (struct net_device *dev,u16 val); +void mac802154_dev_set_pan_coord (struct net_device *dev); +void mac802154_dev_set_short_addr (struct net_device *dev,u16 val); +void mac802154_dev_set_ieee_addr (struct net_device *dev); +void mac802154_dev_set_page_channel (struct net_device *dev,u8 page,u8 chan); +struct wpan_phy *mac802154_get_phy (const struct net_device *dev); +struct mac802154_priv *mac802154_slave_get_priv (struct net_device *dev); + +#endif
Signature · 1 line
1.7.2.3
PATCH 9/12 ieee802154: type of device to be added
In reply to Alexander SmirnovDevice type argument is added to callback which creates interface.
--- include/net/wpan-phy.h | 2 +- net/ieee802154/nl-phy.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
include/net/wpan-phy.h +1 -1
@@ -42,7 +42,7 @@ struct wpan_phy {int idx;struct net_device *(*add_iface)(struct wpan_phy *phy, -const char *name); +const char *name,int type);void (*del_iface)(struct wpan_phy *phy,struct net_device *dev); char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
net/ieee802154/nl-phy.c +2 -1
@@ -179,6 +179,7 @@ static int ieee802154_add_iface(struct sk_buff *skb,const char *devname;int rc = -ENOBUFS ;struct net_device *dev; +int type = -EINVAL ;pr_debug ("%s\n" , __func__);
@@ -221,7 +222,7 @@ static int ieee802154_add_iface(struct sk_buff *skb, goto nla_put_failure; } - dev = phy->add_iface (phy, devname); + dev = phy->add_iface (phy, devname, type);if (IS_ERR (dev)) { rc =PTR_ERR (dev); goto nla_put_failure;
Signature · 1 line
1.7.2.3
PATCH 11/12 mac802154: base support for wpan device
In reply to Alexander SmirnovBase support for wpan device. By wpan device it means any IEEE 802.15.4 compatible transciever. This code attaches wpan device to networking stack.
--- include/linux/nl802154.h | 6 + include/net/wpan-phy.h | 2 + net/mac802154/Makefile | 2 +- net/mac802154/ieee802154_dev.c | 5 +- net/mac802154/mac802154.h | 17 ++ net/mac802154/rx.c | 1 + net/mac802154/wpan.c | 613 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 644 insertions(+), 2 deletions(-) create mode 100644 net/mac802154/wpan.c
include/linux/nl802154.h +6 -0
@@ -124,4 +124,10 @@ enum {#define IEEE802154_CMD_MAX (__IEEE802154_CMD_MAX - 1) +enum { +IEEE802154_DEV_WPAN , + + __IEEE802154_DEV_MAX, +}; +#endif
include/net/wpan-phy.h +2 -0
@@ -24,6 +24,8 @@#include <linux/netdevice.h> #include <linux/mutex.h> +#define IEEE802154_WPAN_NUM_PAGES 32 +struct wpan_phy {struct mutex pib_lock;
net/mac802154/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_MAC802154) += mac802154.o -mac802154-objs := ieee802154_dev.o rx.o tx.o mib.o mac_cmd.o +mac802154-objs := ieee802154_dev.o rx.o tx.o mib.o mac_cmd.o wpan.o
net/mac802154/ieee802154_dev.c +4 -1
@@ -130,8 +130,11 @@ static struct net_device *mac802154_add_iface(struct wpan_phy *phy,struct net_device *dev;int err = -ENOMEM ; -/* No devices is currently supported */ switch (type) { +case IEEE802154_DEV_WPAN : + dev =alloc_netdev (sizeof (struct mac802154_sub_if_data ), + name, mac802154_wpan_setup); +break ;default : dev =NULL ; err = -EINVAL ;
net/mac802154/mac802154.h +17 -0
@@ -23,6 +23,12 @@ #ifndef MAC802154_H #define MAC802154_H +/* + * FC SeqNum DPAN DA SA Sec + * 2 + 1 + 2 + 8 + 8 + 14 = 37 + */ +#define MAC802154_MAX_MHR_SIZE 37 + struct mac802154_priv { struct ieee802154_dev hw; struct ieee802154_ops *ops;
@@ -75,4 +81,15 @@ struct mac802154_sub_if_data { u8 dsn; }; +extern struct ieee802154_mlme_ops mac802154_mlme_wpan; + +void mac802154_wpan_setup (struct net_device *dev); + +void mac802154_wpans_rx (struct mac802154_priv *priv,struct sk_buff *skb); +netdev_tx_t mac802154_tx (struct mac802154_priv *priv,struct sk_buff *skb, +u8 page,u8 chan); +int mac802154_slave_open (struct net_device *dev); +int mac802154_slave_close (struct net_device *dev); +int mac802154_process_cmd (struct net_device *dev,struct sk_buff *skb); +#endif /* MAC802154_H */
net/mac802154/rx.c +1 -0
@@ -59,6 +59,7 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi) }skb_trim (skb, skb->len -2 );/* CRC */ } +mac802154_wpans_rx (priv, skb); out:dev_kfree_skb (skb);
net/mac802154/wpan.c new file +613 -0
613 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 12/12 ieee802154: set default device as wpan
In reply to Alexander SmirnovSet default device type to wpan during creating interface.
--- net/ieee802154/nl-phy.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ieee802154/nl-phy.c +1 -1
@@ -179,7 +179,7 @@ static int ieee802154_add_iface(struct sk_buff *skb,const char *devname;int rc = -ENOBUFS ;struct net_device *dev; -int type = -EINVAL ; +int type =IEEE802154_DEV_WPAN ;pr_debug ("%s\n" , __func__);
Signature · 1 line
1.7.2.3
PATCH 3/12 mac802154: RX data path
In reply to a message not in the archiveMain RX data path implementation between physical and upper layers.
--- include/net/ieee802154_netdev.h | 2 + include/net/mac802154.h | 4 ++ net/mac802154/Kconfig | 2 +- net/mac802154/Makefile | 2 +- net/mac802154/rx.c | 106 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 net/mac802154/rx.c
include/net/ieee802154_netdev.h +2 -0
@@ -26,6 +26,8 @@#ifndef IEEE802154_NETDEVICE_H #define IEEE802154_NETDEVICE_H +#include <net/af_ieee802154.h> +/* * A control block of skb passed between the ARPHRD_IEEE802154 device * and other stack parts.
include/net/mac802154.h +4 -0
@@ -143,4 +143,8 @@ struct ieee802154_ops {int ieee802154_register_device (struct ieee802154_dev *dev);void ieee802154_unregister_device (struct ieee802154_dev *dev); +void ieee802154_rx (struct ieee802154_dev *dev,struct sk_buff *skb,u8 lqi); +void ieee802154_rx_irqsafe (struct ieee802154_dev *dev,struct sk_buff *skb, +u8 lqi); +#endif /* NET_MAC802154_H */
net/mac802154/Kconfig +1 -1
@@ -9,7 +9,7 @@ config MAC802154 Note: this implementation is neither certified, nor feature complete! Compatibility with other implementations isn't - tested! + tested yet! If you plan to use HardMAC IEEE 802.15.4 devices, you can say N here. Alternatievly you can say M to compile it as
net/mac802154/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_MAC802154) += mac802154.o -mac802154-objs := ieee802154_dev.o +mac802154-objs := ieee802154_dev.o rx.o
net/mac802154/rx.c new file +106 -0
106 lines not on this page · raw message
Signature · 9 lines
1.7.2.3 ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
PATCH 5/12 ieee802154: remove ieee802154 policy from globals
In reply to a message not in the archiveMove ieee802154_policy array definition inside ieee802154 layer.
--- include/linux/nl802154.h | 2 -- net/ieee802154/ieee802154.h | 2 ++ net/ieee802154/wpan-class.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
include/linux/nl802154.h +0 -2
@@ -74,8 +74,6 @@ enum {#define IEEE802154_ATTR_MAX (__IEEE802154_ATTR_MAX - 1) -extern const struct nla_policy ieee802154_policy[]; -/* commands */ /* REQ should be responded with CONF * and INDIC with RESP
net/ieee802154/ieee802154.h +2 -0
@@ -21,6 +21,8 @@int __init ieee802154_nl_init (void ); void __exit ieee802154_nl_exit(void); +extern const struct nla_policy ieee802154_policy[]; +#define IEEE802154_OP (_cmd, _func) \ { \ .cmd = _cmd, \
net/ieee802154/wpan-class.c +1 -0
@@ -21,6 +21,7 @@#include <linux/module.h> #include <linux/device.h> +#include <net/netlink.h> #include <net/wpan-phy.h> #include "ieee802154.h"
Signature · 9 lines
1.7.2.3 ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
PATCH 7/12 ieee802154: define simplified mlme interface
In reply to a message not in the archiveDefine light-weight mlme interface.
--- include/net/ieee802154_netdev.h | 11 +++++++++++ net/ieee802154/nl-mac.c | 2 +- 2 files changed, 12 insertions(+), 1 deletions(-)
include/net/ieee802154_netdev.h +11 -0
@@ -83,7 +83,12 @@ struct wpan_phy;* get_phy should increment the reference counting on returned phy. * Use wpan_wpy_put to put that reference. */ +struct simple_mlme_ops { +struct wpan_phy *(*get_phy)(const struct net_device *dev); +};struct ieee802154_mlme_ops { +struct simple_mlme_ops wpan_ops; +int (*assoc_req)(struct net_device *dev,struct ieee802154_addr *addr,u8 channel,u8 page,u8 cap);
@@ -112,6 +117,12 @@ struct ieee802154_mlme_ops {u8 (*get_bsn)(const struct net_device *dev); }; +static inline struct simple_mlme_ops *simple_mlme_ops ( +const struct net_device *dev) +{ +return dev->ml_priv; +} +static inline struct ieee802154_mlme_ops *ieee802154_mlme_ops (const struct net_device *dev) {
net/ieee802154/nl-mac.c +1 -1
@@ -263,7 +263,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid,if (!hdr) goto out; - phy =ieee802154_mlme_ops (dev)->get_phy (dev); + phy =simple_mlme_ops (dev)->get_phy (dev);BUG_ON (!phy);NLA_PUT_STRING (msg,IEEE802154_ATTR_DEV_NAME , dev->name);
Signature · 9 lines
1.7.2.3 ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
PATCH 8/12 mac802154: MAC commands support
In reply to a message not in the archiveSupport for MAC layer commands. Currently association and disassociation are implemented only.
--- net/mac802154/Makefile | 2 +- net/mac802154/mac_cmd.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 301 insertions(+), 1 deletions(-) create mode 100644 net/mac802154/mac_cmd.c
net/mac802154/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_MAC802154) += mac802154.o -mac802154-objs := ieee802154_dev.o rx.o tx.o mib.o +mac802154-objs := ieee802154_dev.o rx.o tx.o mib.o mac_cmd.o
net/mac802154/mac_cmd.c new file +300 -0
300 lines not on this page · raw message
Signature · 9 lines
1.7.2.3 ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
PATCH 10/12 mac802154: bind network iface to phy
In reply to a message not in the archiveTransciever slaves manipulation. Each slave represents network interface in user space and is described by net_device structure. One transciever may support several slaves and be connected to several networks at the same time.
--- net/mac802154/ieee802154_dev.c | 147 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 147 insertions(+), 0 deletions(-)
net/mac802154/ieee802154_dev.c +147 -0
@@ -18,12 +18,143 @@#include <linux/kernel.h> #include <linux/netdevice.h> +#include <linux/nl802154.h> #include <net/route.h> #include <net/mac802154.h> #include <net/wpan-phy.h> #include "mac802154.h" +#include "mib.h" + +int mac802154_slave_open (struct net_device *dev) +{ +struct mac802154_sub_if_data *priv =netdev_priv (dev); +int res =0 ; + +if (priv->hw->open_count++ ==0 ) { + res = priv->hw->ops->start (&priv->hw->hw); +WARN_ON (res); +if (res) + goto err; + } + +if (priv->hw->ops->ieee_addr) { + res = priv->hw->ops->ieee_addr (&priv->hw->hw, dev->dev_addr); +WARN_ON (res); +if (res) + goto err; +mac802154_dev_set_ieee_addr (dev); + } + +netif_start_queue (dev); +return 0 ; +err: + priv->hw->open_count--; + +return res; +} + +int mac802154_slave_close (struct net_device *dev) +{ +struct mac802154_sub_if_data *priv =netdev_priv (dev); + + dev->priv_flags &= ~IFF_IEEE802154_COORD ; + +netif_stop_queue (dev); + +if ((--priv->hw->open_count) ==0 ) + priv->hw->ops->stop (&priv->hw->hw); + +return 0 ; +} + +static int mac802154_netdev_register (struct wpan_phy *phy, +struct net_device *dev) +{ +struct mac802154_sub_if_data *priv; +struct mac802154_priv *ipriv; +int err; + + ipriv =wpan_phy_priv (phy); + + priv =netdev_priv (dev); + priv->dev = dev; + priv->hw = ipriv; + + dev->needed_headroom = ipriv->hw.extra_tx_headroom; + +SET_NETDEV_DEV (dev, &ipriv->phy->dev); + +mutex_lock (&ipriv->slaves_mtx); +if (!ipriv->running) { +mutex_unlock (&ipriv->slaves_mtx); +return -ENODEV ; + } +mutex_unlock (&ipriv->slaves_mtx); + + err =register_netdev (dev); +if (err <0 ) +return err; + +rtnl_lock (); +mutex_lock (&ipriv->slaves_mtx); +list_add_tail_rcu (&priv->list, &ipriv->slaves); +mutex_unlock (&ipriv->slaves_mtx); +rtnl_unlock (); + +return 0 ; +} + +static void mac802154_del_iface (struct wpan_phy *phy, +struct net_device *dev) +{ +struct mac802154_sub_if_data *sdata; +ASSERT_RTNL (); + + sdata =netdev_priv (dev); + +BUG_ON (sdata->hw->phy != phy); + +mutex_lock (&sdata->hw->slaves_mtx); +list_del_rcu (&sdata->list); +mutex_unlock (&sdata->hw->slaves_mtx); + +synchronize_rcu (); +unregister_netdevice (sdata->dev); +} + +static struct net_device *mac802154_add_iface (struct wpan_phy *phy, +const char *name,int type) +{ +struct net_device *dev; +int err = -ENOMEM ; + +/* No devices is currently supported */ +switch (type) { +default : + dev =NULL ; + err = -EINVAL ; +break ; + } +if (!dev) + goto err; + + + err =mac802154_netdev_register (phy, dev); + +if (err) + goto err_free; + +dev_hold (dev);/* we return a device w/ incremented refcount */ +return dev; + +err_free: +free_netdev (dev); +err: +return ERR_PTR (err); +} +struct ieee802154_dev *ieee802154_alloc_device (size_t priv_size,struct ieee802154_ops *ops)
@@ -61,6 +192,8 @@ void ieee802154_free_device(struct ieee802154_dev *hw) {struct mac802154_priv *priv =mac802154_to_priv (hw); +BUG_ON (!list_empty (&priv->slaves)); +wpan_phy_free (priv->phy);mutex_destroy (&priv->slaves_mtx);
@@ -80,6 +213,9 @@ int ieee802154_register_device(struct ieee802154_dev *dev)wpan_phy_set_dev (priv->phy, priv->hw.parent); + priv->phy->add_iface = mac802154_add_iface; + priv->phy->del_iface = mac802154_del_iface; + rc =wpan_phy_register (priv->phy);if (rc <0 ) goto out_wq;
@@ -99,9 +235,12 @@ out: }EXPORT_SYMBOL (ieee802154_register_device); + +void ieee802154_unregister_device (struct ieee802154_dev *dev) {struct mac802154_priv *priv =mac802154_to_priv (dev); +struct mac802154_sub_if_data *sdata, *next;flush_workqueue (priv->dev_workqueue);destroy_workqueue (priv->dev_workqueue);
@@ -112,6 +251,14 @@ void ieee802154_unregister_device(struct ieee802154_dev *dev) priv->running =0 ;mutex_unlock (&priv->slaves_mtx); +list_for_each_entry_safe (sdata, next, &priv->slaves, list) { +mutex_lock (&sdata->hw->slaves_mtx); +list_del (&sdata->list); +mutex_unlock (&sdata->hw->slaves_mtx); + +unregister_netdevice (sdata->dev); + } +rtnl_unlock ();wpan_phy_unregister (priv->phy);
Signature · 9 lines
1.7.2.3 ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d
Re: [PATCH 04/12] [MAC802154] mac802154: TX data path
In reply to Alexander SmirnovHello,
Quoted 29 lines · Alexander Smirnov
Main TX data path implementation between upper and physical layers.
Signed-off-by Alexander Smirnov <[email protected]>---
net/mac802154/Makefile | 2 +-net/mac802154/ieee802154_dev.c| 3 +-
net/mac802154/tx.c | 102 ++++++++++++++++++++++++++++++++++++++++3 files changed, 105 insertions(+), 2 deletions(-)create mode 100644
net/mac802154/tx.cnet/mac802154/Makefile +0
-0@@ -1,2 +1,2 @@obj-$(CONFIG_MAC802154) += mac802154.o
net/mac802154/Makefile +1
-1-mac802154-objs := ieee802154_dev.o rx.o +mac802154-objs := ieee802154_dev.o rx.o tx.onet/mac802154/ieee802154_dev.c +2
-1@@ -31,7 +31,8 @@ struct ieee802154_dev *ieee802154_alloc_device(size_t priv_size, struct wpan_phy *phy; struct mac802154_priv *priv; - if (!ops || !ops->xmit || !ops->ed || !ops->start || !ops->stop) { + if (!ops || !ops->xmit || !ops->ed || !ops->start || !ops->stop || + !ops->set_channel) {
Quoted 3 lines
printk(KERN_ERR
"Undefined IEEE802.15.4 device operations\n"); return NULL;
Shan't this be present in one of the previous patches instead? Because it's illogical to include the check here and not before, if you define set_channel
operation in previous patch.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 06/12] [MAC802154] mac802154: MIB support
In reply to Alexander SmirnovHello,
Quoted 19 lines · Alexander Smirnov
Support for IEEE 802.15.4 management information base, routine like setting of HW address, PAN id, channel etc...
Signed-off-by Alexander Smirnov <[email protected]>---
include/linux/if.h | 3 +
net/mac802154/Makefile | 2 +-
net/mac802154/mac802154.h | 22 ++++
net/mac802154/mib.c | 247 +++++++++++++++++++++++++++++++++++++++++++++net/mac802154/mib.h| 35 +++++++5 files changed, 308 insertions(+), 1 deletions(-)create mode 100644
net/mac802154/mib.c
create mode 100644net/mac802154/mib.hinclude/linux/if.h +0
-0
include/linux/if.h line 81
Quoted 6 lines
include/linux/if.h +3
-0@@ -76,6 +76,9 @@ #define IFF_BRIDGE_PORT 0x4000 /* device used as bridge port */ #define IFF_OVS_DATAPATH 0x8000 /* device used as Open vSwitch* datapath port */ + +#define IFF_IEEE802154_COORD 0x400/* IEEE802.15.4 PAN coordinator */ +
I remember this define, but I don't remember why we did it this way. Is it suitable
to use this namespace for device-specific flags?
Quoted 3 lines
include/linux/if.h +0
-0#define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing* skbs on transmit */ #define IFF_UNICAST_FLT 0x20000 /* Supports unicast filtering */
Signature · 2 lines
With best wishes Dmitry
Hello colleagues,
On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov <[email protected]> wrote:
[skipped]
Quoted 7 lines
This stack has working implementation in 'linux-zigbee.sourceforge.net' project, but unfortunately all the development was freezed according to unknown issue and it hasn't been merged to mailnline.
Currently I'm the one engineer who continue working on them. So the following patch series is based on the project mentioned above, and I just cut code into roudimentary pieces with minor fixes.
Alexander, thank you for continuing the work on the project! I'm glad to see those patches being submitted to the mainline kernel.
Quoted 4 lines
The code in the following patches was tested by 6LowPAN module. I took at230 transciever driver from 'linux-zigbee' and brought up IPv6 network, it worked.
Could please anyone review patches and let me know what do you think?
Several global notes:
1) Could you please include any (virtual or real) device driver implementing the stack.
There was a "virtual radio" driver written for SoftMAC devices. The driver had some small
design problems, but I think the stripped down version can be included in the patchset.
2) Could you please rearrange the patches a little bit:
I'd really like to see the "monitor" devices interface pushed in the first round of the patches.
It depends only on "simple mlme" and "RX/TX datapath" patches IIRC. It would be really
good to merge those things first as it would then allow one to implement their drivers,
check the radio, capture radio frames, etc.
I'll try reviewing patches really soon (as the time permits). However could you please specify,
your changes over the last state I pushed to sf.net git repos (devel or devel-30 branches)
to ease review?
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface
In reply to Alexander SmirnovQuoted 1 line · Alexander Smirnov
Define light-weight mlme interface.
Could you please elaborate, why it is necessary? I created it for the sub-devices
which didn't have full IEEE 802.15.4 MLME (like monitoring devices, SMAC or MiWi,
or other proprietary protocols), but I don't see support for those coming in this patch set.
Quoted 54 lines
Signed-off-by Alexander Smirnov <[email protected]>---
include/net/ieee802154_netdev.h | 11 +++++++++++net/ieee802154/nl-mac.c| 2 +-2 files changed, 12 insertions(+), 1 deletions(-)include/net/ieee802154_netdev.h +11
-0@@ -83,7 +83,12 @@ struct wpan_phy;* get_phy should increment the reference counting on returned phy. * Use wpan_wpy_put to put that reference. */ +struct simple_mlme_ops { + struct wpan_phy *(*get_phy)(const struct net_device *dev); +}; struct ieee802154_mlme_ops { + struct simple_mlme_ops wpan_ops; + int (*assoc_req)(struct net_device *dev, struct ieee802154_addr *addr, u8 channel, u8 page, u8 cap);@@ -112,6 +117,12 @@ struct ieee802154_mlme_ops { u8 (*get_bsn)(const struct net_device *dev); }; +static inline struct simple_mlme_ops *simple_mlme_ops ( + const struct net_device *dev) +{ + return dev->ml_priv; +} +static inline struct
ieee802154_mlme_ops*ieee802154_mlme_ops( const structnet_device*dev)
{net/ieee802154/nl-mac.c +1
-2@@ -263,7 +263,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid, if (!hdr) goto out; - phy = ieee802154_mlme_ops(dev)->get_phy(dev); + phy = simple_mlme_ops(dev)->get_phy(dev); BUG_ON(!phy); NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); --1.7.2.3
Signature · 2 lines
With best wishes Dmitry
Hello Dmitry,
thank you for the reply,
2011/11/30 Dmitry Eremin-Solenikov <[email protected]>:
Quoted 23 lines
Hello colleagues,
On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov <[email protected]> wrote:
[skipped]
Quoted 7 lines
This stack has working implementation in 'linux-zigbee.sourceforge.net' project, but unfortunately all the development was freezed according to unknown issue and it hasn't been merged to mailnline.
Currently I'm the one engineer who continue working on them. So the following patch series is based on the project mentioned above, and I just cut code into roudimentary pieces with minor fixes.
Alexander, thank you for continuing the work on the project! I'm glad to see those patches being submitted to the mainline kernel.
Quoted 4 lines
The code in the following patches was tested by 6LowPAN module. I took at230 transciever driver from 'linux-zigbee' and brought up IPv6 network, it worked.
Could please anyone review patches and let me know what do you think?
Quoted 8 lines
Several global notes:
1) Could you please include any (virtual or real) device driver implementing the stack.
There was a "virtual radio" driver written for SoftMAC devices. The driver had some small
design problems, but I think the stripped down version can be included in the patchset.
do you think that's a good idea to mix several layers in one patch series? Won't it be better to push some basic MAC support and only after the drivers? I see that way a little bit easier for code review.
But if you don't think so, it's not a problem.
Quoted 10 lines
2) Could you please rearrange the patches a little bit:
I'd really like to see the "monitor" devices interface pushed in the first round of the patches.
It depends only on "simple mlme" and "RX/TX datapath" patches IIRC. It would be really
good to merge those things first as it would then allow one to implement their drivers,
check the radio, capture radio frames, etc.
Hmm, sounds good. I agree with this roadmap. :)
Quoted 6 lines
I'll try reviewing patches really soon (as the time permits). However could you please specify,
your changes over the last state I pushed to sf.net git repos (devel or devel-30 branches)
to ease review?
The changes are really small and they don't affect the code structure/logic: using of common style in debug output, rewrite 'fetch_skb' functions, remove several unused lines etc...
Quoted 3 lines
--
With best wishes
Dmitry
With best regards,
Alexander
Hello,
Quoted 31 lines · Alexander Smirnov
2011/11/30 Dmitry Eremin-Solenikov <[email protected]>:
Quoted 21 lines
On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov <[email protected]> wrote:
[skipped]
Quoted 7 lines
This stack has working implementation in 'linux-zigbee.sourceforge.net' project, but unfortunately all the development was freezed according to unknown issue and it hasn't been merged to mailnline.
Currently I'm the one engineer who continue working on them. So the following patch series is based on the project mentioned above, and I just cut code into roudimentary pieces with minor fixes.
Alexander, thank you for continuing the work on the project! I'm glad to see those patches being submitted to the mainline kernel.
Quoted 4 lines
The code in the following patches was tested by 6LowPAN module. I took at230 transciever driver from 'linux-zigbee' and brought up IPv6 network, it worked.
Could please anyone review patches and let me know what do you think?
Quoted 8 lines
Several global notes:
1) Could you please include any (virtual or real) device driver implementing the stack.
There was a "virtual radio" driver written for SoftMAC devices. The driver had some small
design problems, but I think the stripped down version can be included in the patchset.
Quoted 5 lines
do you think that's a good idea to mix several layers in one patch series? Won't it be better to push some basic MAC support and only after the drivers? I see that way a little bit easier for code review.
But if you don't think so, it's not a problem.
I think it's a good thing to include at least one sample driver (event if it's a fake one).
Quoted 11 lines
Quoted 10 lines
2) Could you please rearrange the patches a little bit:
I'd really like to see the "monitor" devices interface pushed in the first round of the patches.
It depends only on "simple mlme" and "RX/TX datapath" patches IIRC. It would be really
good to merge those things first as it would then allow one to implement their drivers,
check the radio, capture radio frames, etc.
Quoted 1 line
Hmm, sounds good. I agree with this roadmap. :)
You might be interested in checking a MiWi protocols (from Microchip IIRC). One of them was an IEEE 802.15.4 based protocol with lot's of features stirpped out (I think you can find documentation in some of the Microchip applicaiton notes, I either left the docs in Siemens, or I have them in my home, I'll check later). That not-so-standard might be a good 'second step' on the path to full IEEE 802.15.4 compliance.
Quoted 11 lines
Quoted 7 lines
I'll try reviewing patches really soon (as the time permits). However could you please specify,
your changes over the last state I pushed to sf.net git repos (devel or devel-30 branches)
to ease review?The changes are really small and they don't affect the code structure/logic: using of common style in debug output, rewrite '
fetch_skb' functions, remove several unused lines etc...
Fine with me then.
Signature · 2 lines
With best wishes Dmitry