IEEE 802.15.4 stack updates.
Subsystems (3)
Please pull into net-next an update for IEEE 802.15.4
The following changes since commit 6a2a2d6bf8581216e08be15fcb563cfd6c430e1e:
Gilad Ben-Yossef (1):
tcp: Use defaults when no route options are available
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git for-next
Dmitry Eremin-Solenikov (17):
wpan-phy: add a helper to put the wpan_phy device
wpan-phy: add wpan-phy iteration functions
wpan-phy: init channel/page fields
wpan-phy: use snprintf to limit the amount of chars written
wpan-phy: allow specifying a per-page channel mask
wpan-phy: follow usual patter of devices registration
ieee802154: constify struct net_device in some operations
ieee802154: merge nl802154 and wpan-class in single module
ieee802154: split away MAC commands implementation
ieee802154: add LIST_PHY command support
fakehard: no need to export net_to_phy, make it static
fakehard: claim all 2.4 Ghz channels as supported
ieee802154: add an mlme_ops call to retrieve PHY object
fakehard: mlme_ops->get_phy implementation
ieee802154: add two nl802154 helpers
ieee802154: add PHY_NAME to LIST_IFACE command results
ieee802154: add support for creation/removal of logic interfaces
drivers/ieee802154/fakehard.c | 59 +++- include/linux/nl802154.h | 6 + include/net/ieee802154_netdev.h | 16 +- include/net/wpan-phy.h | 22 ++- net/ieee802154/Makefile | 4 +- net/ieee802154/ieee802154.h | 53 ++++ net/ieee802154/netlink.c | 613 ++------------------------------------ net/ieee802154/nl-mac.c | 617 +++++++++++++++++++++++++++++++++++++++ net/ieee802154/nl-phy.c | 344 ++++++++++++++++++++++ net/ieee802154/nl_policy.c | 2 + net/ieee802154/wpan-class.c | 77 +++++- 11 files changed, 1202 insertions(+), 611 deletions(-) create mode 100644 net/ieee802154/ieee802154.h create mode 100644 net/ieee802154/nl-mac.c create mode 100644 net/ieee802154/nl-phy.c
PATCH 1/17 wpan-phy: add a helper to put the wpan_phy device
--- include/net/wpan-phy.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
include/net/wpan-phy.h +6 -0
@@ -56,6 +56,12 @@ static inline void *wpan_phy_priv(struct wpan_phy *phy) }struct wpan_phy *wpan_phy_find (const char *str); + +static inline void wpan_phy_put (struct wpan_phy *phy) +{ +put_device (&phy->dev); +} +static inline const char *wpan_phy_name (struct wpan_phy *phy) {return dev_name (&phy->dev);
Signature · 1 line
1.6.5
PATCH 2/17 wpan-phy: add wpan-phy iteration functions
In reply to Dmitry Eremin-SolenikovAdd API to iterate over the wpan-phy instances.
--- include/net/wpan-phy.h | 2 ++ net/ieee802154/wpan-class.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-)
include/net/wpan-phy.h +2 -0
@@ -48,6 +48,8 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size);int wpan_phy_register (struct device *parent,struct wpan_phy *phy);void wpan_phy_unregister (struct wpan_phy *phy);void wpan_phy_free (struct wpan_phy *phy); +/* Same semantics as for class_for_each_device */ +int wpan_phy_for_each (int (*fn)(struct wpan_phy *phy,void *data),void *data);static inline void *wpan_phy_priv (struct wpan_phy *phy) {
net/ieee802154/wpan-class.c +25 -0
@@ -91,6 +91,31 @@ struct wpan_phy *wpan_phy_find(const char *str) }EXPORT_SYMBOL (wpan_phy_find); +struct wpan_phy_iter_data { +int (*fn)(struct wpan_phy *phy,void *data); +void *data; +}; + +static int wpan_phy_iter (struct device *dev,void *_data) +{ +struct wpan_phy_iter_data *wpid = _data; + struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); +return wpid->fn (phy, wpid->data); +} + +int wpan_phy_for_each (int (*fn)(struct wpan_phy *phy,void *data), +void *data) +{ +struct wpan_phy_iter_data wpid = { + .fn = fn, + .data = data, + }; + +return class_for_each_device (&wpan_phy_class,NULL , + &wpid, wpan_phy_iter); +} +EXPORT_SYMBOL (wpan_phy_for_each); +static int wpan_phy_idx_valid (int idx) {return idx >=0 ;
Signature · 1 line
1.6.5
PATCH 3/17 wpan-phy: init channel/page fields
In reply to Dmitry Eremin-SolenikovSet page to zero (for compatibility w/ devices supporting only first page). Also init channel by default to -1 to disallow transfers for non-initialised devices.
--- net/ieee802154/wpan-class.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
net/ieee802154/wpan-class.c +3 -0
@@ -143,6 +143,9 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size) phy->dev.class = &wpan_phy_class; + phy->current_channel =-1 ;/* not initialised */ + phy->current_page =0 ;/* for compatibility */ +return phy; }EXPORT_SYMBOL (wpan_phy_alloc);
Signature · 1 line
1.6.5
PATCH 4/17 wpan-phy: use snprintf to limit the amount of chars written
In reply to Dmitry Eremin-SolenikovUse snprintf to limit the amount of chars put in the buffer for attr -> show.
--- net/ieee802154/wpan-class.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ieee802154/wpan-class.c +1 -1
@@ -30,7 +30,7 @@ static ssize_t name ## _show(struct device *dev, \int ret; \ \mutex_lock (&phy->pib_lock); \ - ret =sprintf (buf, format_string"\n" , args); \ + ret =snprintf (buf,PAGE_SIZE , format_string"\n" , args); \mutex_unlock (&phy->pib_lock); \return ret; \ }
Signature · 1 line
1.6.5
PATCH 5/17 wpan-phy: allow specifying a per-page channel mask
In reply to Dmitry Eremin-SolenikovIEEE 802.15.4-2006 defines channel pages that hold channels (max 32 pages, 27 channels per page). Allow the driver to specify supported channels on pages, other than the first one.
--- drivers/ieee802154/fakehard.c | 2 +- include/net/wpan-phy.h | 2 +- net/ieee802154/wpan-class.c | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-)
drivers/ieee802154/fakehard.c +1 -1
@@ -356,7 +356,7 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev) dev->addr_len);memcpy (dev->perm_addr, dev->dev_addr, dev->addr_len); - phy->channels_supported = (1 <<27 ) -1 ; + phy->channels_supported[0 ] = (1 <<27 ) -1 ; phy->transmit_power =0xbf ; dev->netdev_ops = &fake_ops;
include/net/wpan-phy.h +1 -1
@@ -34,7 +34,7 @@ struct wpan_phy {*/ u8 current_channel;u8 current_page; -u32 channels_supported; +u32 channels_supported[32 ];u8 transmit_power;u8 cca_mode;
net/ieee802154/wpan-class.c +19 -1
@@ -40,12 +40,30 @@ static ssize_t name ## _show(struct device *dev, \MASTER_SHOW (current_channel,"%d" );MASTER_SHOW (current_page,"%d" ); -MASTER_SHOW (channels_supported,"%#x" );MASTER_SHOW_COMPLEX (transmit_power,"%d +- %d dB" , ((signed char ) (phy->transmit_power <<2 )) >>2 , (phy->transmit_power >>6 ) ? (phy->transmit_power >>6 ) *3 :1 );MASTER_SHOW (cca_mode,"%d" ); +static ssize_t channels_supported_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ + struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); +int ret; +int i, len =0 ; + +mutex_lock (&phy->pib_lock); +for (i =0 ; i <32 ; i++) { + ret =snprintf (buf + len,PAGE_SIZE - len, +"%#09x\n" , phy->channels_supported[i]); +if (ret <0 ) +break ; + len += ret; + } +mutex_unlock (&phy->pib_lock); +return len; +} +static struct device_attribute pmib_attrs[] = {__ATTR_RO (current_channel),__ATTR_RO (current_page),
Signature · 1 line
1.6.5
PATCH 6/17 wpan-phy: follow usual patter of devices registration
In reply to Dmitry Eremin-SolenikovFollow the usual pattern of devices registration by adding new function (wpan_phy_set_dev) that sets child->parent relationship and removing parent argument from wpan_phy_register call.
--- drivers/ieee802154/fakehard.c | 3 ++- include/net/wpan-phy.h | 6 +++++- net/ieee802154/wpan-class.c | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/ieee802154/fakehard.c +2 -1
@@ -372,11 +372,12 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev) goto out; } +wpan_phy_set_dev (phy, &pdev->dev);SET_NETDEV_DEV (dev, &phy->dev);platform_set_drvdata (pdev, dev); - err =wpan_phy_register (&pdev->dev, phy); + err =wpan_phy_register (phy);if (err) goto out;
include/net/wpan-phy.h +5 -1
@@ -45,7 +45,11 @@ struct wpan_phy { };struct wpan_phy *wpan_phy_alloc (size_t priv_size); -int wpan_phy_register (struct device *parent,struct wpan_phy *phy); +static inline void wpan_phy_set_dev (struct wpan_phy *phy,struct device *dev) +{ + phy->dev.parent = dev; +} +int wpan_phy_register (struct wpan_phy *phy);void wpan_phy_unregister (struct wpan_phy *phy);void wpan_phy_free (struct wpan_phy *phy);/* Same semantics as for class_for_each_device */
net/ieee802154/wpan-class.c +1 -3
@@ -168,10 +168,8 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size) }EXPORT_SYMBOL (wpan_phy_alloc); -int wpan_phy_register (struct device *parent,struct wpan_phy *phy) +int wpan_phy_register (struct wpan_phy *phy) { - phy->dev.parent = parent; -return device_add (&phy->dev); }EXPORT_SYMBOL (wpan_phy_register);
Signature · 1 line
1.6.5
PATCH 7/17 ieee802154: constify struct net_device in some operations
In reply to Dmitry Eremin-SolenikovSome of ieee802154 operations really shouldn't change passed net_device. Constify passed argument.
--- drivers/ieee802154/fakehard.c | 8 ++++---- include/net/ieee802154_netdev.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/ieee802154/fakehard.c +4 -4
@@ -43,7 +43,7 @@ struct wpan_phy *net_to_phy(struct net_device *dev)* * Return the ID of the PAN from the PIB. */ -static u16 fake_get_pan_id (struct net_device *dev) +static u16 fake_get_pan_id (const struct net_device *dev) {BUG_ON (dev->type !=ARPHRD_IEEE802154 );
@@ -58,7 +58,7 @@ static u16 fake_get_pan_id(struct net_device *dev)* device. If the device has not yet had a short address assigned * then this should return 0xFFFF to indicate a lack of association. */ -static u16 fake_get_short_addr (struct net_device *dev) +static u16 fake_get_short_addr (const struct net_device *dev) {BUG_ON (dev->type !=ARPHRD_IEEE802154 );
@@ -78,7 +78,7 @@ static u16 fake_get_short_addr(struct net_device *dev)* Note: This is in section 7.2.1.2 of the IEEE 802.15.4-2006 * document. */ -static u8 fake_get_dsn (struct net_device *dev) +static u8 fake_get_dsn (const struct net_device *dev) {BUG_ON (dev->type !=ARPHRD_IEEE802154 );
@@ -98,7 +98,7 @@ static u8 fake_get_dsn(struct net_device *dev)* Note: This is in section 7.2.1.2 of the IEEE 802.15.4-2006 * document. */ -static u8 fake_get_bsn (struct net_device *dev) +static u8 fake_get_bsn (const struct net_device *dev) {BUG_ON (dev->type !=ARPHRD_IEEE802154 );
include/net/ieee802154_netdev.h +5 -5
@@ -98,14 +98,14 @@ struct ieee802154_mlme_ops {* FIXME: these should become the part of PIB/MIB interface. * However we still don't have IB interface of any kind */ -u16 (*get_pan_id)(struct net_device *dev); -u16 (*get_short_addr)(struct net_device *dev); -u8 (*get_dsn)(struct net_device *dev); -u8 (*get_bsn)(struct net_device *dev); +u16 (*get_pan_id)(const struct net_device *dev); +u16 (*get_short_addr)(const struct net_device *dev); +u8 (*get_dsn)(const struct net_device *dev); +u8 (*get_bsn)(const struct net_device *dev); };static inline struct ieee802154_mlme_ops *ieee802154_mlme_ops ( -struct net_device *dev) +const struct net_device *dev) {return dev->ml_priv; }
Signature · 1 line
1.6.5
PATCH 8/17 ieee802154: merge nl802154 and wpan-class in single module
In reply to Dmitry Eremin-SolenikovThere is no real need to have ieee802154 interfaces separate into several small modules, as neither of them has it's own use.
--- net/ieee802154/Makefile | 4 ++-- net/ieee802154/netlink.c | 9 ++------- net/ieee802154/wpan-class.c | 23 ++++++++++++++++++++--- 3 files changed, 24 insertions(+), 12 deletions(-)
net/ieee802154/Makefile +2 -2
@@ -1,5 +1,5 @@ -obj-$(CONFIG_IEEE802154) += nl802154.o af_802154.o wpan-class.o -nl802154-y := netlink.o nl_policy.o +obj-$(CONFIG_IEEE802154) += ieee802154.o af_802154.o +ieee802154-y := netlink.o nl_policy.o wpan-class.o af_802154-y := af_ieee802154.o raw.o dgram.o ccflags-y += -Wall -DDEBUG
net/ieee802154/netlink.c +2 -7
@@ -643,7 +643,7 @@ static struct genl_ops ieee802154_coordinator_ops[] = { ieee802154_dump_iface), }; -static int __init ieee802154_nl_init (void ) +int __init ieee802154_nl_init (void ) {int rc;int i;
@@ -676,14 +676,9 @@ fail:genl_unregister_family (&ieee802154_coordinator_family);return rc; } -module_init (ieee802154_nl_init); -static void __exit ieee802154_nl_exit(void) +void __exit ieee802154_nl_exit(void) {genl_unregister_family (&ieee802154_coordinator_family); } -module_exit (ieee802154_nl_exit); - -MODULE_LICENSE ("GPL v2" ); -MODULE_DESCRIPTION ("ieee 802.15.4 configuration interface" );
net/ieee802154/wpan-class.c +20 -3
@@ -22,6 +22,8 @@#include <net/wpan-phy.h> +#include "ieee802154.h" + #define MASTER_SHOW_COMPLEX(name, format_string, args...) \ static ssize_t name ## _show(struct device *dev, \ struct device_attribute *attr, char *buf) \
@@ -188,16 +190,31 @@ EXPORT_SYMBOL(wpan_phy_free);static int __init wpan_phy_class_init (void ) { -return class_register (&wpan_phy_class); +int rc; + rc =class_register (&wpan_phy_class); +if (rc) + goto err; + + rc =ieee802154_nl_init (); +if (rc) + goto err_nl; + +return 0 ; +err_nl: +class_unregister (&wpan_phy_class); +err: +return rc; } -subsys_initcall (wpan_phy_class_init); +module_init (wpan_phy_class_init); static void __exit wpan_phy_class_exit(void) { +ieee802154_nl_exit ();class_unregister (&wpan_phy_class); }module_exit (wpan_phy_class_exit); -MODULE_DESCRIPTION ("IEEE 802.15.4 device class" );MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("IEEE 802.15.4 configuration interface" ); +MODULE_AUTHOR ("Dmitry Eremin-Solenikov" );
Signature · 1 line
1.6.5
PATCH 9/17 ieee802154: split away MAC commands implementation
In reply to Dmitry Eremin-SolenikovMove all mac-related stuff to separate file so that ieee802154/netlink.c contains only generic code.
---
net/ieee802154/Makefile | 2 +-
net/ieee802154/ieee802154.h | 48 +++
net/ieee802154/netlink.c | 605 +-------------------------------
net/ieee802154/{netlink.c => nl-mac.c} | 117 ++-----
4 files changed, 81 insertions(+), 691 deletions(-)
create mode 100644 net/ieee802154/ieee802154.h
copy net/ieee802154/{netlink.c => nl-mac.c} (86%)net/ieee802154/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_IEEE802154) += ieee802154.o af_802154.o -ieee802154-y := netlink.o nl_policy.o wpan-class.o +ieee802154-y := netlink.o nl-mac.o nl_policy.o wpan-class.o af_802154-y := af_ieee802154.o raw.o dgram.o ccflags-y += -Wall -DDEBUG
net/ieee802154/ieee802154.h new file +48 -0
48 lines not on this page · raw message
net/ieee802154/netlink.c +11 -594
664 lines not on this page · raw message
net/ieee802154/nl-mac.c renamed from net/ieee802154/netlink.c +21 -96
208 lines not on this page · raw message
Signature · 1 line
1.6.5
PATCH 10/17 ieee802154: add LIST_PHY command support
In reply to Dmitry Eremin-SolenikovAdd nl802154 command to get information about PHY's present in the system.
--- include/linux/nl802154.h | 4 + net/ieee802154/Makefile | 2 +- net/ieee802154/netlink.c | 4 + net/ieee802154/nl-phy.c | 188 ++++++++++++++++++++++++++++++++++++++++++++ net/ieee802154/nl_policy.c | 2 + 5 files changed, 199 insertions(+), 1 deletions(-) create mode 100644 net/ieee802154/nl-phy.c
include/linux/nl802154.h +4 -0
@@ -65,6 +65,9 @@ enum {IEEE802154_ATTR_SEC ,IEEE802154_ATTR_PAGE , +IEEE802154_ATTR_CHANNEL_PAGE_LIST , + +IEEE802154_ATTR_PHY_NAME , __IEEE802154_ATTR_MAX, };
@@ -114,6 +117,7 @@ enum {IEEE802154_RX_ENABLE_CONF ,/* Not supported yet */ IEEE802154_LIST_IFACE , +IEEE802154_LIST_PHY , __IEEE802154_CMD_MAX, };
net/ieee802154/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_IEEE802154) += ieee802154.o af_802154.o -ieee802154-y := netlink.o nl-mac.o nl_policy.o wpan-class.o +ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o wpan-class.o af_802154-y := af_ieee802154.o raw.o dgram.o ccflags-y += -Wall -DDEBUG
net/ieee802154/netlink.c +4 -0
@@ -87,6 +87,10 @@ int __init ieee802154_nl_init(void)if (rc) goto fail; + rc =nl802154_phy_register (); +if (rc) + goto fail; +return 0 ; fail:
net/ieee802154/nl-phy.c new file +188 -0
188 lines not on this page · raw message
net/ieee802154/nl_policy.c +2 -0
@@ -27,6 +27,7 @@const struct nla_policy ieee802154_policy[IEEE802154_ATTR_MAX +1 ] = { [IEEE802154_ATTR_DEV_NAME ] = { .type =NLA_STRING , }, [IEEE802154_ATTR_DEV_INDEX ] = { .type =NLA_U32 , }, + [IEEE802154_ATTR_PHY_NAME ] = { .type =NLA_STRING , }, [IEEE802154_ATTR_STATUS ] = { .type =NLA_U8 , }, [IEEE802154_ATTR_SHORT_ADDR ] = { .type =NLA_U16 , },
@@ -50,5 +51,6 @@ const struct nla_policy ieee802154_policy[IEEE802154_ATTR_MAX + 1] = { [IEEE802154_ATTR_CHANNELS] = { .type = NLA_U32, }, [IEEE802154_ATTR_DURATION] = { .type = NLA_U8, }, [IEEE802154_ATTR_ED_LIST] = { .len = 27 }, + [IEEE802154_ATTR_CHANNEL_PAGE_LIST] = { .len = 32 * 4, }, };
Signature · 1 line
1.6.5
PATCH 11/17 fakehard: no need to export net_to_phy, make it static
In reply to Dmitry Eremin-Solenikov--- drivers/ieee802154/fakehard.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/ieee802154/fakehard.c +1 -1
@@ -32,7 +32,7 @@#include <net/nl802154.h> #include <net/wpan-phy.h> -struct wpan_phy *net_to_phy (struct net_device *dev) +static struct wpan_phy *net_to_phy (struct net_device *dev) { return container_of(dev->dev.parent, struct wpan_phy, dev); }
Signature · 1 line
1.6.5
PATCH 12/17 fakehard: claim all 2.4 Ghz channels as supported
In reply to Dmitry Eremin-SolenikovMake fakehard device claim all 2.4 Ghz channels from 802.15.4-2006, 802.15.4a-2007 as supported by the hw.
--- drivers/ieee802154/fakehard.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/ieee802154/fakehard.c +9 -1
@@ -356,7 +356,15 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev) dev->addr_len);memcpy (dev->perm_addr, dev->dev_addr, dev->addr_len); - phy->channels_supported[0 ] = (1 <<27 ) -1 ; +/* +* For now we'd like to emulate 2.4 GHz-only device, +* both O-QPSK and CSS +*/ +/* 2.4 GHz O-QPSK 802.15.4-2003 */ + phy->channels_supported[0 ] |=0x7FFF800 ; +/* 2.4 GHz CSS 802.15.4a-2007 */ + phy->channels_supported[3 ] |=0x3fff ; + phy->transmit_power =0xbf ; dev->netdev_ops = &fake_ops;
Signature · 1 line
1.6.5
PATCH 13/17 ieee802154: add an mlme_ops call to retrieve PHY object
In reply to Dmitry Eremin-Solenikovops->get_phy should increment reference to wpan-phy. As we return the external structure, we should do refcounting correctly.
--- include/net/ieee802154_netdev.h | 6 ++++++ include/net/wpan-phy.h | 2 ++ 2 files changed, 8 insertions(+), 0 deletions(-)
include/net/ieee802154_netdev.h +6 -0
@@ -74,8 +74,12 @@ static inline int mac_cb_type(struct sk_buff *skb)#define IEEE802154_MAC_SCAN_PASSIVE 2#define IEEE802154_MAC_SCAN_ORPHAN 3 +struct wpan_phy ;/* * This should be located at net_device->ml_priv +* +* get_phy should increment the reference counting on returned phy. +* Use wpan_wpy_put to put that reference. */ struct ieee802154_mlme_ops { int (*assoc_req)(struct net_device *dev,
@@ -94,6 +98,8 @@ struct ieee802154_mlme_ops {int (*scan_req)(struct net_device *dev,u8 type,u32 channels,u8 page,u8 duration); +struct wpan_phy *(*get_phy)(const struct net_device *dev); +/* * FIXME: these should become the part of PIB/MIB interface. * However we still don't have IB interface of any kind
include/net/wpan-phy.h +2 -0
@@ -44,6 +44,8 @@ struct wpan_phy { char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); }; +#define to_phy (_dev) container_of(_dev, struct wpan_phy, dev) +struct wpan_phy *wpan_phy_alloc (size_t priv_size);static inline void wpan_phy_set_dev (struct wpan_phy *phy,struct device *dev) {
Signature · 1 line
1.6.5
PATCH 14/17 fakehard: mlme_ops->get_phy implementation
In reply to Dmitry Eremin-Solenikov--- drivers/ieee802154/fakehard.c | 38 ++++++++++++++++++++++++++++++++------ 1 files changed, 32 insertions(+), 6 deletions(-)
drivers/ieee802154/fakehard.c +32 -6
@@ -32,9 +32,29 @@#include <net/nl802154.h> #include <net/wpan-phy.h> -static struct wpan_phy *net_to_phy (struct net_device *dev) +struct fakehard_priv { +struct wpan_phy *phy; +}; + +static struct wpan_phy *fake_to_phy (const struct net_device *dev) +{ +struct fakehard_priv *priv =netdev_priv (dev); +return priv->phy; +} + +/** +* fake_get_phy - Return a phy corresponding to this device. +* @dev: The network device for which to return the wan-phy object +* +* This function returns a wpan-phy object corresponding to the passed +* network device. Reference counter for wpan-phy object is incremented, +* so when the wpan-phy isn't necessary, you should drop the reference +* via @wpan_phy_put() call. +*/ +static struct wpan_phy *fake_get_phy (const struct net_device *dev) { - return container_of(dev->dev.parent, struct wpan_phy, dev); +struct wpan_phy *phy =fake_to_phy (dev); +return to_phy (get_device (&phy->dev)); }/**
@@ -121,7 +141,7 @@ static u8 fake_get_bsn(const struct net_device *dev)static int fake_assoc_req (struct net_device *dev,struct ieee802154_addr *addr,u8 channel,u8 page,u8 cap) { -struct wpan_phy *phy =net_to_phy (dev); +struct wpan_phy *phy =fake_to_phy (dev);mutex_lock (&phy->pib_lock); phy->current_channel = channel;
@@ -196,7 +216,7 @@ static int fake_start_req(struct net_device *dev, struct ieee802154_addr *addr, u8 bcn_ord, u8 sf_ord, u8 pan_coord, u8 blx, u8 coord_realign) { - struct wpan_phy *phy = net_to_phy(dev); + struct wpan_phy *phy = fake_to_phy(dev);mutex_lock (&phy->pib_lock); phy->current_channel = channel;
@@ -239,6 +259,8 @@ static struct ieee802154_mlme_ops fake_mlme = { .start_req = fake_start_req, .scan_req = fake_scan_req, + .get_phy = fake_get_phy, + .get_pan_id = fake_get_pan_id, .get_short_addr = fake_get_short_addr, .get_dsn = fake_get_dsn,
@@ -313,7 +335,7 @@ static const struct net_device_ops fake_ops = {static void ieee802154_fake_destruct (struct net_device *dev) { -struct wpan_phy *phy =net_to_phy (dev); +struct wpan_phy *phy =fake_to_phy (dev);wpan_phy_unregister (phy);free_netdev (dev);
@@ -338,13 +360,14 @@ static void ieee802154_fake_setup(struct net_device *dev)static int __devinit ieee802154fake_probe (struct platform_device *pdev) {struct net_device *dev; +struct fakehard_priv *priv;struct wpan_phy *phy =wpan_phy_alloc (0 );int err;if (!phy)return -ENOMEM ; - dev =alloc_netdev (0 ,"hardwpan%d" , ieee802154_fake_setup); + dev =alloc_netdev (sizeof (struct fakehard_priv ),"hardwpan%d" , ieee802154_fake_setup);if (!dev) {wpan_phy_free (phy);return -ENOMEM ;
@@ -370,6 +393,9 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev) dev->netdev_ops = &fake_ops; dev->ml_priv = &fake_mlme; + priv =netdev_priv (dev); + priv->phy = phy; +/* * If the name is a format string the caller wants us to do a * name allocation.
Signature · 1 line
1.6.5
PATCH 15/17 ieee802154: add two nl802154 helpers
In reply to Dmitry Eremin-SolenikovAdd two nl802154 helpers: one for starting a reply message, one for sending.
--- net/ieee802154/ieee802154.h | 5 +++++ net/ieee802154/netlink.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-)
net/ieee802154/ieee802154.h +5 -0
@@ -38,8 +38,13 @@ void __exit ieee802154_nl_exit(void); .dumpit = _dump, \ } +struct genl_info ; +struct sk_buff *ieee802154_nl_create (int flags,u8 req);int ieee802154_nl_mcast (struct sk_buff *msg,unsigned int group); +struct sk_buff *ieee802154_nl_new_reply (struct genl_info *info, +int flags,u8 req); +int ieee802154_nl_reply (struct sk_buff *msg,struct genl_info *info);extern struct genl_family nl802154_family;int nl802154_mac_register (void );
net/ieee802154/netlink.c +33 -0
@@ -75,6 +75,39 @@ out:return -ENOBUFS ; } +struct sk_buff *ieee802154_nl_new_reply (struct genl_info *info, +int flags,u8 req) +{ +void *hdr; +struct sk_buff *msg =nlmsg_new (NLMSG_GOODSIZE ,GFP_ATOMIC ); + +if (!msg) +return NULL ; + + hdr =genlmsg_put_reply (msg, info, + &nl802154_family, flags, req); +if (!hdr) { +nlmsg_free (msg); +return NULL ; + } + +return msg; +} + +int ieee802154_nl_reply (struct sk_buff *msg,struct genl_info *info) +{ +/* XXX: nlh is right at the start of msg */ +void *hdr =genlmsg_data (NLMSG_DATA (msg->data)); + +if (genlmsg_end (msg, hdr) <0 ) + goto out; + +return genlmsg_reply (msg, info); +out: +nlmsg_free (msg); +return -ENOBUFS ; +} +int __init ieee802154_nl_init (void ) {int rc;
Signature · 1 line
1.6.5
PATCH 16/17 ieee802154: add PHY_NAME to LIST_IFACE command results
In reply to Dmitry Eremin-Solenikov--- net/ieee802154/nl-mac.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
net/ieee802154/nl-mac.c +8 -0
@@ -33,6 +33,7 @@#include <net/nl802154.h> #include <net/ieee802154.h> #include <net/ieee802154_netdev.h> +#include <net/wpan-phy.h> #include "ieee802154.h"
@@ -251,6 +252,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, struct net_device *dev) { void *hdr; +struct wpan_phy *phy;pr_debug ("%s\n" , __func__);
@@ -259,7 +261,11 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid,if (!hdr) goto out; + phy =ieee802154_mlme_ops (dev)->get_phy (dev); +BUG_ON (!phy); +NLA_PUT_STRING (msg,IEEE802154_ATTR_DEV_NAME , dev->name); +NLA_PUT_STRING (msg,IEEE802154_ATTR_PHY_NAME ,wpan_phy_name (phy));NLA_PUT_U32 (msg,IEEE802154_ATTR_DEV_INDEX , dev->ifindex); NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN,
@@ -268,9 +274,11 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid, ieee802154_mlme_ops(dev)->get_short_addr(dev));NLA_PUT_U16 (msg,IEEE802154_ATTR_PAN_ID ,ieee802154_mlme_ops (dev)->get_pan_id (dev)); +wpan_phy_put (phy);return genlmsg_end (msg, hdr); nla_put_failure: +wpan_phy_put (phy);genlmsg_cancel (msg, hdr); out:return -EMSGSIZE ;
Signature · 1 line
1.6.5
PATCH 17/17 ieee802154: add support for creation/removal of logic interfaces
In reply to Dmitry Eremin-SolenikovAdd support for two more NL802154 commands: ADD_IFACE and DEL_IFACE, thus allowing creation and removal of logic WPAN interfaces on the top of wpan-phy.
--- include/linux/nl802154.h | 2 + include/net/wpan-phy.h | 4 + net/ieee802154/nl-phy.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 0 deletions(-)
include/linux/nl802154.h +2 -0
@@ -118,6 +118,8 @@ enum {IEEE802154_LIST_IFACE ,IEEE802154_LIST_PHY , +IEEE802154_ADD_IFACE , +IEEE802154_DEL_IFACE , __IEEE802154_CMD_MAX, };
include/net/wpan-phy.h +4 -0
@@ -41,6 +41,10 @@ struct wpan_phy {struct device dev;int idx; +struct net_device *(*add_iface)(struct wpan_phy *phy, +const char *name); +void (*del_iface)(struct wpan_phy *phy,struct net_device *dev); + char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); };
net/ieee802154/nl-phy.c +156 -0
171 lines not on this page · raw message
Signature · 1 line
1.6.5
David Miller
maintaineraFrom: Dmitry Eremin-Solenikov <[email protected]>
Date: Fri, 6 Nov 2009 15:39:24 +0300
Quoted 9 lines
Please pull into net-next an update for IEEE 802.15.4
The following changes since commit
6a2a2d6bf8581216e08be15fcb563cfd6c430e1e:
Gilad Ben-Yossef (1):
tcp: Use defaults when no route options are availableare available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.gitfor-next
Looks good, pulled, thanks a lot!