ieee802154: change cca ed level to mbm
authorAlexander Aring <alex.aring@gmail.com>
Sun, 17 May 2015 19:44:41 +0000 (21:44 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 19 May 2015 09:44:42 +0000 (11:44 +0200)
This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/net/ieee802154/at86rf230.c
include/net/cfg802154.h
include/net/mac802154.h
net/ieee802154/nl-mac.c
net/mac802154/driver-ops.h

index 3a303e4a3c0787c7cbfd2717f9984eba6024b544..e68d45ed622e952a3bae9937c57fa33de774ff72 100644 (file)
@@ -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;
index b5b3f9f43084e9e6ba274b9b5139197c0b8c34ed..9ced2c9fdbfc8fed7bd95ee619b54af4ce45cdc0 100644 (file)
@@ -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 */
index e863a8557c0ad884e2882d5020fe087eed99b286..71e245605ef8e43a8d625f5ec22c23653587206a 100644 (file)
@@ -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,
index 4ba2e13f7a0789ade79328a4206e6168ba2c7b15..cdc1cc3543f6a2892c54e651f0692b37a779885c 100644 (file)
@@ -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]);
index d289ae3f1e93c49ed456b35e2fa4ca0aeb923a53..caecd5f43aa730341c4e3e6556636ab5f13a285f 100644 (file)
@@ -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)