From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, mkl@pengutronix.de,
Alexander Aring <alex.aring@gmail.com>
Subject: [PATCHv3 bluetooth-next 3/4] ieee802154: move mac pib defaults
Date: Tue, 7 Apr 2015 13:49:52 +0200 [thread overview]
Message-ID: <1428407393-16005-4-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1428407393-16005-1-git-send-email-alex.aring@gmail.com>
This patch moves the mac pib defaults setting out of SoftMAC layer. This
will prepare for possible HardMAC drivers that these values are 802.15.4
defaults while netdev registration. Currently the SoftMAC layer is the wrong
place to do the settings of pib defaults.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/core.c | 30 ++++++++++++++++++++++++++++++
net/mac802154/iface.c | 15 ---------------
2 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index 2ee00e8..7a107b0 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -211,6 +211,35 @@ cfg802154_update_iface_num(struct cfg802154_registered_device *rdev,
rdev->num_running_ifaces += num;
}
+static void
+cfg802154_reset_mac_pib(struct wpan_dev *wpan_dev)
+{
+ get_random_bytes(&wpan_dev->bsn, 1);
+ get_random_bytes(&wpan_dev->dsn, 1);
+
+ /* defaults per 802.15.4-2011 */
+ wpan_dev->min_be = 3;
+ wpan_dev->max_be = 5;
+ wpan_dev->csma_retries = 4;
+ /* for compatibility, actual default is 3 */
+ wpan_dev->frame_retries = -1;
+
+ wpan_dev->pan_id = cpu_to_le16(IEEE802154_PAN_ID_BROADCAST);
+ wpan_dev->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST);
+
+ /* normally false, but monitors are always in promiscuous_mode */
+ switch (wpan_dev->iftype) {
+ case NL802154_IFTYPE_NODE:
+ wpan_dev->promiscuous_mode = false;
+ break;
+ case NL802154_IFTYPE_MONITOR:
+ wpan_dev->promiscuous_mode = true;
+ break;
+ default:
+ BUG();
+ }
+}
+
static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
unsigned long state, void *ptr)
{
@@ -234,6 +263,7 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
rdev->devlist_generation++;
wpan_dev->netdev = dev;
+ cfg802154_reset_mac_pib(wpan_dev);
break;
case NETDEV_DOWN:
cfg802154_update_iface_num(rdev, wpan_dev->iftype, -1);
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 38b56f9..3f6a3fe 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -479,19 +479,6 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
sdata->vif.type = type;
sdata->wpan_dev.iftype = type;
- get_random_bytes(&wpan_dev->bsn, 1);
- get_random_bytes(&wpan_dev->dsn, 1);
-
- /* defaults per 802.15.4-2011 */
- wpan_dev->min_be = 3;
- wpan_dev->max_be = 5;
- wpan_dev->csma_retries = 4;
- /* for compatibility, actual default is 3 */
- wpan_dev->frame_retries = -1;
-
- wpan_dev->pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
- wpan_dev->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
-
switch (type) {
case NL802154_IFTYPE_NODE:
ieee802154_be64_to_le64(&wpan_dev->extended_addr,
@@ -501,7 +488,6 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
sdata->dev->destructor = mac802154_wpan_free;
sdata->dev->netdev_ops = &mac802154_wpan_ops;
sdata->dev->ml_priv = &mac802154_mlme_wpan;
- wpan_dev->promiscuous_mode = false;
spin_lock_init(&sdata->mib_lock);
mutex_init(&sdata->sec_mtx);
@@ -511,7 +497,6 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
case NL802154_IFTYPE_MONITOR:
sdata->dev->destructor = free_netdev;
sdata->dev->netdev_ops = &mac802154_monitor_ops;
- wpan_dev->promiscuous_mode = true;
break;
default:
BUG();
--
2.3.5
next prev parent reply other threads:[~2015-04-07 11:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 11:49 [PATCHv3 bluetooth-next 0/4] ieee802154: nl802154 SET commands and pib defaults Alexander Aring
2015-04-07 11:49 ` [PATCHv3 bluetooth-next 1/4] nl802154: add set wpan phy cmd Alexander Aring
2015-04-07 11:49 ` [PATCHv3 bluetooth-next 2/4] nl802154: add set interface cmd Alexander Aring
2015-04-07 11:59 ` Phoebe Buckheister
2015-04-07 12:21 ` Alexander Aring
2015-04-07 12:29 ` Varka Bhadram
2015-04-07 13:14 ` Alexander Aring
2015-04-07 12:29 ` Phoebe Buckheister
2015-04-07 12:59 ` Alexander Aring
2015-04-07 13:02 ` Phoebe Buckheister
2015-04-07 13:25 ` Alexander Aring
2015-04-07 13:32 ` Phoebe Buckheister
2015-04-07 13:40 ` Alexander Aring
2015-04-07 11:49 ` Alexander Aring [this message]
2015-04-07 11:49 ` [PATCHv3 bluetooth-next 4/4] ieee802154: set aret handling according to 802.15.4 Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1428407393-16005-4-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-wpan@vger.kernel.org \
--cc=mkl@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox