nl802154: implement new SET commands
Subsystems (2)
Alexander Aring
maintainercover nl802154: implement new SET commands
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(+)
Signature · 1 line
2.3.3
Alexander Aring
maintainerPATCH 1/2 nl802154: add set wpan phy cmd
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.
--- net/ieee802154/nl802154.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
net/ieee802154/nl802154.c +52 -0
@@ -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,
Signature · 1 line
2.3.3
Alexander Aring
maintainerRe: [PATCH bluetooth-next 1/2] nl802154: add set wpan phy cmd
Hi,
On Wed, Mar 18, 2015 at 12:40:21PM +0100, Alexander Aring wrote:
...
net/ieee802154/nl802154.c static const struct genl_ops nl802154_ops[] = { · line 944
Quoted 4 lines
net/ieee802154/nl802154.c +3
-0{ + .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
Alexander Aring
maintainerPATCH 2/2 nl802154: add set interface cmd
In reply to Alexander AringThis 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.
--- net/ieee802154/nl802154.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+)
net/ieee802154/nl802154.c +110 -0
@@ -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,
Signature · 1 line
2.3.3
Hi Alex,
Quoted 10 lines · 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.
Quoted 3 lines
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..
Quoted 17 lines
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 cmdnet/ieee802154/nl802154.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+)
Signature · 1 line
Varka Bhadram
Alexander Aring
maintainerHi Varka,
Quoted 14 lines · Varka Bhadram
Hi Alex,
Quoted 10 lines · 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.
Quoted 6 lines
Quoted 3 lines
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