aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2015-05-17 15:44:40 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-05-19 05:44:41 -0400
commite2eb173aaacd1a1bcd255d3e74ffb719e47eeadb (patch)
treea0f074e27b399f23a5ca497e3afed3595631d27c
parent1a19cb680be0d4b06ce9a9d6516b8f45f544d3e8 (diff)
ieee802154: change transmit power to mbm
This patch change the handling of transmit power level from dbm to mbm. This prepares to handle floating point transmit power 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> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--drivers/net/ieee802154/at86rf230.c3
-rw-r--r--include/net/cfg802154.h1
-rw-r--r--include/net/mac802154.h4
-rw-r--r--net/ieee802154/nl-mac.c4
-rw-r--r--net/mac802154/driver-ops.h4
5 files changed, 9 insertions, 7 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 02b6bb72304d..3a303e4a3c07 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1194,9 +1194,10 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
1194} 1194}
1195 1195
1196static int 1196static int
1197at86rf230_set_txpower(struct ieee802154_hw *hw, s32 db) 1197at86rf230_set_txpower(struct ieee802154_hw *hw, s32 mbm)
1198{ 1198{
1199 struct at86rf230_local *lp = hw->priv; 1199 struct at86rf230_local *lp = hw->priv;
1200 s8 db = mbm / 100;
1200 1201
1201 /* typical maximum output is 5dBm with RG_PHY_TX_PWR 0x60, lower five 1202 /* typical maximum output is 5dBm with RG_PHY_TX_PWR 0x60, lower five
1202 * bits decrease power in 1dB steps. 0x60 represents extra PA gain of 1203 * bits decrease power in 1dB steps. 0x60 represents extra PA gain of
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 47804cddb46f..b5b3f9f43084 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -85,6 +85,7 @@ struct wpan_phy {
85 u8 current_channel; 85 u8 current_channel;
86 u8 current_page; 86 u8 current_page;
87 u32 channels_supported[IEEE802154_MAX_PAGE + 1]; 87 u32 channels_supported[IEEE802154_MAX_PAGE + 1];
88 /* current transmit_power in mBm */
88 s32 transmit_power; 89 s32 transmit_power;
89 struct wpan_phy_cca cca; 90 struct wpan_phy_cca cca;
90 91
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 400e4e85c53f..e863a8557c0a 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -171,7 +171,7 @@ struct ieee802154_hw {
171 * Returns either zero, or negative errno. 171 * Returns either zero, or negative errno.
172 * 172 *
173 * set_txpower: 173 * set_txpower:
174 * Set radio transmit power in dB. Called with pib_lock held. 174 * Set radio transmit power in mBm. Called with pib_lock held.
175 * Returns either zero, or negative errno. 175 * Returns either zero, or negative errno.
176 * 176 *
177 * set_lbt 177 * set_lbt
@@ -213,7 +213,7 @@ struct ieee802154_ops {
213 int (*set_hw_addr_filt)(struct ieee802154_hw *hw, 213 int (*set_hw_addr_filt)(struct ieee802154_hw *hw,
214 struct ieee802154_hw_addr_filt *filt, 214 struct ieee802154_hw_addr_filt *filt,
215 unsigned long changed); 215 unsigned long changed);
216 int (*set_txpower)(struct ieee802154_hw *hw, s32 dbm); 216 int (*set_txpower)(struct ieee802154_hw *hw, s32 mbm);
217 int (*set_lbt)(struct ieee802154_hw *hw, bool on); 217 int (*set_lbt)(struct ieee802154_hw *hw, bool on);
218 int (*set_cca_mode)(struct ieee802154_hw *hw, 218 int (*set_cca_mode)(struct ieee802154_hw *hw,
219 const struct wpan_phy_cca *cca); 219 const struct wpan_phy_cca *cca);
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index 2b4955d7aae5..4ba2e13f7a07 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -117,7 +117,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
117 rtnl_unlock(); 117 rtnl_unlock();
118 118
119 if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER, 119 if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER,
120 params.transmit_power) || 120 params.transmit_power / 100) ||
121 nla_put_u8(msg, IEEE802154_ATTR_LBT_ENABLED, params.lbt) || 121 nla_put_u8(msg, IEEE802154_ATTR_LBT_ENABLED, params.lbt) ||
122 nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE, 122 nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE,
123 params.cca.mode) || 123 params.cca.mode) ||
@@ -510,7 +510,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
510 ops->get_mac_params(dev, &params); 510 ops->get_mac_params(dev, &params);
511 511
512 if (info->attrs[IEEE802154_ATTR_TXPOWER]) 512 if (info->attrs[IEEE802154_ATTR_TXPOWER])
513 params.transmit_power = nla_get_s8(info->attrs[IEEE802154_ATTR_TXPOWER]); 513 params.transmit_power = nla_get_s8(info->attrs[IEEE802154_ATTR_TXPOWER]) * 100;
514 514
515 if (info->attrs[IEEE802154_ATTR_LBT_ENABLED]) 515 if (info->attrs[IEEE802154_ATTR_LBT_ENABLED])
516 params.lbt = nla_get_u8(info->attrs[IEEE802154_ATTR_LBT_ENABLED]); 516 params.lbt = nla_get_u8(info->attrs[IEEE802154_ATTR_LBT_ENABLED]);
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
index 57c1bdbfaa91..d289ae3f1e93 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -58,7 +58,7 @@ drv_set_channel(struct ieee802154_local *local, u8 page, u8 channel)
58 return local->ops->set_channel(&local->hw, page, channel); 58 return local->ops->set_channel(&local->hw, page, channel);
59} 59}
60 60
61static inline int drv_set_tx_power(struct ieee802154_local *local, s32 dbm) 61static inline int drv_set_tx_power(struct ieee802154_local *local, s32 mbm)
62{ 62{
63 might_sleep(); 63 might_sleep();
64 64
@@ -67,7 +67,7 @@ static inline int drv_set_tx_power(struct ieee802154_local *local, s32 dbm)
67 return -EOPNOTSUPP; 67 return -EOPNOTSUPP;
68 } 68 }
69 69
70 return local->ops->set_txpower(&local->hw, dbm); 70 return local->ops->set_txpower(&local->hw, mbm);
71} 71}
72 72
73static inline int drv_set_cca_mode(struct ieee802154_local *local, 73static inline int drv_set_cca_mode(struct ieee802154_local *local,