Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
* [PATCH bluetooth-next 0/2] nl802154: implement new SET commands
@ 2015-03-18 11:40 Alexander Aring
  2015-03-18 11:40 ` [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd Alexander Aring
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alexander Aring @ 2015-03-18 11:40 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, mkl, Alexander Aring

Hi,

this patch-series implement the already existed SET commands of an interface
and a wpan-phy. Currently we have one CMD for each setting which was a mistake
by me to implement it in this way. So we aren't currently a "real" UAPI header
for nl802154 and it's still under development. I decide now to change to
implement these setting in this way now. Currently I let these commands in
coexistens with the old commands but _NOTE_ I will remove the other commands
from the nl802154 later.

So please use the new commands. When these patches are mainline I also want to
release a new wpan-tools release which use this new interface. Then everybody
has some time to change to the new wpan-tools release. After this "time" I will
remove the obsolete nl802154 commands from the header. This means older
wpan-tools releases doesn't work any more with new kernels. Also this means
newer wpan-tools releases doesn't work with older kernels. That will end in
some kind of chaos and I will note this on the website.

This beahviour to do it in only one command is much easier to handle in
userspace, like clicking an "apply button".

- Alex

Alexander Aring (2):
  nl802154: add set wpan phy cmd
  nl802154: add set interface cmd

 net/ieee802154/nl802154.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 162 insertions(+)

-- 
2.3.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd
  2015-03-18 11:40 [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Alexander Aring
@ 2015-03-18 11:40 ` Alexander Aring
  2015-03-18 11:52   ` Alexander Aring
  2015-03-18 11:40 ` [PATCH bluetooth-next 2/2] nl802154: add set interface cmd Alexander Aring
  2015-03-18 11:59 ` [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Varka Bhadram
  2 siblings, 1 reply; 6+ messages in thread
From: Alexander Aring @ 2015-03-18 11:40 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, mkl, Alexander Aring

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 | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index a4daf91..111e9a1 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,15 @@ static const struct genl_ops nl802154_ops[] = {
 				  NL802154_FLAG_NEED_RTNL,
 	},
 	{
+		.cmd = NL802154_CMD_SET_WPAN_PHY,
+		.doit = nl802154_set_wpan_phy,
+		.done = nl802154_dump_wpan_phy_done,
+		.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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH bluetooth-next 2/2] nl802154: add set interface cmd
  2015-03-18 11:40 [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Alexander Aring
  2015-03-18 11:40 ` [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd Alexander Aring
@ 2015-03-18 11:40 ` Alexander Aring
  2015-03-18 11:59 ` [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Varka Bhadram
  2 siblings, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2015-03-18 11:40 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, mkl, Alexander Aring

This patch introduce the NL802154_CMD_SET_INTERFACE command which
handles setting of all wpan interface mac attributes. This will reduce
the complexity of several netlink commands for each attributes and
userspace applications are easier to implement.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/ieee802154/nl802154.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 111e9a1..b1d8e51 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -603,6 +603,108 @@ static int nl802154_get_interface(struct sk_buff *skb, struct genl_info *info)
 	return genlmsg_reply(msg, info);
 }
 
+static int nl802154_set_interface(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg802154_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
+	int ret;
+
+	if (info->attrs[NL802154_ATTR_PAN_ID]) {
+		__le16 pan_id;
+
+		if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+			return -EINVAL;
+
+		if (netif_running(dev))
+			return -EBUSY;
+
+		pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);
+		ret = rdev_set_pan_id(rdev, wpan_dev, pan_id);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (info->attrs[NL802154_ATTR_SHORT_ADDR]) {
+		__le16 short_addr;
+
+		if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+			return -EINVAL;
+
+		if (netif_running(dev))
+			return -EBUSY;
+
+		short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
+
+		ret = rdev_set_short_addr(rdev, wpan_dev, short_addr);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (info->attrs[NL802154_ATTR_MAX_FRAME_RETRIES]) {
+		s8 max_frame_retries;
+
+		if (netif_running(dev))
+			return -EBUSY;
+
+		max_frame_retries = nla_get_s8(
+				info->attrs[NL802154_ATTR_MAX_FRAME_RETRIES]);
+		if (max_frame_retries < -1 || max_frame_retries > 7)
+			return -EINVAL;
+
+		ret = rdev_set_max_frame_retries(rdev, wpan_dev,
+						 max_frame_retries);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (info->attrs[NL802154_ATTR_MIN_BE] &&
+	    info->attrs[NL802154_ATTR_MAX_BE]) {
+		u8 min_be, max_be;
+
+		if (netif_running(dev))
+			return -EBUSY;
+
+		min_be = nla_get_u8(info->attrs[NL802154_ATTR_MIN_BE]);
+		max_be = nla_get_u8(info->attrs[NL802154_ATTR_MAX_BE]);
+		if (max_be < 3 || max_be > 8 || min_be > max_be)
+			return -EINVAL;
+
+		ret = rdev_set_backoff_exponent(rdev, wpan_dev, min_be, max_be);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (info->attrs[NL802154_ATTR_MAX_CSMA_BACKOFFS]) {
+		u8 max_csma_backoffs;
+
+		if (netif_running(dev))
+			return -EBUSY;
+
+		max_csma_backoffs = nla_get_u8(
+				info->attrs[NL802154_ATTR_MAX_CSMA_BACKOFFS]);
+		if (max_csma_backoffs > 5)
+			return -EINVAL;
+
+		ret = rdev_set_max_csma_backoffs(rdev, wpan_dev,
+						 max_csma_backoffs);
+		if (ret < 0)
+			return ret;
+	}
+
+	if (info->attrs[NL802154_ATTR_LBT_MODE]) {
+		bool mode;
+
+		if (netif_running(dev))
+			return -EBUSY;
+
+		mode = !!nla_get_u8(info->attrs[NL802154_ATTR_LBT_MODE]);
+		return rdev_set_lbt_mode(rdev, wpan_dev, mode);
+	}
+
+	return 0;
+}
+
 static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
 {
 	struct cfg802154_registered_device *rdev = info->user_ptr[0];
@@ -965,6 +1067,14 @@ static const struct genl_ops nl802154_ops[] = {
 				  NL802154_FLAG_NEED_RTNL,
 	},
 	{
+		.cmd = NL802154_CMD_SET_INTERFACE,
+		.doit = nl802154_set_interface,
+		.policy = nl802154_policy,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = NL802154_FLAG_NEED_NETDEV |
+				  NL802154_FLAG_NEED_RTNL,
+	},
+	{
 		.cmd = NL802154_CMD_DEL_INTERFACE,
 		.doit = nl802154_del_interface,
 		.policy = nl802154_policy,
-- 
2.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd
  2015-03-18 11:40 ` [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd Alexander Aring
@ 2015-03-18 11:52   ` Alexander Aring
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2015-03-18 11:52 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, mkl

Hi,

On Wed, Mar 18, 2015 at 12:40:21PM +0100, Alexander Aring wrote:
...
>  	{
> +		.cmd = NL802154_CMD_SET_WPAN_PHY,
> +		.doit = nl802154_set_wpan_phy,
> +		.done = nl802154_dump_wpan_phy_done,

this should not belong there, please drop this patch Marcel.
It's a copy&paste error.

Thanks.

- Alex

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bluetooth-next 0/2] nl802154: implement new SET commands
  2015-03-18 11:40 [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Alexander Aring
  2015-03-18 11:40 ` [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd Alexander Aring
  2015-03-18 11:40 ` [PATCH bluetooth-next 2/2] nl802154: add set interface cmd Alexander Aring
@ 2015-03-18 11:59 ` Varka Bhadram
  2015-03-18 12:08   ` Alexander Aring
  2 siblings, 1 reply; 6+ messages in thread
From: Varka Bhadram @ 2015-03-18 11:59 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, mkl

Hi Alex,

On 03/18/2015 05:10 PM, Alexander Aring wrote:

> Hi,
>
> this patch-series implement the already existed SET commands of an interface
> and a wpan-phy. Currently we have one CMD for each setting which was a mistake
> by me to implement it in this way. So we aren't currently a "real" UAPI header
> for nl802154 and it's still under development. I decide now to change to
> implement these setting in this way now. Currently I let these commands in
> coexistens with the old commands but _NOTE_ I will remove the other commands
> from the nl802154 later.
>
> So please use the new commands. When these patches are mainline I also want to
> release a new wpan-tools release which use this new interface. Then everybody
> has some time to change to the new wpan-tools release. After this "time" I will

Its better to send the patches along with wpan-tools, so that we can do the testing..

> remove the obsolete nl802154 commands from the header. This means older
> wpan-tools releases doesn't work any more with new kernels. Also this means
> newer wpan-tools releases doesn't work with older kernels. That will end in
> some kind of chaos and I will note this on the website.
>
> This beahviour to do it in only one command is much easier to handle in
> userspace, like clicking an "apply button".
>
> - Alex
>
> Alexander Aring (2):
>    nl802154: add set wpan phy cmd
>    nl802154: add set interface cmd
>
>   net/ieee802154/nl802154.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 162 insertions(+)
>
-- 
Varka Bhadram


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bluetooth-next 0/2] nl802154: implement new SET commands
  2015-03-18 11:59 ` [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Varka Bhadram
@ 2015-03-18 12:08   ` Alexander Aring
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2015-03-18 12:08 UTC (permalink / raw)
  To: Varka Bhadram; +Cc: linux-wpan, kernel, mkl

Hi Varka,

On Wed, Mar 18, 2015 at 05:29:32PM +0530, Varka Bhadram wrote:
> Hi Alex,
> 
> On 03/18/2015 05:10 PM, Alexander Aring wrote:
> 
> >Hi,
> >
> >this patch-series implement the already existed SET commands of an interface
> >and a wpan-phy. Currently we have one CMD for each setting which was a mistake
> >by me to implement it in this way. So we aren't currently a "real" UAPI header
> >for nl802154 and it's still under development. I decide now to change to
> >implement these setting in this way now. Currently I let these commands in
> >coexistens with the old commands but _NOTE_ I will remove the other commands
> >from the nl802154 later.
> >
> >So please use the new commands. When these patches are mainline I also want to
> >release a new wpan-tools release which use this new interface. Then everybody
> >has some time to change to the new wpan-tools release. After this "time" I will
> 
> Its better to send the patches along with wpan-tools, so that we can do the testing..
> 

of course, I will do.

- Alex

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-18 12:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-18 11:40 [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Alexander Aring
2015-03-18 11:40 ` [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd Alexander Aring
2015-03-18 11:52   ` Alexander Aring
2015-03-18 11:40 ` [PATCH bluetooth-next 2/2] nl802154: add set interface cmd Alexander Aring
2015-03-18 11:59 ` [PATCH bluetooth-next 0/2] nl802154: implement new SET commands Varka Bhadram
2015-03-18 12:08   ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox