aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-11 21:37:01 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-11-11 23:10:41 -0500
commita01ba7652cda5602b248efff168450ec658640b8 (patch)
tree7996fe317a9b6fd68114fba957b547abf3c2d9c2
parenta8d352d458bba4603abd996e541c7f206a101f26 (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>
-rw-r--r--include/net/cfg802154.h3
-rw-r--r--net/ieee802154/nl802154.c33
-rw-r--r--net/ieee802154/rdev-ops.h9
-rw-r--r--net/mac802154/cfg.c16
4 files changed, 61 insertions, 0 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 27e98d10fb2c..79b9ae0abb3b 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -45,6 +45,9 @@ struct cfg802154_ops {
45 int (*set_backoff_exponent)(struct wpan_phy *wpan_phy, 45 int (*set_backoff_exponent)(struct wpan_phy *wpan_phy,
46 struct wpan_dev *wpan_dev, u8 min_be, 46 struct wpan_dev *wpan_dev, u8 min_be,
47 u8 max_be); 47 u8 max_be);
48 int (*set_max_csma_backoffs)(struct wpan_phy *wpan_phy,
49 struct wpan_dev *wpan_dev,
50 u8 max_csma_backoffs);
48}; 51};
49 52
50struct wpan_phy { 53struct wpan_phy {
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 */
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 67c96f981693..d72feebb939d 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -125,6 +125,21 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
125 return 0; 125 return 0;
126} 126}
127 127
128static int ieee802154_set_max_csma_backoffs(struct wpan_phy *wpan_phy,
129 struct wpan_dev *wpan_dev,
130 const u8 max_csma_backoffs)
131{
132 struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
133
134 ASSERT_RTNL();
135
136 if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS))
137 return -EOPNOTSUPP;
138
139 wpan_dev->csma_retries = max_csma_backoffs;
140 return 0;
141}
142
128const struct cfg802154_ops mac802154_config_ops = { 143const struct cfg802154_ops mac802154_config_ops = {
129 .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, 144 .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated,
130 .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, 145 .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated,
@@ -132,4 +147,5 @@ const struct cfg802154_ops mac802154_config_ops = {
132 .set_pan_id = ieee802154_set_pan_id, 147 .set_pan_id = ieee802154_set_pan_id,
133 .set_short_addr = ieee802154_set_short_addr, 148 .set_short_addr = ieee802154_set_short_addr,
134 .set_backoff_exponent = ieee802154_set_backoff_exponent, 149 .set_backoff_exponent = ieee802154_set_backoff_exponent,
150 .set_max_csma_backoffs = ieee802154_set_max_csma_backoffs,
135}; 151};