ieee802154: mac802154: wireless transformation part 2
Subsystems (2)
Alexander Aring
maintainercover ieee802154: mac802154: wireless transformation part 2
Hi,
this is the next series to make the 802.15.4 implementation like wireless. I fixed also some issues from my previous series.
This was:
- a typo in commit ("mac802154: remove not functional monitor device")
- missing tasklet_kill(&local->tasklet) in ieee802154_unregister_hw ("mac802154: rx: use tasklet instead workqueue")
I created a branch for this at github, you can see this at [0].
At the end I will resubmit all patches on this mailinglist and then I will merge this branch to master.
In this series I cleanup a little bit the rx.c file. It contains now all parsing function from wpan.c file until netif_rx call.
Also I rework the open and close callback for the netdev interface. This adds also a driver-ops header file like the mac80211 one. This file contains wrapper function for calling device_ops. We should do this for all device_ops which we call, instead doing local->ops->foobar(local->hw, ...) etc...
We are now a little bit closer to the wireless implementation style, but it need some work to have a similar parsing function call.
Another thing is to have a similar interface/phy registration like wireless, this need a new userspace software. I will try to create one, but this need some time.
Also I will try to implement the perm_address, the perm_address is for an extended address which is set by the driver. This can be a random generated one or contains information from an eeprom. This address would be default mac address of the registered wpan interface. At the moment our mac address is default 00..00.
Sorry, I think we should not accept more patches for next. If you like you can help me with the wireless transformation implementation. Simply ask or send patches which I should apply on the "wpan_rework_rfc" branch.
- Alex
[0] https://github.com/linux-wpan/linux-wpan-next/commits/wpan_rework_rfc
Alexander Aring (12):
mac802154: rx: warn if ieee80211_rx call from irq
mac802154: move header parse functions to rx.c
mac802154: rename sdata slaves and slaves_mtx
mac802154: introduce IEEE802154_DEV_TO_SUB_IF
mac802154: move slave open/close functions to wpan
mac802154: rename wpan.c to iface.c
mac802154: rx: use netif_receive_skb
mac802154: introduce internal driver-ops header
mac802154: remove useless -EBUSY if sdata running
mac802154: rework open count
mac802154: remove ieee802154_addr from driver_ops
mac802154: rework sdata state change to running
include/net/mac802154.h | 1 - net/mac802154/Makefile | 2 +- net/mac802154/driver-ops.h | 29 +++ net/mac802154/ieee802154_i.h | 20 +- net/mac802154/iface.c | 457 +++++++++++++++++++++++++++++++++ net/mac802154/mac_cmd.c | 2 +- net/mac802154/main.c | 114 ++------- net/mac802154/mib.c | 49 ++-- net/mac802154/rx.c | 190 ++++++++++++++ net/mac802154/tx.c | 4 +- net/mac802154/wpan.c | 596 ------------------------------------------- 11 files changed, 739 insertions(+), 725 deletions(-) create mode 100644 net/mac802154/driver-ops.h create mode 100644 net/mac802154/iface.c delete mode 100644 net/mac802154/wpan.c
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 1/12 mac802154: rx: warn if ieee80211_rx call from irq
This patch adds a warning if the ieee80211_rx function is called from an irq context which should never happen.
--- net/mac802154/rx.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac802154/rx.c +2 -0
@@ -65,6 +65,8 @@ fail:void ieee802154_rx (struct ieee802154_hw *hw,struct sk_buff *skb) { +WARN_ON_ONCE (softirq_count () ==0 ); +mac802154_subif_rx (hw, skb); }EXPORT_SYMBOL (ieee802154_rx);
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 2/12 mac802154: move header parse functions to rx.c
In reply to Alexander AringThis patch moves the frame parsing part inside the rx function. It's part of receive handling until netif_rx_ni is called.
--- net/mac802154/ieee802154_i.h | 1 - net/mac802154/rx.c | 188 +++++++++++++++++++++++++++++++++++++++++++ net/mac802154/wpan.c | 182 ----------------------------------------- 3 files changed, 188 insertions(+), 183 deletions(-)
net/mac802154/ieee802154_i.h +0 -1
@@ -122,7 +122,6 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;int mac802154_slave_open (struct net_device *dev);int mac802154_slave_close (struct net_device *dev); -void mac802154_wpans_rx (struct ieee802154_local *local,struct sk_buff *skb);void mac802154_wpan_setup (struct net_device *dev); netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
net/mac802154/rx.c +188 -0
200 lines not on this page · raw message
net/mac802154/wpan.c +0 -182
185 lines not on this page · raw message
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 3/12 mac802154: rename sdata slaves and slaves_mtx
In reply to Alexander AringThis patch namens the slaves attribute in sdata to interfaces and slaves_mtx to iflist_mtx. This patch is part to get the wireless feeling into the 802.15.4 implementation.
--- net/mac802154/ieee802154_i.h | 4 ++-- net/mac802154/main.c | 54 ++++++++++++++++++++++---------------------- net/mac802154/rx.c | 2 +- net/mac802154/tx.c | 4 ++-- net/mac802154/wpan.c | 8 +++---- 5 files changed, 36 insertions(+), 36 deletions(-)
net/mac802154/ieee802154_i.h +2 -2
@@ -87,8 +87,8 @@ struct ieee802154_local {* * So atomic readers can use any of this protection methods. */ -struct list_head slaves; -struct mutex slaves_mtx; +struct list_head interfaces; +struct mutex iflist_mtx;/* This one is used for scanning and other jobs not to be interfered * with serial driver.
net/mac802154/main.c +27 -27
126 lines not on this page · raw message
net/mac802154/rx.c +1 -1
@@ -205,7 +205,7 @@ mac802154_wpans_rx(struct ieee802154_local *local, struct sk_buff *skb) }rcu_read_lock (); -list_for_each_entry_rcu (sdata, &local->slaves, list) { +list_for_each_entry_rcu (sdata, &local->interfaces, list) {if (sdata->type !=NL802154_IFTYPE_NODE || !netif_running (sdata->dev))continue ;
net/mac802154/tx.c +2 -2
@@ -72,7 +72,7 @@ out:/* Restart the netif queue on each sub_if_data object. */ rcu_read_lock (); -list_for_each_entry_rcu (sdata, &xw->local->slaves, list) +list_for_each_entry_rcu (sdata, &xw->local->interfaces, list)netif_wake_queue (sdata->dev);rcu_read_unlock ();
@@ -111,7 +111,7 @@ netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,/* Stop the netif queue on each sub_if_data object. */ rcu_read_lock (); -list_for_each_entry_rcu (sdata, &local->slaves, list) +list_for_each_entry_rcu (sdata, &local->interfaces, list)netif_stop_queue (sdata->dev);rcu_read_unlock ();
net/mac802154/wpan.c +4 -4
@@ -129,9 +129,9 @@ int mac802154_set_mac_params(struct net_device *dev, {struct ieee802154_sub_if_data *sdata =netdev_priv (dev); -mutex_lock (&sdata->local->slaves_mtx); +mutex_lock (&sdata->local->iflist_mtx); sdata->mac_params = *params; -mutex_unlock (&sdata->local->slaves_mtx); +mutex_unlock (&sdata->local->iflist_mtx);return 0 ; }
@@ -141,9 +141,9 @@ void mac802154_get_mac_params(struct net_device *dev, {struct ieee802154_sub_if_data *sdata =netdev_priv (dev); -mutex_lock (&sdata->local->slaves_mtx); +mutex_lock (&sdata->local->iflist_mtx); *params = sdata->mac_params; -mutex_unlock (&sdata->local->slaves_mtx); +mutex_unlock (&sdata->local->iflist_mtx); }static int mac802154_wpan_open (struct net_device *dev)
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 4/12 mac802154: introduce IEEE802154_DEV_TO_SUB_IF
In reply to Alexander AringThis function adds a wrapper to call netdev_priv to getting the sdata attribute. There exists a similar function in the wirless stack.
--- net/mac802154/ieee802154_i.h | 6 ++++++ net/mac802154/mac_cmd.c | 2 +- net/mac802154/main.c | 11 ++++------ net/mac802154/mib.c | 49 ++++++++++++++++++++++---------------------- net/mac802154/wpan.c | 20 ++++++++---------- 5 files changed, 45 insertions(+), 43 deletions(-)
net/mac802154/ieee802154_i.h +6 -0
@@ -116,6 +116,12 @@ hw_to_local(struct ieee802154_hw *hw) return container_of(hw, struct ieee802154_local, hw); } +static inline struct ieee802154_sub_if_data * +IEEE802154_DEV_TO_SUB_IF (const struct net_device *dev) +{ +return netdev_priv (dev); +} +extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
net/mac802154/mac_cmd.c +1 -1
@@ -79,7 +79,7 @@ static int mac802154_mlme_start_req(struct net_device *dev,static struct wpan_phy *mac802154_get_phy (const struct net_device *dev) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);BUG_ON (dev->type !=ARPHRD_IEEE802154 );
net/mac802154/main.c +4 -7
@@ -31,7 +31,7 @@int mac802154_slave_open (struct net_device *dev) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct ieee802154_sub_if_data *subif;struct ieee802154_local *local = sdata->local;int res =0 ;
@@ -81,7 +81,7 @@ err:int mac802154_slave_close (struct net_device *dev) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct ieee802154_local *local = sdata->local;ASSERT_RTNL ();
@@ -101,13 +101,12 @@ int mac802154_slave_close(struct net_device *dev)static int mac802154_netdev_register (struct wpan_phy *phy,struct net_device *dev) { -struct ieee802154_sub_if_data *sdata; +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct ieee802154_local *local;int err; local =wpan_phy_priv (phy); - sdata =netdev_priv (dev); sdata->dev = dev; sdata->local = local;
@@ -138,12 +137,10 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)static void mac802154_del_iface (struct wpan_phy *phy,struct net_device *dev) { -struct ieee802154_sub_if_data *sdata; +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);ASSERT_RTNL (); - sdata =netdev_priv (dev); -BUG_ON (sdata->local->phy != phy);mutex_lock (&sdata->local->iflist_mtx);
net/mac802154/mib.c +25 -24
187 lines not on this page · raw message
net/mac802154/wpan.c +9 -11
@@ -37,7 +37,7 @@static int mac802154_wpan_update_llsec (struct net_device *dev) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct ieee802154_mlme_ops *ops =ieee802154_mlme_ops (dev);int rc =0 ;
@@ -60,7 +60,7 @@ static int mac802154_wpan_update_llsec(struct net_device *dev)static int mac802154_wpan_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct sockaddr_ieee802154 *sa = (struct sockaddr_ieee802154 *)&ifr->ifr_addr;int err = -ENOIOCTLCMD ;
@@ -127,7 +127,7 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)int mac802154_set_mac_params (struct net_device *dev,const struct ieee802154_mac_params *params) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);mutex_lock (&sdata->local->iflist_mtx); sdata->mac_params = *params;
@@ -139,7 +139,7 @@ int mac802154_set_mac_params(struct net_device *dev,void mac802154_get_mac_params (struct net_device *dev,struct ieee802154_mac_params *params) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);mutex_lock (&sdata->local->iflist_mtx); *params = sdata->mac_params;
@@ -149,7 +149,7 @@ void mac802154_get_mac_params(struct net_device *dev,static int mac802154_wpan_open (struct net_device *dev) {int rc; -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct wpan_phy *phy = sdata->local->phy; rc =mac802154_slave_open (dev);
@@ -245,7 +245,7 @@ static int mac802154_header_create(struct sk_buff *skb, unsigned len) {struct ieee802154_hdr hdr; -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct ieee802154_mac_cb *cb =mac_cb (skb);int hlen;
@@ -314,12 +314,10 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)static netdev_tx_t mac802154_wpan_xmit (struct sk_buff *skb,struct net_device *dev) { -struct ieee802154_sub_if_data *sdata; +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);u8 chan, page;int rc; - sdata =netdev_priv (dev); -spin_lock_bh (&sdata->mib_lock); chan = sdata->chan; page = sdata->page;
@@ -361,7 +359,7 @@ static const struct net_device_ops mac802154_wpan_ops = {static void mac802154_wpan_free (struct net_device *dev) { -struct ieee802154_sub_if_data *sdata =netdev_priv (dev); +struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);mac802154_llsec_destroy (&sdata->sec);
@@ -388,7 +386,7 @@ void mac802154_wpan_setup(struct net_device *dev) dev->netdev_ops = &mac802154_wpan_ops; dev->ml_priv = &mac802154_mlme_wpan; - sdata =netdev_priv (dev); + sdata =IEEE802154_DEV_TO_SUB_IF (dev); sdata->type =NL802154_IFTYPE_NODE ; sdata->chan =MAC802154_CHAN_NONE ;
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 5/12 mac802154: move slave open/close functions to wpan
In reply to Alexander AringThis function is never used outside of wpan.c and can be static there. This patch moves these functions into the wpan.c file.
--- net/mac802154/ieee802154_i.h | 3 -- net/mac802154/main.c | 69 -------------------------------------------- net/mac802154/wpan.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 72 deletions(-)
net/mac802154/ieee802154_i.h +0 -3
@@ -125,9 +125,6 @@ IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;extern struct ieee802154_mlme_ops mac802154_mlme_wpan; -int mac802154_slave_open (struct net_device *dev); -int mac802154_slave_close (struct net_device *dev); -void mac802154_wpan_setup (struct net_device *dev); netdev_tx_t mac802154_tx(struct ieee802154_local *local, struct sk_buff *skb,
net/mac802154/main.c +0 -69
75 lines not on this page · raw message
net/mac802154/wpan.c +69 -0
75 lines not on this page · raw message
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 6/12 mac802154: rename wpan.c to iface.c
In reply to Alexander AringThe wpan.c file contains interface handling functions now. This file is similar like the mac80211 iface.c. We rename this file to iface.c to get the wireless feeling into the 802.15.4 implementation.
--- net/mac802154/Makefile | 2 +- net/mac802154/iface.c | 478 ++++++++++++++++++++++++++++++++++++++++++++++++ net/mac802154/wpan.c | 481 ------------------------------------------------- 3 files changed, 479 insertions(+), 482 deletions(-) create mode 100644 net/mac802154/iface.c delete mode 100644 net/mac802154/wpan.c
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 \ - wpan.o llsec.o + iface.o llsec.o ccflags-y += -D__CHECK_ENDIAN__
net/mac802154/iface.c new file +478 -0
478 lines not on this page · raw message
net/mac802154/wpan.c deleted +0 -481
481 lines not on this page · raw message
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 7/12 mac802154: rx: use netif_receive_skb
In reply to Alexander AringTo use netif_receive_skb or netif_rx_ni depends on context. We have a tasklet which is the same like mac80211 and we should use the same net rx delivery function netif_receive_skb.
--- net/mac802154/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac802154/rx.c +1 -1
@@ -36,7 +36,7 @@static int mac802154_process_data (struct net_device *dev,struct sk_buff *skb) { -return netif_rx_ni (skb); +return netif_receive_skb (skb); } static int
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 8/12 mac802154: introduce internal driver-ops header
In reply to Alexander AringWe should not call the driver ops callbacks directly. This patch introduce a driver-ops header file to calling these wrappers. It's like the mac80211 driver-ops header.
--- net/mac802154/driver-ops.h | 29 +++++++++++++++++++++++++++++ net/mac802154/iface.c | 5 +++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 net/mac802154/driver-ops.h
net/mac802154/driver-ops.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef __MAC802154_DRVIER_OPS +#define __MAC802154_DRIVER_OPS + +#include <net/mac802154.h> + +#include "ieee802154_i.h" + +static inline int drv_start (struct ieee802154_local *local) +{ +might_sleep (); + +smp_mb (); +return local->ops->start (&local->hw); +} + +static inline void drv_stop (struct ieee802154_local *local) +{ +might_sleep (); + + local->ops->stop (&local->hw); + +/* sync away all work on the tasklet before clearing started */ +tasklet_disable (&local->tasklet); +tasklet_enable (&local->tasklet); + +barrier (); +} + +#endif /* __MAC802154_DRVIER_OPS */
net/mac802154/iface.c +3 -2
@@ -29,6 +29,7 @@#include <net/ieee802154.h> #include <net/wpan-phy.h> +#include "driver-ops.h" #include "ieee802154_i.h" static int mac802154_slave_open (struct net_device *dev)
@@ -57,7 +58,7 @@ static int mac802154_slave_open(struct net_device *dev)mutex_unlock (&sdata->local->iflist_mtx);if (local->open_count++ ==0 ) { - res = local->ops->start (&local->hw); + res =drv_start (local);WARN_ON (res);if (res) goto err;
@@ -95,7 +96,7 @@ static int mac802154_slave_close(struct net_device *dev)mutex_unlock (&sdata->local->iflist_mtx);if (!--local->open_count) - local->ops->stop (&local->hw); +drv_stop (local);return 0 ; }
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 9/12 mac802154: remove useless -EBUSY if sdata running
In reply to Alexander AringThe slave_open function is only called by ndo_open callback. This callback is already protected to do a ip link set wpan0 up twice. This patch removing also a unnecessary for each loop to find the right entry which is already known.
--- net/mac802154/iface.c | 13 ------------- 1 file changed, 13 deletions(-)
net/mac802154/iface.c +0 -13
@@ -35,24 +35,11 @@static int mac802154_slave_open (struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev); -struct ieee802154_sub_if_data *subif;struct ieee802154_local *local = sdata->local;int res =0 ;ASSERT_RTNL (); -if (sdata->type ==NL802154_IFTYPE_NODE ) { -mutex_lock (&sdata->local->iflist_mtx); -list_for_each_entry (subif, &sdata->local->interfaces, list) { -if (subif != sdata && subif->type == sdata->type && - subif->running) { -mutex_unlock (&sdata->local->iflist_mtx); -return -EBUSY ; - } - } -mutex_unlock (&sdata->local->iflist_mtx); - } -mutex_lock (&sdata->local->iflist_mtx); sdata->running = true;mutex_unlock (&sdata->local->iflist_mtx);
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 10/12 mac802154: rework open count
In reply to Alexander AringSome cleanup to avoid pre- and post-calculation with the open_count variable.
--- net/mac802154/iface.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
net/mac802154/iface.c +11 -8
@@ -40,17 +40,17 @@ static int mac802154_slave_open(struct net_device *dev)ASSERT_RTNL (); -mutex_lock (&sdata->local->iflist_mtx); - sdata->running = true; -mutex_unlock (&sdata->local->iflist_mtx); - -if (local->open_count++ ==0 ) { +if (!local->open_count) { res =drv_start (local);WARN_ON (res);if (res) goto err; } +mutex_lock (&sdata->local->iflist_mtx); + sdata->running = true; +mutex_unlock (&sdata->local->iflist_mtx); +if (local->ops->ieee_addr) {__le64 addr =ieee802154_devaddr_from_raw (dev->dev_addr);
@@ -61,11 +61,12 @@ static int mac802154_slave_open(struct net_device *dev)mac802154_dev_set_ieee_addr (dev); } + local->open_count++; +netif_start_queue (dev); +return 0 ; err: - sdata->local->open_count--; -return res; }
@@ -78,11 +79,13 @@ static int mac802154_slave_close(struct net_device *dev)netif_stop_queue (dev); + local->open_count--; +mutex_lock (&sdata->local->iflist_mtx); sdata->running = false;mutex_unlock (&sdata->local->iflist_mtx); -if (!--local->open_count) +if (!local->open_count)drv_stop (local);return 0 ;
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 11/12 mac802154: remove ieee802154_addr from driver_ops
In reply to Alexander AringThis function is never used by any driver. There exist also no comment for this. In my opinion it was a try to implement hardware address filter but we have already such driver ops for this functionallity.
--- include/net/mac802154.h | 1 - net/mac802154/iface.c | 10 ---------- 2 files changed, 11 deletions(-)
include/net/mac802154.h +0 -1
@@ -173,7 +173,6 @@ struct ieee802154_ops {int (*set_hw_addr_filt)(struct ieee802154_hw *hw,struct ieee802154_hw_addr_filt *filt,unsigned long changed); -int (*ieee_addr)(struct ieee802154_hw *hw,__le64 addr);int (*set_txpower)(struct ieee802154_hw *hw,int db);int (*set_lbt)(struct ieee802154_hw *hw,bool on);int (*set_cca_mode)(struct ieee802154_hw *hw,u8 mode);
net/mac802154/iface.c +0 -10
@@ -51,16 +51,6 @@ static int mac802154_slave_open(struct net_device *dev) sdata->running = true;mutex_unlock (&sdata->local->iflist_mtx); -if (local->ops->ieee_addr) { -__le64 addr =ieee802154_devaddr_from_raw (dev->dev_addr); - - res = local->ops->ieee_addr (&local->hw, addr); -WARN_ON (res); -if (res) - goto err; -mac802154_dev_set_ieee_addr (dev); - } - local->open_count++;netif_start_queue (dev);
Signature · 1 line
2.0.3
Alexander Aring
maintainerPATCH 12/12 mac802154: rework sdata state change to running
In reply to Alexander AringThis patch reworks the handling for setting the state like mac80211. We use bit's instead a bool variable. The mutex is not needed because it's locked by rtnl lock.
--- net/mac802154/ieee802154_i.h | 6 +++++- net/mac802154/iface.c | 10 ++++------ 2 files changed, 9 insertions(+), 7 deletions(-)
net/mac802154/ieee802154_i.h +5 -1
@@ -31,6 +31,10 @@ enum { IEEE802154_RX_MSG = 1, }; +enum ieee802154_sdata_state_bits { +SDATA_STATE_RUNNING , +}; +/* Slave interface definition. * * Slaves represent typical network interfaces available from userspace.
@@ -44,7 +48,7 @@ struct ieee802154_sub_if_data {struct net_device *dev;int type; -bool running; +unsigned long state;spinlock_t mib_lock;
net/mac802154/iface.c +4 -6
@@ -47,9 +47,7 @@ static int mac802154_slave_open(struct net_device *dev) goto err; } -mutex_lock (&sdata->local->iflist_mtx); - sdata->running = true; -mutex_unlock (&sdata->local->iflist_mtx); +set_bit (SDATA_STATE_RUNNING , &sdata->state); local->open_count++;
@@ -57,6 +55,8 @@ static int mac802154_slave_open(struct net_device *dev)return 0 ; err: +/* might already be clear but that doesn't matter */ +clear_bit (SDATA_STATE_RUNNING , &sdata->state);return res; }
@@ -71,9 +71,7 @@ static int mac802154_slave_close(struct net_device *dev) local->open_count--; -mutex_lock (&sdata->local->iflist_mtx); - sdata->running = false; -mutex_unlock (&sdata->local->iflist_mtx); +clear_bit (SDATA_STATE_RUNNING , &sdata->state);if (!local->open_count)drv_stop (local);
Signature · 1 line
2.0.3
Alexander Aring
maintainerRe: [PATCH wpan-next 09/12] mac802154: remove useless -EBUSY if sdata running
In reply to Alexander AringHi,
Quoted 18 lines · Alexander Aring
The
slave_openfunction is only called byndo_opencallback. This callback is already protected to do a ip link set wpan0 up twice. This patch removing also a unnecessary for each loop to find the right entry which is already known.Signed-off-by Alexander Aring <[email protected]>--- net/mac802154/iface.c | 13 ------------- 1 file changed, 13 deletions(-)net/mac802154/iface.c +0
-0@@ -35,24 +35,11 @@static int mac802154_slave_open (struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);
net/mac802154/iface.c line 47
Quoted 10 lines
net/mac802154/iface.c +0
-5-struct ieee802154_sub_if_data *subif;struct ieee802154_local *local = sdata->local;int res =0 ;ASSERT_RTNL (); -if (sdata->type ==NL802154_IFTYPE_NODE ) { -mutex_lock (&sdata->local->iflist_mtx); -list_for_each_entry (subif, &sdata->local->interfaces, list) { - if (subif != sdata && subif->type == sdata->type &&
I will keep this patch, I thought this is subif == sdata... then it would not make sense. But this make sense now. It checks that we don't have an another running interface for a phy.
Sorry.
- Alex
Re: [PATCH wpan-next 12/12] mac802154: rework sdata state change to running
In reply to Alexander AringLooks good, I would think that the mutex is not needed as set_bit and clear_bit are atomic operations??
- Martin.
Quoted 69 lines · Alexander Aring
This patch reworks the handling for setting the state like mac80211. We use bit's instead a bool variable. The mutex is not needed because it's locked by rtnl lock.
Signed-off-by Alexander Aring <[email protected]>--- net/mac802154/ieee802154_i.h | 6 +++++- net/mac802154/iface.c | 10 ++++------ 2 files changed, 9 insertions(+), 7 deletions(-)net/mac802154/ieee802154_i.h +5
-1@@ -31,6 +31,10 @@ enum { IEEE802154_RX_MSG = 1, }; +enum ieee802154_sdata_state_bits { +SDATA_STATE_RUNNING , +}; +/* Slave interface definition. * * Slaves represent typical network interfaces available from userspace. @@ -44,7 +48,7 @@ struct ieee802154_sub_if_data {struct net_device *dev;int type; -bool running; +unsigned long state;spinlock_t mib_lock;net/mac802154/iface.c +4
-6@@ -47,9 +47,7 @@ static int mac802154_slave_open(struct net_device *dev) goto err; } -mutex_lock (&sdata->local->iflist_mtx); - sdata->running = true; -mutex_unlock (&sdata->local->iflist_mtx); +set_bit (SDATA_STATE_RUNNING , &sdata->state); local->open_count++;@@ -57,6 +55,8 @@ static int mac802154_slave_open(struct net_device *dev)return 0 ; err: +/* might already be clear but that doesn't matter */ +clear_bit (SDATA_STATE_RUNNING , &sdata->state);return res; }@@ -71,9 +71,7 @@ static int mac802154_slave_close(struct net_device *dev) local->open_count--; -mutex_lock (&sdata->local->iflist_mtx); - sdata->running = false; -mutex_unlock (&sdata->local->iflist_mtx); +clear_bit (SDATA_STATE_RUNNING , &sdata->state);if (!local->open_count)drv_stop (local);
Alexander Aring
maintainerRe: [PATCH wpan-next 12/12] mac802154: rework sdata state change to running
Quoted 2 lines · Martin Townsend
Looks good, I would think that the mutex is not needed as
set_bitandclear_bitare atomic operations??
you are right, it's atomic. I will change the commit msg according to this. I thought it would be locked because it's only read/write when rtnl lock is hold. This is the current behaviour, but it's not necessary.
- Alex
Alexander Aring
maintainerRe: [PATCH wpan-next 09/12] mac802154: remove useless -EBUSY if sdata running
In reply to Alexander AringHi,
Quoted 25 lines · Alexander Aring
The
slave_openfunction is only called byndo_opencallback. This callback is already protected to do a ip link set wpan0 up twice. This patch removing also a unnecessary for each loop to find the right entry which is already known.Signed-off-by Alexander Aring <[email protected]>--- net/mac802154/iface.c | 13 ------------- 1 file changed, 13 deletions(-)net/mac802154/iface.c +0
-2@@ -35,24 +35,11 @@static int mac802154_slave_open (struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev); -struct ieee802154_sub_if_data *subif;struct ieee802154_local *local = sdata->local;int res =0 ;ASSERT_RTNL (); -if (sdata->type ==NL802154_IFTYPE_NODE ) {
net/mac802154/iface.c line 54
Quoted 10 lines
net/mac802154/iface.c +0
-10-mutex_lock (&sdata->local->iflist_mtx); -list_for_each_entry (subif, &sdata->local->interfaces, list) { -if (subif != sdata && subif->type == sdata->type && - subif->running) { -mutex_unlock (&sdata->local->iflist_mtx); -return -EBUSY ; - } - } -mutex_unlock (&sdata->local->iflist_mtx); - }
I finally found where it was copy&pasted from wireless code and obfuscated afterwards. [0]
It's like a good puzzle. :-)
I adapt the current 80211 behaviour.
I will write a status update about the rework process today.
- Alex
[0] http://lxr.free-electrons.com/source/net/mac80211/iface.c?v=3.16#L257