ieee802154: add support for phy capabilities
Subsystems (5)
Alexander Aring
maintainerv2 cover ieee802154: add support for phy capabilities
Hi,
this patch series contains support for phy capabilities. The phy capabilities can be used to check the setting parameters in nl802154 before we calling the according rdev-ops to send them into SoftMAC/Driver(HardMAC) layer. This avoids that we know before sending them to these layers that we know a "-EINVAL" before, this can be used to check all setting parameters in one setting commands like [0]. Additional we can now dump the capabilities into userspace so users know what the phy is supported.
The initial values for phy capabilities is that if the driver supports the according handling then the full range of 802.15.4 is supported like csma parameters or max frame retries. If the driver doesn't support the setting of these we assume the 802.15.4 standard values which cannot be changed. (If the phy supports that in any way then the driver is broken and need to support that, we assume that the phy doing 802.15.4 defaults). This case is for mac parameters. In case of that the driver supports the according settings like CSMA/frame retries _but_ not the full range of the 802.15.4 then the driver can overwrite this behaviour by changing the capabilities.
For phy parameters, if the driver doesn't set anything, then there is also no possibility to change these values from userspace, this is also a lack of support inside the driver then.
At least this patch series also includes a rework of setting/reporting tx_powers/cca_ed_levels values.
- Alex
changes since v2:
- fix nl802154_capability_attr to nl802154_wpan_phy_capability_attr
- change dbm handling to mbm handling
- reorder patches "mac802154: check for really change" and "mac802154: remove check if operation is supported" because inconsitent when it's applied before "ieee802154: add several phy supported handling"
Alexander Aring (16):
ieee802154: change transmit power to s32
ieee802154: change transmit power to mbm
ieee802154: change cca ed level to mbm
ieee802154: introduce wpan_phy_supported
ieee802154: add several phy supported handling
mac802154: check for really changes
mac802154: remove check if operation is supported
ieee802154: add iftypes capability
ieee802154: add support for get tx powers
ieee802154: add support for get cca ed levels
at86rf230: set cca_modes supported flags
at86rf230: add reset states of tx power level
at86rf230: rework tx power support
at86rf230: rework tx cca energy detection level
ieee802154: check transmit power before driver layer
nl802154: add support for dump phy capabilities
drivers/net/ieee802154/at86rf230.c | 136 +++++++++++++++++++++++-------- drivers/net/ieee802154/cc2520.c | 2 +- drivers/net/ieee802154/fakelb.c | 30 +++---- drivers/net/ieee802154/mrf24j40.c | 2 +- include/net/cfg802154.h | 47 ++++++++++- include/net/mac802154.h | 25 ++++-- include/net/nl802154.h | 79 ++++++++++++++++++ net/ieee802154/nl-mac.c | 8 +- net/ieee802154/nl-phy.c | 4 +- net/ieee802154/nl802154.c | 162 ++++++++++++++++++++++++++++++++++--- net/ieee802154/rdev-ops.h | 23 ++++++ net/ieee802154/trace.h | 45 +++++++++++ net/mac802154/cfg.c | 62 +++++++++----- net/mac802154/driver-ops.h | 32 +++++++- net/mac802154/mac_cmd.c | 41 ++++++++++ net/mac802154/main.c | 32 ++++++++ 16 files changed, 631 insertions(+), 99 deletions(-)
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 1/16 ieee802154: change transmit power to s32
This patch change the transmit power from s8 to s32. This prepares to store a mbm value instead dbm inside the transmit power variable. The old interface keep the a s8 dbm value, which should be backward compatibility when assign s8 to s32.
--- drivers/net/ieee802154/at86rf230.c | 2 +- include/net/cfg802154.h | 2 +- include/net/mac802154.h | 2 +- net/ieee802154/nl802154.c | 6 +++--- net/mac802154/driver-ops.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ieee802154/at86rf230.c +1 -1
@@ -1194,7 +1194,7 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw, }static int -at86rf230_set_txpower (struct ieee802154_hw *hw,s8 db) +at86rf230_set_txpower (struct ieee802154_hw *hw,s32 db) {struct at86rf230_local *lp = hw->priv;
include/net/cfg802154.h +1 -1
@@ -85,7 +85,7 @@ struct wpan_phy {u8 current_channel;u8 current_page;u32 channels_supported[IEEE802154_MAX_PAGE +1 ]; -s8 transmit_power; +s32 transmit_power;struct wpan_phy_cca cca;__le64 perm_extended_addr;
include/net/mac802154.h +1 -1
@@ -213,7 +213,7 @@ 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,s8 dbm); +int (*set_txpower)(struct ieee802154_hw *hw,s32 dbm);int (*set_lbt)(struct ieee802154_hw *hw,bool on);int (*set_cca_mode)(struct ieee802154_hw *hw,const struct wpan_phy_cca *cca);
net/ieee802154/nl802154.c +3 -3
@@ -207,7 +207,7 @@ static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX+1] = { [NL802154_ATTR_PAGE] = { .type = NLA_U8, }, [NL802154_ATTR_CHANNEL] = { .type = NLA_U8, }, - [NL802154_ATTR_TX_POWER] = { .type = NLA_S8, }, + [NL802154_ATTR_TX_POWER] = { .type = NLA_S32, }, [NL802154_ATTR_CCA_MODE] = { .type = NLA_U32, }, [NL802154_ATTR_CCA_OPT] = { .type = NLA_U32, },
@@ -301,8 +301,8 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev, goto nla_put_failure; } -if (nla_put_s8 (msg,NL802154_ATTR_TX_POWER , - rdev->wpan_phy.transmit_power)) +if (nla_put_s32 (msg,NL802154_ATTR_TX_POWER , + rdev->wpan_phy.transmit_power)) goto nla_put_failure; finish:
net/mac802154/driver-ops.h +1 -1
@@ -58,7 +58,7 @@ drv_set_channel(struct ieee802154_local *local, u8 page, u8 channel)return local->ops->set_channel (&local->hw, page, channel); } -static inline int drv_set_tx_power (struct ieee802154_local *local,s8 dbm) +static inline int drv_set_tx_power (struct ieee802154_local *local,s32 dbm) {might_sleep ();
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 2/16 ieee802154: change transmit power to mbm
In reply to Alexander AringThis 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.
--- drivers/net/ieee802154/at86rf230.c | 3 ++- include/net/cfg802154.h | 1 + include/net/mac802154.h | 2 +- net/ieee802154/nl-mac.c | 4 ++-- net/mac802154/driver-ops.h | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-)
drivers/net/ieee802154/at86rf230.c +2 -1
@@ -1194,9 +1194,10 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw, }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; +s8 db = mbm /100 ;/* 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
include/net/cfg802154.h +1 -0
@@ -85,6 +85,7 @@ struct wpan_phy {u8 current_channel;u8 current_page;u32 channels_supported[IEEE802154_MAX_PAGE +1 ]; +/* current transmit_power in mBm */ s32 transmit_power;struct wpan_phy_cca cca;
include/net/mac802154.h +1 -1
@@ -171,7 +171,7 @@ struct ieee802154_hw {* Returns either zero, or negative errno. * * 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. * * set_lbt
net/ieee802154/nl-mac.c +2 -2
@@ -117,7 +117,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,rtnl_unlock (); 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_CCA_MODE, params.cca.mode) ||
@@ -510,7 +510,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info) ops->get_mac_params (dev, ¶ms);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 ]) params.lbt =nla_get_u8 (info->attrs[IEEE802154_ATTR_LBT_ENABLED ]);
net/mac802154/driver-ops.h +2 -2
@@ -58,7 +58,7 @@ drv_set_channel(struct ieee802154_local *local, u8 page, u8 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 ();
@@ -67,7 +67,7 @@ static inline int drv_set_tx_power(struct ieee802154_local *local, s32 dbm)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,
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 3/16 ieee802154: change cca ed level to mbm
In reply to Alexander AringThis 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.
--- 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(-)
drivers/net/ieee802154/at86rf230.c +2 -1
@@ -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 ;
include/net/cfg802154.h +1 -0
@@ -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 */
include/net/mac802154.h +2 -3
@@ -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,
net/ieee802154/nl-mac.c +2 -2
@@ -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 ]);
net/mac802154/driver-ops.h +2 -2
@@ -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)
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 4/16 ieee802154: introduce wpan_phy_supported
In reply to Alexander AringThis patch introduce the wpan_phy_supported struct for wpan_phy. There is currently no way to check if a transceiver can handle IEEE 802.15.4 complaint values. With this struct we can check before if the transceiver supports these values before sending to driver layer.
--- drivers/net/ieee802154/at86rf230.c | 8 ++++---- drivers/net/ieee802154/cc2520.c | 2 +- drivers/net/ieee802154/fakelb.c | 30 +++++++++++++++--------------- drivers/net/ieee802154/mrf24j40.c | 2 +- include/net/cfg802154.h | 6 +++++- net/ieee802154/nl-phy.c | 4 ++-- net/ieee802154/nl802154.c | 4 ++-- 7 files changed, 30 insertions(+), 26 deletions(-)
drivers/net/ieee802154/at86rf230.c +4 -4
@@ -1579,7 +1579,7 @@ at86rf230_detect_device(struct at86rf230_local *lp)case 3 : chip ="at86rf231" ; lp->data = &at86rf231_data; - lp->hw->phy->channels_supported[0 ] =0x7FFF800 ; + lp->hw->phy->supported.channels[0 ] =0x7FFF800 ; lp->hw->phy->current_channel =11 ; lp->hw->phy->symbol_duration =16 ;break ;
@@ -1587,15 +1587,15 @@ at86rf230_detect_device(struct at86rf230_local *lp) chip ="at86rf212" ; lp->data = &at86rf212_data; lp->hw->flags |=IEEE802154_HW_LBT ; - lp->hw->phy->channels_supported[0 ] =0x00007FF ; - lp->hw->phy->channels_supported[2 ] =0x00007FF ; + lp->hw->phy->supported.channels[0 ] =0x00007FF ; + lp->hw->phy->supported.channels[2 ] =0x00007FF ; lp->hw->phy->current_channel =5 ; lp->hw->phy->symbol_duration =25 ;break ;case 11 : chip ="at86rf233" ; lp->data = &at86rf233_data; - lp->hw->phy->channels_supported[0 ] =0x7FFF800 ; + lp->hw->phy->supported.channels[0 ] =0x7FFF800 ; lp->hw->phy->current_channel =13 ; lp->hw->phy->symbol_duration =16 ;break ;
drivers/net/ieee802154/cc2520.c +1 -1
@@ -653,7 +653,7 @@ static int cc2520_register(struct cc2520_private *priv)ieee802154_random_extended_addr (&priv->hw->phy->perm_extended_addr);/* We do support only 2.4 Ghz */ - priv->hw->phy->channels_supported[0 ] =0x7FFF800 ; + priv->hw->phy->supported.channels[0 ] =0x7FFF800 ; priv->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK |IEEE802154_HW_AFILT ;
drivers/net/ieee802154/fakelb.c +15 -15
@@ -149,35 +149,35 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) priv->hw = hw;/* 868 MHz BPSK 802.15.4-2003 */ - hw->phy->channels_supported[0 ] |=1 ; + hw->phy->supported.channels[0 ] |=1 ;/* 915 MHz BPSK 802.15.4-2003 */ - hw->phy->channels_supported[0 ] |=0x7fe ; + hw->phy->supported.channels[0 ] |=0x7fe ;/* 2.4 GHz O-QPSK 802.15.4-2003 */ - hw->phy->channels_supported[0 ] |=0x7FFF800 ; + hw->phy->supported.channels[0 ] |=0x7FFF800 ;/* 868 MHz ASK 802.15.4-2006 */ - hw->phy->channels_supported[1 ] |=1 ; + hw->phy->supported.channels[1 ] |=1 ;/* 915 MHz ASK 802.15.4-2006 */ - hw->phy->channels_supported[1 ] |=0x7fe ; + hw->phy->supported.channels[1 ] |=0x7fe ;/* 868 MHz O-QPSK 802.15.4-2006 */ - hw->phy->channels_supported[2 ] |=1 ; + hw->phy->supported.channels[2 ] |=1 ;/* 915 MHz O-QPSK 802.15.4-2006 */ - hw->phy->channels_supported[2 ] |=0x7fe ; + hw->phy->supported.channels[2 ] |=0x7fe ;/* 2.4 GHz CSS 802.15.4a-2007 */ - hw->phy->channels_supported[3 ] |=0x3fff ; + hw->phy->supported.channels[3 ] |=0x3fff ;/* UWB Sub-gigahertz 802.15.4a-2007 */ - hw->phy->channels_supported[4 ] |=1 ; + hw->phy->supported.channels[4 ] |=1 ;/* UWB Low band 802.15.4a-2007 */ - hw->phy->channels_supported[4 ] |=0x1e ; + hw->phy->supported.channels[4 ] |=0x1e ;/* UWB High band 802.15.4a-2007 */ - hw->phy->channels_supported[4 ] |=0xffe0 ; + hw->phy->supported.channels[4 ] |=0xffe0 ;/* 750 MHz O-QPSK 802.15.4c-2009 */ - hw->phy->channels_supported[5 ] |=0xf ; + hw->phy->supported.channels[5 ] |=0xf ;/* 750 MHz MPSK 802.15.4c-2009 */ - hw->phy->channels_supported[5 ] |=0xf0 ; + hw->phy->supported.channels[5 ] |=0xf0 ;/* 950 MHz BPSK 802.15.4d-2009 */ - hw->phy->channels_supported[6 ] |=0x3ff ; + hw->phy->supported.channels[6 ] |=0x3ff ;/* 950 MHz GFSK 802.15.4d-2009 */ - hw->phy->channels_supported[6 ] |=0x3ffc00 ; + hw->phy->supported.channels[6 ] |=0x3ffc00 ;INIT_LIST_HEAD (&priv->list); priv->fake = fake;
drivers/net/ieee802154/mrf24j40.c +1 -1
@@ -750,7 +750,7 @@ static int mrf24j40_probe(struct spi_device *spi) devrec->hw->priv = devrec; devrec->hw->parent = &devrec->spi->dev; - devrec->hw->phy->channels_supported[0 ] =CHANNEL_MASK ; + devrec->hw->phy->supported.channels[0 ] =CHANNEL_MASK ; devrec->hw->flags =IEEE802154_HW_OMIT_CKSUM |IEEE802154_HW_AACK |IEEE802154_HW_AFILT ;
include/net/cfg802154.h +5 -1
@@ -61,6 +61,10 @@ struct cfg802154_ops { struct wpan_dev *wpan_dev, bool mode); }; +struct wpan_phy_supported { +u32 channels[IEEE802154_MAX_PAGE +1 ]; +}; +struct wpan_phy_cca {enum nl802154_cca_modes mode;enum nl802154_cca_opts opt;
@@ -84,7 +88,7 @@ struct wpan_phy {*/ u8 current_channel;u8 current_page; -u32 channels_supported[IEEE802154_MAX_PAGE +1 ]; +struct wpan_phy_supported supported;/* current transmit_power in mBm */ s32 transmit_power;struct wpan_phy_cca cca;
net/ieee802154/nl-phy.c +2 -2
@@ -56,8 +56,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel)) goto nla_put_failure;for (i =0 ; i <32 ; i++) { -if (phy->channels_supported[i]) - buf[pages++] = phy->channels_supported[i] | (i <<27 ); +if (phy->supported.channels[i]) + buf[pages++] = phy->supported.channels[i] | (i <<27 ); }if (pages && nla_put(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST,
net/ieee802154/nl802154.c +2 -2
@@ -248,7 +248,7 @@ nl802154_send_wpan_phy_channels(struct cfg802154_registered_device *rdev,for (page =0 ; page <=IEEE802154_MAX_PAGE ; page++) {if (nla_put_u32 (msg,NL802154_ATTR_SUPPORTED_CHANNEL , - rdev->wpan_phy.channels_supported[page])) + rdev->wpan_phy.supported.channels[page]))return -ENOBUFS ; }nla_nest_end (msg, nl_page);
@@ -626,7 +626,7 @@ static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info)/* check 802.15.4 constraints */ if (page >IEEE802154_MAX_PAGE || channel >IEEE802154_MAX_CHANNEL || - !(rdev->wpan_phy.channels_supported[page] &BIT (channel))) + !(rdev->wpan_phy.supported.channels[page] &BIT (channel)))return -EINVAL ;return rdev_set_channel (rdev, page, channel);
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 5/16 ieee802154: add several phy supported handling
In reply to Alexander AringThis patch adds support for phy supported handling for all other already existing handling 802.15.4 functionality. We assume now a fully 802.15.4 complaint transceiver at phy allocation. If a transceiver can support 802.15.4 default values only, then the values should be overwirtten by values the transceiver supports. If the transceiver doesn't set the according hardware flags, we assume the 802.15.4 defaults now which cannot be changed.
--- include/net/cfg802154.h | 24 +++++++++++++++++++++++- include/net/nl802154.h | 22 ++++++++++++++++++++++ net/ieee802154/nl802154.c | 22 +++++++++++++++++----- net/mac802154/main.c | 26 ++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 6 deletions(-)
include/net/cfg802154.h +23 -1
@@ -61,8 +61,30 @@ struct cfg802154_ops { struct wpan_dev *wpan_dev, bool mode); }; +static inline bool +wpan_phy_supported_bool (bool b,enum nl802154_supported_bool_states st) +{ +switch (st) { +case NL802154_SUPPORTED_BOOL_TRUE : +return b; +case NL802154_SUPPORTED_BOOL_FALSE : +return !b; +case NL802154_SUPPORTED_BOOL_BOTH : +return true; +default : +WARN_ON (1 ); + } + +return false; +} +struct wpan_phy_supported { -u32 channels[IEEE802154_MAX_PAGE +1 ]; +u32 channels[IEEE802154_MAX_PAGE +1 ], + cca_modes, cca_opts; +enum nl802154_supported_bool_states lbt; +u8 min_minbe, max_minbe, min_maxbe, max_maxbe, + min_csma_backoffs, max_csma_backoffs; +s8 min_frame_retries, max_frame_retries; };struct wpan_phy_cca {
include/net/nl802154.h +22 -0
@@ -162,4 +162,26 @@ enum nl802154_cca_opts {NL802154_CCA_OPT_ATTR_MAX = __NL802154_CCA_OPT_ATTR_AFTER_LAST -1 }; +/** +* enum nl802154_supported_bool_states - bool states for bool capability entry +* +* @NL802154_SUPPORTED_BOOL_FALSE: indicates to set false +* @NL802154_SUPPORTED_BOOL_TRUE: indicates to set true +* @__NL802154_SUPPORTED_BOOL_INVALD: reserved +* @NL802154_SUPPORTED_BOOL_BOTH: indicates to set true and false +* @__NL802154_SUPPORTED_BOOL_AFTER_LAST: Internal +* @NL802154_SUPPORTED_BOOL_MAX: highest value for bool states +*/ +enum nl802154_supported_bool_states { +NL802154_SUPPORTED_BOOL_FALSE , +NL802154_SUPPORTED_BOOL_TRUE , +/* to handle them in a mask */ + __NL802154_SUPPORTED_BOOL_INVALD, +NL802154_SUPPORTED_BOOL_BOTH , + +/* keep last */ + __NL802154_SUPPORTED_BOOL_AFTER_LAST, +NL802154_SUPPORTED_BOOL_MAX = __NL802154_SUPPORTED_BOOL_AFTER_LAST -1 +}; +#endif /* __NL802154_H */
net/ieee802154/nl802154.c +17 -5
@@ -642,7 +642,9 @@ static int nl802154_set_cca_mode(struct sk_buff *skb, struct genl_info *info) cca.mode =nla_get_u32 (info->attrs[NL802154_ATTR_CCA_MODE ]);/* checking 802.15.4 constraints */ -if (cca.mode <NL802154_CCA_ENERGY || cca.mode >NL802154_CCA_ATTR_MAX ) +if (cca.mode <NL802154_CCA_ENERGY || + cca.mode >NL802154_CCA_ATTR_MAX || + !(rdev->wpan_phy.supported.cca_modes &BIT (cca.mode)))return -EINVAL ;if (cca.mode ==NL802154_CCA_ENERGY_CARRIER ) {
@@ -650,7 +652,8 @@ static int nl802154_set_cca_mode(struct sk_buff *skb, struct genl_info *info)return -EINVAL ; cca.opt =nla_get_u32 (info->attrs[NL802154_ATTR_CCA_OPT ]); -if (cca.opt >NL802154_CCA_OPT_ATTR_MAX ) +if (cca.opt >NL802154_CCA_OPT_ATTR_MAX || + !(rdev->wpan_phy.supported.cca_opts &BIT (cca.opt)))return -EINVAL ; }
@@ -744,7 +747,11 @@ nl802154_set_backoff_exponent(struct sk_buff *skb, struct genl_info *info) max_be =nla_get_u8 (info->attrs[NL802154_ATTR_MAX_BE ]);/* check 802.15.4 constraints */ -if (max_be <3 || max_be >8 || min_be > max_be) +if (min_be < rdev->wpan_phy.supported.min_minbe || + min_be > rdev->wpan_phy.supported.max_minbe || + max_be < rdev->wpan_phy.supported.min_maxbe || + max_be > rdev->wpan_phy.supported.max_maxbe || + min_be > max_be)return -EINVAL ;return rdev_set_backoff_exponent (rdev, wpan_dev, min_be, max_be);
@@ -769,7 +776,8 @@ nl802154_set_max_csma_backoffs(struct sk_buff *skb, struct genl_info *info) info->attrs[NL802154_ATTR_MAX_CSMA_BACKOFFS]);/* check 802.15.4 constraints */ -if (max_csma_backoffs >5 ) +if (max_csma_backoffs < rdev->wpan_phy.supported.min_csma_backoffs || + max_csma_backoffs > rdev->wpan_phy.supported.max_csma_backoffs)return -EINVAL ;return rdev_set_max_csma_backoffs (rdev, wpan_dev, max_csma_backoffs);
@@ -793,7 +801,8 @@ nl802154_set_max_frame_retries(struct sk_buff *skb, struct genl_info *info) info->attrs[NL802154_ATTR_MAX_FRAME_RETRIES]);/* check 802.15.4 constraints */ -if (max_frame_retries <-1 || max_frame_retries >7 ) +if (max_frame_retries < rdev->wpan_phy.supported.min_frame_retries || + max_frame_retries > rdev->wpan_phy.supported.max_frame_retries)return -EINVAL ;return rdev_set_max_frame_retries (rdev, wpan_dev, max_frame_retries);
@@ -813,6 +822,9 @@ static int nl802154_set_lbt_mode(struct sk_buff *skb, struct genl_info *info)return -EINVAL ; mode = !!nla_get_u8 (info->attrs[NL802154_ATTR_LBT_MODE ]); +if (!wpan_phy_supported_bool (mode, rdev->wpan_phy.supported.lbt)) +return -EINVAL ; +return rdev_set_lbt_mode (rdev, wpan_dev, mode); }
net/mac802154/main.c +26 -0
@@ -107,6 +107,15 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)skb_queue_head_init (&local->skb_queue); +/* init supported flags with 802.15.4 default ranges */ + phy->supported.max_minbe =8 ; + phy->supported.min_maxbe =3 ; + phy->supported.max_maxbe =8 ; + phy->supported.min_frame_retries =-1 ; + phy->supported.max_frame_retries =7 ; + phy->supported.max_csma_backoffs =5 ; + phy->supported.lbt =NL802154_SUPPORTED_BOOL_FALSE ; +return &local->hw; }EXPORT_SYMBOL (ieee802154_alloc_hw);
@@ -155,6 +164,23 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)ieee802154_setup_wpan_phy_pib (local->phy); +if (!(hw->flags &IEEE802154_HW_CSMA_PARAMS )) { + local->phy->supported.min_csma_backoffs =4 ; + local->phy->supported.max_csma_backoffs =4 ; + local->phy->supported.min_maxbe =5 ; + local->phy->supported.max_maxbe =5 ; + local->phy->supported.min_minbe =3 ; + local->phy->supported.max_minbe =3 ; + } + +if (!(hw->flags &IEEE802154_HW_FRAME_RETRIES )) { +/* TODO should be 3, but our default value is -1 which means +* no ARET handling. +*/ + local->phy->supported.min_frame_retries =-1 ; + local->phy->supported.max_frame_retries =-1 ; + } + rc =wpan_phy_register (local->phy);if (rc <0 ) goto out_wq;
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 6/16 mac802154: check for really changes
In reply to Alexander AringThis patch adds check if the value is really changed inside pib/mib. If a transceiver do support only one value for e.g. max_be then this will also handle that the driver layer doesn't need to care about handling to set one value only.
--- include/net/cfg802154.h | 12 ++++++++++++ net/mac802154/cfg.c | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
include/net/cfg802154.h +12 -0
@@ -92,6 +92,18 @@ struct wpan_phy_cca {enum nl802154_cca_opts opt; }; +static inline bool +wpan_phy_cca_cmp (const struct wpan_phy_cca *a,const struct wpan_phy_cca *b) +{ +if (a->mode != b->mode) +return false; + +if (a->mode ==NL802154_CCA_ENERGY_CARRIER ) +return a->opt == b->opt; + +return true; +} +struct wpan_phy {struct mutex pib_lock;
net/mac802154/cfg.c +26 -0
@@ -73,6 +73,10 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)ASSERT_RTNL (); +if (wpan_phy->current_page == page && + wpan_phy->current_channel == channel) +return 0 ; + ret =drv_set_channel (local, page, channel);if (!ret) { wpan_phy->current_page = page;
@@ -91,6 +95,9 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,ASSERT_RTNL (); +if (wpan_phy_cca_cmp (&wpan_phy->cca, cca)) +return 0 ; +/* check if phy support this setting */ if (!(local->hw.flags &IEEE802154_HW_CCA_MODE ))return -EOPNOTSUPP ;
@@ -108,6 +115,9 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, {ASSERT_RTNL (); +if (wpan_dev->pan_id == pan_id) +return 0 ; + wpan_dev->pan_id = pan_id;return 0 ; }
@@ -121,6 +131,10 @@ ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy,ASSERT_RTNL (); +if (wpan_dev->min_be == min_be && + wpan_dev->max_be == max_be) +return 0 ; +if (!(local->hw.flags &IEEE802154_HW_CSMA_PARAMS ))return -EOPNOTSUPP ;
@@ -135,6 +149,9 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, {ASSERT_RTNL (); +if (wpan_dev->short_addr == short_addr) +return 0 ; + wpan_dev->short_addr = short_addr;return 0 ; }
@@ -148,6 +165,9 @@ ieee802154_set_max_csma_backoffs(struct wpan_phy *wpan_phy,ASSERT_RTNL (); +if (wpan_dev->csma_retries == max_csma_backoffs) +return 0 ; +if (!(local->hw.flags &IEEE802154_HW_CSMA_PARAMS ))return -EOPNOTSUPP ;
@@ -164,6 +184,9 @@ ieee802154_set_max_frame_retries(struct wpan_phy *wpan_phy,ASSERT_RTNL (); +if (wpan_dev->frame_retries == max_frame_retries) +return 0 ; +if (!(local->hw.flags &IEEE802154_HW_FRAME_RETRIES ))return -EOPNOTSUPP ;
@@ -179,6 +202,9 @@ ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,ASSERT_RTNL (); +if (wpan_dev->lbt == mode) +return 0 ; +if (!(local->hw.flags &IEEE802154_HW_LBT ))return -EOPNOTSUPP ;
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 7/16 mac802154: remove check if operation is supported
In reply to Alexander AringThis patch removes the check if operation is supported by driver layer. This is done now by capabilities flags, if these are valid then the driver should support the operation, otherwise a WARN_ON occurs.
--- net/mac802154/cfg.c | 24 ------------------------ 1 file changed, 24 deletions(-)
net/mac802154/cfg.c +0 -24
@@ -98,10 +98,6 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,if (wpan_phy_cca_cmp (&wpan_phy->cca, cca))return 0 ; -/* check if phy support this setting */ -if (!(local->hw.flags &IEEE802154_HW_CCA_MODE )) -return -EOPNOTSUPP ; - ret =drv_set_cca_mode (local, cca);if (!ret) wpan_phy->cca = *cca;
@@ -127,17 +123,12 @@ ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy,struct wpan_dev *wpan_dev, u8 min_be, u8 max_be) { - struct ieee802154_local *local = wpan_phy_priv(wpan_phy); -ASSERT_RTNL ();if (wpan_dev->min_be == min_be && wpan_dev->max_be == max_be)return 0 ; -if (!(local->hw.flags &IEEE802154_HW_CSMA_PARAMS )) -return -EOPNOTSUPP ; - wpan_dev->min_be = min_be; wpan_dev->max_be = max_be;return 0 ;
@@ -161,16 +152,11 @@ ieee802154_set_max_csma_backoffs(struct wpan_phy *wpan_phy,struct wpan_dev *wpan_dev, u8 max_csma_backoffs) { -struct ieee802154_local *local =wpan_phy_priv (wpan_phy); -ASSERT_RTNL ();if (wpan_dev->csma_retries == max_csma_backoffs)return 0 ; -if (!(local->hw.flags &IEEE802154_HW_CSMA_PARAMS )) -return -EOPNOTSUPP ; - wpan_dev->csma_retries = max_csma_backoffs;return 0 ; }
@@ -180,16 +166,11 @@ ieee802154_set_max_frame_retries(struct wpan_phy *wpan_phy,struct wpan_dev *wpan_dev, s8 max_frame_retries) { -struct ieee802154_local *local =wpan_phy_priv (wpan_phy); -ASSERT_RTNL ();if (wpan_dev->frame_retries == max_frame_retries)return 0 ; -if (!(local->hw.flags &IEEE802154_HW_FRAME_RETRIES )) -return -EOPNOTSUPP ; - wpan_dev->frame_retries = max_frame_retries;return 0 ; }
@@ -198,16 +179,11 @@ static int ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, bool mode) { - struct ieee802154_local *local = wpan_phy_priv(wpan_phy); -ASSERT_RTNL ();if (wpan_dev->lbt == mode)return 0 ; -if (!(local->hw.flags &IEEE802154_HW_LBT )) -return -EOPNOTSUPP ; - wpan_dev->lbt = mode;return 0 ; }
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 8/16 ieee802154: add iftypes capability
In reply to Alexander AringThis patch adds capability flags for supported interface types.
--- include/net/cfg802154.h | 2 +- net/ieee802154/nl802154.c | 3 ++- net/mac802154/main.c | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
include/net/cfg802154.h +1 -1
@@ -80,7 +80,7 @@ wpan_phy_supported_bool(bool b, enum nl802154_supported_bool_states st)struct wpan_phy_supported {u32 channels[IEEE802154_MAX_PAGE +1 ], - cca_modes, cca_opts; + cca_modes, cca_opts, iftypes;enum nl802154_supported_bool_states lbt;u8 min_minbe, max_minbe, min_maxbe, max_maxbe, min_csma_backoffs, max_csma_backoffs;
net/ieee802154/nl802154.c +2 -1
@@ -575,7 +575,8 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)if (info->attrs[NL802154_ATTR_IFTYPE ]) { type =nla_get_u32 (info->attrs[NL802154_ATTR_IFTYPE ]); -if (type >NL802154_IFTYPE_MAX ) +if (type >NL802154_IFTYPE_MAX || + !(rdev->wpan_phy.supported.iftypes &BIT (type)))return -EINVAL ; }
net/mac802154/main.c +6 -0
@@ -116,6 +116,9 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops) phy->supported.max_csma_backoffs =5 ; phy->supported.lbt =NL802154_SUPPORTED_BOOL_FALSE ; +/* always supported */ + phy->supported.iftypes =BIT (NL802154_IFTYPE_NODE ); +return &local->hw; }EXPORT_SYMBOL (ieee802154_alloc_hw);
@@ -181,6 +184,9 @@ int ieee802154_register_hw(struct ieee802154_hw *hw) local->phy->supported.max_frame_retries =-1 ; } +if (hw->flags &IEEE802154_HW_PROMISCUOUS ) + local->phy->supported.iftypes |=BIT (NL802154_IFTYPE_MONITOR ); + rc =wpan_phy_register (local->phy);if (rc <0 ) goto out_wq;
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 9/16 ieee802154: add support for get tx powers
In reply to Alexander AringThis 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.
--- 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(-)
include/net/cfg802154.h +1 -0
@@ -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,
include/net/mac802154.h +9 -1
@@ -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);
net/ieee802154/rdev-ops.h +11 -0
@@ -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) {
net/ieee802154/trace.h +31 -0
@@ -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),
net/mac802154/cfg.c +11 -0
@@ -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,
net/mac802154/driver-ops.h +12 -0
@@ -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) {
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 10/16 ieee802154: add support for get cca ed levels
In reply to Alexander AringThis 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.
--- include/net/cfg802154.h | 2 ++ include/net/mac802154.h | 8 ++++++++ net/ieee802154/rdev-ops.h | 12 ++++++++++++ net/ieee802154/trace.h | 14 ++++++++++++++ net/mac802154/cfg.c | 11 +++++++++++ net/mac802154/driver-ops.h | 12 ++++++++++++ 6 files changed, 59 insertions(+)
include/net/cfg802154.h +2 -0
@@ -45,6 +45,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,s32 *mbm,u32 idx); +int (*get_cca_ed_levels)(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,
include/net/mac802154.h +8 -0
@@ -180,6 +180,12 @@ struct ieee802154_hw {* Returns either zero or negative errno. One should be returned for * indicate to break the iteration of tx power settings. * +* 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. +* * set_lbt * Enables or disables listen before talk on the device. Called with * pib_lock held.
@@ -222,6 +228,8 @@ struct ieee802154_ops {int (*set_txpower)(struct ieee802154_hw *hw,s32 mbm);int (*get_tx_powers)(struct ieee802154_hw *hw,s32 *mbm,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);
net/ieee802154/rdev-ops.h +12 -0
@@ -75,6 +75,18 @@ rdev_set_cca_mode(struct cfg802154_registered_device *rdev, }static inline int +rdev_get_cca_ed_levels (struct cfg802154_registered_device *rdev,s32 *mbm, +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, mbm, idx); +trace_802154_rdev_return_int_mbm (&rdev->wpan_phy, ret, mbm); +return ret; +} + +static inline int rdev_get_tx_powers (struct cfg802154_registered_device *rdev,s32 *mbm,u32 idx) {int ret;
net/ieee802154/trace.h +14 -0
@@ -108,6 +108,20 @@ 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_get_tx_powers, TP_PROTO(struct wpan_phy *wpan_phy, u32 idx), TP_ARGS(wpan_phy, idx),
net/mac802154/cfg.c +11 -0
@@ -106,6 +106,16 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy, }static int +ieee802154_get_cca_ed_levels (struct wpan_phy *wpan_phy,s32 *mbm,u32 idx) +{ +struct ieee802154_local *local =wpan_phy_priv (wpan_phy); + +ASSERT_RTNL (); + +return drv_get_cca_ed_levels (local, mbm, idx); +} + +static int ieee802154_get_tx_powers (struct wpan_phy *wpan_phy,s32 *mbm,u32 idx) {struct ieee802154_local *local =wpan_phy_priv (wpan_phy);
@@ -206,6 +216,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,
net/mac802154/driver-ops.h +12 -0
@@ -120,6 +120,18 @@ drv_set_cca_ed_level(struct ieee802154_local *local, s32 mbm)return local->ops->set_cca_ed_level (&local->hw, mbm); } +static inline int +drv_get_cca_ed_levels (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_cca_ed_levels (&local->hw, mbm, idx); +} +static inline int drv_set_pan_id (struct ieee802154_local *local,__le16 pan_id) {struct ieee802154_hw_addr_filt filt;
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 11/16 at86rf230: set cca_modes supported flags
In reply to Alexander AringThis patch sets the at86rf230 supported cca modes. In case of at86rf212 it also can support listen before transmit.
--- drivers/net/ieee802154/at86rf230.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ieee802154/at86rf230.c +6 -0
@@ -1569,6 +1569,11 @@ at86rf230_detect_device(struct at86rf230_local *lp)IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET |IEEE802154_HW_AFILT |IEEE802154_HW_PROMISCUOUS ; + lp->hw->phy->supported.cca_modes =BIT (NL802154_CCA_ENERGY ) | +BIT (NL802154_CCA_CARRIER ) |BIT (NL802154_CCA_ENERGY_CARRIER ); + lp->hw->phy->supported.cca_opts =BIT (NL802154_CCA_OPT_ENERGY_CARRIER_AND ) | +BIT (NL802154_CCA_OPT_ENERGY_CARRIER_OR ); + lp->hw->phy->cca.mode =NL802154_CCA_ENERGY ;switch (part) {
@@ -1591,6 +1596,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->phy->supported.channels[2 ] =0x00007FF ; lp->hw->phy->current_channel =5 ; lp->hw->phy->symbol_duration =25 ; + lp->hw->phy->supported.lbt =NL802154_SUPPORTED_BOOL_BOTH ;break ;case 11 : chip ="at86rf233" ;
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 12/16 at86rf230: add reset states of tx power level
In reply to Alexander AringThis patch adds the reset states for tx power levels after running reset procedure.
--- drivers/net/ieee802154/at86rf230.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ieee802154/at86rf230.c +3 -0
@@ -1587,6 +1587,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->phy->supported.channels[0 ] =0x7FFF800 ; lp->hw->phy->current_channel =11 ; lp->hw->phy->symbol_duration =16 ; + lp->hw->phy->transmit_power =300 ;break ;case 7 : chip ="at86rf212" ;
@@ -1597,6 +1598,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->phy->current_channel =5 ; lp->hw->phy->symbol_duration =25 ; lp->hw->phy->supported.lbt =NL802154_SUPPORTED_BOOL_BOTH ; + lp->hw->phy->transmit_power =500 ;break ;case 11 : chip ="at86rf233" ;
@@ -1604,6 +1606,7 @@ at86rf230_detect_device(struct at86rf230_local *lp) lp->hw->phy->supported.channels[0 ] =0x7FFF800 ; lp->hw->phy->current_channel =13 ; lp->hw->phy->symbol_duration =16 ; + lp->hw->phy->transmit_power =400 ;break ;default : chip ="unknown" ;
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 13/16 at86rf230: rework tx power support
In reply to Alexander AringThis patch adds support for get transmit power levels and reworks the set of transmit power levels which was broken before.
--- drivers/net/ieee802154/at86rf230.c | 94 +++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 11 deletions(-)
drivers/net/ieee802154/at86rf230.c +83 -11
@@ -48,9 +48,12 @@ struct at86rf2xx_chip_data {u16 t_frame;u16 t_p_ack;int rssi_base_val; +const s32 *tx_powers_table;int (*set_channel)(struct at86rf230_local *,u8 ,u8 );int (*get_desense_steps)(struct at86rf230_local *,s32 ); +int (*set_txpower)(struct at86rf230_local *,s32 ); +int (*get_txpowers)(struct at86rf230_local *,s32 *,u32 ); };#define AT86RF2XX_MAX_BUF (127 + 3)
@@ -124,9 +127,12 @@ struct at86rf230_local {#define SR_IRQ_2_EXT_EN 0x04, 0x40, 6#define SR_PA_EXT_EN 0x04, 0x80, 7#define RG_PHY_TX_PWR (0x05) -#define SR_TX_PWR 0x05, 0x0f, 0 -#define SR_PA_LT 0x05, 0x30, 4 -#define SR_PA_BUF_LT 0x05, 0xc0, 6 +#define SR_TX_PWR_23X 0x05, 0x0f, 0 +#define SR_PA_LT_230 0x05, 0x30, 4 +#define SR_PA_BUF_LT_230 0x05, 0xc0, 6 +#define SR_TX_PWR_212 0x05, 0x1f, 0 +#define SR_GC_PA_212 0x05, 0x60, 5 +#define SR_PA_BOOST_LT_212 0x05, 0x80, 7#define RG_PHY_RSSI (0x06)#define SR_RSSI 0x06, 0x1f, 0#define SR_RND_VALUE 0x06, 0x60, 5
@@ -1193,12 +1199,34 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,return 0 ; } +#define AT86RF23X_MAX_TX_POWERS 0xF +static const s32 at86rf233_powers[AT86RF23X_MAX_TX_POWERS +1 ] = { +400 ,370 ,340 ,300 ,250 ,200 ,100 ,0 ,-100 ,-200 ,-300 ,-400 ,-600 , +-800 ,-1200 ,-1700 , +}; + +static const s32 at86rf231_powers[AT86RF23X_MAX_TX_POWERS +1 ] = { +300 ,280 ,230 ,180 ,130 ,70 ,0 ,-100 ,-200 ,-300 ,-400 ,-500 ,-700 , +-900 ,-1200 ,-1700 , +}; +static int -at86rf230_set_txpower (struct ieee802154_hw *hw,s32 mbm) +at86rf23x_set_txpower (struct at86rf230_local *lp,s32 mbm) { -struct at86rf230_local *lp = hw->priv; -s8 db = mbm /100 ; +u32 i; +for (i =0 ; i <AT86RF23X_MAX_TX_POWERS ; i++) { +if (lp->data->tx_powers_table[i] == mbm) +return at86rf230_write_subreg (lp,SR_TX_PWR_23X , i); + } + +return -EINVAL ; +} + +static int +at86rf212_set_txpower (struct at86rf230_local *lp,s32 mbm) +{ +s8 db = mbm /100 ;/* 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 * 0dB.
@@ -1208,9 +1236,44 @@ at86rf230_set_txpower(struct ieee802154_hw *hw, s32 mbm)if (db >5 || db <-26 )return -EINVAL ; - db = -(db -5 ); +return at86rf230_write_subreg (lp,SR_TX_PWR_212 , -(db -5 )); +} + +static int +at86rf230_set_txpower (struct ieee802154_hw *hw,s32 mbm) +{ +struct at86rf230_local *lp = hw->priv; + +return lp->data->set_txpower (lp, mbm); +} + +static int +at86rf23x_get_txpowers (struct at86rf230_local *lp,s32 *mbm,u32 idx) +{ +if (idx >AT86RF23X_MAX_TX_POWERS ) +return 1 ; + + *mbm = lp->data->tx_powers_table[idx]; +return 0 ; +} + +#define AT86RF212_MAX_TX_POWERS 0x1F +static int +at86rf212_get_txpowers (struct at86rf230_local *lp,s32 *mbm,u32 idx) +{ +if (idx >AT86RF212_MAX_TX_POWERS ) +return 1 ; + + *mbm = (5 - idx) *100 ; +return 0 ; +} + +static int +at86rf230_get_txpowers (struct ieee802154_hw *hw,s32 *mbm,u32 idx) +{ +struct at86rf230_local *lp = hw->priv; -return __at86rf230_write (lp,RG_PHY_TX_PWR ,0x60 | db); +return lp->data->get_txpowers (lp, mbm, idx); } static int
@@ -1349,6 +1412,7 @@ static const struct ieee802154_ops at86rf230_ops = { .stop = at86rf230_stop, .set_hw_addr_filt = at86rf230_set_hw_addr_filt, .set_txpower = at86rf230_set_txpower, + .get_tx_powers = at86rf230_get_txpowers, .set_lbt = at86rf230_set_lbt, .set_cca_mode = at86rf230_set_cca_mode, .set_cca_ed_level = at86rf230_set_cca_ed_level,
@@ -1366,8 +1430,11 @@ static struct at86rf2xx_chip_data at86rf233_data = { .t_frame = 4096, .t_p_ack = 545, .rssi_base_val = -91, + .tx_powers_table = at86rf233_powers, .set_channel = at86rf23x_set_channel, - .get_desense_steps = at86rf23x_get_desens_steps + .get_desense_steps = at86rf23x_get_desens_steps, + .set_txpower = at86rf23x_set_txpower, + .get_txpowers = at86rf23x_get_txpowers, };static struct at86rf2xx_chip_data at86rf231_data = {
@@ -1379,8 +1446,11 @@ static struct at86rf2xx_chip_data at86rf231_data = { .t_frame = 4096, .t_p_ack = 545, .rssi_base_val = -91, + .tx_powers_table = at86rf231_powers, .set_channel = at86rf23x_set_channel, - .get_desense_steps = at86rf23x_get_desens_steps + .get_desense_steps = at86rf23x_get_desens_steps, + .set_txpower = at86rf23x_set_txpower, + .get_txpowers = at86rf23x_get_txpowers, };static struct at86rf2xx_chip_data at86rf212_data = {
@@ -1393,7 +1463,9 @@ static struct at86rf2xx_chip_data at86rf212_data = { .t_p_ack = 545, .rssi_base_val = -100, .set_channel = at86rf212_set_channel, - .get_desense_steps = at86rf212_get_desens_steps + .get_desense_steps = at86rf212_get_desens_steps, + .set_txpower = at86rf212_set_txpower, + .get_txpowers = at86rf212_get_txpowers, };static int at86rf230_hw_init (struct at86rf230_local *lp,u8 xtal_trim)
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 14/16 at86rf230: rework tx cca energy detection level
In reply to Alexander AringThis patch reworks the cca energy detection level handling. This contains a calculation which works on all transceiver types and add support for dump cca energy detection levels.
--- drivers/net/ieee802154/at86rf230.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/net/ieee802154/at86rf230.c +18 -17
@@ -51,7 +51,6 @@ struct at86rf2xx_chip_data {const s32 *tx_powers_table;int (*set_channel)(struct at86rf230_local *,u8 ,u8 ); -int (*get_desense_steps)(struct at86rf230_local *,s32 );int (*set_txpower)(struct at86rf230_local *,s32 );int (*get_txpowers)(struct at86rf230_local *,s32 *,u32 ); };
@@ -1319,28 +1318,32 @@ at86rf230_set_cca_mode(struct ieee802154_hw *hw, }static int -at86rf212_get_desens_steps (struct at86rf230_local *lp,s32 level) +at86rf230_set_cca_ed_level (struct ieee802154_hw *hw,s32 mbm) { -return (level - lp->data->rssi_base_val) *100 /207 ; -} +struct at86rf230_local *lp = hw->priv; +s32 level = mbm /100 ; -static int -at86rf23x_get_desens_steps (struct at86rf230_local *lp,s32 level) -{ -return (level - lp->data->rssi_base_val) /2 ; +/* backwards compatible for old interface, should be removed */ +if (level < lp->data->rssi_base_val || + level > lp->data->rssi_base_val +2 *0xF ) +return -EINVAL ; + +return at86rf230_write_subreg (lp,SR_CCA_ED_THRES , + (level - lp->data->rssi_base_val) /2 ); } +#define AT86RF230_MAX_ED_LEVELS_IDX 0xF +static int -at86rf230_set_cca_ed_level (struct ieee802154_hw *hw,s32 mbm) +at86rf230_get_cca_ed_levels (struct ieee802154_hw *hw,s32 *mbm,u32 idx) {struct at86rf230_local *lp = hw->priv; -s32 level = mbm /100 ; -if (level < lp->data->rssi_base_val || level >30 ) -return -EINVAL ; +if (idx >AT86RF230_MAX_ED_LEVELS_IDX ) +return 1 ; -return at86rf230_write_subreg (lp,SR_CCA_ED_THRES , - lp->data->get_desense_steps (lp, level)); + *mbm = (lp->data->rssi_base_val +2 * idx) *100 ; +return 0 ; } static int
@@ -1413,6 +1416,7 @@ static const struct ieee802154_ops at86rf230_ops = { .set_hw_addr_filt = at86rf230_set_hw_addr_filt, .set_txpower = at86rf230_set_txpower, .get_tx_powers = at86rf230_get_txpowers, + .get_cca_ed_levels = at86rf230_get_cca_ed_levels, .set_lbt = at86rf230_set_lbt, .set_cca_mode = at86rf230_set_cca_mode, .set_cca_ed_level = at86rf230_set_cca_ed_level,
@@ -1432,7 +1436,6 @@ static struct at86rf2xx_chip_data at86rf233_data = { .rssi_base_val = -91, .tx_powers_table = at86rf233_powers, .set_channel = at86rf23x_set_channel, - .get_desense_steps = at86rf23x_get_desens_steps, .set_txpower = at86rf23x_set_txpower, .get_txpowers = at86rf23x_get_txpowers, };
@@ -1448,7 +1451,6 @@ static struct at86rf2xx_chip_data at86rf231_data = { .rssi_base_val = -91, .tx_powers_table = at86rf231_powers, .set_channel = at86rf23x_set_channel, - .get_desense_steps = at86rf23x_get_desens_steps, .set_txpower = at86rf23x_set_txpower, .get_txpowers = at86rf23x_get_txpowers, };
@@ -1463,7 +1465,6 @@ static struct at86rf2xx_chip_data at86rf212_data = { .t_p_ack = 545, .rssi_base_val = -100, .set_channel = at86rf212_set_channel, - .get_desense_steps = at86rf212_get_desens_steps, .set_txpower = at86rf212_set_txpower, .get_txpowers = at86rf212_get_txpowers, };
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 15/16 ieee802154: check transmit power before driver layer
In reply to Alexander AringThis patch moves the validation check of transmit power mbm values to the netlink layer by using the callback to get all transmit power levels mbm values.
--- drivers/net/ieee802154/at86rf230.c | 22 +++----------------- net/mac802154/mac_cmd.c | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 19 deletions(-)
drivers/net/ieee802154/at86rf230.c +3 -19
@@ -1225,17 +1225,7 @@ at86rf23x_set_txpower(struct at86rf230_local *lp, s32 mbm)static int at86rf212_set_txpower (struct at86rf230_local *lp,s32 mbm) { -s8 db = mbm /100 ; -/* 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 -* 0dB. -* thus, supported values for db range from -26 to 5, for 31dB of -* reduction to 0dB of reduction. -*/ -if (db >5 || db <-26 ) -return -EINVAL ; - -return at86rf230_write_subreg (lp,SR_TX_PWR_212 , -(db -5 )); +return at86rf230_write_subreg (lp,SR_TX_PWR_212 , -((mbm /100 ) -5 )); } static int
@@ -1321,15 +1311,9 @@ static int at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm) {struct at86rf230_local *lp = hw->priv; -s32 level = mbm /100 ; - -/* backwards compatible for old interface, should be removed */ -if (level < lp->data->rssi_base_val || - level > lp->data->rssi_base_val +2 *0xF ) -return -EINVAL ; +s32 val = ((mbm /100 ) - lp->data->rssi_base_val) /2 ; -return at86rf230_write_subreg (lp,SR_CCA_ED_THRES , - (level - lp->data->rssi_base_val) /2 ); +return at86rf230_write_subreg (lp,SR_CCA_ED_THRES , val); }#define AT86RF230_MAX_ED_LEVELS_IDX 0xF
net/mac802154/mac_cmd.c +41 -0
59 lines not on this page · raw message
Signature · 1 line
2.3.7
Alexander Aring
maintainerPATCH v2 16/16 nl802154: add support for dump phy capabilities
In reply to Alexander AringThis patch add support to nl802154 to dump all phy capabilities which is inside the wpan_phy_supported struct. Also we introduce a new method to dumping supported channels. The new method will offer a easier interface and has lesser netlink traffic.
--- include/net/nl802154.h | 57 +++++++++++++++++++++ net/ieee802154/nl802154.c | 127 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 183 insertions(+), 1 deletion(-)
include/net/nl802154.h +57 -0
@@ -100,6 +100,8 @@ enum nl802154_attrs {NL802154_ATTR_EXTENDED_ADDR , +NL802154_ATTR_WPAN_PHY_CAPS , +/* add attributes here, update the policy in nl802154.c */ __NL802154_ATTR_AFTER_LAST,
@@ -120,6 +122,61 @@ enum nl802154_iftype { };/** +* enum nl802154_wpan_phy_capability_attr - wpan phy capability attributes +* +* @__NL802154_CAP_ATTR_INVALID: attribute number 0 is reserved +* @NL802154_CAP_ATTR_CHANNELS: a nested attribute for nl802154_channel_attr +* @NL802154_CAP_ATTR_TX_POWERS: a nested attribute for +* nl802154_wpan_phy_tx_power +* @NL802154_CAP_ATTR_MIN_CCA_ED_LEVEL: minimum value for cca_ed_level +* @NL802154_CAP_ATTR_MAX_CCA_ED_LEVEL: maxmimum value for cca_ed_level +* @NL802154_CAP_ATTR_CCA_MODES: nl802154_cca_modes flags +* @NL802154_CAP_ATTR_CCA_OPTS: nl802154_cca_opts flags +* @NL802154_CAP_ATTR_MIN_MINBE: minimum of minbe value +* @NL802154_CAP_ATTR_MAX_MINBE: maximum of minbe value +* @NL802154_CAP_ATTR_MIN_MAXBE: minimum of maxbe value +* @NL802154_CAP_ATTR_MAX_MINBE: maximum of maxbe value +* @NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS: minimum of csma backoff value +* @NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS: maximum of csma backoffs value +* @NL802154_CAP_ATTR_MIN_FRAME_RETRIES: minimum of frame retries value +* @NL802154_CAP_ATTR_MAX_FRAME_RETRIES: maximum of frame retries value +* @NL802154_CAP_ATTR_IFTYPES: nl802154_iftype flags +* @NL802154_CAP_ATTR_LBT: nl802154_supported_bool_states flags +* @NL802154_CAP_ATTR_MAX: highest cap attribute currently defined +* @__NL802154_CAP_ATTR_AFTER_LAST: internal use +*/ +enum nl802154_wpan_phy_capability_attr { + __NL802154_CAP_ATTR_INVALID, + +NL802154_CAP_ATTR_IFTYPES , + +NL802154_CAP_ATTR_CHANNELS , +NL802154_CAP_ATTR_TX_POWERS , + +NL802154_CAP_ATTR_CCA_ED_LEVELS , +NL802154_CAP_ATTR_CCA_MODES , +NL802154_CAP_ATTR_CCA_OPTS , + +NL802154_CAP_ATTR_MIN_MINBE , +NL802154_CAP_ATTR_MAX_MINBE , + +NL802154_CAP_ATTR_MIN_MAXBE , +NL802154_CAP_ATTR_MAX_MAXBE , + +NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS , +NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS , + +NL802154_CAP_ATTR_MIN_FRAME_RETRIES , +NL802154_CAP_ATTR_MAX_FRAME_RETRIES , + +NL802154_CAP_ATTR_LBT , + +/* keep last */ + __NL802154_CAP_ATTR_AFTER_LAST, +NL802154_CAP_ATTR_MAX = __NL802154_CAP_ATTR_AFTER_LAST -1 +}; + +/** * enum nl802154_cca_modes - cca modes * * @__NL802154_CCA_INVALID: cca mode number 0 is reserved
net/ieee802154/nl802154.c +126 -1
157 lines not on this page · raw message
Signature · 1 line
2.3.7
Re: [PATCHv2 wpan-next 09/16] ieee802154: add support for get tx powers
In reply to Alexander AringQuoted 5 lines · On Wed, 6 May 2015 13:40:21 +0200 Alexander Aring <[email protected]> wrote:
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.
Now that every tx power value can be represented, why not just return a const s32* and a number of elements in that array?
Quoted 175 lines
Signed-off-by Alexander Aring <[email protected]>--- 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(-)include/net/cfg802154.h +0
-0@@ -44,6 +44,7 @@ struct cfg802154_ops { int (*set_channel)(struct wpan_phy *wpan_phy, u8page, u8 channel); int (*set_cca_mode)(struct
wpan_phy*wpan_phy, const structwpan_phy_cca*cca);include/net/cfg802154.h +1
-0+ int (*get_tx_powers)(struct wpan_phy *wpan_phy, s32*mbm, u32 idx); int (*set_pan_id)(struct
wpan_phy*wpan_phy,
structwpan_dev*wpan_dev,__le16pan_id); int (*set_short_addr)(structwpan_phy*wpan_phy,include/net/mac802154.h +0
-0@@ -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_lockheld.include/net/mac802154.h +3
-1@@ -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)(structieee802154_hw*hw,
const structwpan_phy_cca
*cca); diff --gita/net/ieee802154/rdev-ops.hb/net/ieee802154/rdev-ops.hindex 7b5a9dd..8fc1afe 100644net/ieee802154/rdev-ops.h +10
-0@@ -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) {net/ieee802154/trace.h +30
-0@@ -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,__le16le16arg),net/mac802154/cfg.c +10
-0@@ -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,net/mac802154/driver-ops.h +0
-0@@ -70,6 +70,18 @@ static inline int drv_set_tx_power(struct
ieee802154_local*local, s32 mbm) returnlocal->ops->set_txpower(&local->hw, mbm); }net/mac802154/driver-ops.h +12
-0+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) {
Alexander Aring
maintainerRe: [PATCHv2 wpan-next 09/16] ieee802154: add support for get tx powers
Quoted 11 lines · Phoebe Buckheister
Quoted 5 lines · On Wed, 6 May 2015 13:40:21 +0200 Alexander Aring <[email protected]> wrote:
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.
Now that every tx power value can be represented, why not just return a const s32* and a number of elements in that array?
ok, I will try to implement it, sounds better.
I followed the first implementation like the station dump in wireless [0]. (Some example to print a list over netlink) Now I detect that they use "-ENOENT" for the last entry which should be better than "1".
Nevertheless I think this is only good for dynamic changeable list like the use case for [0]. It's very unlikely that the capabilities changes while using of the stack.
- Alex
[0] http://lxr.free-electrons.com/source/net/wireless/nl80211.c#L3876