netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation
@ 2011-11-30 14:18 Alexander Smirnov
  2011-11-30 14:22 ` [PATCH 01/12] [MAC802154] mac802154: basic ieee802.15.4 device structures Alexander Smirnov
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:18 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, alex.bluesman.smirnov

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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 01/12] [MAC802154] mac802154: basic ieee802.15.4 device structures
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
@ 2011-11-30 14:22 ` Alexander Smirnov
  2011-11-30 14:23 ` [PATCH 02/12] [MAC802154] mac802154: allocation of ieee802154 device Alexander Smirnov
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:22 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, Alexander Smirnov

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.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 include/net/mac802154.h |  146 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 146 insertions(+), 0 deletions(-)
 create mode 100644 include/net/mac802154.h

diff --git a/include/net/mac802154.h b/include/net/mac802154.h
new file mode 100644
index 0000000..1b1b1f2
--- /dev/null
+++ b/include/net/mac802154.h
@@ -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 */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 02/12] [MAC802154] mac802154: allocation of ieee802154 device
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
  2011-11-30 14:22 ` [PATCH 01/12] [MAC802154] mac802154: basic ieee802.15.4 device structures Alexander Smirnov
@ 2011-11-30 14:23 ` Alexander Smirnov
  2011-11-30 14:23 ` [PATCH 04/12] [MAC802154] mac802154: TX data path Alexander Smirnov
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:23 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, Alexander Smirnov

Interface for device drivers to allocate and register ieee802154
compatible devices and bind callbacks.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 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

diff --git a/net/Kconfig b/net/Kconfig
index 63d2c5d..bac101a 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -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"
diff --git a/net/Makefile b/net/Makefile
index acdde49..1969e93 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -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
diff --git a/net/mac802154/Kconfig b/net/mac802154/Kconfig
new file mode 100644
index 0000000..7ab24f8
--- /dev/null
+++ b/net/mac802154/Kconfig
@@ -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.
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
new file mode 100644
index 0000000..cda9393
--- /dev/null
+++ b/net/mac802154/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_MAC802154)	+= mac802154.o
+mac802154-objs		:= ieee802154_dev.o
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
new file mode 100644
index 0000000..42f95b2
--- /dev/null
+++ b/net/mac802154/ieee802154_dev.c
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <net/route.h>
+
+#include <net/mac802154.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+
+struct ieee802154_dev *ieee802154_alloc_device(size_t priv_size,
+		struct ieee802154_ops *ops)
+{
+	struct wpan_phy *phy;
+	struct mac802154_priv *priv;
+
+	if (!ops || !ops->xmit || !ops->ed || !ops->start || !ops->stop) {
+		printk(KERN_ERR
+			"Undefined IEEE802.15.4 device operations\n");
+		return NULL;
+	}
+
+	phy = wpan_phy_alloc(ALIGN(sizeof(*priv), NETDEV_ALIGN) + priv_size);
+	if (!phy) {
+		printk(KERN_ERR
+			"Failure to initialize master IEEE802154 device\n");
+		return NULL;
+	}
+
+	priv = wpan_phy_priv(phy);
+	priv->hw.phy = priv->phy = phy;
+	priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN);
+	priv->ops = ops;
+
+	INIT_LIST_HEAD(&priv->slaves);
+	mutex_init(&priv->slaves_mtx);
+
+	return &priv->hw;
+}
+EXPORT_SYMBOL(ieee802154_alloc_device);
+
+void ieee802154_free_device(struct ieee802154_dev *hw)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
+
+	wpan_phy_free(priv->phy);
+
+	mutex_destroy(&priv->slaves_mtx);
+}
+EXPORT_SYMBOL(ieee802154_free_device);
+
+
+int ieee802154_register_device(struct ieee802154_dev *dev)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(dev);
+	int rc = -ENOMEM;
+
+	priv->dev_workqueue =
+		create_singlethread_workqueue(wpan_phy_name(priv->phy));
+	if (!priv->dev_workqueue)
+		goto out;
+
+	wpan_phy_set_dev(priv->phy, priv->hw.parent);
+
+	rc = wpan_phy_register(priv->phy);
+	if (rc < 0)
+		goto out_wq;
+
+	rtnl_lock();
+	mutex_lock(&priv->slaves_mtx);
+	priv->running = 1;
+	mutex_unlock(&priv->slaves_mtx);
+	rtnl_unlock();
+
+	return 0;
+
+out_wq:
+	destroy_workqueue(priv->dev_workqueue);
+out:
+	return rc;
+}
+EXPORT_SYMBOL(ieee802154_register_device);
+
+void ieee802154_unregister_device(struct ieee802154_dev *dev)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(dev);
+
+	flush_workqueue(priv->dev_workqueue);
+	destroy_workqueue(priv->dev_workqueue);
+
+	rtnl_lock();
+
+	mutex_lock(&priv->slaves_mtx);
+	priv->running = 0;
+	mutex_unlock(&priv->slaves_mtx);
+
+	rtnl_unlock();
+
+	wpan_phy_unregister(priv->phy);
+}
+EXPORT_SYMBOL(ieee802154_unregister_device);
+
+MODULE_DESCRIPTION("IEEE 802.15.4 implementation");
+MODULE_LICENSE("GPL v2");
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
new file mode 100644
index 0000000..99c16ac
--- /dev/null
+++ b/net/mac802154/mac802154.h
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ * Written by:
+ * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
+ * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
+ * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
+ * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
+ */
+#ifndef MAC802154_H
+#define MAC802154_H
+
+struct mac802154_priv {
+	struct ieee802154_dev	hw;
+	struct ieee802154_ops	*ops;
+
+	struct wpan_phy *phy;
+
+	int open_count;
+	/* As in mac80211 slaves list is modified:
+	 * 1) under the RTNL
+	 * 2) protected by slaves_mtx;
+	 * 3) in an RCU manner
+	 *
+	 * So atomic readers can use any of this protection methods
+	 */
+	struct list_head	slaves;
+	struct mutex		slaves_mtx;
+	/* This one is used for scanning and other
+	 * jobs not to be interfered with serial driver */
+	struct workqueue_struct	*dev_workqueue;
+
+	/*
+	 * These flags are also modified under slaves_mtx and RTNL,
+	 * so you can read them using any of protection methods.
+	 */
+	/* SoftMAC device is registered and running. One can add subinterfaces. */
+	unsigned running: 1;
+};
+
+#define mac802154_to_priv(_hw)	container_of(_hw, struct mac802154_priv, hw)
+
+#endif /* MAC802154_H */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 03/12] [MAC802154] mac802154: RX data path
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
@ 2011-11-30 14:23   ` Alexander Smirnov
  2011-11-30 14:24   ` [PATCH 05/12] [IEEE802154] ieee802154: remove ieee802154 policy from globals Alexander Smirnov
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:23 UTC (permalink / raw)
  To: dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Main RX data path implementation between physical and upper layers.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 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

diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
index 5743055..12a7ee4 100644
--- a/include/net/ieee802154_netdev.h
+++ b/include/net/ieee802154_netdev.h
@@ -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.
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 1b1b1f2..7f6474c 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -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 */
diff --git a/net/mac802154/Kconfig b/net/mac802154/Kconfig
index 7ab24f8..9ff82e3 100644
--- a/net/mac802154/Kconfig
+++ b/net/mac802154/Kconfig
@@ -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
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index cda9393..e00fe47 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,2 +1,2 @@
 obj-$(CONFIG_MAC802154)	+= mac802154.o
-mac802154-objs		:= ieee802154_dev.o
+mac802154-objs		:= ieee802154_dev.o rx.o
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
new file mode 100644
index 0000000..1642c48
--- /dev/null
+++ b/net/mac802154/rx.c
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ *
+ * Written by:
+ * Pavel Smolenskiy <pavel.smolenskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ * Maxim Gorbachyov <maxim.gorbachev-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
+ * Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ * Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <linux/netdevice.h>
+#include <linux/crc-ccitt.h>
+
+#include <net/mac802154.h>
+#include <net/ieee802154_netdev.h>
+
+#include "mac802154.h"
+
+static void
+mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(hw);
+
+	BUG_ON(!skb);
+
+	mac_cb(skb)->lqi = lqi;
+	skb->protocol = htons(ETH_P_IEEE802154);
+	skb_reset_mac_header(skb);
+
+	BUILD_BUG_ON(sizeof(struct ieee802154_mac_cb) > sizeof(skb->cb));
+
+	if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
+		u16 crc;
+
+		if (skb->len < 2) {
+			pr_debug("(%s): Got invalid frame\n", __func__);
+			goto out;
+		}
+		crc = crc_ccitt(0, skb->data, skb->len);
+		if (crc) {
+			pr_debug("(%s): CRC mismatch\n", __func__);
+			goto out;
+		}
+		skb_trim(skb, skb->len - 2); /* CRC */
+	}
+
+out:
+	dev_kfree_skb(skb);
+	return;
+}
+
+struct rx_work {
+	struct sk_buff *skb;
+	struct work_struct work;
+	struct ieee802154_dev *dev;
+	u8 lqi;
+};
+
+static void mac802154_rx_worker(struct work_struct *work)
+{
+	struct rx_work *rw = container_of(work, struct rx_work, work);
+	struct sk_buff *skb = rw->skb;
+
+	mac802154_subif_rx(rw->dev, skb, rw->lqi);
+	kfree(rw);
+}
+
+void ieee802154_rx_irqsafe(struct ieee802154_dev *dev,
+		struct sk_buff *skb, u8 lqi)
+{
+	struct mac802154_priv *priv = mac802154_to_priv(dev);
+	struct rx_work *work = kzalloc(sizeof(struct rx_work), GFP_ATOMIC);
+
+	if (!work)
+		return;
+
+	INIT_WORK(&work->work, mac802154_rx_worker);
+	work->skb = skb;
+	work->dev = dev;
+	work->lqi = lqi;
+
+	queue_work(priv->dev_workqueue, &work->work);
+}
+EXPORT_SYMBOL(ieee802154_rx_irqsafe);
+
+void mac802154_rx(struct ieee802154_dev *dev, struct sk_buff *skb, u8 lqi)
+{
+	mac802154_subif_rx(dev, skb, lqi);
+}
+EXPORT_SYMBOL(mac802154_rx);
-- 
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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 04/12] [MAC802154] mac802154: TX data path
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
  2011-11-30 14:22 ` [PATCH 01/12] [MAC802154] mac802154: basic ieee802.15.4 device structures Alexander Smirnov
  2011-11-30 14:23 ` [PATCH 02/12] [MAC802154] mac802154: allocation of ieee802154 device Alexander Smirnov
@ 2011-11-30 14:23 ` Alexander Smirnov
  2011-11-30 15:56   ` Dmitry Eremin-Solenikov
  2011-11-30 14:25 ` [PATCH 06/12] [MAC802154] mac802154: MIB support Alexander Smirnov
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:23 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, Alexander Smirnov

Main TX data path implementation between upper and physical layers.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 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

diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index e00fe47..490beef 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -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
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 42f95b2..e90d336 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -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;
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
new file mode 100644
index 0000000..3325cde
--- /dev/null
+++ b/net/mac802154/tx.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright 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.
+ *
+ * Written by:
+ * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
+ * Sergey Lapin <slapin@ossfans.org>
+ * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
+ */
+
+#include <linux/netdevice.h>
+#include <linux/if_arp.h>
+#include <linux/crc-ccitt.h>
+
+#include <net/mac802154.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+
+struct xmit_work {
+	struct sk_buff *skb;
+	struct work_struct work;
+	struct mac802154_priv *priv;
+	u8 page;
+	u8 chan;
+};
+
+static void mac802154_xmit_worker(struct work_struct *work)
+{
+	struct xmit_work *xw = container_of(work, struct xmit_work, work);
+	int res;
+
+	mutex_lock(&xw->priv->phy->pib_lock);
+	if (xw->priv->phy->current_channel != xw->chan ||
+	    xw->priv->phy->current_page != xw->page) {
+		res = xw->priv->ops->set_channel(&xw->priv->hw,
+				xw->page,
+				xw->chan);
+		if (res) {
+			pr_debug("(%s): set_channel failed\n", __func__);
+			goto out;
+		}
+	}
+
+	res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
+
+out:
+	mutex_unlock(&xw->priv->phy->pib_lock);
+
+	/* FIXME: result processing and/or requeue!!! */
+	dev_kfree_skb(xw->skb);
+
+	kfree(xw);
+}
+
+netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
+		u8 page, u8 chan)
+{
+	struct xmit_work *work;
+
+	if (WARN_ON(!(priv->phy->channels_supported[page] &
+					(1 << chan))))
+		return NETDEV_TX_OK;
+
+	if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
+		u16 crc = crc_ccitt(0, skb->data, skb->len);
+		u8 *data = skb_put(skb, 2);
+		data[0] = crc & 0xff;
+		data[1] = crc >> 8;
+	}
+
+	if (skb_cow_head(skb, priv->hw.extra_tx_headroom)) {
+		dev_kfree_skb(skb);
+		return NETDEV_TX_OK;
+	}
+
+	work = kzalloc(sizeof(struct xmit_work), GFP_ATOMIC);
+	if (!work)
+		return NETDEV_TX_BUSY;
+
+	INIT_WORK(&work->work, mac802154_xmit_worker);
+	work->skb = skb;
+	work->priv = priv;
+	work->page = page;
+	work->chan = chan;
+
+	queue_work(priv->dev_workqueue, &work->work);
+
+	return NETDEV_TX_OK;
+}
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 05/12] [IEEE802154] ieee802154: remove ieee802154 policy from globals
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
  2011-11-30 14:23   ` [PATCH 03/12] [MAC802154] mac802154: RX data path Alexander Smirnov
@ 2011-11-30 14:24   ` Alexander Smirnov
  2011-11-30 14:25   ` [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface Alexander Smirnov
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:24 UTC (permalink / raw)
  To: dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Move ieee802154_policy array definition inside ieee802154 layer.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 include/linux/nl802154.h    |    2 --
 net/ieee802154/ieee802154.h |    2 ++
 net/ieee802154/wpan-class.c |    1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index 33d9f51..d2b5ae2 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -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
diff --git a/net/ieee802154/ieee802154.h b/net/ieee802154/ieee802154.h
index aadec42..e9799af 100644
--- a/net/ieee802154/ieee802154.h
+++ b/net/ieee802154/ieee802154.h
@@ -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,				\
diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c
index 1627ef2..36d32e2 100644
--- a/net/ieee802154/wpan-class.c
+++ b/net/ieee802154/wpan-class.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 
+#include <net/netlink.h>
 #include <net/wpan-phy.h>
 
 #include "ieee802154.h"
-- 
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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 06/12] [MAC802154] mac802154: MIB support
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
                   ` (2 preceding siblings ...)
  2011-11-30 14:23 ` [PATCH 04/12] [MAC802154] mac802154: TX data path Alexander Smirnov
@ 2011-11-30 14:25 ` Alexander Smirnov
  2011-11-30 16:00   ` Dmitry Eremin-Solenikov
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:25 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, 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 <alex.bluesman.smirnov@gmail.com>
---
 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

diff --git a/include/linux/if.h b/include/linux/if.h
index 06b6ef6..deaf14c 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -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	*/
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 490beef..875feb2 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -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
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 99c16ac..752ae6a 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -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 */
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
new file mode 100644
index 0000000..8574bf6
--- /dev/null
+++ b/net/mac802154/mib.c
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2007, 2008, 2009 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.
+ *
+ * Written by:
+ * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
+ * Sergey Lapin <slapin@ossfans.org>
+ * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
+ */
+
+#include <linux/if_arp.h>
+
+#include <net/mac802154.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+#include "mib.h"
+
+struct phy_chan_notify_work {
+	struct work_struct work;
+	struct net_device *dev;
+};
+
+struct hw_addr_filt_notify_work {
+	struct work_struct work;
+	struct net_device *dev;
+	unsigned long changed;
+};
+
+static void hw_addr_notify(struct work_struct *work)
+{
+	struct hw_addr_filt_notify_work *nw =
+		container_of(work, struct hw_addr_filt_notify_work, work);
+	struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev);
+	int res;
+
+	res = hw->ops->set_hw_addr_filt(&hw->hw, &hw->hw.hw_filt, nw->changed);
+	if (res)
+		pr_debug("(%s): failed changed mask %lx\n",
+			__func__, nw->changed);
+
+	kfree(nw);
+
+	return;
+}
+
+static void set_hw_addr_filt(struct net_device *dev, unsigned long changed)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct hw_addr_filt_notify_work *work;
+
+	work = kzalloc(sizeof(*work), GFP_ATOMIC);
+	if (!work)
+		return;
+
+	INIT_WORK(&work->work, hw_addr_notify);
+	work->dev = dev;
+	work->changed = changed;
+	queue_work(priv->hw->dev_workqueue, &work->work);
+
+	return;
+}
+
+static void phy_chan_notify(struct work_struct *work)
+{
+	struct phy_chan_notify_work *nw =
+		container_of(work, struct phy_chan_notify_work, work);
+	struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev);
+	struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
+	int res;
+
+	res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
+	if (res)
+		pr_debug("(%s): set_channel failed\n", __func__);
+
+	kfree(nw);
+
+	return;
+}
+
+u16 mac802154_dev_get_pan_id(const struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	u16 ret;
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	ret = priv->pan_id;
+	spin_unlock_bh(&priv->mib_lock);
+
+	return ret;
+}
+
+u16 mac802154_dev_get_short_addr(const struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	u16 ret;
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	ret = priv->short_addr;
+	spin_unlock_bh(&priv->mib_lock);
+
+	return ret;
+}
+
+void mac802154_dev_set_pan_id(struct net_device *dev, u16 val)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	priv->pan_id = val;
+	spin_unlock_bh(&priv->mib_lock);
+
+	if (priv->hw->ops->set_hw_addr_filt &&
+		(priv->hw->hw.hw_filt.pan_id != priv->pan_id)) {
+		priv->hw->hw.hw_filt.pan_id = priv->pan_id;
+		set_hw_addr_filt(dev, IEEE802515_PANID_CHANGED);
+	}
+}
+
+void mac802154_dev_set_pan_coord(struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	int pan_coord = !!(dev->priv_flags & IFF_IEEE802154_COORD);
+
+	if (priv->hw->ops->set_hw_addr_filt &&
+		(priv->hw->hw.hw_filt.pan_coord != pan_coord)) {
+		priv->hw->hw.hw_filt.pan_coord = pan_coord;
+		set_hw_addr_filt(dev, IEEE802515_PANC_CHANGED);
+	}
+}
+
+void mac802154_dev_set_short_addr(struct net_device *dev, u16 val)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	priv->short_addr = val;
+	spin_unlock_bh(&priv->mib_lock);
+
+	if (priv->hw->ops->set_hw_addr_filt &&
+		(priv->hw->hw.hw_filt.short_addr != priv->short_addr)) {
+		priv->hw->hw.hw_filt.short_addr = priv->short_addr;
+		set_hw_addr_filt(dev, IEEE802515_SADDR_CHANGED);
+	}
+}
+
+void mac802154_dev_set_ieee_addr(struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+	if (priv->hw->ops->set_hw_addr_filt &&
+		memcmp(priv->hw->hw.hw_filt.ieee_addr,
+			dev->dev_addr, IEEE802154_ALEN)) {
+		memcpy(priv->hw->hw.hw_filt.ieee_addr,
+			dev->dev_addr, IEEE802154_ALEN);
+		set_hw_addr_filt(dev, IEEE802515_IEEEADDR_CHANGED);
+	}
+}
+
+void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct phy_chan_notify_work *work;
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	priv->page = page;
+	priv->chan = chan;
+	spin_unlock_bh(&priv->mib_lock);
+
+	if (priv->hw->phy->current_channel != priv->chan ||
+	    priv->hw->phy->current_page != priv->page) {
+		work = kzalloc(sizeof(*work), GFP_ATOMIC);
+		if (!work)
+			return;
+
+		INIT_WORK(&work->work, phy_chan_notify);
+		work->dev = dev;
+		queue_work(priv->hw->dev_workqueue, &work->work);
+	}
+}
+
+u8 mac802154_dev_get_dsn(const struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	u16 ret;
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	ret = priv->dsn++;
+	spin_unlock_bh(&priv->mib_lock);
+
+	return ret;
+}
+
+u8 mac802154_dev_get_bsn(const struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	u16 ret;
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	spin_lock_bh(&priv->mib_lock);
+	ret = priv->bsn++;
+	spin_unlock_bh(&priv->mib_lock);
+
+	return ret;
+}
+
+struct mac802154_priv *mac802154_slave_get_priv(struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	return priv->hw;
+}
+
+struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	return to_phy(get_device(&priv->hw->phy->dev));
+}
diff --git a/net/mac802154/mib.h b/net/mac802154/mib.h
new file mode 100644
index 0000000..a243339
--- /dev/null
+++ b/net/mac802154/mib.h
@@ -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
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
  2011-11-30 14:23   ` [PATCH 03/12] [MAC802154] mac802154: RX data path Alexander Smirnov
  2011-11-30 14:24   ` [PATCH 05/12] [IEEE802154] ieee802154: remove ieee802154 policy from globals Alexander Smirnov
@ 2011-11-30 14:25   ` Alexander Smirnov
  2011-11-30 16:22     ` Dmitry Eremin-Solenikov
  2011-11-30 14:25   ` [PATCH 08/12] [MAC802154] mac802154: MAC commands support Alexander Smirnov
  2011-11-30 14:27   ` [PATCH 10/12] [MAC802154] mac802154: bind network iface to phy Alexander Smirnov
  4 siblings, 1 reply; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:25 UTC (permalink / raw)
  To: dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Define light-weight mlme interface.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 include/net/ieee802154_netdev.h |   11 +++++++++++
 net/ieee802154/nl-mac.c         |    2 +-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
index 12a7ee4..5264b00 100644
--- a/include/net/ieee802154_netdev.h
+++ b/include/net/ieee802154_netdev.h
@@ -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)
 {
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index adaf462..1d23aa6 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -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


------------------------------------------------------------------------------
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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 08/12] [MAC802154] mac802154: MAC commands support
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
                     ` (2 preceding siblings ...)
  2011-11-30 14:25   ` [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface Alexander Smirnov
@ 2011-11-30 14:25   ` Alexander Smirnov
  2011-11-30 14:27   ` [PATCH 10/12] [MAC802154] mac802154: bind network iface to phy Alexander Smirnov
  4 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:25 UTC (permalink / raw)
  To: dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Support for MAC layer commands. Currently association and
disassociation are implemented only.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 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

diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 875feb2..50e2569 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -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
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
new file mode 100644
index 0000000..0013358
--- /dev/null
+++ b/net/mac802154/mac_cmd.c
@@ -0,0 +1,300 @@
+/*
+ * MAC commands interface
+ *
+ * Copyright 2007, 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.
+ *
+ * Written by:
+ * Sergey Lapin <slapin-9cOl001CZnBAfugRpC6u6w@public.gmane.org>
+ * Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ */
+
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+#include <linux/if_arp.h>
+#include <net/af_ieee802154.h>
+#include <net/mac802154.h>
+#include <net/ieee802154.h>
+#include <net/ieee802154_netdev.h>
+#include <net/nl802154.h>
+
+#include "mac802154.h"
+#include "mib.h"
+
+static int mac802154_cmd_assoc_req(struct sk_buff *skb)
+{
+	u8 cap;
+
+	if (skb->len != 2)
+		return -EINVAL;
+
+	if (skb->pkt_type != PACKET_HOST)
+		return 0;
+
+	if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_LONG ||
+	    mac_cb(skb)->sa.pan_id != IEEE802154_PANID_BROADCAST)
+		return -EINVAL;
+
+	/*
+	 * FIXME: check that we allow incoming ASSOC requests
+	 * by consulting MIB
+	 */
+
+	cap = skb->data[1];
+
+	return ieee802154_nl_assoc_indic(skb->dev, &mac_cb(skb)->sa, cap);
+}
+
+static int mac802154_cmd_assoc_resp(struct sk_buff *skb)
+{
+	u8 status;
+	u16 short_addr;
+
+	if (skb->len != 4)
+		return -EINVAL;
+
+	if (skb->pkt_type != PACKET_HOST)
+		return 0;
+
+	if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_LONG ||
+	    mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_LONG ||
+	    !(mac_cb(skb)->flags & MAC_CB_FLAG_INTRAPAN))
+		return -EINVAL;
+
+	/* FIXME: check that we requested association ? */
+
+	status = skb->data[3];
+	short_addr = skb->data[1] | (skb->data[2] << 8);
+	pr_info("Received ASSOC-RESP status %x, addr %hx\n", status,
+			short_addr);
+	if (status) {
+		mac802154_dev_set_short_addr(skb->dev,
+				IEEE802154_ADDR_BROADCAST);
+		mac802154_dev_set_pan_id(skb->dev,
+				IEEE802154_PANID_BROADCAST);
+	} else
+		mac802154_dev_set_short_addr(skb->dev, short_addr);
+
+	return ieee802154_nl_assoc_confirm(skb->dev, short_addr, status);
+}
+
+static int mac802154_cmd_disassoc_notify(struct sk_buff *skb)
+{
+	u8 reason;
+
+	if (skb->len != 2)
+		return -EINVAL;
+
+	if (skb->pkt_type != PACKET_HOST)
+		return 0;
+
+	if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_LONG ||
+	    (mac_cb(skb)->da.addr_type != IEEE802154_ADDR_LONG &&
+	     mac_cb(skb)->da.addr_type != IEEE802154_ADDR_SHORT) ||
+	    mac_cb(skb)->sa.pan_id != mac_cb(skb)->da.pan_id)
+		return -EINVAL;
+
+	reason = skb->data[1];
+
+	/* FIXME: checks if this was our coordinator and the disassoc us */
+	/* FIXME: if we device, one should receive ->da and not ->sa */
+	/* FIXME: the status should also help */
+
+	return ieee802154_nl_disassoc_indic(skb->dev, &mac_cb(skb)->sa,
+			reason);
+}
+
+int mac802154_process_cmd(struct net_device *dev, struct sk_buff *skb)
+{
+	u8 cmd;
+
+	if (skb->len < 1) {
+		pr_warning("Uncomplete command frame!\n");
+		goto drop;
+	}
+
+	cmd = *(skb->data);
+	pr_debug("(%s): command %02x on device %s\n",
+					__func__, cmd, dev->name);
+
+	switch (cmd) {
+	case IEEE802154_CMD_ASSOCIATION_REQ:
+		mac802154_cmd_assoc_req(skb);
+		break;
+	case IEEE802154_CMD_ASSOCIATION_RESP:
+		mac802154_cmd_assoc_resp(skb);
+		break;
+	case IEEE802154_CMD_DISASSOCIATION_NOTIFY:
+		mac802154_cmd_disassoc_notify(skb);
+		break;
+	case IEEE802154_CMD_BEACON_REQ:
+	default:
+		pr_debug("(%s): frame type is not supported yet\n", __func__);
+		goto drop;
+	}
+
+
+	kfree_skb(skb);
+	return NET_RX_SUCCESS;
+
+drop:
+	kfree_skb(skb);
+	return NET_RX_DROP;
+}
+
+static int mac802154_send_cmd(struct net_device *dev,
+		struct ieee802154_addr *addr, struct ieee802154_addr *saddr,
+		const u8 *buf, int len)
+{
+	struct sk_buff *skb;
+	int err;
+	int hlen = LL_RESERVED_SPACE(dev), tlen = dev->needed_tailroom;
+
+	BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+	skb = alloc_skb(hlen + tlen + len, GFP_KERNEL);
+	if (!skb)
+		return -ENOMEM;
+
+	skb_reserve(skb, hlen);
+
+	skb_reset_network_header(skb);
+
+	mac_cb(skb)->flags = IEEE802154_FC_TYPE_MAC_CMD | MAC_CB_FLAG_ACKREQ;
+	mac_cb(skb)->seq = ieee802154_mlme_ops(dev)->get_dsn(dev);
+	err = dev_hard_header(skb, dev, ETH_P_IEEE802154, addr, saddr, len);
+	if (err < 0) {
+		kfree_skb(skb);
+		return err;
+	}
+
+	skb_reset_mac_header(skb);
+	memcpy(skb_put(skb, len), buf, len);
+
+	skb->dev = dev;
+	skb->protocol = htons(ETH_P_IEEE802154);
+
+	return dev_queue_xmit(skb);
+}
+
+static int mac802154_mlme_assoc_req(struct net_device *dev,
+		struct ieee802154_addr *addr, u8 channel, u8 page, u8 cap)
+{
+	struct ieee802154_addr saddr;
+	u8 buf[2];
+	int pos = 0;
+
+	saddr.addr_type = IEEE802154_ADDR_LONG;
+	saddr.pan_id = IEEE802154_PANID_BROADCAST;
+	memcpy(saddr.hwaddr, dev->dev_addr, IEEE802154_ADDR_LEN);
+
+
+	/* FIXME: set PIB/MIB info */
+	mac802154_dev_set_pan_id(dev, addr->pan_id);
+	mac802154_dev_set_page_channel(dev, page, channel);
+	mac802154_dev_set_ieee_addr(dev);
+
+	buf[pos++] = IEEE802154_CMD_ASSOCIATION_REQ;
+	buf[pos++] = cap;
+
+	return mac802154_send_cmd(dev, addr, &saddr, buf, pos);
+}
+
+static int mac802154_mlme_assoc_resp(struct net_device *dev,
+		struct ieee802154_addr *addr, u16 short_addr, u8 status)
+{
+	struct ieee802154_addr saddr;
+	u8 buf[4];
+	int pos = 0;
+
+	saddr.addr_type = IEEE802154_ADDR_LONG;
+	saddr.pan_id = addr->pan_id;
+	memcpy(saddr.hwaddr, dev->dev_addr, IEEE802154_ADDR_LEN);
+
+	buf[pos++] = IEEE802154_CMD_ASSOCIATION_RESP;
+	buf[pos++] = short_addr;
+	buf[pos++] = short_addr >> 8;
+	buf[pos++] = status;
+
+	return mac802154_send_cmd(dev, addr, &saddr, buf, pos);
+}
+
+static int mac802154_mlme_disassoc_req(struct net_device *dev,
+		struct ieee802154_addr *addr, u8 reason)
+{
+	struct ieee802154_addr saddr;
+	u8 buf[2];
+	int pos = 0;
+	int ret;
+
+	saddr.addr_type = IEEE802154_ADDR_LONG;
+	saddr.pan_id = addr->pan_id;
+	memcpy(saddr.hwaddr, dev->dev_addr, IEEE802154_ADDR_LEN);
+
+	buf[pos++] = IEEE802154_CMD_DISASSOCIATION_NOTIFY;
+	buf[pos++] = reason;
+
+	ret = mac802154_send_cmd(dev, addr, &saddr, buf, pos);
+
+	/* FIXME: this should be after the ack receved */
+	mac802154_dev_set_pan_id(dev, 0xffff);
+	mac802154_dev_set_short_addr(dev, 0xffff);
+	ieee802154_nl_disassoc_confirm(dev, 0x00);
+
+	return ret;
+}
+
+static int mac802154_mlme_start_req(struct net_device *dev,
+				struct ieee802154_addr *addr,
+				u8 channel, u8 page,
+				u8 bcn_ord, u8 sf_ord, u8 pan_coord, u8 blx,
+				u8 coord_realign)
+{
+	BUG_ON(addr->addr_type != IEEE802154_ADDR_SHORT);
+
+	mac802154_dev_set_pan_id(dev, addr->pan_id);
+	mac802154_dev_set_short_addr(dev, addr->short_addr);
+	mac802154_dev_set_ieee_addr(dev);
+	mac802154_dev_set_page_channel(dev, page, channel);
+
+	/*
+	 * FIXME: add validation for unused parameters to be sane
+	 * for SoftMAC
+	 */
+
+	if (pan_coord)
+		dev->priv_flags |= IFF_IEEE802154_COORD;
+	else
+		dev->priv_flags &= ~IFF_IEEE802154_COORD;
+
+	mac802154_dev_set_pan_coord(dev);
+	ieee802154_nl_start_confirm(dev, IEEE802154_SUCCESS);
+
+	return 0;
+}
+
+struct ieee802154_mlme_ops mac802154_mlme_wpan = {
+	.assoc_req = mac802154_mlme_assoc_req,
+	.assoc_resp = mac802154_mlme_assoc_resp,
+	.disassoc_req = mac802154_mlme_disassoc_req,
+	.start_req = mac802154_mlme_start_req,
+
+	.wpan_ops.get_phy = mac802154_get_phy,
+
+	.get_pan_id = mac802154_dev_get_pan_id,
+	.get_short_addr = mac802154_dev_get_short_addr,
+	.get_dsn = mac802154_dev_get_dsn,
+	.get_bsn = mac802154_dev_get_bsn,
+};
-- 
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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 09/12] [IEEE802154] ieee802154: type of device to be added
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
                   ` (4 preceding siblings ...)
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
@ 2011-11-30 14:26 ` Alexander Smirnov
  2011-11-30 14:27 ` [PATCH 11/12] [MAC802154] mac802154: base support for wpan device Alexander Smirnov
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:26 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, Alexander Smirnov

Device type argument is added to callback which creates interface.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 include/net/wpan-phy.h  |    2 +-
 net/ieee802154/nl-phy.c |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index d86fffd..0c2c931 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -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)));
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index c64a38d..0c02fcf 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -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;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 10/12] [MAC802154] mac802154: bind network iface to phy
       [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
                     ` (3 preceding siblings ...)
  2011-11-30 14:25   ` [PATCH 08/12] [MAC802154] mac802154: MAC commands support Alexander Smirnov
@ 2011-11-30 14:27   ` Alexander Smirnov
  4 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:27 UTC (permalink / raw)
  To: dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Transciever 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.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/mac802154/ieee802154_dev.c |  147 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 147 insertions(+), 0 deletions(-)

diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index e90d336..8fe1a9b 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -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);
-- 
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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 11/12] [MAC802154] mac802154: base support for wpan device
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
                   ` (5 preceding siblings ...)
  2011-11-30 14:26 ` [PATCH 09/12] [IEEE802154] ieee802154: type of device to be added Alexander Smirnov
@ 2011-11-30 14:27 ` Alexander Smirnov
  2011-11-30 14:28 ` [PATCH 12/12] [IEEE802154] ieee802154: set default device as wpan Alexander Smirnov
  2011-11-30 16:13 ` [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Dmitry Eremin-Solenikov
  8 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:27 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, Alexander Smirnov

Base support for wpan device. By wpan device it means any
IEEE 802.15.4 compatible transciever. This code attaches wpan
device to networking stack.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 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

diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index d2b5ae2..2c3b1cf 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -124,4 +124,10 @@ enum {
 
 #define IEEE802154_CMD_MAX (__IEEE802154_CMD_MAX - 1)
 
+enum {
+	IEEE802154_DEV_WPAN,
+
+	__IEEE802154_DEV_MAX,
+};
+
 #endif
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index 0c2c931..469e0e6 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -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;
 
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 50e2569..082eee7 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -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
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 8fe1a9b..89731be 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -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;
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 752ae6a..43ef561 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -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 */
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 1642c48..21af50a 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -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);
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
new file mode 100644
index 0000000..b8648bc
--- /dev/null
+++ b/net/mac802154/wpan.c
@@ -0,0 +1,613 @@
+/*
+ * Copyright 2007, 2008, 2009 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.
+ *
+ * Written by:
+ * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
+ * Sergey Lapin <slapin@ossfans.org>
+ * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
+ * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
+ */
+
+#include <linux/netdevice.h>
+#include <linux/capability.h>
+#include <linux/module.h>
+#include <linux/if_arp.h>
+#include <linux/rculist.h>
+#include <linux/random.h>
+#include <linux/crc-ccitt.h>
+#include <linux/nl802154.h>
+#include <linux/interrupt.h>
+
+#include <net/rtnetlink.h>
+#include <net/af_ieee802154.h>
+#include <net/mac802154.h>
+#include <net/ieee802154_netdev.h>
+#include <net/ieee802154.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+#include "mib.h"
+
+static netdev_tx_t mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv;
+	u8 chan, page;
+
+	priv = netdev_priv(dev);
+
+	spin_lock_bh(&priv->mib_lock);
+	chan = priv->chan;
+	page = priv->page;
+	spin_unlock_bh(&priv->mib_lock);
+
+	if (chan == (u8)-1 || chan >= 27 || page >= IEEE802154_WPAN_NUM_PAGES)
+		return NETDEV_TX_OK;
+
+	skb->skb_iif = dev->ifindex;
+	dev->stats.tx_packets++;
+	dev->stats.tx_bytes += skb->len;
+
+	return mac802154_tx(priv->hw, skb, page, chan);
+}
+
+static int mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr,
+		int cmd)
+{
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+	struct sockaddr_ieee802154 *sa =
+		(struct sockaddr_ieee802154 *)&ifr->ifr_addr;
+	int err = -ENOIOCTLCMD;
+
+	spin_lock_bh(&priv->mib_lock);
+
+	switch (cmd) {
+	case SIOCGIFADDR:
+		if (priv->pan_id == IEEE802154_PANID_BROADCAST ||
+		    priv->short_addr == IEEE802154_ADDR_BROADCAST) {
+			err = -EADDRNOTAVAIL;
+			break;
+		}
+
+		sa->family = AF_IEEE802154;
+		sa->addr.addr_type = IEEE802154_ADDR_SHORT;
+		sa->addr.pan_id = priv->pan_id;
+		sa->addr.short_addr = priv->short_addr;
+
+		err = 0;
+		break;
+	case SIOCSIFADDR:
+		dev_warn(&dev->dev,
+			"Using DEBUGing ioctl SIOCSIFADDR isn't recommened!\n");
+		if (sa->family != AF_IEEE802154 ||
+		    sa->addr.addr_type != IEEE802154_ADDR_SHORT ||
+		    sa->addr.pan_id == IEEE802154_PANID_BROADCAST ||
+		    sa->addr.short_addr == IEEE802154_ADDR_BROADCAST ||
+		    sa->addr.short_addr == IEEE802154_ADDR_UNDEF) {
+			err = -EINVAL;
+			break;
+		}
+
+		priv->pan_id = sa->addr.pan_id;
+		priv->short_addr = sa->addr.short_addr;
+		err = 0;
+		break;
+	}
+	spin_unlock_bh(&priv->mib_lock);
+	return err;
+}
+
+static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)
+{
+	struct sockaddr *addr = p;
+
+	if (netif_running(dev))
+		return -EBUSY;
+
+	/* FIXME: validate addr */
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+	mac802154_dev_set_ieee_addr(dev);
+
+	return 0;
+}
+
+static inline void mac802154_haddr_copy_swap(u8 *dest, const u8 *src)
+{
+	int i;
+	for (i = 0; i < IEEE802154_ADDR_LEN; i++)
+		dest[IEEE802154_ADDR_LEN - i - 1] = src[i];
+}
+
+static int mac802154_header_create(struct sk_buff *skb,
+			   struct net_device *dev,
+			   unsigned short type, const void *_daddr,
+			   const void *_saddr, unsigned len)
+{
+	u8 head[MAC802154_MAX_MHR_SIZE] = {};
+	int pos = 2;
+
+	u16 fc;
+	const struct ieee802154_addr *saddr = _saddr;
+	const struct ieee802154_addr *daddr = _daddr;
+	struct ieee802154_addr dev_addr;
+	struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+	fc = mac_cb_type(skb);
+	if (mac_cb_is_ackreq(skb))
+		fc |= IEEE802154_FC_ACK_REQ;
+
+	head[pos++] = mac_cb(skb)->seq; /* DSN/BSN */
+
+	if (!daddr)
+		return -EINVAL;
+
+	if (!saddr) {
+		spin_lock_bh(&priv->mib_lock);
+		if (priv->short_addr == IEEE802154_ADDR_BROADCAST ||
+		    priv->short_addr == IEEE802154_ADDR_UNDEF ||
+		    priv->pan_id == IEEE802154_PANID_BROADCAST) {
+			dev_addr.addr_type = IEEE802154_ADDR_LONG;
+			memcpy(dev_addr.hwaddr, dev->dev_addr,
+					IEEE802154_ADDR_LEN);
+		} else {
+			dev_addr.addr_type = IEEE802154_ADDR_SHORT;
+			dev_addr.short_addr = priv->short_addr;
+		}
+
+		dev_addr.pan_id = priv->pan_id;
+		saddr = &dev_addr;
+
+		spin_unlock_bh(&priv->mib_lock);
+	}
+
+	if (daddr->addr_type != IEEE802154_ADDR_NONE) {
+		fc |= (daddr->addr_type << IEEE802154_FC_DAMODE_SHIFT);
+
+		head[pos++] = daddr->pan_id & 0xff;
+		head[pos++] = daddr->pan_id >> 8;
+
+		if (daddr->addr_type == IEEE802154_ADDR_SHORT) {
+			head[pos++] = daddr->short_addr & 0xff;
+			head[pos++] = daddr->short_addr >> 8;
+		} else {
+			mac802154_haddr_copy_swap(head + pos, daddr->hwaddr);
+			pos += IEEE802154_ADDR_LEN;
+		}
+	}
+
+	if (saddr->addr_type != IEEE802154_ADDR_NONE) {
+		fc |= (saddr->addr_type << IEEE802154_FC_SAMODE_SHIFT);
+
+		if ((saddr->pan_id == daddr->pan_id) &&
+		    (saddr->pan_id != IEEE802154_PANID_BROADCAST))
+			/* PANID compression/ intra PAN */
+			fc |= IEEE802154_FC_INTRA_PAN;
+		else {
+			head[pos++] = saddr->pan_id & 0xff;
+			head[pos++] = saddr->pan_id >> 8;
+		}
+
+		if (saddr->addr_type == IEEE802154_ADDR_SHORT) {
+			head[pos++] = saddr->short_addr & 0xff;
+			head[pos++] = saddr->short_addr >> 8;
+		} else {
+			mac802154_haddr_copy_swap(head + pos, saddr->hwaddr);
+			pos += IEEE802154_ADDR_LEN;
+		}
+	}
+
+	head[0] = fc;
+	head[1] = fc >> 8;
+
+	memcpy(skb_push(skb, pos), head, pos);
+
+	return pos;
+}
+
+static int mac802154_header_parse(const struct sk_buff *skb,
+		unsigned char *haddr)
+{
+	const u8 *hdr = skb_mac_header(skb), *tail = skb_tail_pointer(skb);
+	struct ieee802154_addr *addr = (struct ieee802154_addr *)haddr;
+	u16 fc;
+	int da_type;
+
+	if (hdr + 3 > tail)
+		goto malformed;
+
+	fc = hdr[0] | (hdr[1] << 8);
+
+	hdr += 3;
+
+	da_type = IEEE802154_FC_DAMODE(fc);
+	addr->addr_type = IEEE802154_FC_SAMODE(fc);
+
+	switch (da_type) {
+	case IEEE802154_ADDR_NONE:
+		if (fc & IEEE802154_FC_INTRA_PAN)
+			goto malformed;
+		break;
+
+	case IEEE802154_ADDR_LONG:
+		if (hdr + 2 > tail)
+			goto malformed;
+		if (fc & IEEE802154_FC_INTRA_PAN) {
+			addr->pan_id = hdr[0] | (hdr[1] << 8);
+			hdr += 2;
+		}
+
+		if (hdr + IEEE802154_ADDR_LEN > tail)
+			goto malformed;
+		hdr += IEEE802154_ADDR_LEN;
+		break;
+
+	case IEEE802154_ADDR_SHORT:
+		if (hdr + 2 > tail)
+			goto malformed;
+		if (fc & IEEE802154_FC_INTRA_PAN) {
+			addr->pan_id = hdr[0] | (hdr[1] << 8);
+			hdr += 2;
+		}
+
+		if (hdr + 2 > tail)
+			goto malformed;
+		hdr += 2;
+		break;
+
+	default:
+		goto malformed;
+
+	}
+
+	switch (addr->addr_type) {
+	case IEEE802154_ADDR_NONE:
+		break;
+
+	case IEEE802154_ADDR_LONG:
+		if (hdr + 2 > tail)
+			goto malformed;
+		if (!(fc & IEEE802154_FC_INTRA_PAN)) {
+			addr->pan_id = hdr[0] | (hdr[1] << 8);
+			hdr += 2;
+		}
+
+		if (hdr + IEEE802154_ADDR_LEN > tail)
+			goto malformed;
+		mac802154_haddr_copy_swap(addr->hwaddr, hdr);
+		hdr += IEEE802154_ADDR_LEN;
+		break;
+
+	case IEEE802154_ADDR_SHORT:
+		if (hdr + 2 > tail)
+			goto malformed;
+		if (!(fc & IEEE802154_FC_INTRA_PAN)) {
+			addr->pan_id = hdr[0] | (hdr[1] << 8);
+			hdr += 2;
+		}
+
+		if (hdr + 2 > tail)
+			goto malformed;
+		addr->short_addr = hdr[0] | (hdr[1] << 8);
+		hdr += 2;
+		break;
+
+	default:
+		goto malformed;
+
+	}
+
+	return sizeof(struct ieee802154_addr);
+
+malformed:
+	pr_debug("(%s): malformed packet\n", __func__);
+	return 0;
+}
+
+static struct header_ops mac802154_header_ops = {
+	.create		= mac802154_header_create,
+	.parse		= mac802154_header_parse,
+};
+
+static const struct net_device_ops mac802154_wpan_ops = {
+	.ndo_open		= mac802154_slave_open,
+	.ndo_stop		= mac802154_slave_close,
+	.ndo_start_xmit		= mac802154_wpan_xmit,
+	.ndo_do_ioctl		= mac802154_wpan_ioctl,
+	.ndo_set_mac_address	= mac802154_wpan_mac_addr,
+};
+
+void mac802154_wpan_setup(struct net_device *dev)
+{
+	struct mac802154_sub_if_data *priv;
+
+	dev->addr_len		= IEEE802154_ADDR_LEN;
+	memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN);
+	dev->hard_header_len	= MAC802154_MAX_MHR_SIZE;
+	dev->header_ops		= &mac802154_header_ops;
+	dev->needed_tailroom	= 2; /* FCS */
+	dev->mtu		= IEEE802154_MTU;
+	dev->tx_queue_len	= 10;
+	dev->type		= ARPHRD_IEEE802154;
+	dev->flags		= IFF_NOARP | IFF_BROADCAST;
+	dev->watchdog_timeo	= 0;
+
+	dev->destructor		= free_netdev;
+	dev->netdev_ops		= &mac802154_wpan_ops;
+	dev->ml_priv		= &mac802154_mlme_wpan.wpan_ops;
+
+	priv			= netdev_priv(dev);
+	priv->type		= IEEE802154_DEV_WPAN;
+
+	priv->chan = -1; /* not initialized */
+	priv->page = 0; /* for compat */
+
+	spin_lock_init(&priv->mib_lock);
+
+	get_random_bytes(&priv->bsn, 1);
+	get_random_bytes(&priv->dsn, 1);
+
+	priv->pan_id = IEEE802154_PANID_BROADCAST;
+	priv->short_addr = IEEE802154_ADDR_BROADCAST;
+}
+
+static int mac802154_process_data(struct net_device *dev, struct sk_buff *skb)
+{
+	if (in_interrupt())
+		return netif_rx(skb);
+	else
+		return netif_rx_ni(skb);
+}
+
+static int mac802154_subif_frame(struct mac802154_sub_if_data *sdata,
+		struct sk_buff *skb)
+{
+	pr_debug("(%s): getting packet via slave interface %s\n",
+				__func__, sdata->dev->name);
+
+	spin_lock_bh(&sdata->mib_lock);
+
+	switch (mac_cb(skb)->da.addr_type) {
+	case IEEE802154_ADDR_NONE:
+		if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_NONE)
+			/* FIXME: check if we are PAN coordinator :) */
+			skb->pkt_type = PACKET_OTHERHOST;
+		else
+			/* ACK comes with both addresses empty */
+			skb->pkt_type = PACKET_HOST;
+		break;
+	case IEEE802154_ADDR_LONG:
+		if (mac_cb(skb)->da.pan_id != sdata->pan_id &&
+		    mac_cb(skb)->da.pan_id != IEEE802154_PANID_BROADCAST)
+			skb->pkt_type = PACKET_OTHERHOST;
+		else if (!memcmp(mac_cb(skb)->da.hwaddr, sdata->dev->dev_addr,
+					IEEE802154_ADDR_LEN))
+			skb->pkt_type = PACKET_HOST;
+		else
+			skb->pkt_type = PACKET_OTHERHOST;
+		break;
+	case IEEE802154_ADDR_SHORT:
+		if (mac_cb(skb)->da.pan_id != sdata->pan_id &&
+		    mac_cb(skb)->da.pan_id != IEEE802154_PANID_BROADCAST)
+			skb->pkt_type = PACKET_OTHERHOST;
+		else if (mac_cb(skb)->da.short_addr ==
+					IEEE802154_ADDR_BROADCAST)
+			skb->pkt_type = PACKET_BROADCAST;
+		else if (mac_cb(skb)->da.short_addr == sdata->short_addr)
+			skb->pkt_type = PACKET_HOST;
+		else
+			skb->pkt_type = PACKET_OTHERHOST;
+		break;
+	}
+
+	spin_unlock_bh(&sdata->mib_lock);
+
+	skb->dev = sdata->dev;
+
+	sdata->dev->stats.rx_packets++;
+	sdata->dev->stats.rx_bytes += skb->len;
+
+	if (skb->pkt_type == PACKET_HOST && mac_cb_is_ackreq(skb) &&
+			!(sdata->hw->hw.flags & IEEE802154_HW_AACK))
+		dev_warn(&sdata->dev->dev,
+			"ACK requested, however AACK not supported.\n");
+
+	switch (mac_cb_type(skb)) {
+	case IEEE802154_FC_TYPE_DATA:
+		return mac802154_process_data(sdata->dev, skb);
+	case IEEE802154_FC_TYPE_BEACON:
+	case IEEE802154_FC_TYPE_ACK:
+	case IEEE802154_FC_TYPE_MAC_CMD:
+		return mac802154_process_cmd(sdata->dev, skb);
+	default:
+		pr_warning("ieee802154: bad frame received (type = %d)\n",
+				mac_cb_type(skb));
+		kfree_skb(skb);
+		return NET_RX_DROP;
+	}
+}
+
+static int mac802154_fetch_skb_u8(struct sk_buff *skb, u8 *dest)
+{
+	if (!pskb_may_pull(skb, 1))
+		return -EINVAL;
+
+	*dest = skb->data[0];
+	skb_pull(skb, 1);
+
+	return 0;
+}
+
+static int mac802154_fetch_skb_u16(struct sk_buff *skb, u16 *dest)
+{
+	if (!pskb_may_pull(skb, 2))
+		return -EINVAL;
+
+	*dest = skb->data[0] + (skb->data[1] << 8);
+	skb_pull(skb, 2);
+
+	return 0;
+}
+
+static int mac802154_fetch_skb_u64(struct sk_buff *skb, u8 *dest)
+{
+	int i;
+
+	if (!pskb_may_pull(skb, IEEE802154_ADDR_LEN))
+		return -EINVAL;
+
+	for (i = 0; i < IEEE802154_ADDR_LEN; i++)
+		dest[IEEE802154_ADDR_LEN - i - 1] = skb->data[i];
+	skb_pull(skb, IEEE802154_ADDR_LEN);
+
+	return 0;
+}
+
+static int parse_frame_start(struct sk_buff *skb)
+{
+	u8 *head = skb->data;
+	u16 fc;
+
+	if (!pskb_may_pull(skb, 3)) {
+		pr_debug("(%s): frame size %d bytes is too short\n",
+					__func__, skb->len);
+		goto exit_error;
+	}
+
+	mac802154_fetch_skb_u16(skb, &fc);
+	mac802154_fetch_skb_u8(skb, &mac_cb(skb)->seq);
+
+	pr_debug("(%s): %04x dsn%02x\n", __func__, fc, head[2]);
+
+	mac_cb(skb)->flags = IEEE802154_FC_TYPE(fc);
+
+	if (fc & IEEE802154_FC_ACK_REQ) {
+		pr_debug("(%s): ACKNOWLEDGE required\n", __func__);
+		mac_cb(skb)->flags |= MAC_CB_FLAG_ACKREQ;
+	}
+
+	if (fc & IEEE802154_FC_SECEN)
+		mac_cb(skb)->flags |= MAC_CB_FLAG_SECEN;
+
+	if (fc & IEEE802154_FC_INTRA_PAN)
+		mac_cb(skb)->flags |= MAC_CB_FLAG_INTRAPAN;
+
+	/* TODO */
+	if (mac_cb_is_secen(skb)) {
+		pr_info("security support is not implemented\n");
+		goto exit_error;
+	}
+
+	mac_cb(skb)->sa.addr_type = IEEE802154_FC_SAMODE(fc);
+	if (mac_cb(skb)->sa.addr_type == IEEE802154_ADDR_NONE)
+		pr_debug("(%s): src addr_type is NONE\n", __func__);
+
+	mac_cb(skb)->da.addr_type = IEEE802154_FC_DAMODE(fc);
+	if (mac_cb(skb)->da.addr_type == IEEE802154_ADDR_NONE)
+		pr_debug("(%s): dst addr_type is NONE\n", __func__);
+
+	if (IEEE802154_FC_TYPE(fc) == IEEE802154_FC_TYPE_ACK) {
+		/* ACK can only have NONE-type addresses */
+		if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_NONE ||
+		    mac_cb(skb)->da.addr_type != IEEE802154_ADDR_NONE)
+			goto exit_error;
+	}
+
+	if (mac_cb(skb)->da.addr_type != IEEE802154_ADDR_NONE) {
+		if (mac802154_fetch_skb_u16(skb, &mac_cb(skb)->da.pan_id))
+			goto exit_error;
+
+		if (mac_cb_is_intrapan(skb)) { /* ! panid compress */
+			pr_debug("(%s): src IEEE802154_FC_INTRA_PAN\n",
+					__func__);
+			mac_cb(skb)->sa.pan_id = mac_cb(skb)->da.pan_id;
+			pr_debug("(%s): src PAN address %04x\n",
+					__func__, mac_cb(skb)->sa.pan_id);
+		}
+
+		pr_debug("(%s): dst PAN address %04x\n",
+				__func__, mac_cb(skb)->da.pan_id);
+
+		if (mac_cb(skb)->da.addr_type == IEEE802154_ADDR_SHORT) {
+			if (mac802154_fetch_skb_u16(skb,
+						&mac_cb(skb)->da.short_addr))
+				goto exit_error;
+			pr_debug("(%s): dst SHORT address %04x\n",
+					__func__, mac_cb(skb)->da.short_addr);
+
+		} else {
+			if (mac802154_fetch_skb_u64(skb,
+						mac_cb(skb)->da.hwaddr))
+				goto exit_error;
+			pr_debug("(%s): dst hardware addr\n", __func__);
+		}
+	}
+
+	if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_NONE) {
+		pr_debug("(%s): got src non-NONE address\n", __func__);
+		if (!(mac_cb_is_intrapan(skb))) { /* ! panid compress */
+			if (mac802154_fetch_skb_u16(skb,
+						&mac_cb(skb)->sa.pan_id))
+				goto exit_error;
+			pr_debug("(%s): src IEEE802154_FC_INTRA_PAN\n",
+					__func__);
+		}
+
+		if (mac_cb(skb)->sa.addr_type == IEEE802154_ADDR_SHORT) {
+			if (mac802154_fetch_skb_u16(skb,
+						&mac_cb(skb)->sa.short_addr))
+				goto exit_error;
+			pr_debug("(%s): src IEEE802154_ADDR_SHORT\n",
+					__func__);
+		} else {
+			if (mac802154_fetch_skb_u64(skb,
+					mac_cb(skb)->sa.hwaddr))
+				goto exit_error;
+			pr_debug("(%s): src hardware addr\n", __func__);
+		}
+	}
+
+	return 0;
+
+exit_error:
+	return -EINVAL;
+}
+
+void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb)
+{
+	int ret;
+	struct mac802154_sub_if_data *sdata;
+	struct sk_buff *skb2;
+
+	ret = parse_frame_start(skb); /* 3 bytes pulled after this */
+	if (ret) {
+		pr_debug("(%s): Got invalid frame\n", __func__);
+		return;
+	}
+
+	pr_debug("(%s): frame %d\n", __func__, mac_cb_type(skb));
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(sdata, &priv->slaves, list)
+	{
+		if (sdata->type != IEEE802154_DEV_WPAN)
+			continue;
+
+		skb2 = skb_clone(skb, GFP_ATOMIC);
+		if (skb2)
+			mac802154_subif_frame(sdata, skb2);
+	}
+
+	rcu_read_unlock();
+}
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 12/12] [IEEE802154] ieee802154: set default device as wpan
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
                   ` (6 preceding siblings ...)
  2011-11-30 14:27 ` [PATCH 11/12] [MAC802154] mac802154: base support for wpan device Alexander Smirnov
@ 2011-11-30 14:28 ` Alexander Smirnov
  2011-11-30 16:13 ` [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Dmitry Eremin-Solenikov
  8 siblings, 0 replies; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 14:28 UTC (permalink / raw)
  To: dbaryshkov; +Cc: linux-zigbee-devel, netdev, davem, Alexander Smirnov

Set default device type to wpan during creating interface.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 net/ieee802154/nl-phy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 0c02fcf..ab211d2 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -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__);
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/12] [MAC802154] mac802154: TX data path
  2011-11-30 14:23 ` [PATCH 04/12] [MAC802154] mac802154: TX data path Alexander Smirnov
@ 2011-11-30 15:56   ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-30 15:56 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: linux-zigbee-devel, netdev, davem

Hello,

On Wed, Nov 30, 2011 at 6:23 PM, Alexander Smirnov
<alex.bluesman.smirnov@gmail.com> wrote:
> Main TX data path implementation between upper and physical layers.
>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> ---
>  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
>
> diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
> index e00fe47..490beef 100644
> --- a/net/mac802154/Makefile
> +++ b/net/mac802154/Makefile
> @@ -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
> diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
> index 42f95b2..e90d336 100644
> --- a/net/mac802154/ieee802154_dev.c
> +++ b/net/mac802154/ieee802154_dev.c
> @@ -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;

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.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 06/12] [MAC802154] mac802154: MIB support
  2011-11-30 14:25 ` [PATCH 06/12] [MAC802154] mac802154: MIB support Alexander Smirnov
@ 2011-11-30 16:00   ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-30 16:00 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: linux-zigbee-devel, netdev, davem

Hello,

On Wed, Nov 30, 2011 at 6:25 PM, Alexander Smirnov
<alex.bluesman.smirnov@gmail.com> wrote:
> Support for IEEE 802.15.4 management information base,
> routine like setting of HW address, PAN id, channel etc...
>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> ---
>  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
>
> diff --git a/include/linux/if.h b/include/linux/if.h
> index 06b6ef6..deaf14c 100644
> --- a/include/linux/if.h
> +++ b/include/linux/if.h
> @@ -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?

>  #define IFF_TX_SKB_SHARING     0x10000 /* The interface supports sharing
>                                         * skbs on transmit */
>  #define IFF_UNICAST_FLT        0x20000         /* Supports unicast filtering   */

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation
  2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
                   ` (7 preceding siblings ...)
  2011-11-30 14:28 ` [PATCH 12/12] [IEEE802154] ieee802154: set default device as wpan Alexander Smirnov
@ 2011-11-30 16:13 ` Dmitry Eremin-Solenikov
  2011-11-30 16:54   ` Alexander Smirnov
  8 siblings, 1 reply; 19+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-30 16:13 UTC (permalink / raw)
  To: Alexander Smirnov, Jon Smirl; +Cc: linux-zigbee-devel, netdev, davem

Hello colleagues,

On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov
<alex.bluesman.smirnov@gmail.com> wrote:

[skipped]

> 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.

> 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?

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface
  2011-11-30 14:25   ` [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface Alexander Smirnov
@ 2011-11-30 16:22     ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-30 16:22 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: linux-zigbee-devel, netdev, davem

On Wed, Nov 30, 2011 at 6:25 PM, Alexander Smirnov
<alex.bluesman.smirnov@gmail.com> wrote:
> 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.

>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> ---
>  include/net/ieee802154_netdev.h |   11 +++++++++++
>  net/ieee802154/nl-mac.c         |    2 +-
>  2 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
> index 12a7ee4..5264b00 100644
> --- a/include/net/ieee802154_netdev.h
> +++ b/include/net/ieee802154_netdev.h
> @@ -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)
>  {
> diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
> index adaf462..1d23aa6 100644
> --- a/net/ieee802154/nl-mac.c
> +++ b/net/ieee802154/nl-mac.c
> @@ -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
>
>



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation
  2011-11-30 16:13 ` [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Dmitry Eremin-Solenikov
@ 2011-11-30 16:54   ` Alexander Smirnov
  2011-11-30 17:17     ` Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 19+ messages in thread
From: Alexander Smirnov @ 2011-11-30 16:54 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: Jon Smirl, linux-zigbee-devel, netdev, davem

Hello Dmitry,

thank you for the reply,

2011/11/30 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>:
> Hello colleagues,
>
> On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov
> <alex.bluesman.smirnov@gmail.com> wrote:
>
> [skipped]
>
>> 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.
>
>> 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.

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.
>
> 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. :)

> 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...

> --
> With best wishes
> Dmitry

With best regards,
Alexander

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation
  2011-11-30 16:54   ` Alexander Smirnov
@ 2011-11-30 17:17     ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-30 17:17 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: Jon Smirl, linux-zigbee-devel, netdev, davem

Hello,

On Wed, Nov 30, 2011 at 8:54 PM, Alexander Smirnov
<alex.bluesman.smirnov@gmail.com> wrote:
> 2011/11/30 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>:
>> On Wed, Nov 30, 2011 at 6:18 PM, Alexander Smirnov
>> <alex.bluesman.smirnov@gmail.com> wrote:
>>
>> [skipped]
>>
>>> 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.
>>
>>> 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.
>
> 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).

>>
>> 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. :)

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.

>
>> 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.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-11-30 17:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-30 14:18 [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Alexander Smirnov
2011-11-30 14:22 ` [PATCH 01/12] [MAC802154] mac802154: basic ieee802.15.4 device structures Alexander Smirnov
2011-11-30 14:23 ` [PATCH 02/12] [MAC802154] mac802154: allocation of ieee802154 device Alexander Smirnov
2011-11-30 14:23 ` [PATCH 04/12] [MAC802154] mac802154: TX data path Alexander Smirnov
2011-11-30 15:56   ` Dmitry Eremin-Solenikov
2011-11-30 14:25 ` [PATCH 06/12] [MAC802154] mac802154: MIB support Alexander Smirnov
2011-11-30 16:00   ` Dmitry Eremin-Solenikov
     [not found] ` <20111130141827.GA3739-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
2011-11-30 14:23   ` [PATCH 03/12] [MAC802154] mac802154: RX data path Alexander Smirnov
2011-11-30 14:24   ` [PATCH 05/12] [IEEE802154] ieee802154: remove ieee802154 policy from globals Alexander Smirnov
2011-11-30 14:25   ` [PATCH 07/12] [IEEE802154] ieee802154: define simplified mlme interface Alexander Smirnov
2011-11-30 16:22     ` Dmitry Eremin-Solenikov
2011-11-30 14:25   ` [PATCH 08/12] [MAC802154] mac802154: MAC commands support Alexander Smirnov
2011-11-30 14:27   ` [PATCH 10/12] [MAC802154] mac802154: bind network iface to phy Alexander Smirnov
2011-11-30 14:26 ` [PATCH 09/12] [IEEE802154] ieee802154: type of device to be added Alexander Smirnov
2011-11-30 14:27 ` [PATCH 11/12] [MAC802154] mac802154: base support for wpan device Alexander Smirnov
2011-11-30 14:28 ` [PATCH 12/12] [IEEE802154] ieee802154: set default device as wpan Alexander Smirnov
2011-11-30 16:13 ` [MAC802154] DRAFT: IEEE 802.15.4 MAC layer basic implementation Dmitry Eremin-Solenikov
2011-11-30 16:54   ` Alexander Smirnov
2011-11-30 17:17     ` Dmitry Eremin-Solenikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).