mac802154: iface: fix order while interface up
Subsystems (2)
Alexander Aring
maintainerPATCH 1/2 mac802154: iface: fix order while interface up
This patch moves the hardware setting before calling the driver start callback which activates the receive handling. The hardware setup contains settings like address filtering which should be setup before activate the receive handling on the transceiver. These setting are protected by ieee802154_check_concurrent_iface check. This means we need to set these registers once before calling drv_start and can't be overwritten by other interfaces.
--- net/mac802154/iface.c | 103 +++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 48 deletions(-)
net/mac802154/iface.c +55 -48
@@ -135,6 +135,56 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)return mac802154_wpan_update_llsec (dev); } +static int ieee802154_setup_hw (struct ieee802154_sub_if_data *sdata) +{ +struct ieee802154_local *local = sdata->local; +struct wpan_dev *wpan_dev = &sdata->wpan_dev; +int ret; + +if (local->hw.flags &IEEE802154_HW_PROMISCUOUS ) { + ret =drv_set_promiscuous_mode (local, + wpan_dev->promiscuous_mode); +if (ret <0 ) +return ret; + } + +if (local->hw.flags &IEEE802154_HW_AFILT ) { + ret =drv_set_pan_id (local, wpan_dev->pan_id); +if (ret <0 ) +return ret; + + ret =drv_set_extended_addr (local, wpan_dev->extended_addr); +if (ret <0 ) +return ret; + + ret =drv_set_short_addr (local, wpan_dev->short_addr); +if (ret <0 ) +return ret; + } + +if (local->hw.flags &IEEE802154_HW_LBT ) { + ret =drv_set_lbt_mode (local, wpan_dev->lbt); +if (ret <0 ) +return ret; + } + +if (local->hw.flags &IEEE802154_HW_CSMA_PARAMS ) { + ret =drv_set_csma_params (local, wpan_dev->min_be, + wpan_dev->max_be, + wpan_dev->csma_retries); +if (ret <0 ) +return ret; + } + +if (local->hw.flags &IEEE802154_HW_FRAME_RETRIES ) { + ret =drv_set_max_frame_retries (local, wpan_dev->frame_retries); +if (ret <0 ) +return ret; + } + +return 0 ; +} +static int mac802154_slave_open (struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);
@@ -146,6 +196,10 @@ static int mac802154_slave_open(struct net_device *dev)set_bit (SDATA_STATE_RUNNING , &sdata->state);if (!local->open_count) { + res =ieee802154_setup_hw (sdata); +if (res) + goto err; + res =drv_start (local);if (res) goto err;
@@ -239,60 +293,13 @@ static int mac802154_wpan_open(struct net_device *dev) {int rc;struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev); -struct ieee802154_local *local = sdata->local;struct wpan_dev *wpan_dev = &sdata->wpan_dev; rc =ieee802154_check_concurrent_iface (sdata, wpan_dev->iftype);if (rc <0 )return rc; - rc =mac802154_slave_open (dev); -if (rc <0 ) -return rc; - -if (local->hw.flags &IEEE802154_HW_PROMISCUOUS ) { - rc =drv_set_promiscuous_mode (local, - wpan_dev->promiscuous_mode); -if (rc <0 ) - goto out; - } - -if (local->hw.flags &IEEE802154_HW_AFILT ) { - rc =drv_set_pan_id (local, wpan_dev->pan_id); -if (rc <0 ) - goto out; - - rc =drv_set_extended_addr (local, wpan_dev->extended_addr); -if (rc <0 ) - goto out; - - rc =drv_set_short_addr (local, wpan_dev->short_addr); -if (rc <0 ) - goto out; - } - -if (local->hw.flags &IEEE802154_HW_LBT ) { - rc =drv_set_lbt_mode (local, wpan_dev->lbt); -if (rc <0 ) - goto out; - } - -if (local->hw.flags &IEEE802154_HW_CSMA_PARAMS ) { - rc =drv_set_csma_params (local, wpan_dev->min_be, - wpan_dev->max_be, - wpan_dev->csma_retries); -if (rc <0 ) - goto out; - } - -if (local->hw.flags &IEEE802154_HW_FRAME_RETRIES ) { - rc =drv_set_max_frame_retries (local, wpan_dev->frame_retries); -if (rc <0 ) - goto out; - } - -out: -return rc; +return mac802154_slave_open (dev); }static int mac802154_slave_close (struct net_device *dev)
Signature · 1 line
2.4.1
Alexander Aring
maintainerPATCH 2/2 mac802154: iface: cleanup stack variable
There is no need to init res with zero, res can be unused but then we returning zero and not res.
--- net/mac802154/iface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac802154/iface.c +1 -1
@@ -189,7 +189,7 @@ static int mac802154_slave_open(struct net_device *dev) {struct ieee802154_sub_if_data *sdata =IEEE802154_DEV_TO_SUB_IF (dev);struct ieee802154_local *local = sdata->local; -int res =0 ; +int res;ASSERT_RTNL ();
Signature · 1 line
2.4.1
Re: [PATCH bluetooth-next 2/2] mac802154: iface: cleanup stack variable
Hi Alex,
Quoted 7 lines
There is no need to init res with zero, res can be unused but then we returning zero and not res.
Signed-off-by Alexander Aring <[email protected]>---
net/mac802154/iface.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Hi Alex,
Quoted 8 lines
This patch moves the hardware setting before calling the driver start callback which activates the receive handling. The hardware setup contains settings like address filtering which should be setup before activate the receive handling on the transceiver. These setting are protected by
ieee802154_check_concurrent_ifacecheck. This means we need to set these registers once before callingdrv_startand can't be overwritten by other interfaces.
Quoted 4 lines
Signed-off-by Alexander Aring <[email protected]>---
net/mac802154/iface.c| 103 +++++++++++++++++++++++++++-----------------------1 file changed, 55 insertions(+), 48 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel