aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154
diff options
context:
space:
mode:
authorPhoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>2014-02-17 05:34:14 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-17 16:42:39 -0500
commit4244db1b0b7bc9ab7b67d8c1c38de6cf15bc87a8 (patch)
treec729b4b8546421f0f17fd5e9bee0820e2335882d /net/ieee802154
parent7dcbd22a97eb0689e6c583ad630ae0e7341e34c1 (diff)
ieee802154: add netlink APIs for smartMAC configuration
Introduce new netlink attributes for SET_PHY_ATTRS: * CSMA minimal backoff exponent * CSMA maximal backoff exponent * CSMA retry limit * frame retransmission limit The CSMA attributes shall correspond to minBE, maxBE and maxCSMABackoffs of 802.15.4, respectively. The frame retransmission shall correspond to maxFrameRetries of 802.15.4, unless given as -1: then the old behaviour of the stack shall apply. For RF2xy, the old behaviour is to not do channel sensing at all and simply send *right now*, which is not intended behaviour for most applications and actually prohibited for some channel/page combinations. For all values except frame retransmission limit, the defaults of 802.15.4 apply. Frame retransmission limits are set to -1 to indicate backward-compatible behaviour. Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154')
-rw-r--r--net/ieee802154/nl-phy.c69
-rw-r--r--net/ieee802154/nl_policy.c5
-rw-r--r--net/ieee802154/wpan-class.c6
3 files changed, 78 insertions, 2 deletions
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 0af0d424dee0..c9dfd6f59e34 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -59,7 +59,11 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
59 nla_put_s8(msg, IEEE802154_ATTR_TXPOWER, phy->transmit_power) || 59 nla_put_s8(msg, IEEE802154_ATTR_TXPOWER, phy->transmit_power) ||
60 nla_put_u8(msg, IEEE802154_ATTR_LBT_ENABLED, phy->lbt) || 60 nla_put_u8(msg, IEEE802154_ATTR_LBT_ENABLED, phy->lbt) ||
61 nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE, phy->cca_mode) || 61 nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE, phy->cca_mode) ||
62 nla_put_s32(msg, IEEE802154_ATTR_CCA_ED_LEVEL, phy->cca_ed_level)) 62 nla_put_s32(msg, IEEE802154_ATTR_CCA_ED_LEVEL, phy->cca_ed_level) ||
63 nla_put_u8(msg, IEEE802154_ATTR_CSMA_RETRIES, phy->csma_retries) ||
64 nla_put_u8(msg, IEEE802154_ATTR_CSMA_MIN_BE, phy->min_be) ||
65 nla_put_u8(msg, IEEE802154_ATTR_CSMA_MAX_BE, phy->max_be) ||
66 nla_put_s8(msg, IEEE802154_ATTR_FRAME_RETRIES, phy->frame_retries))
63 goto nla_put_failure; 67 goto nla_put_failure;
64 for (i = 0; i < 32; i++) { 68 for (i = 0; i < 32; i++) {
65 if (phy->channels_supported[i]) 69 if (phy->channels_supported[i])
@@ -418,6 +422,49 @@ static int phy_set_cca_ed_level(struct wpan_phy *phy, struct genl_info *info)
418 return 0; 422 return 0;
419} 423}
420 424
425static int phy_set_csma_params(struct wpan_phy *phy, struct genl_info *info)
426{
427 int rc;
428 u8 min_be = phy->min_be;
429 u8 max_be = phy->max_be;
430 u8 retries = phy->csma_retries;
431
432 if (info->attrs[IEEE802154_ATTR_CSMA_RETRIES])
433 retries = nla_get_u8(info->attrs[IEEE802154_ATTR_CSMA_RETRIES]);
434 if (info->attrs[IEEE802154_ATTR_CSMA_MIN_BE])
435 min_be = nla_get_u8(info->attrs[IEEE802154_ATTR_CSMA_MIN_BE]);
436 if (info->attrs[IEEE802154_ATTR_CSMA_MAX_BE])
437 max_be = nla_get_u8(info->attrs[IEEE802154_ATTR_CSMA_MAX_BE]);
438
439 if (retries > 5 || max_be > 8 || min_be > max_be ||
440 retries < -1 || retries > 7)
441 return -EINVAL;
442
443 rc = phy->set_csma_params(phy, min_be, max_be, retries);
444 if (rc < 0)
445 return rc;
446
447 phy->min_be = min_be;
448 phy->max_be = max_be;
449 phy->csma_retries = retries;
450
451 return 0;
452}
453
454static int phy_set_frame_retries(struct wpan_phy *phy, struct genl_info *info)
455{
456 s8 retries = nla_get_s8(info->attrs[IEEE802154_ATTR_FRAME_RETRIES]);
457 int rc;
458
459 rc = phy->set_frame_retries(phy, retries);
460 if (rc < 0)
461 return rc;
462
463 phy->frame_retries = retries;
464
465 return 0;
466}
467
421int ieee802154_set_phyparams(struct sk_buff *skb, struct genl_info *info) 468int ieee802154_set_phyparams(struct sk_buff *skb, struct genl_info *info)
422{ 469{
423 struct wpan_phy *phy; 470 struct wpan_phy *phy;
@@ -429,7 +476,11 @@ int ieee802154_set_phyparams(struct sk_buff *skb, struct genl_info *info)
429 if (!info->attrs[IEEE802154_ATTR_PHY_NAME] && 476 if (!info->attrs[IEEE802154_ATTR_PHY_NAME] &&
430 !info->attrs[IEEE802154_ATTR_LBT_ENABLED] && 477 !info->attrs[IEEE802154_ATTR_LBT_ENABLED] &&
431 !info->attrs[IEEE802154_ATTR_CCA_MODE] && 478 !info->attrs[IEEE802154_ATTR_CCA_MODE] &&
432 !info->attrs[IEEE802154_ATTR_CCA_ED_LEVEL]) 479 !info->attrs[IEEE802154_ATTR_CCA_ED_LEVEL] &&
480 !info->attrs[IEEE802154_ATTR_CSMA_RETRIES] &&
481 !info->attrs[IEEE802154_ATTR_CSMA_MIN_BE] &&
482 !info->attrs[IEEE802154_ATTR_CSMA_MAX_BE] &&
483 !info->attrs[IEEE802154_ATTR_FRAME_RETRIES])
433 return -EINVAL; 484 return -EINVAL;
434 485
435 name = nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]); 486 name = nla_data(info->attrs[IEEE802154_ATTR_PHY_NAME]);
@@ -473,6 +524,20 @@ int ieee802154_set_phyparams(struct sk_buff *skb, struct genl_info *info)
473 goto error; 524 goto error;
474 } 525 }
475 526
527 if (info->attrs[IEEE802154_ATTR_CSMA_RETRIES] ||
528 info->attrs[IEEE802154_ATTR_CSMA_MIN_BE] ||
529 info->attrs[IEEE802154_ATTR_CSMA_MAX_BE]) {
530 rc = phy_set_csma_params(phy, info);
531 if (rc < 0)
532 goto error;
533 }
534
535 if (info->attrs[IEEE802154_ATTR_FRAME_RETRIES]) {
536 rc = phy_set_frame_retries(phy, info);
537 if (rc < 0)
538 goto error;
539 }
540
476 mutex_unlock(&phy->pib_lock); 541 mutex_unlock(&phy->pib_lock);
477 542
478 wpan_phy_put(phy); 543 wpan_phy_put(phy);
diff --git a/net/ieee802154/nl_policy.c b/net/ieee802154/nl_policy.c
index 55b5616295ff..fd7be5e45cef 100644
--- a/net/ieee802154/nl_policy.c
+++ b/net/ieee802154/nl_policy.c
@@ -57,5 +57,10 @@ const struct nla_policy ieee802154_policy[IEEE802154_ATTR_MAX + 1] = {
57 [IEEE802154_ATTR_LBT_ENABLED] = { .type = NLA_U8, }, 57 [IEEE802154_ATTR_LBT_ENABLED] = { .type = NLA_U8, },
58 [IEEE802154_ATTR_CCA_MODE] = { .type = NLA_U8, }, 58 [IEEE802154_ATTR_CCA_MODE] = { .type = NLA_U8, },
59 [IEEE802154_ATTR_CCA_ED_LEVEL] = { .type = NLA_S32, }, 59 [IEEE802154_ATTR_CCA_ED_LEVEL] = { .type = NLA_S32, },
60 [IEEE802154_ATTR_CSMA_RETRIES] = { .type = NLA_U8, },
61 [IEEE802154_ATTR_CSMA_MIN_BE] = { .type = NLA_U8, },
62 [IEEE802154_ATTR_CSMA_MAX_BE] = { .type = NLA_U8, },
63
64 [IEEE802154_ATTR_FRAME_RETRIES] = { .type = NLA_S8, },
60}; 65};
61 66
diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c
index 8d6f6704da84..edd0962d55f9 100644
--- a/net/ieee802154/wpan-class.c
+++ b/net/ieee802154/wpan-class.c
@@ -169,6 +169,12 @@ struct wpan_phy *wpan_phy_alloc(size_t priv_size)
169 phy->current_channel = -1; /* not initialised */ 169 phy->current_channel = -1; /* not initialised */
170 phy->current_page = 0; /* for compatibility */ 170 phy->current_page = 0; /* for compatibility */
171 171
172 /* defaults per 802.15.4-2011 */
173 phy->min_be = 3;
174 phy->max_be = 5;
175 phy->csma_retries = 4;
176 phy->frame_retries = -1; /* for compatibility, actual default is 3 */
177
172 return phy; 178 return phy;
173 179
174out: 180out: