Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, Alexander Aring <alex.aring@gmail.com>
Subject: [PATCHv2 wpan-next 03/16] ieee802154: change cca ed level to mbm
Date: Wed,  6 May 2015 13:40:15 +0200	[thread overview]
Message-ID: <1430912428-17284-4-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1430912428-17284-1-git-send-email-alex.aring@gmail.com>

This patch change the handling of cca energy detection level from dbm to
mbm. This prepares to handle floating point cca energy detection levels
values. The old netlink 802.15.4 will convert the dbm value to mbm for
handling backward compatibility.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 3 ++-
 include/net/cfg802154.h            | 1 +
 include/net/mac802154.h            | 5 ++---
 net/ieee802154/nl-mac.c            | 4 ++--
 net/mac802154/driver-ops.h         | 4 ++--
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 3a303e4..e68d45e 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1268,9 +1268,10 @@ at86rf23x_get_desens_steps(struct at86rf230_local *lp, s32 level)
 }
 
 static int
-at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 level)
+at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
 {
 	struct at86rf230_local *lp = hw->priv;
+	s32 level = mbm / 100;
 
 	if (level < lp->data->rssi_base_val || level > 30)
 		return -EINVAL;
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index b5b3f9f..9ced2c9 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -91,6 +91,7 @@ struct wpan_phy {
 
 	__le64 perm_extended_addr;
 
+	/* current cca ed threshold in mBm */
 	s32 cca_ed_level;
 
 	/* PHY depended MAC PIB values */
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index beb07ce..3b76aab 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -184,7 +184,7 @@ struct ieee802154_hw {
  *	  Returns either zero, or negative errno.
  *
  * set_cca_ed_level
- *	  Sets the CCA energy detection threshold in dBm. Called with pib_lock
+ *	  Sets the CCA energy detection threshold in mBm. Called with pib_lock
  *	  held.
  *	  Returns either zero, or negative errno.
  *
@@ -217,8 +217,7 @@ struct ieee802154_ops {
 	int		(*set_lbt)(struct ieee802154_hw *hw, bool on);
 	int		(*set_cca_mode)(struct ieee802154_hw *hw,
 					const struct wpan_phy_cca *cca);
-	int		(*set_cca_ed_level)(struct ieee802154_hw *hw,
-					    s32 level);
+	int		(*set_cca_ed_level)(struct ieee802154_hw *hw, s32 mbm);
 	int		(*set_csma_params)(struct ieee802154_hw *hw,
 					   u8 min_be, u8 max_be, u8 retries);
 	int		(*set_frame_retries)(struct ieee802154_hw *hw,
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index 4ba2e13..cdc1cc3 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -122,7 +122,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
 		    nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE,
 			       params.cca.mode) ||
 		    nla_put_s32(msg, IEEE802154_ATTR_CCA_ED_LEVEL,
-				params.cca_ed_level) ||
+				params.cca_ed_level / 100) ||
 		    nla_put_u8(msg, IEEE802154_ATTR_CSMA_RETRIES,
 			       params.csma_retries) ||
 		    nla_put_u8(msg, IEEE802154_ATTR_CSMA_MIN_BE,
@@ -519,7 +519,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
 		params.cca.mode = nla_get_u8(info->attrs[IEEE802154_ATTR_CCA_MODE]);
 
 	if (info->attrs[IEEE802154_ATTR_CCA_ED_LEVEL])
-		params.cca_ed_level = nla_get_s32(info->attrs[IEEE802154_ATTR_CCA_ED_LEVEL]);
+		params.cca_ed_level = nla_get_s32(info->attrs[IEEE802154_ATTR_CCA_ED_LEVEL]) * 100;
 
 	if (info->attrs[IEEE802154_ATTR_CSMA_RETRIES])
 		params.csma_retries = nla_get_u8(info->attrs[IEEE802154_ATTR_CSMA_RETRIES]);
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
index d289ae3..caecd5f 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -96,7 +96,7 @@ static inline int drv_set_lbt_mode(struct ieee802154_local *local, bool mode)
 }
 
 static inline int
-drv_set_cca_ed_level(struct ieee802154_local *local, s32 ed_level)
+drv_set_cca_ed_level(struct ieee802154_local *local, s32 mbm)
 {
 	might_sleep();
 
@@ -105,7 +105,7 @@ drv_set_cca_ed_level(struct ieee802154_local *local, s32 ed_level)
 		return -EOPNOTSUPP;
 	}
 
-	return local->ops->set_cca_ed_level(&local->hw, ed_level);
+	return local->ops->set_cca_ed_level(&local->hw, mbm);
 }
 
 static inline int drv_set_pan_id(struct ieee802154_local *local, __le16 pan_id)
-- 
2.3.7


  parent reply	other threads:[~2015-05-06 11:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 11:40 [PATCHv2 wpan-next 00/16] ieee802154: add support for phy capabilities Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 01/16] ieee802154: change transmit power to s32 Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 02/16] ieee802154: change transmit power to mbm Alexander Aring
2015-05-06 11:40 ` Alexander Aring [this message]
2015-05-06 11:40 ` [PATCHv2 wpan-next 04/16] ieee802154: introduce wpan_phy_supported Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 05/16] ieee802154: add several phy supported handling Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 06/16] mac802154: check for really changes Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 07/16] mac802154: remove check if operation is supported Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 08/16] ieee802154: add iftypes capability Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 09/16] ieee802154: add support for get tx powers Alexander Aring
2015-05-06 12:02   ` Phoebe Buckheister
2015-05-06 13:19     ` Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 10/16] ieee802154: add support for get cca ed levels Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 11/16] at86rf230: set cca_modes supported flags Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 12/16] at86rf230: add reset states of tx power level Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 13/16] at86rf230: rework tx power support Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 14/16] at86rf230: rework tx cca energy detection level Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 15/16] ieee802154: check transmit power before driver layer Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 16/16] nl802154: add support for dump phy capabilities Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430912428-17284-4-git-send-email-alex.aring@gmail.com \
    --to=alex.aring@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-wpan@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox