ieee802154: rework cca settings
Subsystems (3)
Alexander Aring
maintainercover ieee802154: rework cca settings
Hi,
this patch changes the CCA setting handling. I know this will completely broken the deprecated netlink call for cca setting. This call is driver specific and we need to change that. Since this interface is deprecated we don't care about this now. Also the official userspace tool software "lowpan-tools" doesn't support this netlink interface.
I will send later patches for wpan-tools to support the new cca setting.
- Alex
Alexander Aring (4):
nl802154: introduce cca mode enums
ieee802154: rework cca setting
nl802154: introduce support for cca settings
at86rf230: add reset state cca handling
drivers/net/ieee802154/at86rf230.c | 32 ++++++++++++++++++++++++-- include/net/cfg802154.h | 10 ++++++++- include/net/ieee802154_netdev.h | 4 +++- include/net/mac802154.h | 5 ++++- include/net/nl802154.h | 45 ++++++++++++++++++++++++++++++++++++- net/ieee802154/nl-mac.c | 4 ++-- net/ieee802154/nl802154.c | 46 +++++++++++++++++++++++++++++++++++--- net/ieee802154/rdev-ops.h | 7 ++++++ net/ieee802154/sysfs.c | 2 +- net/mac802154/cfg.c | 21 +++++++++++++++++ net/mac802154/driver-ops.h | 5 +++-- net/mac802154/mac_cmd.c | 6 ++--- 12 files changed, 170 insertions(+), 17 deletions(-)
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 1/4 nl802154: introduce cca mode enums
This patch adds enums for 802.15.4 specific CCA settings.
--- include/net/nl802154.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
include/net/nl802154.h +43 -0
@@ -119,4 +119,47 @@ enum nl802154_iftype {NL802154_IFTYPE_MAX =NUM_NL802154_IFTYPES -1 }; +/** +* enum nl802154_cca_modes - cca modes +* +* @__NL802154_CCA_INVALID: cca mode number 0 is reserved +* @NL802154_CCA_ENERGY: Energy above threshold +* @NL802154_CCA_CARRIER: Carrier sense only +* @NL802154_CCA_ENERGY_CARRIER: Carrier sense with energy above threshold +* @NL802154_CCA_ALOHA: CCA shall always report an idle medium +* @NL802154_CCA_UWB_SHR: UWB preamble sense based on the SHR of a frame +* @NL802154_CCA_UWB_MULTIPEXED: UWB preamble sense based on the packet with +* the multiplexed preamble +* @__NL802154_CCA_ATTR_AFTER_LAST: Internal +* @NL802154_CCA_ATTR_MAX: Maximum CCA attribute number +*/ +enum nl802154_cca_modes { + __NL802154_CCA_INVALID, +NL802154_CCA_ENERGY , +NL802154_CCA_CARRIER , +NL802154_CCA_ENERGY_CARRIER , +NL802154_CCA_ALOHA , +NL802154_CCA_UWB_SHR , +NL802154_CCA_UWB_MULTIPEXED , + +/* keep last */ + __NL802154_CCA_ATTR_AFTER_LAST, +NL802154_CCA_ATTR_MAX = __NL802154_CCA_ATTR_AFTER_LAST -1 +}; + +/** +* enum nl802154_cca_opts - additional options for cca modes +* +* @NL802154_CCA_OPT_ENERGY_CARRIER_OR: NL802154_CCA_ENERGY_CARRIER with OR +* @NL802154_CCA_OPT_ENERGY_CARRIER_AND: NL802154_CCA_ENERGY_CARRIER with AND +*/ +enum nl802154_cca_opts { +NL802154_CCA_OPT_ENERGY_CARRIER_AND , +NL802154_CCA_OPT_ENERGY_CARRIER_OR , + +/* keep last */ + __NL802154_CCA_OPT_ATTR_AFTER_LAST, +NL802154_CCA_OPT_ATTR_MAX = __NL802154_CCA_OPT_ATTR_AFTER_LAST -1 +}; +#endif /* __NL802154_H */
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 2/4 ieee802154: rework cca setting
In reply to Alexander AringThe current cca setting handle is a driver specific call. We need to introduce some 802.15.4 specific layer and mapping 802.15.4 cca modes to driver specific ones inside the 802.15.4 driver. This patch will add such 802.15.4 layer and mapping the cca settings to driver specific ones.
--- drivers/net/ieee802154/at86rf230.c | 30 ++++++++++++++++++++++++++++-- include/net/cfg802154.h | 7 ++++++- include/net/ieee802154_netdev.h | 4 +++- include/net/mac802154.h | 5 ++++- net/ieee802154/nl-mac.c | 4 ++-- net/ieee802154/nl802154.c | 2 +- net/ieee802154/sysfs.c | 2 +- net/mac802154/driver-ops.h | 5 +++-- net/mac802154/mac_cmd.c | 6 +++--- 9 files changed, 51 insertions(+), 14 deletions(-)
drivers/net/ieee802154/at86rf230.c +28 -2
@@ -1146,11 +1146,37 @@ at86rf230_set_lbt(struct ieee802154_hw *hw, bool on) }static int -at86rf230_set_cca_mode (struct ieee802154_hw *hw,u8 mode) +at86rf230_set_cca_mode (struct ieee802154_hw *hw, +const struct wpan_phy_cca *cca) {struct at86rf230_local *lp = hw->priv; +u8 val; -return at86rf230_write_subreg (lp,SR_CCA_MODE , mode); +/* mapping 802.15.4 to driver spec */ +switch (cca->mode) { +case NL802154_CCA_ENERGY : + val =1 ; +break ; +case NL802154_CCA_CARRIER : + val =2 ; +break ; +case NL802154_CCA_ENERGY_CARRIER : +switch (cca->opt) { +case NL802154_CCA_OPT_ENERGY_CARRIER_AND : + val =3 ; +break ; +case NL802154_CCA_OPT_ENERGY_CARRIER_OR : + val =0 ; +break ; +default : +return -EINVAL ; + } +break ; +default : +return -EINVAL ; + } + +return at86rf230_write_subreg (lp,SR_CCA_MODE , val); } static int
include/net/cfg802154.h +6 -1
@@ -56,6 +56,11 @@ struct cfg802154_ops { struct wpan_dev *wpan_dev, bool mode); }; +struct wpan_phy_cca { +enum nl802154_cca_modes mode; +enum nl802154_cca_opts opt; +}; +struct wpan_phy {struct mutex pib_lock;
@@ -76,7 +81,7 @@ struct wpan_phy {u8 current_page;u32 channels_supported[IEEE802154_MAX_PAGE +1 ];s8 transmit_power; -u8 cca_mode; +struct wpan_phy_cca cca;__le64 perm_extended_addr;
include/net/ieee802154_netdev.h +3 -1
@@ -28,6 +28,8 @@#include <linux/skbuff.h> #include <linux/ieee802154.h> +#include <net/cfg802154.h> +struct ieee802154_sechdr {#if defined(__LITTLE_ENDIAN_BITFIELD) u8 level:3,
@@ -337,7 +339,7 @@ struct ieee802154_mac_params {s8 frame_retries;bool lbt; -u8 cca_mode; +struct wpan_phy_cca cca;s32 cca_ed_level; };
include/net/mac802154.h +4 -1
@@ -20,6 +20,8 @@#include <linux/ieee802154.h> #include <linux/skbuff.h> +#include <net/cfg802154.h> +/* General MAC frame format: * 2 bytes: Frame Control * 1 byte: Sequence Number
@@ -212,7 +214,8 @@ struct ieee802154_ops { unsigned long changed);int (*set_txpower)(struct ieee802154_hw *hw,int db);int (*set_lbt)(struct ieee802154_hw *hw,bool on); -int (*set_cca_mode)(struct ieee802154_hw *hw,u8 mode); +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_csma_params)(struct ieee802154_hw *hw,
net/ieee802154/nl-mac.c +2 -2
@@ -121,7 +121,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid, params.transmit_power) ||nla_put_u8 (msg,IEEE802154_ATTR_LBT_ENABLED , params.lbt) ||nla_put_u8 (msg,IEEE802154_ATTR_CCA_MODE , - params.cca_mode) || + params.cca.mode) ||nla_put_s32 (msg,IEEE802154_ATTR_CCA_ED_LEVEL , params.cca_ed_level) || nla_put_u8(msg, IEEE802154_ATTR_CSMA_RETRIES,
@@ -516,7 +516,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info) params.lbt =nla_get_u8 (info->attrs[IEEE802154_ATTR_LBT_ENABLED ]);if (info->attrs[IEEE802154_ATTR_CCA_MODE ]) - params.cca_mode =nla_get_u8 (info->attrs[IEEE802154_ATTR_CCA_MODE ]); + 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 ]);
net/ieee802154/nl802154.c +1 -1
@@ -291,7 +291,7 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,/* cca mode */ if (nla_put_u8 (msg,NL802154_ATTR_CCA_MODE , - rdev->wpan_phy.cca_mode)) + rdev->wpan_phy.cca.mode)) goto nla_put_failure; if (nla_put_s8(msg, NL802154_ATTR_TX_POWER,
net/ieee802154/sysfs.c +1 -1
@@ -68,7 +68,7 @@ static DEVICE_ATTR_RO(name)MASTER_SHOW (current_channel,"%d" );MASTER_SHOW (current_page,"%d" );MASTER_SHOW (transmit_power,"%d +- 1 dB" ); -MASTER_SHOW (cca_mode,"%d" ); +MASTER_SHOW_COMPLEX (cca_mode,"%d" , phy->cca.mode); static ssize_t channels_supported_show(struct device *dev, struct device_attribute *attr,
net/mac802154/driver-ops.h +3 -2
@@ -70,7 +70,8 @@ static inline int drv_set_tx_power(struct ieee802154_local *local, s8 dbm)return local->ops->set_txpower (&local->hw, dbm); } -static inline int drv_set_cca_mode (struct ieee802154_local *local,u8 cca_mode) +static inline int drv_set_cca_mode (struct ieee802154_local *local, +const struct wpan_phy_cca *cca) {might_sleep ();
@@ -79,7 +80,7 @@ static inline int drv_set_cca_mode(struct ieee802154_local *local, u8 cca_mode)return -EOPNOTSUPP ; } -return local->ops->set_cca_mode (&local->hw, cca_mode); +return local->ops->set_cca_mode (&local->hw, cca); }static inline int drv_set_lbt_mode (struct ieee802154_local *local,bool mode)
net/mac802154/mac_cmd.c +3 -3
@@ -81,7 +81,7 @@ static int mac802154_set_mac_params(struct net_device *dev,/* PHY */ wpan_dev->wpan_phy->transmit_power = params->transmit_power; - wpan_dev->wpan_phy->cca_mode = params->cca_mode; + wpan_dev->wpan_phy->cca = params->cca; wpan_dev->wpan_phy->cca_ed_level = params->cca_ed_level;/* MAC */
@@ -98,7 +98,7 @@ static int mac802154_set_mac_params(struct net_device *dev, }if (local->hw.flags &IEEE802154_HW_CCA_MODE ) { - ret =drv_set_cca_mode (local, params->cca_mode); + ret =drv_set_cca_mode (local, ¶ms->cca);if (ret <0 )return ret; }
@@ -122,7 +122,7 @@ static void mac802154_get_mac_params(struct net_device *dev,/* PHY */ params->transmit_power = wpan_dev->wpan_phy->transmit_power; - params->cca_mode = wpan_dev->wpan_phy->cca_mode; + params->cca = wpan_dev->wpan_phy->cca; params->cca_ed_level = wpan_dev->wpan_phy->cca_ed_level;/* MAC */
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 3/4 nl802154: introduce support for cca settings
In reply to Alexander AringThis patch adds support for setting cca parameters via nl802154.
--- include/net/cfg802154.h | 3 +++ include/net/nl802154.h | 2 +- net/ieee802154/nl802154.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- net/ieee802154/rdev-ops.h | 7 +++++++ net/mac802154/cfg.c | 21 +++++++++++++++++++++ 5 files changed, 75 insertions(+), 4 deletions(-)
include/net/cfg802154.h +3 -0
@@ -25,6 +25,7 @@#include <net/nl802154.h> struct wpan_phy ; +struct wpan_phy_cca ;struct cfg802154_ops { struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
@@ -39,6 +40,8 @@ struct cfg802154_ops {int (*del_virtual_intf)(struct wpan_phy *wpan_phy,struct wpan_dev *wpan_dev);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 (*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/nl802154.h +1 -1
@@ -82,7 +82,7 @@ enum nl802154_attrs {NL802154_ATTR_TX_POWER ,NL802154_ATTR_CCA_MODE , -NL802154_ATTR_CCA_MODE3_AND , +NL802154_ATTR_CCA_OPT ,NL802154_ATTR_CCA_ED_LEVEL , NL802154_ATTR_MAX_FRAME_RETRIES,
net/ieee802154/nl802154.c +43 -3
72 lines not on this page · raw message
net/ieee802154/rdev-ops.h +7 -0
@@ -42,6 +42,13 @@ rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) }static inline int +rdev_set_cca_mode (struct cfg802154_registered_device *rdev, +const struct wpan_phy_cca *cca) +{ +return rdev->ops->set_cca_mode (&rdev->wpan_phy, cca); +} + +static inline int rdev_set_pan_id (struct cfg802154_registered_device *rdev,struct wpan_dev *wpan_dev,__le16 pan_id) {
net/mac802154/cfg.c +21 -0
@@ -87,6 +87,26 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) }static int +ieee802154_set_cca_mode (struct wpan_phy *wpan_phy, +const struct wpan_phy_cca *cca) +{ +struct ieee802154_local *local =wpan_phy_priv (wpan_phy); +int ret; + +ASSERT_RTNL (); + +/* 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; + +return ret; +} + +static int ieee802154_set_pan_id (struct wpan_phy *wpan_phy,struct wpan_dev *wpan_dev,__le16 pan_id) {
@@ -201,6 +221,7 @@ const struct cfg802154_ops mac802154_config_ops = { .add_virtual_intf = ieee802154_add_iface, .del_virtual_intf = ieee802154_del_iface, .set_channel = ieee802154_set_channel, + .set_cca_mode = ieee802154_set_cca_mode, .set_pan_id = ieee802154_set_pan_id, .set_short_addr = ieee802154_set_short_addr, .set_backoff_exponent = ieee802154_set_backoff_exponent,
Signature · 1 line
2.1.3
Alexander Aring
maintainerPATCH 4/4 at86rf230: add reset state cca handling
In reply to Alexander AringThis patch adds the default cca setting after device reset for at86rf230 driver.
--- drivers/net/ieee802154/at86rf230.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ieee802154/at86rf230.c +2 -0
@@ -1441,6 +1441,8 @@ at86rf230_detect_device(struct at86rf230_local *lp)IEEE802154_HW_TXPOWER |IEEE802154_HW_ARET |IEEE802154_HW_AFILT |IEEE802154_HW_PROMISCUOUS ; + lp->hw->phy->cca.mode =NL802154_CCA_ENERGY ; +switch (part) {case 2 : chip ="at86rf230" ;
Signature · 1 line
2.1.3
Hi Alex,
Quoted 16 lines
this patch changes the CCA setting handling. I know this will completely broken the deprecated netlink call for cca setting. This call is driver specific and we need to change that. Since this interface is deprecated we don't care about this now. Also the official userspace tool software "lowpan-tools" doesn't support this netlink interface.
I will send later patches for wpan-tools to support the new cca setting.
- Alex
Alexander Aring (4):
nl802154: introduce cca mode enums
ieee802154: rework cca setting
nl802154: introduce support for cca settings
at86rf230: add reset state cca handling
Quoted 13 lines
drivers/net/ieee802154/at86rf230.c | 32 ++++++++++++++++++++++++-- include/net/cfg802154.h | 10 ++++++++- include/net/ieee802154_netdev.h | 4 +++- include/net/mac802154.h | 5 ++++- include/net/nl802154.h | 45 ++++++++++++++++++++++++++++++++++++- net/ieee802154/nl-mac.c | 4 ++-- net/ieee802154/nl802154.c | 46 +++++++++++++++++++++++++++++++++++--- net/ieee802154/rdev-ops.h | 7 ++++++ net/ieee802154/sysfs.c | 2 +- net/mac802154/cfg.c | 21 +++++++++++++++++ net/mac802154/driver-ops.h | 5 +++-- net/mac802154/mac_cmd.c | 6 ++--- 12 files changed, 170 insertions(+), 17 deletions(-)
all 4 patches have been applied to bluetooth-next tree.
Regards
Marcel