aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154
diff options
context:
space:
mode:
Diffstat (limited to 'net/ieee802154')
-rw-r--r--net/ieee802154/nl802154.c33
-rw-r--r--net/ieee802154/rdev-ops.h9
2 files changed, 42 insertions, 0 deletions
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index d1cf3021ff36..af383553bdd2 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -642,6 +642,31 @@ nl802154_set_backoff_exponent(struct sk_buff *skb, struct genl_info *info)
642 return rdev_set_backoff_exponent(rdev, wpan_dev, min_be, max_be); 642 return rdev_set_backoff_exponent(rdev, wpan_dev, min_be, max_be);
643} 643}
644 644
645static int
646nl802154_set_max_csma_backoffs(struct sk_buff *skb, struct genl_info *info)
647{
648 struct cfg802154_registered_device *rdev = info->user_ptr[0];
649 struct net_device *dev = info->user_ptr[1];
650 struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
651 u8 max_csma_backoffs;
652
653 /* conflict here while other running iface settings */
654 if (netif_running(dev))
655 return -EBUSY;
656
657 if (!info->attrs[NL802154_ATTR_MAX_CSMA_BACKOFFS])
658 return -EINVAL;
659
660 max_csma_backoffs = nla_get_u8(
661 info->attrs[NL802154_ATTR_MAX_CSMA_BACKOFFS]);
662
663 /* check 802.15.4 constraints */
664 if (max_csma_backoffs > 5)
665 return -EINVAL;
666
667 return rdev_set_max_csma_backoffs(rdev, wpan_dev, max_csma_backoffs);
668}
669
645#define NL802154_FLAG_NEED_WPAN_PHY 0x01 670#define NL802154_FLAG_NEED_WPAN_PHY 0x01
646#define NL802154_FLAG_NEED_NETDEV 0x02 671#define NL802154_FLAG_NEED_NETDEV 0x02
647#define NL802154_FLAG_NEED_RTNL 0x04 672#define NL802154_FLAG_NEED_RTNL 0x04
@@ -784,6 +809,14 @@ static const struct genl_ops nl802154_ops[] = {
784 .internal_flags = NL802154_FLAG_NEED_NETDEV | 809 .internal_flags = NL802154_FLAG_NEED_NETDEV |
785 NL802154_FLAG_NEED_RTNL, 810 NL802154_FLAG_NEED_RTNL,
786 }, 811 },
812 {
813 .cmd = NL802154_CMD_SET_MAX_CSMA_BACKOFFS,
814 .doit = nl802154_set_max_csma_backoffs,
815 .policy = nl802154_policy,
816 .flags = GENL_ADMIN_PERM,
817 .internal_flags = NL802154_FLAG_NEED_NETDEV |
818 NL802154_FLAG_NEED_RTNL,
819 },
787}; 820};
788 821
789/* initialisation/exit functions */ 822/* initialisation/exit functions */
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index dbccfa9383fd..263095c8686c 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -50,4 +50,13 @@ rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
50 min_be, max_be); 50 min_be, max_be);
51} 51}
52 52
53static inline int
54rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
55 struct wpan_dev *wpan_dev,
56 const u8 max_csma_backoffs)
57{
58 return rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
59 max_csma_backoffs);
60}
61
53#endif /* __CFG802154_RDEV_OPS */ 62#endif /* __CFG802154_RDEV_OPS */