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 09/16] ieee802154: add support for get tx powers
Date: Wed, 6 May 2015 13:40:21 +0200 [thread overview]
Message-ID: <1430912428-17284-10-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1430912428-17284-1-git-send-email-alex.aring@gmail.com>
This patch adds support for get transmit power 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 | 1 +
include/net/mac802154.h | 10 +++++++++-
net/ieee802154/rdev-ops.h | 11 +++++++++++
net/ieee802154/trace.h | 31 +++++++++++++++++++++++++++++++
net/mac802154/cfg.c | 11 +++++++++++
net/mac802154/driver-ops.h | 12 ++++++++++++
6 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 387db39..6758e61 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -44,6 +44,7 @@ struct cfg802154_ops {
int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel);
int (*set_cca_mode)(struct wpan_phy *wpan_phy,
const struct wpan_phy_cca *cca);
+ int (*get_tx_powers)(struct wpan_phy *wpan_phy, s32 *mbm, u32 idx);
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 3b76aab..be8d3de 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -174,6 +174,12 @@ struct ieee802154_hw {
* Set radio transmit power in mBm. Called with pib_lock held.
* Returns either zero, or negative errno.
*
+ * get_txpowers:
+ * Get radio transmit powers in mBm. Called when rtnl lock is held.
+ * Parameter idx descibes the index of transmit power which is supported.
+ * Returns either zero or negative errno. One should be returned for
+ * indicate to break the iteration of tx power settings.
+ *
* set_lbt
* Enables or disables listen before talk on the device. Called with
* pib_lock held.
@@ -213,7 +219,9 @@ struct ieee802154_ops {
int (*set_hw_addr_filt)(struct ieee802154_hw *hw,
struct ieee802154_hw_addr_filt *filt,
unsigned long changed);
- int (*set_txpower)(struct ieee802154_hw *hw, s32 dbm);
+ int (*set_txpower)(struct ieee802154_hw *hw, s32 mbm);
+ int (*get_tx_powers)(struct ieee802154_hw *hw, s32 *mbm,
+ 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 7b5a9dd..8fc1afe 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -75,6 +75,17 @@ rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
}
static inline int
+rdev_get_tx_powers(struct cfg802154_registered_device *rdev, s32 *mbm, u32 idx)
+{
+ int ret;
+
+ trace_802154_rdev_get_tx_powers(&rdev->wpan_phy, idx);
+ ret = rdev->ops->get_tx_powers(&rdev->wpan_phy, mbm, idx);
+ trace_802154_rdev_return_int_mbm(&rdev->wpan_phy, ret, mbm);
+ return ret;
+}
+
+static inline int
rdev_set_pan_id(struct cfg802154_registered_device *rdev,
struct wpan_dev *wpan_dev, __le16 pan_id)
{
diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
index 5ac25eb..3c54b5e 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_tx_powers,
+ 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_mbm,
+ TP_PROTO(struct wpan_phy *wpan_phy, int ret, s32 *mbm),
+ TP_ARGS(wpan_phy, ret, mbm),
+ TP_STRUCT__entry(
+ WPAN_PHY_ENTRY
+ __field(int, ret)
+ __field(s32, mbm)
+ ),
+ TP_fast_assign(
+ WPAN_PHY_ASSIGN;
+ __entry->ret = ret;
+ __entry->mbm = *mbm;
+ ),
+ TP_printk(WPAN_PHY_PR_FMT ", returned: %d, mbm: %d", WPAN_PHY_PR_ARG,
+ __entry->ret, __entry->mbm)
+);
+
DECLARE_EVENT_CLASS(802154_le16_template,
TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
__le16 le16arg),
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index d5290ea..4228069 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -106,6 +106,16 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,
}
static int
+ieee802154_get_tx_powers(struct wpan_phy *wpan_phy, s32 *mbm, u32 idx)
+{
+ struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
+
+ ASSERT_RTNL();
+
+ return drv_get_tx_powers(local, mbm, idx);
+}
+
+static int
ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
__le16 pan_id)
{
@@ -195,6 +205,7 @@ const struct cfg802154_ops mac802154_config_ops = {
.del_virtual_intf = ieee802154_del_iface,
.set_channel = ieee802154_set_channel,
.set_cca_mode = ieee802154_set_cca_mode,
+ .get_tx_powers = ieee802154_get_tx_powers,
.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 caecd5f..27a59dc 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -70,6 +70,18 @@ static inline int drv_set_tx_power(struct ieee802154_local *local, s32 mbm)
return local->ops->set_txpower(&local->hw, mbm);
}
+static inline int
+drv_get_tx_powers(struct ieee802154_local *local, s32 *mbm, u32 idx)
+{
+ might_sleep();
+
+ /* if not implemented indicate a empty list */
+ if (!local->ops->get_tx_powers)
+ return 1;
+
+ return local->ops->get_tx_powers(&local->hw, mbm, idx);
+}
+
static inline int drv_set_cca_mode(struct ieee802154_local *local,
const struct wpan_phy_cca *cca)
{
--
2.3.7
next prev 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 ` [PATCHv2 wpan-next 03/16] ieee802154: change cca ed level " Alexander Aring
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 ` Alexander Aring [this message]
2015-05-06 12:02 ` [PATCHv2 wpan-next 09/16] ieee802154: add support for get tx powers 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-10-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