提交 e2eb173a 编写于 作者: A Alexander Aring 提交者: Marcel Holtmann

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: NAlexander Aring <alex.aring@gmail.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 1a19cb68
...@@ -1194,9 +1194,10 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw, ...@@ -1194,9 +1194,10 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
} }
static int static int
at86rf230_set_txpower(struct ieee802154_hw *hw, s32 db) at86rf230_set_txpower(struct ieee802154_hw *hw, s32 mbm)
{ {
struct at86rf230_local *lp = hw->priv; struct at86rf230_local *lp = hw->priv;
s8 db = mbm / 100;
/* typical maximum output is 5dBm with RG_PHY_TX_PWR 0x60, lower five /* typical maximum output is 5dBm with RG_PHY_TX_PWR 0x60, lower five
* bits decrease power in 1dB steps. 0x60 represents extra PA gain of * bits decrease power in 1dB steps. 0x60 represents extra PA gain of
......
...@@ -85,6 +85,7 @@ struct wpan_phy { ...@@ -85,6 +85,7 @@ struct wpan_phy {
u8 current_channel; u8 current_channel;
u8 current_page; u8 current_page;
u32 channels_supported[IEEE802154_MAX_PAGE + 1]; u32 channels_supported[IEEE802154_MAX_PAGE + 1];
/* current transmit_power in mBm */
s32 transmit_power; s32 transmit_power;
struct wpan_phy_cca cca; struct wpan_phy_cca cca;
......
...@@ -171,7 +171,7 @@ struct ieee802154_hw { ...@@ -171,7 +171,7 @@ struct ieee802154_hw {
* Returns either zero, or negative errno. * Returns either zero, or negative errno.
* *
* set_txpower: * set_txpower:
* Set radio transmit power in dB. Called with pib_lock held. * Set radio transmit power in mBm. Called with pib_lock held.
* Returns either zero, or negative errno. * Returns either zero, or negative errno.
* *
* set_lbt * set_lbt
...@@ -213,7 +213,7 @@ struct ieee802154_ops { ...@@ -213,7 +213,7 @@ struct ieee802154_ops {
int (*set_hw_addr_filt)(struct ieee802154_hw *hw, int (*set_hw_addr_filt)(struct ieee802154_hw *hw,
struct ieee802154_hw_addr_filt *filt, struct ieee802154_hw_addr_filt *filt,
unsigned long changed); unsigned long changed);
int (*set_txpower)(struct ieee802154_hw *hw, s32 dbm); int (*set_txpower)(struct ieee802154_hw *hw, s32 mbm);
int (*set_lbt)(struct ieee802154_hw *hw, bool on); int (*set_lbt)(struct ieee802154_hw *hw, bool on);
int (*set_cca_mode)(struct ieee802154_hw *hw, int (*set_cca_mode)(struct ieee802154_hw *hw,
const struct wpan_phy_cca *cca); const struct wpan_phy_cca *cca);
......
...@@ -117,7 +117,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid, ...@@ -117,7 +117,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
rtnl_unlock(); rtnl_unlock();
if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER, if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER,
params.transmit_power) || params.transmit_power / 100) ||
nla_put_u8(msg, IEEE802154_ATTR_LBT_ENABLED, params.lbt) || nla_put_u8(msg, IEEE802154_ATTR_LBT_ENABLED, params.lbt) ||
nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE, nla_put_u8(msg, IEEE802154_ATTR_CCA_MODE,
params.cca.mode) || params.cca.mode) ||
...@@ -510,7 +510,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info) ...@@ -510,7 +510,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
ops->get_mac_params(dev, &params); ops->get_mac_params(dev, &params);
if (info->attrs[IEEE802154_ATTR_TXPOWER]) if (info->attrs[IEEE802154_ATTR_TXPOWER])
params.transmit_power = nla_get_s8(info->attrs[IEEE802154_ATTR_TXPOWER]); params.transmit_power = nla_get_s8(info->attrs[IEEE802154_ATTR_TXPOWER]) * 100;
if (info->attrs[IEEE802154_ATTR_LBT_ENABLED]) if (info->attrs[IEEE802154_ATTR_LBT_ENABLED])
params.lbt = nla_get_u8(info->attrs[IEEE802154_ATTR_LBT_ENABLED]); params.lbt = nla_get_u8(info->attrs[IEEE802154_ATTR_LBT_ENABLED]);
......
...@@ -58,7 +58,7 @@ drv_set_channel(struct ieee802154_local *local, u8 page, u8 channel) ...@@ -58,7 +58,7 @@ drv_set_channel(struct ieee802154_local *local, u8 page, u8 channel)
return local->ops->set_channel(&local->hw, page, channel); return local->ops->set_channel(&local->hw, page, channel);
} }
static inline int drv_set_tx_power(struct ieee802154_local *local, s32 dbm) static inline int drv_set_tx_power(struct ieee802154_local *local, s32 mbm)
{ {
might_sleep(); might_sleep();
...@@ -67,7 +67,7 @@ static inline int drv_set_tx_power(struct ieee802154_local *local, s32 dbm) ...@@ -67,7 +67,7 @@ static inline int drv_set_tx_power(struct ieee802154_local *local, s32 dbm)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
return local->ops->set_txpower(&local->hw, dbm); return local->ops->set_txpower(&local->hw, mbm);
} }
static inline int drv_set_cca_mode(struct ieee802154_local *local, static inline int drv_set_cca_mode(struct ieee802154_local *local,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册