ieee802154: introduce cfg802154 and address filter handling
Subsystems (3)
Alexander Aring
maintainercover ieee802154: introduce cfg802154 and address filter handling
This series introduce basic cfg802154 handling and add cfg802154 ops for deprecated interface add/del netlink operations. Also reparing handling with default channels and change handling for setup hardware address filter. While change handling for setup hardware address filter this patch series adds a function to validate the extended address while setting the extended address over netdev_ops parameter.
Alexander Aring (16):
at86rf230: fix page parameter constraints
ieee802154: remove default channel settings
at86rf230: add default channel settings
cfg802154: introduce cfg802154_registered_device
mac802154: introduce mac802154_config_ops
ieee802154: add helper wpan_phy_to_rdev function
cfg802154: convert deprecated iface add and del
ieee802154: don't allow to change addr while netif_running
mac802154: add helper for converting dev_addr
mac802154: set extended address filter on ifup
mac802154: set short address filter on ifup
mac802154: set panid address filter on ifup
mac802154: move phy settings into netlink receive
ieee802154: add extended address validation helper
mac802154: iface: add validation for extended address
ieee802154: 6lowpan: remove set of mac address
drivers/net/ieee802154/at86rf230.c | 5 ++- include/linux/ieee802154.h | 14 ++++++++ include/net/cfg802154.h | 17 ++++++--- include/net/mac802154.h | 9 +++++ net/ieee802154/6lowpan_rtnl.c | 14 -------- net/ieee802154/core.c | 42 +++++++++++++--------- net/ieee802154/core.h | 26 ++++++++++++++ net/ieee802154/nl-mac.c | 10 ++++-- net/ieee802154/nl-phy.c | 19 ++++------ net/ieee802154/rdev-ops.h | 23 ++++++++++++ net/ieee802154/sysfs.c | 15 ++++++-- net/mac802154/Makefile | 2 +- net/mac802154/cfg.c | 36 +++++++++++++++++++ net/mac802154/cfg.h | 9 +++++ net/mac802154/ieee802154_i.h | 5 ++- net/mac802154/iface.c | 27 ++++++++------- net/mac802154/mac_cmd.c | 22 +++++++++++- net/mac802154/main.c | 11 +++--- net/mac802154/mib.c | 71 -------------------------------------- 19 files changed, 229 insertions(+), 148 deletions(-) create mode 100644 net/ieee802154/core.h create mode 100644 net/ieee802154/rdev-ops.h create mode 100644 net/mac802154/cfg.c create mode 100644 net/mac802154/cfg.h
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 1/16 at86rf230: fix page parameter constraints
Since commit e37d2ec82a222f1819e7793a27bc052999a379fb ("mac802154: ops:
declare channel and page as u8") the page parameter can't be below zero. This patch fix a kbuild test robot warning. Furthermore this check should be removed and handled by netlink 802.15.4 interface.
--- drivers/net/ieee802154/at86rf230.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/at86rf230.c +1 -1
@@ -1047,7 +1047,7 @@ at86rf230_channel(struct ieee802154_hw *hw, u8 page, u8 channel)struct at86rf230_local *lp = hw->priv;int rc; -if (page <0 || page >31 || +if (page >31 || !(lp->hw->phy->channels_supported[page] &BIT (channel))) {WARN_ON (1 );return -EINVAL ;
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 2/16 ieee802154: remove default channel settings
In reply to Alexander AringThis patch removes the default channel setting. A channel is always set and there is no default channel setting according 802.15.4.
Drivers should set the default channel and page in probing routine. This behaviour is currently a lack of all 802.15.4 drivers.
--- net/ieee802154/core.c | 3 --- 1 file changed, 3 deletions(-)
net/ieee802154/core.c +0 -3
@@ -100,9 +100,6 @@ 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; out:
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 3/16 at86rf230: add default channel settings
In reply to Alexander AringThis patch sets the reset state channels accoridng at86rf2xx datasheets. We don't need to set the default page here which is zero on all chips.
--- drivers/net/ieee802154/at86rf230.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ieee802154/at86rf230.c +3 -0
@@ -1427,6 +1427,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) chip ="at86rf231" ; lp->data = &at86rf231_data; lp->hw->phy->channels_supported[0 ] =0x7FFF800 ; + lp->hw->phy->current_channel =11 ;break ;case 7 : chip ="at86rf212" ;
@@ -1435,6 +1436,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->flags |=IEEE802154_HW_LBT ; lp->hw->phy->channels_supported[0 ] =0x00007FF ; lp->hw->phy->channels_supported[2 ] =0x00007FF ; + lp->hw->phy->current_channel =5 ; }else { rc = -ENOTSUPP ; }
@@ -1443,6 +1445,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) chip ="at86rf233" ; lp->data = &at86rf233_data; lp->hw->phy->channels_supported[0 ] =0x7FFF800 ; + lp->hw->phy->current_channel =13 ;break ;default : chip ="unkown" ;
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 4/16 cfg802154: introduce cfg802154_registered_device
In reply to Alexander AringThis patch introduce the cfg802154_registered_device struct. Like cfg80211_registered_device in wireless this should contain similar functionality for cfg802154. This patch should not change any behaviour. We just adds cfg802154_registered_device as container for wpan_phy struct.
--- include/net/cfg802154.h | 8 +++++++- net/ieee802154/core.c | 39 ++++++++++++++++++++++++++------------- net/ieee802154/core.h | 18 ++++++++++++++++++ net/ieee802154/sysfs.c | 15 ++++++++++++--- net/mac802154/main.c | 2 +- 5 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 net/ieee802154/core.h
include/net/cfg802154.h +7 -1
@@ -29,6 +29,11 @@#define WPAN_NUM_CHANNELS 27#define WPAN_NUM_PAGES 32 +struct wpan_phy ; + +struct cfg802154_ops { +}; +struct wpan_phy {struct mutex pib_lock;
@@ -62,7 +67,8 @@ struct wpan_phy {#define to_phy (_dev) container_of(_dev, struct wpan_phy, dev) -struct wpan_phy *wpan_phy_alloc (size_t priv_size); +struct wpan_phy * +wpan_phy_alloc (const struct cfg802154_ops *ops,size_t priv_size);static inline void wpan_phy_set_dev (struct wpan_phy *phy,struct device *dev) { phy->dev.parent = dev;
net/ieee802154/core.c +26 -13
@@ -21,6 +21,7 @@#include "ieee802154.h" #include "sysfs.h" +#include "core.h" static DEFINE_MUTEX (wpan_phy_mutex);static int wpan_phy_idx;
@@ -76,31 +77,38 @@ static int wpan_phy_idx_valid(int idx)return idx >=0 ; } -struct wpan_phy *wpan_phy_alloc (size_t priv_size) +struct wpan_phy * +wpan_phy_alloc (const struct cfg802154_ops *ops,size_t priv_size) { -struct wpan_phy *phy =kzalloc (sizeof (*phy) + priv_size, -GFP_KERNEL ); +struct cfg802154_registered_device *rdev; +size_t alloc_size; + + alloc_size =sizeof (*rdev) + priv_size; + rdev =kzalloc (alloc_size,GFP_KERNEL ); +if (!rdev) +return NULL ; + + rdev->ops = ops; -if (!phy) - goto out;mutex_lock (&wpan_phy_mutex); - phy->idx = wpan_phy_idx++; -if (unlikely (!wpan_phy_idx_valid (phy->idx))) { + rdev->wpan_phy.idx = wpan_phy_idx++; +if (unlikely (!wpan_phy_idx_valid (rdev->wpan_phy.idx))) { wpan_phy_idx--;mutex_unlock (&wpan_phy_mutex); -kfree (phy); +kfree (rdev); goto out; }mutex_unlock (&wpan_phy_mutex); -mutex_init (&phy->pib_lock); +mutex_init (&rdev->wpan_phy.pib_lock); -device_initialize (&phy->dev); -dev_set_name (&phy->dev,"wpan-phy%d" , phy->idx); +device_initialize (&rdev->wpan_phy.dev); +dev_set_name (&rdev->wpan_phy.dev,"wpan-phy%d" , rdev->wpan_phy.idx); - phy->dev.class = &wpan_phy_class; + rdev->wpan_phy.dev.class = &wpan_phy_class; + rdev->wpan_phy.dev.platform_data = rdev; -return phy; +return &rdev->wpan_phy; out:return NULL ;
@@ -125,6 +133,11 @@ void wpan_phy_free(struct wpan_phy *phy) }EXPORT_SYMBOL (wpan_phy_free); +void cfg802154_dev_free (struct cfg802154_registered_device *rdev) +{ +kfree (rdev); +} +static int __init wpan_phy_class_init (void ) {int rc;
net/ieee802154/core.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __IEEE802154_CORE_H +#define __IEEE802154_CORE_H + +#include <net/cfg802154.h> + +struct cfg802154_registered_device { +const struct cfg802154_ops *ops; + +/* must be last because of the way we do wpan_phy_priv(), +* and it should at least be aligned to NETDEV_ALIGN +*/ +struct wpan_phy wpan_phy__aligned(NETDEV_ALIGN) ; +}; + +/* free object */ +void cfg802154_dev_free (struct cfg802154_registered_device *rdev); + +#endif /* __IEEE802154_CORE_H */
net/ieee802154/sysfs.c +12 -3
@@ -17,6 +17,15 @@#include <net/cfg802154.h> +#include "core.h" + +static inline struct cfg802154_registered_device * +dev_to_rdev (struct device *dev) +{ + return container_of(dev, struct cfg802154_registered_device, + wpan_phy.dev); +} + #define MASTER_SHOW_COMPLEX(name, format_string, args...) \ static ssize_t name ## _show(struct device *dev, \ struct device_attribute *attr, char *buf) \
@@ -60,11 +69,11 @@ static ssize_t channels_supported_show(struct device *dev, }static DEVICE_ATTR_RO (channels_supported); -static void wpan_phy_release (struct device *d) +static void wpan_phy_release (struct device *dev) { - struct wpan_phy *phy = container_of(d, struct wpan_phy, dev); +struct cfg802154_registered_device *rdev =dev_to_rdev (dev); -kfree (phy); +cfg802154_dev_free (rdev); }static struct attribute *pmib_attrs[] = {
net/mac802154/main.c +1 -1
@@ -169,7 +169,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops) priv_size =ALIGN (sizeof (*local),NETDEV_ALIGN ) + priv_data_len; - phy =wpan_phy_alloc (priv_size); + phy =wpan_phy_alloc (NULL , priv_size);if (!phy) {pr_err ("failure to allocate master IEEE802.15.4 device\n" );return NULL ;
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 5/16 mac802154: introduce mac802154_config_ops
In reply to Alexander AringThis patch introduces mac802154_config_ops struct. Like wireless this struct should be the only one interface between ieee802154 to mac802154 or possible HardMAC drivers.
--- net/mac802154/Makefile | 2 +- net/mac802154/cfg.c | 19 +++++++++++++++++++ net/mac802154/cfg.h | 9 +++++++++ net/mac802154/main.c | 3 ++- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 net/mac802154/cfg.c create mode 100644 net/mac802154/cfg.h
net/mac802154/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_MAC802154) += mac802154.o mac802154-objs := main.o rx.o tx.o mac_cmd.o mib.o \ - iface.o llsec.o util.o + iface.o llsec.o util.o cfg.o ccflags-y += -D__CHECK_ENDIAN__
net/mac802154/cfg.c new file +19 -0
@@ -0,0 +1,19 @@ +/* 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. +* +* Authors: +* Alexander Aring <[email protected]> +* +* Based on: net/mac80211/cfg.c +*/ + +#include <net/cfg802154.h> + +const struct cfg802154_ops mac802154_config_ops = { +};
net/mac802154/cfg.h new file +9 -0
@@ -0,0 +1,9 @@ +/* mac802154 configuration hooks for cfg802154 +*/ + +#ifndef __CFG_H +#define __CFG_H + +extern const struct cfg802154_ops mac802154_config_ops; + +#endif /* __CFG_H */
net/mac802154/main.c +2 -1
@@ -28,6 +28,7 @@#include <net/cfg802154.h> #include "ieee802154_i.h" +#include "cfg.h" static int mac802154_netdev_register (struct wpan_phy *phy,struct net_device *dev)
@@ -169,7 +170,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops) priv_size =ALIGN (sizeof (*local),NETDEV_ALIGN ) + priv_data_len; - phy =wpan_phy_alloc (NULL , priv_size); + phy =wpan_phy_alloc (&mac802154_config_ops, priv_size);if (!phy) {pr_err ("failure to allocate master IEEE802.15.4 device\n" );return NULL ;
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 6/16 ieee802154: add helper wpan_phy_to_rdev function
In reply to Alexander AringThis patch introduce a function to get the cfg802154_registered_device from a wpan_phy.
--- net/ieee802154/core.h | 8 ++++++++ 1 file changed, 8 insertions(+)
net/ieee802154/core.h +8 -0
@@ -12,6 +12,14 @@ struct cfg802154_registered_device {struct wpan_phy wpan_phy__aligned(NETDEV_ALIGN) ; }; +static inline struct cfg802154_registered_device * +wpan_phy_to_rdev (struct wpan_phy *wpan_phy) +{ +BUG_ON (!wpan_phy); + return container_of(wpan_phy, struct cfg802154_registered_device, + wpan_phy); +} +/* free object */ void cfg802154_dev_free (struct cfg802154_registered_device *rdev);
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 7/16 cfg802154: convert deprecated iface add and del
In reply to Alexander AringThis patch removes the wpan_phy callbacks for add and del an interface on a phy. Instead we introduce deprecated cfg802154 callbacks for this. Furthermore we introduce a new netlink interface nl802154 which use different callbacks. The deprecated function is to have a backwards compatibility with the current netlink interface.
--- include/net/cfg802154.h | 9 +++++---- net/ieee802154/nl-phy.c | 19 ++++++------------- net/ieee802154/rdev-ops.h | 23 +++++++++++++++++++++++ net/mac802154/cfg.c | 17 +++++++++++++++++ net/mac802154/ieee802154_i.h | 4 ++++ net/mac802154/main.c | 8 ++------ 6 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 net/ieee802154/rdev-ops.h
include/net/cfg802154.h +5 -4
@@ -32,6 +32,11 @@struct wpan_phy ;struct cfg802154_ops { +struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, +const char *name, +int type); +void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, +struct net_device *dev); };struct wpan_phy {
@@ -58,10 +63,6 @@ struct wpan_phy {struct device dev;int idx; -struct net_device *(*add_iface)(struct wpan_phy *phy, -const char *name,int type); -void (*del_iface)(struct wpan_phy *phy,struct net_device *dev); -char priv[0 ]__aligned(NETDEV_ALIGN) ; };
net/ieee802154/nl-phy.c +6 -13
@@ -30,6 +30,8 @@#include <linux/nl802154.h> #include "ieee802154.h" +#include "rdev-ops.h" +#include "core.h" static int ieee802154_nl_fill_phy (struct sk_buff *msg,u32 portid,u32 seq,int flags,struct wpan_phy *phy)
@@ -203,11 +205,6 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)if (!msg) goto out_dev; -if (!phy->add_iface) { - rc = -EINVAL ; - goto nla_put_failure; - } -if (info->attrs[IEEE802154_ATTR_HW_ADDR ] &&nla_len (info->attrs[IEEE802154_ATTR_HW_ADDR ]) !=IEEE802154_ADDR_LEN ) {
@@ -223,7 +220,8 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) } } - dev = phy->add_iface (phy, devname, type); + dev =rdev_add_virtual_intf_deprecated (wpan_phy_to_rdev (phy), devname, + type);if (IS_ERR (dev)) { rc =PTR_ERR (dev); goto nla_put_failure;
@@ -257,7 +255,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) dev_unregister:rtnl_lock ();/* del_iface must be called with RTNL lock */ - phy->del_iface (phy, dev); +rdev_del_virtual_intf_deprecated (wpan_phy_to_rdev (phy), dev);dev_put (dev);rtnl_unlock (); nla_put_failure:
@@ -319,13 +317,8 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info)if (!msg) goto out_dev; -if (!phy->del_iface) { - rc = -EINVAL ; - goto nla_put_failure; - } -rtnl_lock (); - phy->del_iface (phy, dev); +rdev_del_virtual_intf_deprecated (wpan_phy_to_rdev (phy), dev);/* We don't have device anymore */ dev_put (dev);
net/ieee802154/rdev-ops.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef __CFG802154_RDEV_OPS +#define __CFG802154_RDEV_OPS + +#include <net/cfg802154.h> + +#include "core.h" + +static inline struct net_device * +rdev_add_virtual_intf_deprecated (struct cfg802154_registered_device *rdev, +const char *name,int type) +{ +return rdev->ops->add_virtual_intf_deprecated (&rdev->wpan_phy, name, + type); +} + +static inline void +rdev_del_virtual_intf_deprecated (struct cfg802154_registered_device *rdev, +struct net_device *dev) +{ + rdev->ops->del_virtual_intf_deprecated (&rdev->wpan_phy, dev); +} + +#endif /* __CFG802154_RDEV_OPS */
net/mac802154/cfg.c +17 -0
@@ -15,5 +15,22 @@#include <net/cfg802154.h> +#include "ieee802154_i.h" + +static struct net_device * +ieee802154_add_iface_deprecated (struct wpan_phy *wpan_phy, +const char *name,int type) +{ +return mac802154_add_iface (wpan_phy, name, type); +} + +static void ieee802154_del_iface_deprecated (struct wpan_phy *wpan_phy, +struct net_device *dev) +{ +mac802154_del_iface (wpan_phy, dev); +} +const struct cfg802154_ops mac802154_config_ops = { + .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, + .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, };
net/mac802154/ieee802154_i.h +4 -0
@@ -174,4 +174,8 @@ void mac802154_get_table(struct net_device *dev, struct ieee802154_llsec_table **t);void mac802154_unlock_table (struct net_device *dev); +struct net_device * +mac802154_add_iface (struct wpan_phy *phy,const char *name,int type); +void mac802154_del_iface (struct wpan_phy *phy,struct net_device *dev); +#endif /* __IEEE802154_I_H */
net/mac802154/main.c +2 -6
@@ -59,8 +59,7 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)return 0 ; } -static void -mac802154_del_iface (struct wpan_phy *phy,struct net_device *dev) +void mac802154_del_iface (struct wpan_phy *phy,struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);
@@ -76,7 +75,7 @@ mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)unregister_netdevice (sdata->dev); } -static struct net_device * +struct net_device *mac802154_add_iface (struct wpan_phy *phy,const char *name,int type) {struct net_device *dev;
@@ -221,9 +220,6 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)wpan_phy_set_dev (local->phy, local->hw.parent); - local->phy->add_iface = mac802154_add_iface; - local->phy->del_iface = mac802154_del_iface; - rc =wpan_phy_register (local->phy);if (rc <0 ) goto out_wq;
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 8/16 ieee802154: don't allow to change addr while netif_running
In reply to Alexander AringThis patch changes the actual behaviour for setting address attributes. We should not change addresses while netif_running is true. Furthermore when netif_running is running the address attributes becomes read only and we can remove locking mechanism in receive and transmit hothpaths of 802.15.4 subsystem.
--- net/ieee802154/nl-mac.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/ieee802154/nl-mac.c +8 -2
@@ -477,7 +477,7 @@ int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info)u8 channel, bcn_ord, sf_ord;u8 page;int pan_coord, blx, coord_realign; -int ret = -EOPNOTSUPP ; +int ret = -EBUSY ; if (!info->attrs[IEEE802154_ATTR_COORD_PAN_ID] || !info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR] ||
@@ -493,9 +493,15 @@ int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) dev =ieee802154_nl_get_dev (info);if (!dev)return -ENODEV ; -if (!ieee802154_mlme_ops (dev)->start_req) + +if (netif_running (dev)) goto out; +if (!ieee802154_mlme_ops (dev)->start_req) { + ret = -EOPNOTSUPP ; + goto out; + } + addr.mode =IEEE802154_ADDR_SHORT ; addr.short_addr =nla_get_shortaddr ( info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR ]);
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 9/16 mac802154: add helper for converting dev_addr
In reply to Alexander AringThis patch adds a helper for converting the dev_addr attribute in netdevice to __le64 type. The dev_addr attribute is a char pointer and contains the extended address in big endian byte order.
--- include/net/mac802154.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/net/mac802154.h +9 -0
@@ -214,6 +214,15 @@ struct ieee802154_ops { const bool on); }; +/** +* ieee802154_netdev_to_extended_addr - convert __be64 u8 pointer to __le64 +* @dev_addr: big endian address pointer like netdevice dev_addr attribute +*/ +static inline __le64 ieee802154_netdev_to_extended_addr (const u8 *dev_addr) +{ +return (__le64 )swab64 (*((__be64 *)dev_addr)); +} +/* Basic interface to register ieee802154 hwice */ struct ieee802154_hw *ieee802154_alloc_hw (size_t priv_data_len,const struct ieee802154_ops *ops);
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 10/16 mac802154: set extended address filter on ifup
In reply to Alexander AringThis patch moves the setting of hardware extended address filtering inside of interface up instead doing it directly inside of netlink interface. Also we don't need to set the sdata extended attribute in netlink. This is already done by ndo_set_mac_address of net_device_ops.
--- net/mac802154/ieee802154_i.h | 1 - net/mac802154/iface.c | 10 +++++++++- net/mac802154/mac_cmd.c | 1 - net/mac802154/mib.c | 14 -------------- 4 files changed, 9 insertions(+), 17 deletions(-)
net/mac802154/ieee802154_i.h +0 -1
@@ -135,7 +135,6 @@ ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);/* MIB callbacks */ void mac802154_dev_set_short_addr (struct net_device *dev,__le16 val);__le16 mac802154_dev_get_short_addr (const struct net_device *dev); -void mac802154_dev_set_ieee_addr (struct net_device *dev);__le16 mac802154_dev_get_pan_id (const struct net_device *dev);void mac802154_dev_set_pan_id (struct net_device *dev,__le16 val);void mac802154_dev_set_page_channel (struct net_device *dev,u8 page,u8 chan);
net/mac802154/iface.c +9 -1
@@ -110,6 +110,7 @@ mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)static int mac802154_wpan_mac_addr (struct net_device *dev,void *p) { +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct sockaddr *addr = p;if (netif_running (dev))
@@ -117,7 +118,8 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)/* FIXME: validate addr */ memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); -mac802154_dev_set_ieee_addr (dev); + sdata->extended_addr =ieee802154_netdev_to_extended_addr (dev->dev_addr); +return mac802154_wpan_update_llsec (dev); }
@@ -202,6 +204,12 @@ static int mac802154_wpan_open(struct net_device *dev) goto out; } +if (local->hw.flags &IEEE802154_HW_AFILT ) { + rc =drv_set_extended_addr (local, sdata->extended_addr); +if (rc <0 ) + goto out; + } +if (local->hw.flags &IEEE802154_HW_TXPOWER ) { rc =drv_set_tx_power (local, sdata->mac_params.transmit_power);if (rc <0 )
net/mac802154/mac_cmd.c +0 -1
@@ -43,7 +43,6 @@ static int mac802154_mlme_start_req(struct net_device *dev,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);if (ops->llsec) {
net/mac802154/mib.c +0 -14
@@ -102,20 +102,6 @@ __le16 mac802154_dev_get_short_addr(const struct net_device *dev)return ret; } -void mac802154_dev_set_ieee_addr (struct net_device *dev) -{ -struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev); -struct ieee802154_local *local = sdata->local; - - sdata->extended_addr =ieee802154_devaddr_from_raw (dev->dev_addr); - -if (local->ops->set_hw_addr_filt && - local->hw.hw_filt.ieee_addr != sdata->extended_addr) { - local->hw.hw_filt.ieee_addr = sdata->extended_addr; -set_hw_addr_filt (dev,IEEE802154_AFILT_IEEEADDR_CHANGED ); - } -} -__le16 mac802154_dev_get_pan_id (const struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 11/16 mac802154: set short address filter on ifup
In reply to Alexander AringThis patch moves the setting of hardware short address filtering inside of interface up instead doing it it directly inside of netlink interface. The netlink call which can only be called when netif isn't running sets only the necessary short_addr value in sdata. After an interface up the address filter will be set with this value.
--- net/mac802154/iface.c | 4 ++++ net/mac802154/mib.c | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-)
net/mac802154/iface.c +4 -0
@@ -208,6 +208,10 @@ static int mac802154_wpan_open(struct net_device *dev) rc =drv_set_extended_addr (local, sdata->extended_addr);if (rc <0 ) goto out; + + rc =drv_set_short_addr (local, sdata->short_addr); +if (rc <0 ) + goto out; }if (local->hw.flags &IEEE802154_HW_TXPOWER ) {
net/mac802154/mib.c +0 -6
@@ -80,12 +80,6 @@ void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val)spin_lock_bh (&sdata->mib_lock); sdata->short_addr = val;spin_unlock_bh (&sdata->mib_lock); - -if ((sdata->local->ops->set_hw_addr_filt) && - (sdata->local->hw.hw_filt.short_addr != sdata->short_addr)) { - sdata->local->hw.hw_filt.short_addr = sdata->short_addr; -set_hw_addr_filt (dev,IEEE802154_AFILT_SADDR_CHANGED ); - } }__le16 mac802154_dev_get_short_addr (const struct net_device *dev)
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 12/16 mac802154: set panid address filter on ifup
In reply to Alexander AringThis patch moves the setting of hardware panid address filtering inside of interface up instead doing it it directly inside of netlink interface. The netlink call which can only be called when netif isn't running sets only the necessary panid value in sdata. After an interface up the address filter will be set with this value.
--- net/mac802154/iface.c | 4 ++++ net/mac802154/mib.c | 51 --------------------------------------------------- 2 files changed, 4 insertions(+), 51 deletions(-)
net/mac802154/iface.c +4 -0
@@ -205,6 +205,10 @@ static int mac802154_wpan_open(struct net_device *dev) }if (local->hw.flags &IEEE802154_HW_AFILT ) { + rc =drv_set_pan_id (local, sdata->pan_id); +if (rc <0 ) + goto out; + rc =drv_set_extended_addr (local, sdata->extended_addr);if (rc <0 ) goto out;
net/mac802154/mib.c +0 -51
63 lines not on this page · raw message
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 13/16 mac802154: move phy settings into netlink receive
In reply to Alexander AringAll PHY attributes should be directly set to the transceiver after netlink. MAC attributes should be set by interface up. Currently the macparams netlink cmd contains mixed attributes of phy and mac settings. This patch moves all phy settings to the netlink receive function for setting macparams. This is the only way which doesn't change the userspace API and keep the deprecated netlink interface alive.
--- net/mac802154/iface.c | 19 ------------------- net/mac802154/mac_cmd.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 19 deletions(-)
net/mac802154/iface.c +0 -19
@@ -218,31 +218,12 @@ static int mac802154_wpan_open(struct net_device *dev) goto out; } -if (local->hw.flags &IEEE802154_HW_TXPOWER ) { - rc =drv_set_tx_power (local, sdata->mac_params.transmit_power); -if (rc <0 ) - goto out; - } -if (local->hw.flags &IEEE802154_HW_LBT ) { rc =drv_set_lbt_mode (local, sdata->mac_params.lbt);if (rc <0 ) goto out; } -if (local->hw.flags &IEEE802154_HW_CCA_MODE ) { - rc =drv_set_cca_mode (local, sdata->mac_params.cca_mode); -if (rc <0 ) - goto out; - } - -if (local->hw.flags &IEEE802154_HW_CCA_ED_LEVEL ) { - rc =drv_set_cca_ed_level (local, - sdata->mac_params.cca_ed_level); -if (rc <0 ) - goto out; - } -if (local->hw.flags &IEEE802154_HW_CSMA_PARAMS ) { rc = drv_set_csma_params(local, sdata->mac_params.min_be, sdata->mac_params.max_be,
net/mac802154/mac_cmd.c +21 -0
@@ -28,6 +28,7 @@#include <net/nl802154.h> #include "ieee802154_i.h" +#include "driver-ops.h" static int mac802154_mlme_start_req(struct net_device *dev, struct ieee802154_addr *addr,
@@ -85,11 +86,31 @@ static int mac802154_set_mac_params(struct net_device *dev, const struct ieee802154_mac_params *params) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev); +struct ieee802154_local *local = sdata->local; +int ret;mutex_lock (&sdata->local->iflist_mtx); sdata->mac_params = *params;mutex_unlock (&sdata->local->iflist_mtx); +if (local->hw.flags &IEEE802154_HW_TXPOWER ) { + ret =drv_set_tx_power (local, params->transmit_power); +if (ret <0 ) +return ret; + } + +if (local->hw.flags &IEEE802154_HW_CCA_MODE ) { + ret =drv_set_cca_mode (local, params->cca_mode); +if (ret <0 ) +return ret; + } + +if (local->hw.flags &IEEE802154_HW_CCA_ED_LEVEL ) { + ret =drv_set_cca_ed_level (local, params->cca_ed_level); +if (ret <0 ) +return ret; + } +return 0 ; }
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 14/16 ieee802154: add extended address validation helper
In reply to Alexander AringThis patch introduce an extended address validation helper to check if an extended address is valid or not.
--- include/linux/ieee802154.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/linux/ieee802154.h +14 -0
@@ -197,4 +197,18 @@ static inline bool ieee802154_is_valid_psdu_len(const u8 len) return (len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU); } +/** +* ieee802154_is_valid_psdu_len - check if extended addr is valid +* @addr: extended addr to check +*/ +static inline bool ieee802154_is_valid_extended_addr (const __le64 addr) +{ +/* These EUI-64 addresses are reserved by IEEE. 0xffffffffffffffff +* is used internally as extended to short address broadcast mapping. +* This is currently a workaround because neighbor discovery can't +* deal with short addresses types right now. +*/ +return ((addr !=0x0000000000000000 ) || (addr !=0xffffffffffffffff )); +} +#endif /* LINUX_IEEE802154_H */
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 15/16 mac802154: iface: add validation for extended address
In reply to Alexander AringThis patch use the validation function to check if an extended address is valid or not while set the extended address.
--- net/mac802154/iface.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/mac802154/iface.c +6 -2
@@ -112,13 +112,17 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct sockaddr *addr = p; +__le64 extended_addr;if (netif_running (dev))return -EBUSY ; -/* FIXME: validate addr */ + extended_addr =ieee802154_netdev_to_extended_addr (addr->sa_data); +if (!ieee802154_is_valid_extended_addr (extended_addr)) +return -EINVAL ; +memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); - sdata->extended_addr =ieee802154_netdev_to_extended_addr (dev->dev_addr); + sdata->extended_addr = extended_addr;return mac802154_wpan_update_llsec (dev); }
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 16/16 ieee802154: 6lowpan: remove set of mac address
In reply to Alexander AringCurrently the ieee802154 6lowpan interface operates on wpan interfaces only. Setting the wpan mac address over 6lowpan interface is complex and maybe we can't never do this. This patch removes the set of mac address handling in ieee802154 6lowpan interface for now.
--- net/ieee802154/6lowpan_rtnl.c | 14 -------------- 1 file changed, 14 deletions(-)
net/ieee802154/6lowpan_rtnl.c +0 -14
@@ -206,19 +206,6 @@ drop:return -EINVAL ; } -static int lowpan_set_address (struct net_device *dev,void *p) -{ -struct sockaddr *sa = p; - -if (netif_running (dev)) -return -EBUSY ; - -/* TODO: validate addr */ -memcpy (dev->dev_addr, sa->sa_data, dev->addr_len); - -return 0 ; -} -static struct sk_buff *lowpan_alloc_frag (struct sk_buff *skb,int size,const struct ieee802154_hdr *master_hdr)
@@ -474,7 +461,6 @@ static int lowpan_dev_init(struct net_device *dev)static const struct net_device_ops lowpan_netdev_ops = { .ndo_init = lowpan_dev_init, .ndo_start_xmit = lowpan_xmit, - .ndo_set_mac_address = lowpan_set_address, };static struct ieee802154_mlme_ops lowpan_mlme = {
Signature · 1 line
2.1.3
Hi Alex,
Quoted 45 lines
This series introduce basic cfg802154 handling and add cfg802154 ops for deprecated interface add/del netlink operations. Also reparing handling with default channels and change handling for setup hardware address filter. While change handling for setup hardware address filter this patch series adds a function to validate the extended address while setting the extended address over
netdev_opsparameter.Alexander Aring (16):
at86rf230: fix page parameter constraints
ieee802154: remove default channel settings
at86rf230: add default channel settings
cfg802154: introducecfg802154_registered_device
mac802154: introducemac802154_config_ops
ieee802154: add helperwpan_phy_to_rdevfunction
cfg802154: convert deprecated iface add and del
ieee802154: don't allow to change addr whilenetif_running
mac802154: add helper for convertingdev_addr
mac802154: set extended address filter on ifup
mac802154: set short address filter on ifup
mac802154: set panid address filter on ifup
mac802154: move phy settings into netlink receive
ieee802154: add extended address validation helper
mac802154: iface: add validation for extended address
ieee802154: 6lowpan: remove set of mac addressdrivers/net/ieee802154/at86rf230.c | 5 ++- include/linux/ieee802154.h | 14 ++++++++ include/net/cfg802154.h | 17 ++++++--- include/net/mac802154.h | 9 +++++ net/ieee802154/6lowpan_rtnl.c | 14 -------- net/ieee802154/core.c | 42 +++++++++++++--------- net/ieee802154/core.h | 26 ++++++++++++++ net/ieee802154/nl-mac.c | 10 ++++-- net/ieee802154/nl-phy.c | 19 ++++------ net/ieee802154/rdev-ops.h | 23 ++++++++++++ net/ieee802154/sysfs.c | 15 ++++++-- net/mac802154/Makefile | 2 +- net/mac802154/cfg.c | 36 +++++++++++++++++++ net/mac802154/cfg.h | 9 +++++ net/mac802154/ieee802154_i.h | 5 ++- net/mac802154/iface.c | 27 ++++++++------- net/mac802154/mac_cmd.c | 22 +++++++++++- net/mac802154/main.c | 11 +++--- net/mac802154/mib.c | 71 -------------------------------------- 19 files changed, 229 insertions(+), 148 deletions(-)
Quoted 4 lines
create mode 100644
net/ieee802154/core.h
create mode 100644net/ieee802154/rdev-ops.h
create mode 100644net/mac802154/cfg.c
create mode 100644net/mac802154/cfg.h
all 16 patches have been applied to bluetooth-next tree.
Regards
Marcel