diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-11-11 21:37:01 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-11 23:10:41 -0500 |
commit | a01ba7652cda5602b248efff168450ec658640b8 (patch) | |
tree | 7996fe317a9b6fd68114fba957b547abf3c2d9c2 /net/ieee802154 | |
parent | a8d352d458bba4603abd996e541c7f206a101f26 (diff) |
ieee820154: add max csma backoffs setting support
This patch add support for max csma backoffs setting via nl802154
framework.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/ieee802154')
-rw-r--r-- | net/ieee802154/nl802154.c | 33 | ||||
-rw-r--r-- | net/ieee802154/rdev-ops.h | 9 |
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 | ||
645 | static int | ||
646 | nl802154_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 | ||
53 | static inline int | ||
54 | rdev_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 */ |