aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154
diff options
context:
space:
mode:
Diffstat (limited to 'net/ieee802154')
-rw-r--r--net/ieee802154/nl802154.c34
-rw-r--r--net/ieee802154/rdev-ops.h9
2 files changed, 43 insertions, 0 deletions
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 2978c1a78017..d1cf3021ff36 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -616,6 +616,32 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
616 return rdev_set_short_addr(rdev, wpan_dev, short_addr); 616 return rdev_set_short_addr(rdev, wpan_dev, short_addr);
617} 617}
618 618
619static int
620nl802154_set_backoff_exponent(struct sk_buff *skb, struct genl_info *info)
621{
622 struct cfg802154_registered_device *rdev = info->user_ptr[0];
623 struct net_device *dev = info->user_ptr[1];
624 struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
625 u8 min_be, max_be;
626
627 /* should be set on netif open inside phy settings */
628 if (netif_running(dev))
629 return -EBUSY;
630
631 if (!info->attrs[NL802154_ATTR_MIN_BE] ||
632 !info->attrs[NL802154_ATTR_MAX_BE])
633 return -EINVAL;
634
635 min_be = nla_get_u8(info->attrs[NL802154_ATTR_MIN_BE]);
636 max_be = nla_get_u8(info->attrs[NL802154_ATTR_MAX_BE]);
637
638 /* check 802.15.4 constraints */
639 if (max_be < 3 || max_be > 8 || min_be > max_be)
640 return -EINVAL;
641
642 return rdev_set_backoff_exponent(rdev, wpan_dev, min_be, max_be);
643}
644
619#define NL802154_FLAG_NEED_WPAN_PHY 0x01 645#define NL802154_FLAG_NEED_WPAN_PHY 0x01
620#define NL802154_FLAG_NEED_NETDEV 0x02 646#define NL802154_FLAG_NEED_NETDEV 0x02
621#define NL802154_FLAG_NEED_RTNL 0x04 647#define NL802154_FLAG_NEED_RTNL 0x04
@@ -750,6 +776,14 @@ static const struct genl_ops nl802154_ops[] = {
750 .internal_flags = NL802154_FLAG_NEED_NETDEV | 776 .internal_flags = NL802154_FLAG_NEED_NETDEV |
751 NL802154_FLAG_NEED_RTNL, 777 NL802154_FLAG_NEED_RTNL,
752 }, 778 },
779 {
780 .cmd = NL802154_CMD_SET_BACKOFF_EXPONENT,
781 .doit = nl802154_set_backoff_exponent,
782 .policy = nl802154_policy,
783 .flags = GENL_ADMIN_PERM,
784 .internal_flags = NL802154_FLAG_NEED_NETDEV |
785 NL802154_FLAG_NEED_RTNL,
786 },
753}; 787};
754 788
755/* initialisation/exit functions */ 789/* initialisation/exit functions */
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index 16b0de06c3af..dbccfa9383fd 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -41,4 +41,13 @@ rdev_set_short_addr(struct cfg802154_registered_device *rdev,
41 return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr); 41 return rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
42} 42}
43 43
44static inline int
45rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
46 struct wpan_dev *wpan_dev, const u8 min_be,
47 const u8 max_be)
48{
49 return rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
50 min_be, max_be);
51}
52
44#endif /* __CFG802154_RDEV_OPS */ 53#endif /* __CFG802154_RDEV_OPS */