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: [PATCHv2 bluetooth-next 1/4] nl802154: add set wpan phy cmd
Date: Mon, 23 Mar 2015 16:45:38 +0100 [thread overview]
Message-ID: <1427125541-28708-2-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1427125541-28708-1-git-send-email-alex.aring@gmail.com>
This patch adds NL802154_CMD_SET_WPAN_PHY command to set all wpan phy
attributes instead of doing separate commands. This will improve
userspace application handling of nl802154.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/ieee802154/nl802154.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index a4daf91..c12c07f 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -437,6 +437,49 @@ static int nl802154_get_wpan_phy(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info);
}
+static int nl802154_set_wpan_phy(struct sk_buff *skb, struct genl_info *info)
+{
+ struct cfg802154_registered_device *rdev = info->user_ptr[0];
+ int ret;
+
+ if (info->attrs[NL802154_ATTR_PAGE] &&
+ info->attrs[NL802154_ATTR_CHANNEL]) {
+ u8 channel, page;
+
+ page = nla_get_u8(info->attrs[NL802154_ATTR_PAGE]);
+ channel = nla_get_u8(info->attrs[NL802154_ATTR_CHANNEL]);
+ if (page > IEEE802154_MAX_PAGE ||
+ channel > IEEE802154_MAX_CHANNEL)
+ return -EINVAL;
+
+ ret = rdev_set_channel(rdev, page, channel);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (info->attrs[NL802154_ATTR_CCA_MODE]) {
+ struct wpan_phy_cca cca;
+
+ cca.mode = nla_get_u32(info->attrs[NL802154_ATTR_CCA_MODE]);
+ if (cca.mode < NL802154_CCA_ENERGY ||
+ cca.mode > NL802154_CCA_ATTR_MAX)
+ return -EINVAL;
+
+ if (cca.mode == NL802154_CCA_ENERGY_CARRIER) {
+ if (!info->attrs[NL802154_ATTR_CCA_OPT])
+ return -EINVAL;
+
+ cca.opt = nla_get_u32(info->attrs[NL802154_ATTR_CCA_OPT]);
+ if (cca.opt > NL802154_CCA_OPT_ATTR_MAX)
+ return -EINVAL;
+ }
+
+ return rdev_set_cca_mode(rdev, &cca);
+ }
+
+ return 0;
+}
+
static inline u64 wpan_dev_id(struct wpan_dev *wpan_dev)
{
return (u64)wpan_dev->identifier |
@@ -896,6 +939,14 @@ static const struct genl_ops nl802154_ops[] = {
NL802154_FLAG_NEED_RTNL,
},
{
+ .cmd = NL802154_CMD_SET_WPAN_PHY,
+ .doit = nl802154_set_wpan_phy,
+ .policy = nl802154_policy,
+ .flags = GENL_ADMIN_PERM,
+ .internal_flags = NL802154_FLAG_NEED_WPAN_PHY |
+ NL802154_FLAG_NEED_RTNL,
+ },
+ {
.cmd = NL802154_CMD_GET_INTERFACE,
.doit = nl802154_get_interface,
.dumpit = nl802154_dump_interface,
--
2.3.3
next prev parent reply other threads:[~2015-03-23 15:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 15:45 [PATCHv2 bluetooth-next 0/4] ieee802154: nl802154 SET commands and pib defaults Alexander Aring
2015-03-23 15:45 ` Alexander Aring [this message]
2015-03-24 3:41 ` [PATCHv2 bluetooth-next 1/4] nl802154: add set wpan phy cmd Varka Bhadram
2015-03-24 8:43 ` Alexander Aring
2015-03-23 15:45 ` [PATCHv2 bluetooth-next 2/4] nl802154: add set interface cmd Alexander Aring
2015-03-23 15:45 ` [PATCHv2 bluetooth-next 3/4] ieee802154: move mac pib defaults Alexander Aring
2015-03-23 15:45 ` [PATCHv2 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=1427125541-28708-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.