Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
From: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
To: Alexander Aring <alex.aring@gmail.com>
Cc: linux-wpan@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels
Date: Mon, 27 Apr 2015 13:50:19 +0200	[thread overview]
Message-ID: <20150427135019.7795da22@zoidberg> (raw)
In-Reply-To: <1429807674-24849-11-git-send-email-alex.aring@gmail.com>

On Thu, 23 Apr 2015 18:47:49 +0200
Alexander Aring <alex.aring@gmail.com> wrote:

> This patch adds support for get cca energy detection levels. The
> driver needs to implement a driver ops callback which can iterate
> over each transmit power level index. This callback can return zero
> for successful iteration, 1 for ending the iteration, 2 for continue
> the iteration which an index increment and values below 0 zero if
> failed.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  include/net/cfg802154.h    |  2 ++
>  include/net/mac802154.h    |  9 +++++++++
>  net/ieee802154/rdev-ops.h  | 12 ++++++++++++
>  net/ieee802154/trace.h     | 31 +++++++++++++++++++++++++++++++
>  net/mac802154/cfg.c        | 11 +++++++++++
>  net/mac802154/driver-ops.h | 12 ++++++++++++
>  6 files changed, 77 insertions(+)
> 
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index 89995dd..7d44dcc 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -43,6 +43,8 @@ struct cfg802154_ops {
>  	int	(*set_cca_mode)(struct wpan_phy *wpan_phy,
>  				const struct wpan_phy_cca *cca);
>  	int	(*get_tx_powers)(struct wpan_phy *wpan_phy, s8
> *dbm, u32 idx);
> +	int	(*get_cca_ed_levels)(struct wpan_phy *wpan_phy,
> s32 *dbm,
> +				     u32 idx);

mBm instead of dBm would be better here, too.

>  	int	(*set_pan_id)(struct wpan_phy *wpan_phy,
>  			      struct wpan_dev *wpan_dev, __le16
> pan_id); int	(*set_short_addr)(struct wpan_phy *wpan_phy,
> diff --git a/include/net/mac802154.h b/include/net/mac802154.h
> index c489946..009e64c 100644
> --- a/include/net/mac802154.h
> +++ b/include/net/mac802154.h
> @@ -182,6 +182,13 @@ struct ieee802154_hw {
>   *	  returned for skipping dbm but increment idx value, this
> can be useful
>   *	  for register to dbm array mapping.
>   *
> + * get_cca_ed_levels
> + *	  Get cca ed levels in dBm for cca mode 3. Called when
> rtnl lock is
> + *	  held. Parameter idx descibes the index of cca ed levels
> which is
> + *	  supported. Returns either zero or negative errno. One
> should be
> + *	  returned to break the iteration of cca ed levels
> setting. Two should
> + *	  be returned for skipping dbm but increment idx value.
> + *
>   * set_lbt
>   *	  Enables or disables listen before talk on the device.
> Called with
>   *	  pib_lock held.
> @@ -224,6 +231,8 @@ struct ieee802154_ops {
>  	int		(*set_txpower)(struct ieee802154_hw *hw,
> s8 dbm); int		(*get_tx_powers)(struct ieee802154_hw
> *hw, s8 *dbm, u32 idx);
> +	int		(*get_cca_ed_levels)(struct ieee802154_hw
> *hw,
> +					     s32 *dbm, u32 idx);
>  	int		(*set_lbt)(struct ieee802154_hw *hw, bool
> on); int		(*set_cca_mode)(struct ieee802154_hw *hw,
>  					const struct wpan_phy_cca
> *cca); diff --git a/net/ieee802154/rdev-ops.h
> b/net/ieee802154/rdev-ops.h index d944a7a..5d2666f 100644
> --- a/net/ieee802154/rdev-ops.h
> +++ b/net/ieee802154/rdev-ops.h
> @@ -71,6 +71,18 @@ rdev_set_cca_mode(struct
> cfg802154_registered_device *rdev, }
>  
>  static inline int
> +rdev_get_cca_ed_levels(struct cfg802154_registered_device *rdev, s32
> *dbm,
> +		       u32 idx)
> +{
> +	int ret;
> +
> +	trace_802154_rdev_get_cca_ed_levels(&rdev->wpan_phy, idx);
> +	ret = rdev->ops->get_cca_ed_levels(&rdev->wpan_phy, dbm,
> idx);
> +	trace_802154_rdev_return_int_cca_ed_levels(&rdev->wpan_phy,
> ret, dbm);
> +	return ret;
> +}
> +
> +static inline int
>  rdev_get_tx_powers(struct cfg802154_registered_device *rdev, s8
> *dbm, u32 idx) {
>  	int ret;
> diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
> index 94ac3b9..c06b57f 100644
> --- a/net/ieee802154/trace.h
> +++ b/net/ieee802154/trace.h
> @@ -108,6 +108,37 @@ TRACE_EVENT(802154_rdev_set_cca_mode,
>  		  WPAN_CCA_PR_ARG)
>  );
>  
> +TRACE_EVENT(802154_rdev_get_cca_ed_levels,
> +	TP_PROTO(struct wpan_phy *wpan_phy, u32 idx),
> +	TP_ARGS(wpan_phy, idx),
> +	TP_STRUCT__entry(
> +		WPAN_PHY_ENTRY
> +		__field(u32, idx)
> +	),
> +	TP_fast_assign(
> +		WPAN_PHY_ASSIGN;
> +		__entry->idx = idx;
> +	),
> +	TP_printk(WPAN_PHY_PR_FMT ", idx: %d", WPAN_PHY_PR_ARG,
> __entry->idx) +);
> +
> +TRACE_EVENT(802154_rdev_return_int_cca_ed_levels,
> +	TP_PROTO(struct wpan_phy *wpan_phy, int ret, s32 *dbm),
> +	TP_ARGS(wpan_phy, ret, dbm),
> +	TP_STRUCT__entry(
> +		WPAN_PHY_ENTRY
> +		__field(int, ret)
> +		__field(s32, dbm)
> +	),
> +	TP_fast_assign(
> +		WPAN_PHY_ASSIGN;
> +		__entry->ret = ret;
> +		__entry->dbm = *dbm;
> +	),
> +	TP_printk(WPAN_PHY_PR_FMT ", returned: %d, dbm: %d",
> WPAN_PHY_PR_ARG,
> +		  __entry->ret, __entry->dbm)
> +);
> +
>  TRACE_EVENT(802154_rdev_get_tx_powers,
>  	TP_PROTO(struct wpan_phy *wpan_phy, u32 idx),
>  	TP_ARGS(wpan_phy, idx),
> diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> index 2b80a77..e5234ab 100644
> --- a/net/mac802154/cfg.c
> +++ b/net/mac802154/cfg.c
> @@ -103,6 +103,16 @@ ieee802154_set_cca_mode(struct wpan_phy
> *wpan_phy, }
>  
>  static int
> +ieee802154_get_cca_ed_levels(struct wpan_phy *wpan_phy, s32 *dbm,
> u32 idx) +{
> +	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
> +
> +	ASSERT_RTNL();
> +
> +	return drv_get_cca_ed_levels(local, dbm, idx);
> +}
> +
> +static int
>  ieee802154_get_tx_powers(struct wpan_phy *wpan_phy, s8 *dbm, u32 idx)
>  {
>  	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
> @@ -203,6 +213,7 @@ const struct cfg802154_ops mac802154_config_ops =
> { .set_channel = ieee802154_set_channel,
>  	.set_cca_mode = ieee802154_set_cca_mode,
>  	.get_tx_powers = ieee802154_get_tx_powers,
> +	.get_cca_ed_levels = ieee802154_get_cca_ed_levels,
>  	.set_pan_id = ieee802154_set_pan_id,
>  	.set_short_addr = ieee802154_set_short_addr,
>  	.set_backoff_exponent = ieee802154_set_backoff_exponent,
> diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
> index 08e2b09..323da5c 100644
> --- a/net/mac802154/driver-ops.h
> +++ b/net/mac802154/driver-ops.h
> @@ -120,6 +120,18 @@ drv_set_cca_ed_level(struct ieee802154_local
> *local, s32 ed_level) return local->ops->set_cca_ed_level(&local->hw,
> ed_level); }
>  
> +static inline int
> +drv_get_cca_ed_levels(struct ieee802154_local *local, s32 *dbm, u32
> idx) +{
> +	might_sleep();
> +
> +	/* if not implemented indicate a empty list */
> +	if (!local->ops->get_tx_powers)
> +		return 1;
> +
> +	return local->ops->get_cca_ed_levels(&local->hw, dbm, idx);
> +}
> +
>  static inline int drv_set_pan_id(struct ieee802154_local *local,
> __le16 pan_id) {
>  	struct ieee802154_hw_addr_filt filt;


  reply	other threads:[~2015-04-27 11:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 01/15] nl802154: cleanup invalid argument handling Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 02/15] at86rf230: remove tabs after define Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 03/15] ieee802154: move validation check out of softmac Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 04/15] mac802154: check for really changes Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 05/15] mac802154: remove check if operation is supported Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 06/15] ieee802154: introduce wpan_phy_supported Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 07/15] ieee802154: add several phy supported handling Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 08/15] ieee802154: add iftypes capability Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers Alexander Aring
2015-04-27 11:49   ` Phoebe Buckheister
2015-04-29  9:07     ` Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels Alexander Aring
2015-04-27 11:50   ` Phoebe Buckheister [this message]
2015-04-23 16:47 ` [RFC bluetooth-next 11/15] at86rf230: set cca_modes supported flags Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 12/15] at86rf230: add reset states of tx power level Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 13/15] at86rf230: rework tx power support Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 14/15] at86rf230: rework tx cca energy detection level Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities Alexander Aring
2015-04-24  4:43   ` Varka Bhadram
2015-04-25  6:47     ` Alexander Aring
2015-04-24  3:38 ` [RFC bluetooth-next 00/15] ieee802154: add support for " Varka Bhadram
2015-04-24  5:11   ` Varka Bhadram
2015-04-25 10:06     ` Alexander Aring
2015-04-27  6:51       ` Varka Bhadram
2015-04-25  6:48   ` 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=20150427135019.7795da22@zoidberg \
    --to=phoebe.buckheister@itwm.fraunhofer.de \
    --cc=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