All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities
@ 2015-04-23 16:47 Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 01/15] nl802154: cleanup invalid argument handling Alexander Aring
                   ` (15 more replies)
  0 siblings, 16 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

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.


Note: this patch series based on the ("ieee802154: Add trace events for rdev->ops") by
Guido Günther <agx@sigxcpu.org>.

- Alex

[0] http://www.spinics.net/lists/linux-wpan/msg01603.html

Alexander Aring (15):
  nl802154: cleanup invalid argument handling
  at86rf230: remove tabs after define
  ieee802154: move validation check out of softmac
  mac802154: check for really changes
  mac802154: remove check if operation is supported
  ieee802154: introduce wpan_phy_supported
  ieee802154: add several phy supported handling
  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
  nl802154: add support for dump phy capabilities

 drivers/net/ieee802154/at86rf230.c | 442 ++++++++++++++++++++++---------------
 drivers/net/ieee802154/cc2520.c    |   2 +-
 drivers/net/ieee802154/fakelb.c    |  30 +--
 drivers/net/ieee802154/mrf24j40.c  |   2 +-
 include/net/cfg802154.h            |  43 +++-
 include/net/mac802154.h            |  19 ++
 include/net/nl802154.h             |  79 +++++++
 net/ieee802154/nl-phy.c            |   4 +-
 net/ieee802154/nl802154.c          | 198 +++++++++++++++--
 net/ieee802154/rdev-ops.h          |  23 ++
 net/ieee802154/trace.h             |  62 ++++++
 net/mac802154/cfg.c                |  85 ++++---
 net/mac802154/driver-ops.h         |  24 ++
 net/mac802154/main.c               |  32 +++
 14 files changed, 787 insertions(+), 258 deletions(-)

-- 
2.3.6


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 01/15] nl802154: cleanup invalid argument handling
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 02/15] at86rf230: remove tabs after define Alexander Aring
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch cleanups the -EINVAL cases by combining them in one
condition.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/ieee802154/nl802154.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index a4daf91..9de427d 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -668,10 +668,8 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
 		return -EBUSY;
 
 	/* don't change address fields on monitor */
-	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
-		return -EINVAL;
-
-	if (!info->attrs[NL802154_ATTR_PAN_ID])
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||
+	    !info->attrs[NL802154_ATTR_PAN_ID])
 		return -EINVAL;
 
 	pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);
@@ -691,10 +689,8 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
 		return -EBUSY;
 
 	/* don't change address fields on monitor */
-	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
-		return -EINVAL;
-
-	if (!info->attrs[NL802154_ATTR_SHORT_ADDR])
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR ||
+	    !info->attrs[NL802154_ATTR_SHORT_ADDR])
 		return -EINVAL;
 
 	short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 02/15] at86rf230: remove tabs after define
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 01/15] nl802154: cleanup invalid argument handling Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 03/15] ieee802154: move validation check out of softmac Alexander Aring
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch cleanups the at86rf230 driver to use a space instead a tab
after define.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 304 ++++++++++++++++++-------------------
 1 file changed, 152 insertions(+), 152 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 3802665..22a0789 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -100,158 +100,158 @@ struct at86rf230_local {
 	struct at86rf230_state_change tx;
 };
 
-#define	RG_TRX_STATUS	(0x01)
-#define	SR_TRX_STATUS		0x01, 0x1f, 0
-#define	SR_RESERVED_01_3	0x01, 0x20, 5
-#define	SR_CCA_STATUS		0x01, 0x40, 6
-#define	SR_CCA_DONE		0x01, 0x80, 7
-#define	RG_TRX_STATE	(0x02)
-#define	SR_TRX_CMD		0x02, 0x1f, 0
-#define	SR_TRAC_STATUS		0x02, 0xe0, 5
-#define	RG_TRX_CTRL_0	(0x03)
-#define	SR_CLKM_CTRL		0x03, 0x07, 0
-#define	SR_CLKM_SHA_SEL		0x03, 0x08, 3
-#define	SR_PAD_IO_CLKM		0x03, 0x30, 4
-#define	SR_PAD_IO		0x03, 0xc0, 6
-#define	RG_TRX_CTRL_1	(0x04)
-#define	SR_IRQ_POLARITY		0x04, 0x01, 0
-#define	SR_IRQ_MASK_MODE	0x04, 0x02, 1
-#define	SR_SPI_CMD_MODE		0x04, 0x0c, 2
-#define	SR_RX_BL_CTRL		0x04, 0x10, 4
-#define	SR_TX_AUTO_CRC_ON	0x04, 0x20, 5
-#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	RG_PHY_RSSI	(0x06)
-#define	SR_RSSI			0x06, 0x1f, 0
-#define	SR_RND_VALUE		0x06, 0x60, 5
-#define	SR_RX_CRC_VALID		0x06, 0x80, 7
-#define	RG_PHY_ED_LEVEL	(0x07)
-#define	SR_ED_LEVEL		0x07, 0xff, 0
-#define	RG_PHY_CC_CCA	(0x08)
-#define	SR_CHANNEL		0x08, 0x1f, 0
-#define	SR_CCA_MODE		0x08, 0x60, 5
-#define	SR_CCA_REQUEST		0x08, 0x80, 7
-#define	RG_CCA_THRES	(0x09)
-#define	SR_CCA_ED_THRES		0x09, 0x0f, 0
-#define	SR_RESERVED_09_1	0x09, 0xf0, 4
-#define	RG_RX_CTRL	(0x0a)
-#define	SR_PDT_THRES		0x0a, 0x0f, 0
-#define	SR_RESERVED_0a_1	0x0a, 0xf0, 4
-#define	RG_SFD_VALUE	(0x0b)
-#define	SR_SFD_VALUE		0x0b, 0xff, 0
-#define	RG_TRX_CTRL_2	(0x0c)
-#define	SR_OQPSK_DATA_RATE	0x0c, 0x03, 0
-#define	SR_SUB_MODE		0x0c, 0x04, 2
-#define	SR_BPSK_QPSK		0x0c, 0x08, 3
-#define	SR_OQPSK_SUB1_RC_EN	0x0c, 0x10, 4
-#define	SR_RESERVED_0c_5	0x0c, 0x60, 5
-#define	SR_RX_SAFE_MODE		0x0c, 0x80, 7
-#define	RG_ANT_DIV	(0x0d)
-#define	SR_ANT_CTRL		0x0d, 0x03, 0
-#define	SR_ANT_EXT_SW_EN	0x0d, 0x04, 2
-#define	SR_ANT_DIV_EN		0x0d, 0x08, 3
-#define	SR_RESERVED_0d_2	0x0d, 0x70, 4
-#define	SR_ANT_SEL		0x0d, 0x80, 7
-#define	RG_IRQ_MASK	(0x0e)
-#define	SR_IRQ_MASK		0x0e, 0xff, 0
-#define	RG_IRQ_STATUS	(0x0f)
-#define	SR_IRQ_0_PLL_LOCK	0x0f, 0x01, 0
-#define	SR_IRQ_1_PLL_UNLOCK	0x0f, 0x02, 1
-#define	SR_IRQ_2_RX_START	0x0f, 0x04, 2
-#define	SR_IRQ_3_TRX_END	0x0f, 0x08, 3
-#define	SR_IRQ_4_CCA_ED_DONE	0x0f, 0x10, 4
-#define	SR_IRQ_5_AMI		0x0f, 0x20, 5
-#define	SR_IRQ_6_TRX_UR		0x0f, 0x40, 6
-#define	SR_IRQ_7_BAT_LOW	0x0f, 0x80, 7
-#define	RG_VREG_CTRL	(0x10)
-#define	SR_RESERVED_10_6	0x10, 0x03, 0
-#define	SR_DVDD_OK		0x10, 0x04, 2
-#define	SR_DVREG_EXT		0x10, 0x08, 3
-#define	SR_RESERVED_10_3	0x10, 0x30, 4
-#define	SR_AVDD_OK		0x10, 0x40, 6
-#define	SR_AVREG_EXT		0x10, 0x80, 7
-#define	RG_BATMON	(0x11)
-#define	SR_BATMON_VTH		0x11, 0x0f, 0
-#define	SR_BATMON_HR		0x11, 0x10, 4
-#define	SR_BATMON_OK		0x11, 0x20, 5
-#define	SR_RESERVED_11_1	0x11, 0xc0, 6
-#define	RG_XOSC_CTRL	(0x12)
-#define	SR_XTAL_TRIM		0x12, 0x0f, 0
-#define	SR_XTAL_MODE		0x12, 0xf0, 4
-#define	RG_RX_SYN	(0x15)
-#define	SR_RX_PDT_LEVEL		0x15, 0x0f, 0
-#define	SR_RESERVED_15_2	0x15, 0x70, 4
-#define	SR_RX_PDT_DIS		0x15, 0x80, 7
-#define	RG_XAH_CTRL_1	(0x17)
-#define	SR_RESERVED_17_8	0x17, 0x01, 0
-#define	SR_AACK_PROM_MODE	0x17, 0x02, 1
-#define	SR_AACK_ACK_TIME	0x17, 0x04, 2
-#define	SR_RESERVED_17_5	0x17, 0x08, 3
-#define	SR_AACK_UPLD_RES_FT	0x17, 0x10, 4
-#define	SR_AACK_FLTR_RES_FT	0x17, 0x20, 5
-#define	SR_CSMA_LBT_MODE	0x17, 0x40, 6
-#define	SR_RESERVED_17_1	0x17, 0x80, 7
-#define	RG_FTN_CTRL	(0x18)
-#define	SR_RESERVED_18_2	0x18, 0x7f, 0
-#define	SR_FTN_START		0x18, 0x80, 7
-#define	RG_PLL_CF	(0x1a)
-#define	SR_RESERVED_1a_2	0x1a, 0x7f, 0
-#define	SR_PLL_CF_START		0x1a, 0x80, 7
-#define	RG_PLL_DCU	(0x1b)
-#define	SR_RESERVED_1b_3	0x1b, 0x3f, 0
-#define	SR_RESERVED_1b_2	0x1b, 0x40, 6
-#define	SR_PLL_DCU_START	0x1b, 0x80, 7
-#define	RG_PART_NUM	(0x1c)
-#define	SR_PART_NUM		0x1c, 0xff, 0
-#define	RG_VERSION_NUM	(0x1d)
-#define	SR_VERSION_NUM		0x1d, 0xff, 0
-#define	RG_MAN_ID_0	(0x1e)
-#define	SR_MAN_ID_0		0x1e, 0xff, 0
-#define	RG_MAN_ID_1	(0x1f)
-#define	SR_MAN_ID_1		0x1f, 0xff, 0
-#define	RG_SHORT_ADDR_0	(0x20)
-#define	SR_SHORT_ADDR_0		0x20, 0xff, 0
-#define	RG_SHORT_ADDR_1	(0x21)
-#define	SR_SHORT_ADDR_1		0x21, 0xff, 0
-#define	RG_PAN_ID_0	(0x22)
-#define	SR_PAN_ID_0		0x22, 0xff, 0
-#define	RG_PAN_ID_1	(0x23)
-#define	SR_PAN_ID_1		0x23, 0xff, 0
-#define	RG_IEEE_ADDR_0	(0x24)
-#define	SR_IEEE_ADDR_0		0x24, 0xff, 0
-#define	RG_IEEE_ADDR_1	(0x25)
-#define	SR_IEEE_ADDR_1		0x25, 0xff, 0
-#define	RG_IEEE_ADDR_2	(0x26)
-#define	SR_IEEE_ADDR_2		0x26, 0xff, 0
-#define	RG_IEEE_ADDR_3	(0x27)
-#define	SR_IEEE_ADDR_3		0x27, 0xff, 0
-#define	RG_IEEE_ADDR_4	(0x28)
-#define	SR_IEEE_ADDR_4		0x28, 0xff, 0
-#define	RG_IEEE_ADDR_5	(0x29)
-#define	SR_IEEE_ADDR_5		0x29, 0xff, 0
-#define	RG_IEEE_ADDR_6	(0x2a)
-#define	SR_IEEE_ADDR_6		0x2a, 0xff, 0
-#define	RG_IEEE_ADDR_7	(0x2b)
-#define	SR_IEEE_ADDR_7		0x2b, 0xff, 0
-#define	RG_XAH_CTRL_0	(0x2c)
-#define	SR_SLOTTED_OPERATION	0x2c, 0x01, 0
-#define	SR_MAX_CSMA_RETRIES	0x2c, 0x0e, 1
-#define	SR_MAX_FRAME_RETRIES	0x2c, 0xf0, 4
-#define	RG_CSMA_SEED_0	(0x2d)
-#define	SR_CSMA_SEED_0		0x2d, 0xff, 0
-#define	RG_CSMA_SEED_1	(0x2e)
-#define	SR_CSMA_SEED_1		0x2e, 0x07, 0
-#define	SR_AACK_I_AM_COORD	0x2e, 0x08, 3
-#define	SR_AACK_DIS_ACK		0x2e, 0x10, 4
-#define	SR_AACK_SET_PD		0x2e, 0x20, 5
-#define	SR_AACK_FVN_MODE	0x2e, 0xc0, 6
-#define	RG_CSMA_BE	(0x2f)
-#define	SR_MIN_BE		0x2f, 0x0f, 0
-#define	SR_MAX_BE		0x2f, 0xf0, 4
+#define RG_TRX_STATUS	(0x01)
+#define SR_TRX_STATUS		0x01, 0x1f, 0
+#define SR_RESERVED_01_3	0x01, 0x20, 5
+#define SR_CCA_STATUS		0x01, 0x40, 6
+#define SR_CCA_DONE		0x01, 0x80, 7
+#define RG_TRX_STATE	(0x02)
+#define SR_TRX_CMD		0x02, 0x1f, 0
+#define SR_TRAC_STATUS		0x02, 0xe0, 5
+#define RG_TRX_CTRL_0	(0x03)
+#define SR_CLKM_CTRL		0x03, 0x07, 0
+#define SR_CLKM_SHA_SEL		0x03, 0x08, 3
+#define SR_PAD_IO_CLKM		0x03, 0x30, 4
+#define SR_PAD_IO		0x03, 0xc0, 6
+#define RG_TRX_CTRL_1	(0x04)
+#define SR_IRQ_POLARITY		0x04, 0x01, 0
+#define SR_IRQ_MASK_MODE	0x04, 0x02, 1
+#define SR_SPI_CMD_MODE		0x04, 0x0c, 2
+#define SR_RX_BL_CTRL		0x04, 0x10, 4
+#define SR_TX_AUTO_CRC_ON	0x04, 0x20, 5
+#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 RG_PHY_RSSI	(0x06)
+#define SR_RSSI			0x06, 0x1f, 0
+#define SR_RND_VALUE		0x06, 0x60, 5
+#define SR_RX_CRC_VALID		0x06, 0x80, 7
+#define RG_PHY_ED_LEVEL	(0x07)
+#define SR_ED_LEVEL		0x07, 0xff, 0
+#define RG_PHY_CC_CCA	(0x08)
+#define SR_CHANNEL		0x08, 0x1f, 0
+#define SR_CCA_MODE		0x08, 0x60, 5
+#define SR_CCA_REQUEST		0x08, 0x80, 7
+#define RG_CCA_THRES	(0x09)
+#define SR_CCA_ED_THRES		0x09, 0x0f, 0
+#define SR_RESERVED_09_1	0x09, 0xf0, 4
+#define RG_RX_CTRL	(0x0a)
+#define SR_PDT_THRES		0x0a, 0x0f, 0
+#define SR_RESERVED_0a_1	0x0a, 0xf0, 4
+#define RG_SFD_VALUE	(0x0b)
+#define SR_SFD_VALUE		0x0b, 0xff, 0
+#define RG_TRX_CTRL_2	(0x0c)
+#define SR_OQPSK_DATA_RATE	0x0c, 0x03, 0
+#define SR_SUB_MODE		0x0c, 0x04, 2
+#define SR_BPSK_QPSK		0x0c, 0x08, 3
+#define SR_OQPSK_SUB1_RC_EN	0x0c, 0x10, 4
+#define SR_RESERVED_0c_5	0x0c, 0x60, 5
+#define SR_RX_SAFE_MODE		0x0c, 0x80, 7
+#define RG_ANT_DIV	(0x0d)
+#define SR_ANT_CTRL		0x0d, 0x03, 0
+#define SR_ANT_EXT_SW_EN	0x0d, 0x04, 2
+#define SR_ANT_DIV_EN		0x0d, 0x08, 3
+#define SR_RESERVED_0d_2	0x0d, 0x70, 4
+#define SR_ANT_SEL		0x0d, 0x80, 7
+#define RG_IRQ_MASK	(0x0e)
+#define SR_IRQ_MASK		0x0e, 0xff, 0
+#define RG_IRQ_STATUS	(0x0f)
+#define SR_IRQ_0_PLL_LOCK	0x0f, 0x01, 0
+#define SR_IRQ_1_PLL_UNLOCK	0x0f, 0x02, 1
+#define SR_IRQ_2_RX_START	0x0f, 0x04, 2
+#define SR_IRQ_3_TRX_END	0x0f, 0x08, 3
+#define SR_IRQ_4_CCA_ED_DONE	0x0f, 0x10, 4
+#define SR_IRQ_5_AMI		0x0f, 0x20, 5
+#define SR_IRQ_6_TRX_UR		0x0f, 0x40, 6
+#define SR_IRQ_7_BAT_LOW	0x0f, 0x80, 7
+#define RG_VREG_CTRL	(0x10)
+#define SR_RESERVED_10_6	0x10, 0x03, 0
+#define SR_DVDD_OK		0x10, 0x04, 2
+#define SR_DVREG_EXT		0x10, 0x08, 3
+#define SR_RESERVED_10_3	0x10, 0x30, 4
+#define SR_AVDD_OK		0x10, 0x40, 6
+#define SR_AVREG_EXT		0x10, 0x80, 7
+#define RG_BATMON	(0x11)
+#define SR_BATMON_VTH		0x11, 0x0f, 0
+#define SR_BATMON_HR		0x11, 0x10, 4
+#define SR_BATMON_OK		0x11, 0x20, 5
+#define SR_RESERVED_11_1	0x11, 0xc0, 6
+#define RG_XOSC_CTRL	(0x12)
+#define SR_XTAL_TRIM		0x12, 0x0f, 0
+#define SR_XTAL_MODE		0x12, 0xf0, 4
+#define RG_RX_SYN	(0x15)
+#define SR_RX_PDT_LEVEL		0x15, 0x0f, 0
+#define SR_RESERVED_15_2	0x15, 0x70, 4
+#define SR_RX_PDT_DIS		0x15, 0x80, 7
+#define RG_XAH_CTRL_1	(0x17)
+#define SR_RESERVED_17_8	0x17, 0x01, 0
+#define SR_AACK_PROM_MODE	0x17, 0x02, 1
+#define SR_AACK_ACK_TIME	0x17, 0x04, 2
+#define SR_RESERVED_17_5	0x17, 0x08, 3
+#define SR_AACK_UPLD_RES_FT	0x17, 0x10, 4
+#define SR_AACK_FLTR_RES_FT	0x17, 0x20, 5
+#define SR_CSMA_LBT_MODE	0x17, 0x40, 6
+#define SR_RESERVED_17_1	0x17, 0x80, 7
+#define RG_FTN_CTRL	(0x18)
+#define SR_RESERVED_18_2	0x18, 0x7f, 0
+#define SR_FTN_START		0x18, 0x80, 7
+#define RG_PLL_CF	(0x1a)
+#define SR_RESERVED_1a_2	0x1a, 0x7f, 0
+#define SR_PLL_CF_START		0x1a, 0x80, 7
+#define RG_PLL_DCU	(0x1b)
+#define SR_RESERVED_1b_3	0x1b, 0x3f, 0
+#define SR_RESERVED_1b_2	0x1b, 0x40, 6
+#define SR_PLL_DCU_START	0x1b, 0x80, 7
+#define RG_PART_NUM	(0x1c)
+#define SR_PART_NUM		0x1c, 0xff, 0
+#define RG_VERSION_NUM	(0x1d)
+#define SR_VERSION_NUM		0x1d, 0xff, 0
+#define RG_MAN_ID_0	(0x1e)
+#define SR_MAN_ID_0		0x1e, 0xff, 0
+#define RG_MAN_ID_1	(0x1f)
+#define SR_MAN_ID_1		0x1f, 0xff, 0
+#define RG_SHORT_ADDR_0	(0x20)
+#define SR_SHORT_ADDR_0		0x20, 0xff, 0
+#define RG_SHORT_ADDR_1	(0x21)
+#define SR_SHORT_ADDR_1		0x21, 0xff, 0
+#define RG_PAN_ID_0	(0x22)
+#define SR_PAN_ID_0		0x22, 0xff, 0
+#define RG_PAN_ID_1	(0x23)
+#define SR_PAN_ID_1		0x23, 0xff, 0
+#define RG_IEEE_ADDR_0	(0x24)
+#define SR_IEEE_ADDR_0		0x24, 0xff, 0
+#define RG_IEEE_ADDR_1	(0x25)
+#define SR_IEEE_ADDR_1		0x25, 0xff, 0
+#define RG_IEEE_ADDR_2	(0x26)
+#define SR_IEEE_ADDR_2		0x26, 0xff, 0
+#define RG_IEEE_ADDR_3	(0x27)
+#define SR_IEEE_ADDR_3		0x27, 0xff, 0
+#define RG_IEEE_ADDR_4	(0x28)
+#define SR_IEEE_ADDR_4		0x28, 0xff, 0
+#define RG_IEEE_ADDR_5	(0x29)
+#define SR_IEEE_ADDR_5		0x29, 0xff, 0
+#define RG_IEEE_ADDR_6	(0x2a)
+#define SR_IEEE_ADDR_6		0x2a, 0xff, 0
+#define RG_IEEE_ADDR_7	(0x2b)
+#define SR_IEEE_ADDR_7		0x2b, 0xff, 0
+#define RG_XAH_CTRL_0	(0x2c)
+#define SR_SLOTTED_OPERATION	0x2c, 0x01, 0
+#define SR_MAX_CSMA_RETRIES	0x2c, 0x0e, 1
+#define SR_MAX_FRAME_RETRIES	0x2c, 0xf0, 4
+#define RG_CSMA_SEED_0	(0x2d)
+#define SR_CSMA_SEED_0		0x2d, 0xff, 0
+#define RG_CSMA_SEED_1	(0x2e)
+#define SR_CSMA_SEED_1		0x2e, 0x07, 0
+#define SR_AACK_I_AM_COORD	0x2e, 0x08, 3
+#define SR_AACK_DIS_ACK		0x2e, 0x10, 4
+#define SR_AACK_SET_PD		0x2e, 0x20, 5
+#define SR_AACK_FVN_MODE	0x2e, 0xc0, 6
+#define RG_CSMA_BE	(0x2f)
+#define SR_MIN_BE		0x2f, 0x0f, 0
+#define SR_MAX_BE		0x2f, 0xf0, 4
 
 #define CMD_REG		0x80
 #define CMD_REG_MASK	0x3f
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 03/15] ieee802154: move validation check out of softmac
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 01/15] nl802154: cleanup invalid argument handling Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 02/15] at86rf230: remove tabs after define Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 04/15] mac802154: check for really changes Alexander Aring
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch moves the value validation out of softmac layer. after
calling rdev-ops we need to be sure now that this value is accepted by
the transceiver/mac802154 or "possible" hardmac drivers.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/ieee802154/nl802154.c | 28 +++++++++++++++++++++++++++-
 net/mac802154/cfg.c       | 29 -----------------------------
 2 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 9de427d..e19f218 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -625,7 +625,8 @@ static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info)
 	channel = nla_get_u8(info->attrs[NL802154_ATTR_CHANNEL]);
 
 	/* check 802.15.4 constraints */
-	if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL)
+	if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL ||
+	    !(rdev->wpan_phy.channels_supported[page] & BIT(channel)))
 		return -EINVAL;
 
 	return rdev_set_channel(rdev, page, channel);
@@ -674,6 +675,16 @@ static int nl802154_set_pan_id(struct sk_buff *skb, struct genl_info *info)
 
 	pan_id = nla_get_le16(info->attrs[NL802154_ATTR_PAN_ID]);
 
+	/* TODO
+	 * I am not sure about to check here on broadcast pan_id.
+	 * Broadcast is a valid setting, comment from 802.15.4:
+	 * If this value is 0xffff, the device is not associated.
+	 *
+	 * This could useful to simple deassociate an device.
+	 */
+	if (pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
+		return -EINVAL;
+
 	return rdev_set_pan_id(rdev, wpan_dev, pan_id);
 }
 
@@ -695,6 +706,21 @@ static int nl802154_set_short_addr(struct sk_buff *skb, struct genl_info *info)
 
 	short_addr = nla_get_le16(info->attrs[NL802154_ATTR_SHORT_ADDR]);
 
+	/* TODO
+	 * I am not sure about to check here on broadcast short_addr.
+	 * Broadcast is a valid setting, comment from 802.15.4:
+	 * A value of 0xfffe indicates that the device has
+	 * associated but has not been allocated an address. A
+	 * value of 0xffff indicates that the device does not
+	 * have a short address.
+	 *
+	 * I think we should allow to set these settings but
+	 * don't allow to allow socket communication with it.
+	 */
+	if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) ||
+	    short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST))
+		return -EINVAL;
+
 	return rdev_set_short_addr(rdev, wpan_dev, short_addr);
 }
 
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 5d9f68c..e53aec9 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -70,10 +70,6 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)
 
 	ASSERT_RTNL();
 
-	/* check if phy support this setting */
-	if (!(wpan_phy->channels_supported[page] & BIT(channel)))
-		return -EINVAL;
-
 	ret = drv_set_channel(local, page, channel);
 	if (!ret) {
 		wpan_phy->current_page = page;
@@ -109,16 +105,6 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
 {
 	ASSERT_RTNL();
 
-	/* TODO
-	 * I am not sure about to check here on broadcast pan_id.
-	 * Broadcast is a valid setting, comment from 802.15.4:
-	 * If this value is 0xffff, the device is not associated.
-	 *
-	 * This could useful to simple deassociate an device.
-	 */
-	if (pan_id == cpu_to_le16(IEEE802154_PAN_ID_BROADCAST))
-		return -EINVAL;
-
 	wpan_dev->pan_id = pan_id;
 	return 0;
 }
@@ -146,21 +132,6 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
 {
 	ASSERT_RTNL();
 
-	/* TODO
-	 * I am not sure about to check here on broadcast short_addr.
-	 * Broadcast is a valid setting, comment from 802.15.4:
-	 * A value of 0xfffe indicates that the device has
-	 * associated but has not been allocated an address. A
-	 * value of 0xffff indicates that the device does not
-	 * have a short address.
-	 *
-	 * I think we should allow to set these settings but
-	 * don't allow to allow socket communication with it.
-	 */
-	if (short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC) ||
-	    short_addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST))
-		return -EINVAL;
-
 	wpan_dev->short_addr = short_addr;
 	return 0;
 }
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 04/15] mac802154: check for really changes
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (2 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 03/15] ieee802154: move validation check out of softmac Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 05/15] mac802154: remove check if operation is supported Alexander Aring
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/net/cfg802154.h | 12 ++++++++++++
 net/mac802154/cfg.c     | 26 ++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index eeda676..4fec61d 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -64,6 +64,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;
 
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index e53aec9..b6a986a 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -70,6 +70,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;
@@ -88,6 +92,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;
@@ -105,6 +112,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;
 }
@@ -118,6 +128,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;
 
@@ -132,6 +146,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;
 }
@@ -145,6 +162,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;
 
@@ -161,6 +181,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;
 
@@ -176,6 +199,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;
 
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 05/15] mac802154: remove check if operation is supported
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (3 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 04/15] mac802154: check for really changes Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 06/15] ieee802154: introduce wpan_phy_supported Alexander Aring
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/cfg.c | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index b6a986a..c252a45 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -95,10 +95,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;
@@ -124,17 +120,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;
@@ -158,16 +149,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;
 }
@@ -177,16 +163,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;
 }
@@ -195,16 +176,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;
 }
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 06/15] ieee802154: introduce wpan_phy_supported
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (4 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 05/15] mac802154: remove check if operation is supported Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 07/15] ieee802154: add several phy supported handling Alexander Aring
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan
  Cc: kernel, phoebe.buckheister, Alexander Aring, Varka Bhadram, Alan Ott

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Suggested-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Cc: Varka Bhadram <varkabhadram@gmail.com>
Cc: Alan Ott <alan@signal11.us>
---
 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(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 22a0789..46fcdaa 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1556,7 +1556,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;
@@ -1564,15 +1564,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;
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index f833b8b..84b28a0 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -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;
 
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index dc2bfb6..91bbf03 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -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;
diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index fba2dfd..f2a1bd1 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -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;
 
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 4fec61d..7448603 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -59,6 +59,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;
@@ -94,7 +98,7 @@ struct wpan_phy {
 	 */
 	u8 current_channel;
 	u8 current_page;
-	u32 channels_supported[IEEE802154_MAX_PAGE + 1];
+	struct wpan_phy_supported supported;
 	s8 transmit_power;
 	struct wpan_phy_cca cca;
 
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index 1b9d25f6..b6826cf 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -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,
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index e19f218..ef99ad6 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -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);
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 07/15] ieee802154: add several phy supported handling
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (5 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 06/15] ieee802154: introduce wpan_phy_supported Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 08/15] ieee802154: add iftypes capability Alexander Aring
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Suggested-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
---
 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(-)

diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 7448603..0a2d367 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -59,8 +59,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 {
diff --git a/include/net/nl802154.h b/include/net/nl802154.h
index f8b5bc9..0552771 100644
--- a/include/net/nl802154.h
+++ b/include/net/nl802154.h
@@ -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 */
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index ef99ad6..779e7d9 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -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);
 }
 
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 8500378..68d08c4 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -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;
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 08/15] ieee802154: add iftypes capability
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (6 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 07/15] ieee802154: add several phy supported handling Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers Alexander Aring
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch adds capability flags for supported interface types.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/net/cfg802154.h   | 2 +-
 net/ieee802154/nl802154.c | 3 ++-
 net/mac802154/main.c      | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 0a2d367..a4fde09 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -78,7 +78,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;
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 779e7d9..3fe3ef2 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -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;
 	}
 
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 68d08c4..da626cb 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -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);
@@ -180,6 +183,9 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
 		local->phy->supported.min_frame_retries = -1;
 		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)
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (7 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 08/15] ieee802154: add iftypes capability Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-27 11:49   ` Phoebe Buckheister
  2015-04-23 16:47 ` [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels Alexander Aring
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 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, 76 insertions(+)

diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index a4fde09..89995dd 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -42,6 +42,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, s8 *dbm, 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,
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index e18e7fd..c489946 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -174,6 +174,14 @@ struct ieee802154_hw {
  *	  Set radio transmit power in dB. Called with pib_lock held.
  *	  Returns either zero, or negative errno.
  *
+ * get_txpowers:
+ *	  Get radio transmit powers in dB. 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. Two should be
+ *	  returned for skipping dbm but increment idx value, this can be useful
+ *	  for register to dbm array mapping.
+ *
  * set_lbt
  *	  Enables or disables listen before talk on the device. Called with
  *	  pib_lock held.
@@ -214,6 +222,8 @@ struct ieee802154_ops {
 					    struct ieee802154_hw_addr_filt *filt,
 					    unsigned long changed);
 	int		(*set_txpower)(struct ieee802154_hw *hw, s8 dbm);
+	int		(*get_tx_powers)(struct ieee802154_hw *hw, s8 *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);
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index 624413e..d944a7a 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -71,6 +71,17 @@ rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
 }
 
 static inline int
+rdev_get_tx_powers(struct cfg802154_registered_device *rdev, s8 *dbm, u32 idx)
+{
+	int ret;
+
+	trace_802154_rdev_get_tx_powers(&rdev->wpan_phy, idx);
+	ret = rdev->ops->get_tx_powers(&rdev->wpan_phy, dbm, idx);
+	trace_802154_rdev_return_int_tx_powers(&rdev->wpan_phy, ret, dbm);
+	return ret;
+}
+
+static inline int
 rdev_set_pan_id(struct cfg802154_registered_device *rdev,
 		struct wpan_dev *wpan_dev, __le16 pan_id)
 {
diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
index 8ed9f97..94ac3b9 100644
--- a/net/ieee802154/trace.h
+++ b/net/ieee802154/trace.h
@@ -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_tx_powers,
+	TP_PROTO(struct wpan_phy *wpan_phy, int ret, s8 *dbm),
+	TP_ARGS(wpan_phy, ret, dbm),
+	TP_STRUCT__entry(
+		WPAN_PHY_ENTRY
+		__field(int, ret)
+		__field(s8, dbm)
+	),
+	TP_fast_assign(
+		WPAN_PHY_ASSIGN;
+		__entry->ret = ret;
+		__entry->dbm = *dbm;
+	),
+	TP_printk(WPAN_PHY_PR_FMT ", returned: %d, dbm: %d", WPAN_PHY_PR_ARG,
+		  __entry->ret, __entry->dbm)
+);
+
 DECLARE_EVENT_CLASS(802154_le16_template,
 	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
 		 __le16 le16arg),
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index c252a45..2b80a77 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -103,6 +103,16 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,
 }
 
 static int
+ieee802154_get_tx_powers(struct wpan_phy *wpan_phy, s8 *dbm, u32 idx)
+{
+	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
+
+	ASSERT_RTNL();
+
+	return drv_get_tx_powers(local, dbm, idx);
+}
+
+static int
 ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
 		      __le16 pan_id)
 {
@@ -192,6 +202,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,
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
index a053335..08e2b09 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -70,6 +70,18 @@ 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_get_tx_powers(struct ieee802154_local *local, s8 *dbm, 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, dbm, idx);
+}
+
 static inline int drv_set_cca_mode(struct ieee802154_local *local,
 				   const struct wpan_phy_cca *cca)
 {
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (8 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-27 11:50   ` Phoebe Buckheister
  2015-04-23 16:47 ` [RFC bluetooth-next 11/15] at86rf230: set cca_modes supported flags Alexander Aring
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/net/cfg802154.h    |  2 ++
 include/net/mac802154.h    |  9 +++++++++
 net/ieee802154/rdev-ops.h  | 12 ++++++++++++
 net/ieee802154/trace.h     | 31 +++++++++++++++++++++++++++++++
 net/mac802154/cfg.c        | 11 +++++++++++
 net/mac802154/driver-ops.h | 12 ++++++++++++
 6 files changed, 77 insertions(+)

diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 89995dd..7d44dcc 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -43,6 +43,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, s8 *dbm, u32 idx);
+	int	(*get_cca_ed_levels)(struct wpan_phy *wpan_phy, s32 *dbm,
+				     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,
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index c489946..009e64c 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -182,6 +182,13 @@ struct ieee802154_hw {
  *	  returned for skipping dbm but increment idx value, this can be useful
  *	  for register to dbm array mapping.
  *
+ * 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. Two should
+ *	  be returned for skipping dbm but increment idx value.
+ *
  * set_lbt
  *	  Enables or disables listen before talk on the device. Called with
  *	  pib_lock held.
@@ -224,6 +231,8 @@ struct ieee802154_ops {
 	int		(*set_txpower)(struct ieee802154_hw *hw, s8 dbm);
 	int		(*get_tx_powers)(struct ieee802154_hw *hw, s8 *dbm,
 					 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);
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index d944a7a..5d2666f 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -71,6 +71,18 @@ rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
 }
 
 static inline int
+rdev_get_cca_ed_levels(struct cfg802154_registered_device *rdev, s32 *dbm,
+		       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, dbm, idx);
+	trace_802154_rdev_return_int_cca_ed_levels(&rdev->wpan_phy, ret, dbm);
+	return ret;
+}
+
+static inline int
 rdev_get_tx_powers(struct cfg802154_registered_device *rdev, s8 *dbm, u32 idx)
 {
 	int ret;
diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
index 94ac3b9..c06b57f 100644
--- a/net/ieee802154/trace.h
+++ b/net/ieee802154/trace.h
@@ -108,6 +108,37 @@ 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_return_int_cca_ed_levels,
+	TP_PROTO(struct wpan_phy *wpan_phy, int ret, s32 *dbm),
+	TP_ARGS(wpan_phy, ret, dbm),
+	TP_STRUCT__entry(
+		WPAN_PHY_ENTRY
+		__field(int, ret)
+		__field(s32, dbm)
+	),
+	TP_fast_assign(
+		WPAN_PHY_ASSIGN;
+		__entry->ret = ret;
+		__entry->dbm = *dbm;
+	),
+	TP_printk(WPAN_PHY_PR_FMT ", returned: %d, dbm: %d", WPAN_PHY_PR_ARG,
+		  __entry->ret, __entry->dbm)
+);
+
 TRACE_EVENT(802154_rdev_get_tx_powers,
 	TP_PROTO(struct wpan_phy *wpan_phy, u32 idx),
 	TP_ARGS(wpan_phy, idx),
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 2b80a77..e5234ab 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -103,6 +103,16 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,
 }
 
 static int
+ieee802154_get_cca_ed_levels(struct wpan_phy *wpan_phy, s32 *dbm, u32 idx)
+{
+	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
+
+	ASSERT_RTNL();
+
+	return drv_get_cca_ed_levels(local, dbm, idx);
+}
+
+static int
 ieee802154_get_tx_powers(struct wpan_phy *wpan_phy, s8 *dbm, u32 idx)
 {
 	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
@@ -203,6 +213,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,
diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
index 08e2b09..323da5c 100644
--- a/net/mac802154/driver-ops.h
+++ b/net/mac802154/driver-ops.h
@@ -120,6 +120,18 @@ drv_set_cca_ed_level(struct ieee802154_local *local, s32 ed_level)
 	return local->ops->set_cca_ed_level(&local->hw, ed_level);
 }
 
+static inline int
+drv_get_cca_ed_levels(struct ieee802154_local *local, s32 *dbm, 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, dbm, idx);
+}
+
 static inline int drv_set_pan_id(struct ieee802154_local *local, __le16 pan_id)
 {
 	struct ieee802154_hw_addr_filt filt;
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 11/15] at86rf230: set cca_modes supported flags
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (9 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 12/15] at86rf230: add reset states of tx power level Alexander Aring
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch sets the at86rf230 supported cca modes. In case of at86rf212
it also can support listen before transmit.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 46fcdaa..2c0aa29 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1546,6 +1546,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) {
@@ -1568,6 +1573,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";
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 12/15] at86rf230: add reset states of tx power level
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (10 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 11/15] at86rf230: set cca_modes supported flags Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 13/15] at86rf230: rework tx power support Alexander Aring
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch adds the reset states for tx power levels after running reset
procedure.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 2c0aa29..04a4e8e 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1564,6 +1564,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 = 3;
 		break;
 	case 7:
 		chip = "at86rf212";
@@ -1574,6 +1575,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 = 5;
 		break;
 	case 11:
 		chip = "at86rf233";
@@ -1581,6 +1583,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 = 4;
 		break;
 	default:
 		chip = "unknown";
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 13/15] at86rf230: rework tx power support
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (11 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 12/15] at86rf230: add reset states of tx power level Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 14/15] at86rf230: rework tx cca energy detection level Alexander Aring
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This patch adds support for get transmit power levels and reworks the
set of transmit power levels which was broken before.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 102 +++++++++++++++++++++++++++++++++----
 1 file changed, 92 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 04a4e8e..b4fce87 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -48,9 +48,12 @@ struct at86rf2xx_chip_data {
 	u16 t_frame;
 	u16 t_p_ack;
 	int rssi_base_val;
+	const s8 *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 *, s8);
+	int (*get_txpowers)(struct at86rf230_local *, s8 *, u32);
 };
 
 #define AT86RF2XX_MAX_BUF		(127 + 3)
@@ -122,9 +125,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
@@ -1172,11 +1178,34 @@ at86rf230_set_hw_addr_filt(struct ieee802154_hw *hw,
 	return 0;
 }
 
+#define AT86RF23X_MAX_TX_POWERS 0xF
+static const s8 at86rf233_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
+	4, S8_MAX /* 3.7 */, S8_MAX /* 3.4 */, 3, S8_MAX /* 2.5 */, 2, 1, 0,
+	-1, -2, -3, -4, -6, -8, -12, -17,
+};
+
+static const s8 at86rf231_powers[AT86RF23X_MAX_TX_POWERS + 1] = {
+	3, S8_MAX /* 2.8 */, S8_MAX /* 2.3 */, 2 /* 1.8 */, S8_MAX /* 1.3 */,
+	1 /* 0.7 */, 0, -1, -2, -3, -4, -5, -7, -9, -12, -17,
+};
+
 static int
-at86rf230_set_txpower(struct ieee802154_hw *hw, s8 db)
+at86rf23x_set_txpower(struct at86rf230_local *lp, s8 db)
 {
-	struct at86rf230_local *lp = hw->priv;
+	u32 i;
+
+	for (i = 0; i < AT86RF23X_MAX_TX_POWERS; i++) {
+		if (lp->data->tx_powers_table[i] == db &&
+		    lp->data->tx_powers_table[i] != S8_MAX)
+			return at86rf230_write_subreg(lp, SR_TX_PWR_23X, i);
+	}
+
+	return -EINVAL;
+}
 
+static int
+at86rf212_set_txpower(struct at86rf230_local *lp, s8 db)
+{
 	/* 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.
@@ -1186,9 +1215,53 @@ at86rf230_set_txpower(struct ieee802154_hw *hw, s8 db)
 	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, s8 db)
+{
+	struct at86rf230_local *lp = hw->priv;
+
+	return lp->data->set_txpower(lp, db);
+}
+
+static int
+at86rf23x_get_txpowers(struct at86rf230_local *lp, s8 *db, u32 idx)
+{
+	if (!lp->data->tx_powers_table)
+		return -EOPNOTSUPP;
+
+	if (idx > AT86RF23X_MAX_TX_POWERS)
+		return 1;
+
+	if (lp->data->tx_powers_table[idx] == S8_MAX)
+		return 2;
+
+	*db = lp->data->tx_powers_table[idx];
+	return 0;
+}
+
+#define AT86RF212_MAX_TX_POWERS 0x1F
+static int
+at86rf212_get_txpowers(struct at86rf230_local *lp, s8 *db, u32 idx)
+{
+	if (!lp->data->tx_powers_table)
+		return -EOPNOTSUPP;
+
+	if (idx > AT86RF212_MAX_TX_POWERS)
+		return 1;
+
+	*db = 5 - idx;
+	return 0;
+}
+
+static int
+at86rf230_get_txpowers(struct ieee802154_hw *hw, s8 *db, u32 idx)
+{
+	struct at86rf230_local *lp = hw->priv;
 
-	return __at86rf230_write(lp, RG_PHY_TX_PWR, 0x60 | db);
+	return lp->data->get_txpowers(lp, db, idx);
 }
 
 static int
@@ -1326,6 +1399,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,
@@ -1343,8 +1417,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 = {
@@ -1356,8 +1433,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 = {
@@ -1370,7 +1450,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)
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 14/15] at86rf230: rework tx cca energy detection level
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (12 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 13/15] at86rf230: rework tx power support Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-23 16:47 ` [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities Alexander Aring
  2015-04-24  3:38 ` [RFC bluetooth-next 00/15] ieee802154: add support for " Varka Bhadram
  15 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index b4fce87..4feab9a 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -51,7 +51,6 @@ struct at86rf2xx_chip_data {
 	const s8 *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 *, s8);
 	int (*get_txpowers)(struct at86rf230_local *, s8 *, u32);
 };
@@ -1307,27 +1306,29 @@ 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 level)
 {
-	return (level - lp->data->rssi_base_val) * 100 / 207;
-}
+	struct at86rf230_local *lp = hw->priv;
 
-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);
 }
 
 static int
-at86rf230_set_cca_ed_level(struct ieee802154_hw *hw, s32 level)
+at86rf230_get_cca_ed_levels(struct ieee802154_hw *hw, s32 *dbm, u32 idx)
 {
 	struct at86rf230_local *lp = hw->priv;
 
-	if (level < lp->data->rssi_base_val || level > 30)
-		return -EINVAL;
+	if (idx > 0xF)
+		return 1;
 
-	return at86rf230_write_subreg(lp, SR_CCA_ED_THRES,
-				      lp->data->get_desense_steps(lp, level));
+	*dbm = lp->data->rssi_base_val + 2 * idx;
+	return 0;
 }
 
 static int
@@ -1400,6 +1401,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,
@@ -1419,7 +1421,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,
 };
@@ -1435,7 +1436,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,
 };
@@ -1450,7 +1450,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,
 };
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (13 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 14/15] at86rf230: rework tx cca energy detection level Alexander Aring
@ 2015-04-23 16:47 ` Alexander Aring
  2015-04-24  4:43   ` Varka Bhadram
  2015-04-24  3:38 ` [RFC bluetooth-next 00/15] ieee802154: add support for " Varka Bhadram
  15 siblings, 1 reply; 26+ messages in thread
From: Alexander Aring @ 2015-04-23 16:47 UTC (permalink / raw)
  To: linux-wpan; +Cc: kernel, phoebe.buckheister, Alexander Aring

This 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.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/net/nl802154.h    |  57 ++++++++++++++++++++
 net/ieee802154/nl802154.c | 131 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 187 insertions(+), 1 deletion(-)

diff --git a/include/net/nl802154.h b/include/net/nl802154.h
index 0552771..8c49714 100644
--- a/include/net/nl802154.h
+++ b/include/net/nl802154.h
@@ -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 - 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_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
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 3fe3ef2..04317ce 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -225,6 +225,8 @@ static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX+1] = {
 	[NL802154_ATTR_MAX_FRAME_RETRIES] = { .type = NLA_S8, },
 
 	[NL802154_ATTR_LBT_MODE] = { .type = NLA_U8, },
+
+	[NL802154_ATTR_WPAN_PHY_CAPS] = { .type = NLA_NESTED },
 };
 
 /* message building helper */
@@ -236,6 +238,28 @@ static inline void *nl802154hdr_put(struct sk_buff *skb, u32 portid, u32 seq,
 }
 
 static int
+nl802154_put_flags(struct sk_buff *msg, int attr, u32 mask)
+{
+	struct nlattr *nl_flags = nla_nest_start(msg, attr);
+	int i;
+
+	if (!nl_flags)
+		return -ENOBUFS;
+
+	i = 0;
+	while (mask) {
+		if ((mask & 1) && nla_put_flag(msg, i))
+			return -ENOBUFS;
+
+		mask >>= 1;
+		i++;
+	}
+
+	nla_nest_end(msg, nl_flags);
+	return 0;
+}
+
+static int
 nl802154_send_wpan_phy_channels(struct cfg802154_registered_device *rdev,
 				struct sk_buff *msg)
 {
@@ -256,6 +280,106 @@ nl802154_send_wpan_phy_channels(struct cfg802154_registered_device *rdev,
 	return 0;
 }
 
+static int
+nl802154_put_capabilities(struct sk_buff *msg,
+			  struct cfg802154_registered_device *rdev)
+{
+	const struct wpan_phy_supported *caps = &rdev->wpan_phy.supported;
+	struct nlattr *nl_tx_pwrs, *nl_caps, *nl_channels;
+	int idx;
+	s8 pwr;
+	int ret;
+
+	nl_caps = nla_nest_start(msg, NL802154_ATTR_WPAN_PHY_CAPS);
+	if (!nl_caps)
+		return -ENOBUFS;
+
+	nl_channels = nla_nest_start(msg, NL802154_CAP_ATTR_CHANNELS);
+	if (!nl_channels)
+		return -ENOBUFS;
+
+	for (idx = 0; idx <= IEEE802154_MAX_PAGE; idx++) {
+		if (caps->channels[idx]) {
+			if (nl802154_put_flags(msg, idx,
+					       caps->channels[idx]))
+				return -ENOBUFS;
+		}
+	}
+
+	nla_nest_end(msg, nl_channels);
+
+	/* cca_ed_levels only in mode 1 and 3 important, check if supported */
+	if (caps->cca_modes & (BIT(NL802154_CCA_ENERGY_CARRIER) |
+			       BIT(NL802154_CCA_ENERGY))) {
+		struct nlattr *nl_ed_lvls;
+		s32 ed;
+
+		nl_ed_lvls = nla_nest_start(msg,
+					    NL802154_CAP_ATTR_CCA_ED_LEVELS);
+			if (!nl_ed_lvls)
+				return -ENOBUFS;
+
+		idx = 0;
+		while (1) {
+			ret = rdev_get_cca_ed_levels(rdev, &ed, idx++);
+			if (ret < 0)
+				return ret;
+			else if (ret == 1)
+				break;
+			else if (ret == 2)
+				continue;
+
+			nla_put_s32(msg, idx, ed);
+		};
+
+		nla_nest_end(msg, nl_ed_lvls);
+	}
+
+	nl_tx_pwrs = nla_nest_start(msg, NL802154_CAP_ATTR_TX_POWERS);
+	if (!nl_tx_pwrs)
+		return -ENOBUFS;
+
+	idx = 0;
+	while (1) {
+		ret = rdev_get_tx_powers(rdev, &pwr, idx++);
+		if (ret < 0)
+			return ret;
+		else if (ret == 1)
+			break;
+		else if (ret == 2)
+			continue;
+
+		nla_put_s8(msg, idx, pwr);
+	};
+
+	nla_nest_end(msg, nl_tx_pwrs);
+
+	if (nl802154_put_flags(msg, NL802154_CAP_ATTR_CCA_MODES,
+			       caps->cca_modes) ||
+	    nl802154_put_flags(msg, NL802154_CAP_ATTR_CCA_OPTS,
+			       caps->cca_opts) ||
+	    nla_put_u8(msg, NL802154_CAP_ATTR_MIN_MINBE, caps->min_minbe) ||
+	    nla_put_u8(msg, NL802154_CAP_ATTR_MAX_MINBE, caps->max_minbe) ||
+	    nla_put_u8(msg, NL802154_CAP_ATTR_MIN_MAXBE, caps->min_maxbe) ||
+	    nla_put_u8(msg, NL802154_CAP_ATTR_MAX_MAXBE, caps->max_maxbe) ||
+	    nla_put_u8(msg, NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS,
+		       caps->min_csma_backoffs) ||
+	    nla_put_u8(msg, NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS,
+		       caps->max_csma_backoffs) ||
+	    nla_put_s8(msg, NL802154_CAP_ATTR_MIN_FRAME_RETRIES,
+		       caps->min_frame_retries) ||
+	    nla_put_s8(msg, NL802154_CAP_ATTR_MAX_FRAME_RETRIES,
+		       caps->max_frame_retries) ||
+	    nl802154_put_flags(msg, NL802154_CAP_ATTR_IFTYPES,
+			       caps->iftypes) ||
+	    nla_put_u32(msg, NL802154_CAP_ATTR_LBT, caps->lbt))
+		return -ENOBUFS;
+
+	nla_nest_end(msg, nl_caps);
+
+	return 0;
+}
+
 static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,
 				  enum nl802154_commands cmd,
 				  struct sk_buff *msg, u32 portid, u32 seq,
@@ -286,7 +410,9 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,
 		       rdev->wpan_phy.current_channel))
 		goto nla_put_failure;
 
-	/* supported channels array */
+	/* TODO remove this behaviour, we still keep support it for a while
+	 * so users can change the behaviour to the new one.
+	 */
 	if (nl802154_send_wpan_phy_channels(rdev, msg))
 		goto nla_put_failure;
 
@@ -305,6 +431,9 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,
 		       rdev->wpan_phy.transmit_power))
 		goto nla_put_failure;
 
+	if (nl802154_put_capabilities(msg, rdev))
+		goto nla_put_failure;
+
 finish:
 	genlmsg_end(msg, hdr);
 	return 0;
-- 
2.3.6


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities
  2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
                   ` (14 preceding siblings ...)
  2015-04-23 16:47 ` [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities Alexander Aring
@ 2015-04-24  3:38 ` Varka Bhadram
  2015-04-24  5:11   ` Varka Bhadram
  2015-04-25  6:48   ` Alexander Aring
  15 siblings, 2 replies; 26+ messages in thread
From: Varka Bhadram @ 2015-04-24  3:38 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, phoebe.buckheister

On 04/23/2015 10:17 PM, Alexander Aring wrote:
> 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.
>
>
> Note: this patch series based on the ("ieee802154: Add trace events for rdev->ops") by
> Guido Günther <agx@sigxcpu.org>.
>
> - Alex
>
> [0] http://www.spinics.net/lists/linux-wpan/msg01603.html
>
> Alexander Aring (15):
>   nl802154: cleanup invalid argument handling
>   at86rf230: remove tabs after define
>   ieee802154: move validation check out of softmac
>   mac802154: check for really changes
>   mac802154: remove check if operation is supported
>   ieee802154: introduce wpan_phy_supported
>   ieee802154: add several phy supported handling
>   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
>   nl802154: add support for dump phy capabilities
>
>  drivers/net/ieee802154/at86rf230.c | 442 ++++++++++++++++++++++---------------
>  drivers/net/ieee802154/cc2520.c    |   2 +-
>  drivers/net/ieee802154/fakelb.c    |  30 +--
>  drivers/net/ieee802154/mrf24j40.c  |   2 +-
>  include/net/cfg802154.h            |  43 +++-
>  include/net/mac802154.h            |  19 ++
>  include/net/nl802154.h             |  79 +++++++
>  net/ieee802154/nl-phy.c            |   4 +-
>  net/ieee802154/nl802154.c          | 198 +++++++++++++++--
>  net/ieee802154/rdev-ops.h          |  23 ++
>  net/ieee802154/trace.h             |  62 ++++++
>  net/mac802154/cfg.c                |  85 ++++---
>  net/mac802154/driver-ops.h         |  24 ++
>  net/mac802154/main.c               |  32 +++
>  14 files changed, 787 insertions(+), 258 deletions(-)
>
Good your work around phy capabilities for wpan. 

I would suggest to split this series into two.
One for the cleanup for at86rf230 and other for
the adding phy capabilities. Review will also be
easy for us.


-- 
Varka Bhadram


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities
  2015-04-23 16:47 ` [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities Alexander Aring
@ 2015-04-24  4:43   ` Varka Bhadram
  2015-04-25  6:47     ` Alexander Aring
  0 siblings, 1 reply; 26+ messages in thread
From: Varka Bhadram @ 2015-04-24  4:43 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, phoebe.buckheister

On 04/23/2015 10:17 PM, Alexander Aring wrote:

> This 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.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  include/net/nl802154.h    |  57 ++++++++++++++++++++
>  net/ieee802154/nl802154.c | 131 +++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 187 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/nl802154.h b/include/net/nl802154.h
> index 0552771..8c49714 100644
> --- a/include/net/nl802154.h
> +++ b/include/net/nl802154.h
> @@ -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 - capability attributes
> + *

instead of capability attributes also add wpan phy in-front of it. 

* 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_capability_attr {

enum name mismatch. should be *nl802154_wpan_phy_capability_attr*. 

-- 
Varka Bhadram


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities
  2015-04-24  3:38 ` [RFC bluetooth-next 00/15] ieee802154: add support for " Varka Bhadram
@ 2015-04-24  5:11   ` Varka Bhadram
  2015-04-25 10:06     ` Alexander Aring
  2015-04-25  6:48   ` Alexander Aring
  1 sibling, 1 reply; 26+ messages in thread
From: Varka Bhadram @ 2015-04-24  5:11 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan; +Cc: kernel, phoebe.buckheister

On 04/24/2015 09:08 AM, Varka Bhadram wrote:

> On 04/23/2015 10:17 PM, Alexander Aring wrote:
>> 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.
>>
>>
>> Note: this patch series based on the ("ieee802154: Add trace events for rdev->ops") by
>> Guido Günther <agx@sigxcpu.org>.
>>
>> - Alex
>>
>> [0] http://www.spinics.net/lists/linux-wpan/msg01603.html
>>
>> Alexander Aring (15):
>>   nl802154: cleanup invalid argument handling
>>   at86rf230: remove tabs after define
>>   ieee802154: move validation check out of softmac
>>   mac802154: check for really changes
>>   mac802154: remove check if operation is supported
>>   ieee802154: introduce wpan_phy_supported
>>   ieee802154: add several phy supported handling
>>   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
>>   nl802154: add support for dump phy capabilities
>>
>>  drivers/net/ieee802154/at86rf230.c | 442 ++++++++++++++++++++++---------------
>>  drivers/net/ieee802154/cc2520.c    |   2 +-
>>  drivers/net/ieee802154/fakelb.c    |  30 +--
>>  drivers/net/ieee802154/mrf24j40.c  |   2 +-
>>  include/net/cfg802154.h            |  43 +++-
>>  include/net/mac802154.h            |  19 ++
>>  include/net/nl802154.h             |  79 +++++++
>>  net/ieee802154/nl-phy.c            |   4 +-
>>  net/ieee802154/nl802154.c          | 198 +++++++++++++++--
>>  net/ieee802154/rdev-ops.h          |  23 ++
>>  net/ieee802154/trace.h             |  62 ++++++
>>  net/mac802154/cfg.c                |  85 ++++---
>>  net/mac802154/driver-ops.h         |  24 ++
>>  net/mac802154/main.c               |  32 +++
>>  14 files changed, 787 insertions(+), 258 deletions(-)
>>
> Good your work around phy capabilities for wpan. 
>
> I would suggest to split this series into two.
> One for the cleanup for at86rf230 and other for
> the adding phy capabilities. Review will also be
> easy for us.
>
>
May be this is not the right place to ask this question.

Do you think that patch at [0] required to us..?

That will be useful multi-queue environment. Even though
its better to have this feature.

If you agree include this, patch is on the way.. 

[0]: https://git.kernel.org/cgit/linux/kernel/git/jberg/mac80211-next.git/commit/?h=fast-xmit&id=084d8536fc4f1581f975c1a5fcacd4384555bdcf

Thanks

-- 
Varka Bhadram


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities
  2015-04-24  4:43   ` Varka Bhadram
@ 2015-04-25  6:47     ` Alexander Aring
  0 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-25  6:47 UTC (permalink / raw)
  To: Varka Bhadram; +Cc: linux-wpan, kernel, phoebe.buckheister

On Fri, Apr 24, 2015 at 10:13:11AM +0530, Varka Bhadram wrote:
> On 04/23/2015 10:17 PM, Alexander Aring wrote:
> 
> > This 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.
> >
> > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> >  include/net/nl802154.h    |  57 ++++++++++++++++++++
> >  net/ieee802154/nl802154.c | 131 +++++++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 187 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/nl802154.h b/include/net/nl802154.h
> > index 0552771..8c49714 100644
> > --- a/include/net/nl802154.h
> > +++ b/include/net/nl802154.h
> > @@ -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 - capability attributes
> > + *
> 
> instead of capability attributes also add wpan phy in-front of it. 
> 
> * 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_capability_attr {
> 
> enum name mismatch. should be *nl802154_wpan_phy_capability_attr*. 
> 

ok, thanks. This header very important to be correct, otherwise users
getting angry. :-)

- Alex

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities
  2015-04-24  3:38 ` [RFC bluetooth-next 00/15] ieee802154: add support for " Varka Bhadram
  2015-04-24  5:11   ` Varka Bhadram
@ 2015-04-25  6:48   ` Alexander Aring
  1 sibling, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-25  6:48 UTC (permalink / raw)
  To: Varka Bhadram; +Cc: linux-wpan, kernel, phoebe.buckheister

On Fri, Apr 24, 2015 at 09:08:03AM +0530, Varka Bhadram wrote:
...
> Good your work around phy capabilities for wpan. 
> 
> I would suggest to split this series into two.
> One for the cleanup for at86rf230 and other for
> the adding phy capabilities. Review will also be
> easy for us.
> 

okay I will do.

- Alex

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities
  2015-04-24  5:11   ` Varka Bhadram
@ 2015-04-25 10:06     ` Alexander Aring
  2015-04-27  6:51       ` Varka Bhadram
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Aring @ 2015-04-25 10:06 UTC (permalink / raw)
  To: Varka Bhadram; +Cc: linux-wpan, kernel, phoebe.buckheister

On Fri, Apr 24, 2015 at 10:41:52AM +0530, Varka Bhadram wrote:
...
> May be this is not the right place to ask this question.
> 

creating a new mail to linux-wpan next time? And of course you can ask
this here.

> Do you think that patch at [0] required to us..?
> 

no.

> That will be useful multi-queue environment. Even though
> its better to have this feature.
> 

Note about tx multi-queue environment:

Wireless (802.11) != 802.15.4

802.11 follows different strategies like 802.15.4 follows [0]. "was
chartered to investigate a low data rate solution...", of course
low-power and such things. I would not say that performance isn't
important for us. (I also like to remove several shift operation in the
current frame parsing) What I am think is that a multiqueue environment
gives us not a big benefit.

Maybe I am wrong here, you can implement it and give some benchmark
tests if you want.


Another thing is that the multiqueue in wireless do implement a
priority queue (that's what I understand). So we need to have somewhere
option which sets this priority somewhere. [1]

mac802154 do that for different types of content in the payload like
video or audio streaming. They have some priority enums defined at [2].
Every queue has then a own priority.

You see that with multiqueue inside mac80211 they want to improve
different payload content like video which is a use case of the 802.11
standard. For example streaming videos with 802.15.4, you can forget that.
But then we have other things like "low energy".

This is why there is no general "IoT" wireless standard outside, each have
their benefit depends on your use case. If you want to stream videos and call
it "IoT - Application" then 802.15.4 is not what you want. I did a fast
googling and found [3], you see different wireless standards compared with 
Range and data rate.


To detect a priority for _maybe_ implement such multiqueue handling in
802.15.4 then this could be dine by set it in some sockopt of 802.15.4 sockets
or grab it from DCSP field of IPv6 header, like wireless it also does [1] - 
"DSCP (RFC 2474):" for 6LoWPAN then. But general this would be a benefit if you
have a lot of other _lower_ priority traffic.



It also could be that a wireless driver/transceiver can support
put frame in "transceiver queue" when current one is transmitted at the moment.
I don't know if something exists at the moment, the at86rf2xx have only
one frame buffer which cannot be overwritten while transmit (or can but
then it need to handle real time, I think we can't never support that
inside linux).




Now note about patch ("mac80211: use per-CPU TX/RX statistics")
084d8536fc4f1581f975c1a5fcacd4384555bdcf:

First I don't apply something like that if we doesn't have multiqueue tx queue
(if it really increase perfomance), because this patch fix something
which only happen in multiqueue tx queue handling.

Second: This patch is because there is an issue about increment the tx
stats on netdev while using multiqueue. So far I understand this is
because the incrementation is not an atomic operation, so this patch to
a per cpu operation to be sure that this operation "to increment the tx
stats" can be run on one cpu. So before this patch mulitple queues was
running and increment these values at the same time which result in some
inconsistent behaviour.


> If you agree include this, patch is on the way.. 
> 

no. In short:

1. We don't have multple tx queues (and I don't think that we can get
   much benefits from it).

2. The patch ("mac80211: use per-CPU TX/RX statistics")
   084d8536fc4f1581f975c1a5fcacd4384555bdcf solved an issue when multiple
   queues increments the counter on multicore architecture. We don't have
   this issue because we have only one queue which we stop and wake before
   transmit and while tx completion. The incrementation is protected by
   this handling.


You should provide patches for an useful case of multiple tx queues with
benchmark results. Then we need to care about "locking", this is what
your wireless patch fix does.

- Alex

[0] http://www.ieee802.org/15/pub/TG4.html
[1] https://wireless.wiki.kernel.org/en/developers/documentation/mac80211/queues
[2] http://lxr.free-electrons.com/source/include/net/mac80211.h#L102
[3] http://blogs.freescale.com/wp-content/uploads/2014/11/post-10893-image-4-todays-wireless-landscape.jpg
[4] 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities
  2015-04-25 10:06     ` Alexander Aring
@ 2015-04-27  6:51       ` Varka Bhadram
  0 siblings, 0 replies; 26+ messages in thread
From: Varka Bhadram @ 2015-04-27  6:51 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan, kernel, phoebe.buckheister

Hi Alex,

On 04/25/2015 03:36 PM, Alexander Aring wrote:

> On Fri, Apr 24, 2015 at 10:41:52AM +0530, Varka Bhadram wrote:
> ...
>> May be this is not the right place to ask this question.
>>
> creating a new mail to linux-wpan next time? And of course you can ask
> this here.
>
>> Do you think that patch at [0] required to us..?
>>
> no.
>
>> That will be useful multi-queue environment. Even though
>> its better to have this feature.
>>
> Note about tx multi-queue environment:
>
> Wireless (802.11) != 802.15.4
>
> 802.11 follows different strategies like 802.15.4 follows [0]. "was
> chartered to investigate a low data rate solution...", of course
> low-power and such things. I would not say that performance isn't
> important for us. (I also like to remove several shift operation in the
> current frame parsing) What I am think is that a multiqueue environment
> gives us not a big benefit.
>
> Maybe I am wrong here, you can implement it and give some benchmark
> tests if you want.
>
>
> Another thing is that the multiqueue in wireless do implement a
> priority queue (that's what I understand). So we need to have somewhere
> option which sets this priority somewhere. [1]
>
> mac802154 do that for different types of content in the payload like
> video or audio streaming. They have some priority enums defined at [2].
> Every queue has then a own priority.
>
> You see that with multiqueue inside mac80211 they want to improve
> different payload content like video which is a use case of the 802.11
> standard. For example streaming videos with 802.15.4, you can forget that.
> But then we have other things like "low energy".
>
> This is why there is no general "IoT" wireless standard outside, each have
> their benefit depends on your use case. If you want to stream videos and call
> it "IoT - Application" then 802.15.4 is not what you want. I did a fast
> googling and found [3], you see different wireless standards compared with 
> Range and data rate.
>
>
> To detect a priority for _maybe_ implement such multiqueue handling in
> 802.15.4 then this could be dine by set it in some sockopt of 802.15.4 sockets
> or grab it from DCSP field of IPv6 header, like wireless it also does [1] - 
> "DSCP (RFC 2474):" for 6LoWPAN then. But general this would be a benefit if you
> have a lot of other _lower_ priority traffic.
>
>
>
> It also could be that a wireless driver/transceiver can support
> put frame in "transceiver queue" when current one is transmitted at the moment.
> I don't know if something exists at the moment, the at86rf2xx have only
> one frame buffer which cannot be overwritten while transmit (or can but
> then it need to handle real time, I think we can't never support that
> inside linux).
>
>
>
>
> Now note about patch ("mac80211: use per-CPU TX/RX statistics")
> 084d8536fc4f1581f975c1a5fcacd4384555bdcf:
>
> First I don't apply something like that if we doesn't have multiqueue tx queue
> (if it really increase perfomance), because this patch fix something
> which only happen in multiqueue tx queue handling.
>
> Second: This patch is because there is an issue about increment the tx
> stats on netdev while using multiqueue. So far I understand this is
> because the incrementation is not an atomic operation, so this patch to
> a per cpu operation to be sure that this operation "to increment the tx
> stats" can be run on one cpu. So before this patch mulitple queues was
> running and increment these values at the same time which result in some
> inconsistent behaviour.
>
>
>> If you agree include this, patch is on the way.. 
>>
> no. In short:
>
> 1. We don't have multple tx queues (and I don't think that we can get
>    much benefits from it).
>
> 2. The patch ("mac80211: use per-CPU TX/RX statistics")
>    084d8536fc4f1581f975c1a5fcacd4384555bdcf solved an issue when multiple
>    queues increments the counter on multicore architecture. We don't have
>    this issue because we have only one queue which we stop and wake before
>    transmit and while tx completion. The incrementation is protected by
>    this handling.
>
>
> You should provide patches for an useful case of multiple tx queues with
> benchmark results. Then we need to care about "locking", this is what
> your wireless patch fix does.
>
> - Alex
>
> [0] http://www.ieee802.org/15/pub/TG4.html
> [1] https://wireless.wiki.kernel.org/en/developers/documentation/mac80211/queues
> [2] http://lxr.free-electrons.com/source/include/net/mac80211.h#L102
> [3] http://blogs.freescale.com/wp-content/uploads/2014/11/post-10893-image-4-todays-wireless-landscape.jpg
> [4] 

Agree with you.

Thank you for your explanation.

-- 
Varka Bhadram


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers
  2015-04-23 16:47 ` [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers Alexander Aring
@ 2015-04-27 11:49   ` Phoebe Buckheister
  2015-04-29  9:07     ` Alexander Aring
  0 siblings, 1 reply; 26+ messages in thread
From: Phoebe Buckheister @ 2015-04-27 11:49 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan, kernel

On Thu, 23 Apr 2015 18:47:48 +0200
Alexander Aring <alex.aring@gmail.com> 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.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  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, 76 insertions(+)
> 
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index a4fde09..89995dd 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -42,6 +42,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, s8
> *dbm, 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,
> diff --git a/include/net/mac802154.h b/include/net/mac802154.h
> index e18e7fd..c489946 100644
> --- a/include/net/mac802154.h
> +++ b/include/net/mac802154.h
> @@ -174,6 +174,14 @@ struct ieee802154_hw {
>   *	  Set radio transmit power in dB. Called with pib_lock
> held.
>   *	  Returns either zero, or negative errno.
>   *
> + * get_txpowers:
> + *	  Get radio transmit powers in dB. 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.
> Two should be
> + *	  returned for skipping dbm but increment idx value, this
> can be useful
> + *	  for register to dbm array mapping.
> + *
>   * set_lbt
>   *	  Enables or disables listen before talk on the device.
> Called with
>   *	  pib_lock held.
> @@ -214,6 +222,8 @@ struct ieee802154_ops {
>  					    struct
> ieee802154_hw_addr_filt *filt, unsigned long changed);
>  	int		(*set_txpower)(struct ieee802154_hw *hw,
> s8 dbm);
> +	int		(*get_tx_powers)(struct ieee802154_hw
> *hw, s8 *dbm,
> +					 u32 idx);

I suggest you use mBm instead of dBm here, while you're at it anyway.
Especially since one of your later patches will add incorrect values
because dBm isn't accurate enough for what the transceiver support
(rf230, TX power +3.4dBm). This would also make the value-2 return you
have right now unnecessary.

>  	int		(*set_lbt)(struct ieee802154_hw *hw, bool
> on); int		(*set_cca_mode)(struct ieee802154_hw *hw,
>  					const struct wpan_phy_cca
> *cca); diff --git a/net/ieee802154/rdev-ops.h
> b/net/ieee802154/rdev-ops.h index 624413e..d944a7a 100644
> --- a/net/ieee802154/rdev-ops.h
> +++ b/net/ieee802154/rdev-ops.h
> @@ -71,6 +71,17 @@ rdev_set_cca_mode(struct
> cfg802154_registered_device *rdev, }
>  
>  static inline int
> +rdev_get_tx_powers(struct cfg802154_registered_device *rdev, s8
> *dbm, u32 idx) +{
> +	int ret;
> +
> +	trace_802154_rdev_get_tx_powers(&rdev->wpan_phy, idx);
> +	ret = rdev->ops->get_tx_powers(&rdev->wpan_phy, dbm, idx);
> +	trace_802154_rdev_return_int_tx_powers(&rdev->wpan_phy, ret,
> dbm);
> +	return ret;
> +}
> +
> +static inline int
>  rdev_set_pan_id(struct cfg802154_registered_device *rdev,
>  		struct wpan_dev *wpan_dev, __le16 pan_id)
>  {
> diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
> index 8ed9f97..94ac3b9 100644
> --- a/net/ieee802154/trace.h
> +++ b/net/ieee802154/trace.h
> @@ -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_tx_powers,
> +	TP_PROTO(struct wpan_phy *wpan_phy, int ret, s8 *dbm),
> +	TP_ARGS(wpan_phy, ret, dbm),
> +	TP_STRUCT__entry(
> +		WPAN_PHY_ENTRY
> +		__field(int, ret)
> +		__field(s8, dbm)
> +	),
> +	TP_fast_assign(
> +		WPAN_PHY_ASSIGN;
> +		__entry->ret = ret;
> +		__entry->dbm = *dbm;
> +	),
> +	TP_printk(WPAN_PHY_PR_FMT ", returned: %d, dbm: %d",
> WPAN_PHY_PR_ARG,
> +		  __entry->ret, __entry->dbm)
> +);
> +
>  DECLARE_EVENT_CLASS(802154_le16_template,
>  	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev
> *wpan_dev, __le16 le16arg),
> diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> index c252a45..2b80a77 100644
> --- a/net/mac802154/cfg.c
> +++ b/net/mac802154/cfg.c
> @@ -103,6 +103,16 @@ ieee802154_set_cca_mode(struct wpan_phy
> *wpan_phy, }
>  
>  static int
> +ieee802154_get_tx_powers(struct wpan_phy *wpan_phy, s8 *dbm, u32 idx)
> +{
> +	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
> +
> +	ASSERT_RTNL();
> +
> +	return drv_get_tx_powers(local, dbm, idx);
> +}
> +
> +static int
>  ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev
> *wpan_dev, __le16 pan_id)
>  {
> @@ -192,6 +202,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,
> diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
> index a053335..08e2b09 100644
> --- a/net/mac802154/driver-ops.h
> +++ b/net/mac802154/driver-ops.h
> @@ -70,6 +70,18 @@ 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_get_tx_powers(struct ieee802154_local *local, s8 *dbm, 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, dbm, idx);
> +}
> +
>  static inline int drv_set_cca_mode(struct ieee802154_local *local,
>  				   const struct wpan_phy_cca *cca)
>  {


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels
  2015-04-23 16:47 ` [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels Alexander Aring
@ 2015-04-27 11:50   ` Phoebe Buckheister
  0 siblings, 0 replies; 26+ messages in thread
From: Phoebe Buckheister @ 2015-04-27 11:50 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan, kernel

On Thu, 23 Apr 2015 18:47:49 +0200
Alexander Aring <alex.aring@gmail.com> wrote:

> This 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.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  include/net/cfg802154.h    |  2 ++
>  include/net/mac802154.h    |  9 +++++++++
>  net/ieee802154/rdev-ops.h  | 12 ++++++++++++
>  net/ieee802154/trace.h     | 31 +++++++++++++++++++++++++++++++
>  net/mac802154/cfg.c        | 11 +++++++++++
>  net/mac802154/driver-ops.h | 12 ++++++++++++
>  6 files changed, 77 insertions(+)
> 
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index 89995dd..7d44dcc 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -43,6 +43,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, s8
> *dbm, u32 idx);
> +	int	(*get_cca_ed_levels)(struct wpan_phy *wpan_phy,
> s32 *dbm,
> +				     u32 idx);

mBm instead of dBm would be better here, too.

>  	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,
> diff --git a/include/net/mac802154.h b/include/net/mac802154.h
> index c489946..009e64c 100644
> --- a/include/net/mac802154.h
> +++ b/include/net/mac802154.h
> @@ -182,6 +182,13 @@ struct ieee802154_hw {
>   *	  returned for skipping dbm but increment idx value, this
> can be useful
>   *	  for register to dbm array mapping.
>   *
> + * 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. Two should
> + *	  be returned for skipping dbm but increment idx value.
> + *
>   * set_lbt
>   *	  Enables or disables listen before talk on the device.
> Called with
>   *	  pib_lock held.
> @@ -224,6 +231,8 @@ struct ieee802154_ops {
>  	int		(*set_txpower)(struct ieee802154_hw *hw,
> s8 dbm); int		(*get_tx_powers)(struct ieee802154_hw
> *hw, s8 *dbm, 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); diff --git a/net/ieee802154/rdev-ops.h
> b/net/ieee802154/rdev-ops.h index d944a7a..5d2666f 100644
> --- a/net/ieee802154/rdev-ops.h
> +++ b/net/ieee802154/rdev-ops.h
> @@ -71,6 +71,18 @@ rdev_set_cca_mode(struct
> cfg802154_registered_device *rdev, }
>  
>  static inline int
> +rdev_get_cca_ed_levels(struct cfg802154_registered_device *rdev, s32
> *dbm,
> +		       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, dbm,
> idx);
> +	trace_802154_rdev_return_int_cca_ed_levels(&rdev->wpan_phy,
> ret, dbm);
> +	return ret;
> +}
> +
> +static inline int
>  rdev_get_tx_powers(struct cfg802154_registered_device *rdev, s8
> *dbm, u32 idx) {
>  	int ret;
> diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
> index 94ac3b9..c06b57f 100644
> --- a/net/ieee802154/trace.h
> +++ b/net/ieee802154/trace.h
> @@ -108,6 +108,37 @@ 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_return_int_cca_ed_levels,
> +	TP_PROTO(struct wpan_phy *wpan_phy, int ret, s32 *dbm),
> +	TP_ARGS(wpan_phy, ret, dbm),
> +	TP_STRUCT__entry(
> +		WPAN_PHY_ENTRY
> +		__field(int, ret)
> +		__field(s32, dbm)
> +	),
> +	TP_fast_assign(
> +		WPAN_PHY_ASSIGN;
> +		__entry->ret = ret;
> +		__entry->dbm = *dbm;
> +	),
> +	TP_printk(WPAN_PHY_PR_FMT ", returned: %d, dbm: %d",
> WPAN_PHY_PR_ARG,
> +		  __entry->ret, __entry->dbm)
> +);
> +
>  TRACE_EVENT(802154_rdev_get_tx_powers,
>  	TP_PROTO(struct wpan_phy *wpan_phy, u32 idx),
>  	TP_ARGS(wpan_phy, idx),
> diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> index 2b80a77..e5234ab 100644
> --- a/net/mac802154/cfg.c
> +++ b/net/mac802154/cfg.c
> @@ -103,6 +103,16 @@ ieee802154_set_cca_mode(struct wpan_phy
> *wpan_phy, }
>  
>  static int
> +ieee802154_get_cca_ed_levels(struct wpan_phy *wpan_phy, s32 *dbm,
> u32 idx) +{
> +	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
> +
> +	ASSERT_RTNL();
> +
> +	return drv_get_cca_ed_levels(local, dbm, idx);
> +}
> +
> +static int
>  ieee802154_get_tx_powers(struct wpan_phy *wpan_phy, s8 *dbm, u32 idx)
>  {
>  	struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
> @@ -203,6 +213,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,
> diff --git a/net/mac802154/driver-ops.h b/net/mac802154/driver-ops.h
> index 08e2b09..323da5c 100644
> --- a/net/mac802154/driver-ops.h
> +++ b/net/mac802154/driver-ops.h
> @@ -120,6 +120,18 @@ drv_set_cca_ed_level(struct ieee802154_local
> *local, s32 ed_level) return local->ops->set_cca_ed_level(&local->hw,
> ed_level); }
>  
> +static inline int
> +drv_get_cca_ed_levels(struct ieee802154_local *local, s32 *dbm, 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, dbm, idx);
> +}
> +
>  static inline int drv_set_pan_id(struct ieee802154_local *local,
> __le16 pan_id) {
>  	struct ieee802154_hw_addr_filt filt;


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers
  2015-04-27 11:49   ` Phoebe Buckheister
@ 2015-04-29  9:07     ` Alexander Aring
  0 siblings, 0 replies; 26+ messages in thread
From: Alexander Aring @ 2015-04-29  9:07 UTC (permalink / raw)
  To: Phoebe Buckheister; +Cc: linux-wpan, kernel

Hi Phoebe,

On Mon, Apr 27, 2015 at 01:49:32PM +0200, Phoebe Buckheister wrote:
> On Thu, 23 Apr 2015 18:47:48 +0200
> Alexander Aring <alex.aring@gmail.com> wrote:
> 
...
> > +	int		(*get_tx_powers)(struct ieee802154_hw
> > *hw, s8 *dbm,
> > +					 u32 idx);
> 
> I suggest you use mBm instead of dBm here, while you're at it anyway.
> Especially since one of your later patches will add incorrect values
> because dBm isn't accurate enough for what the transceiver support
> (rf230, TX power +3.4dBm). This would also make the value-2 return you
> have right now unnecessary.
> 

The 802.15.4 standard describes in the phy pib for tx power:

attr: phyTXPower
type: signed integer
range: -
describtion: The transmit power of the device in dBm.

I mentioned in my previous mail that this doesn't repsonse the reality
because there are transceivers outside which supports tx power in dbm
which are not signed integer, like +3.4 dbm.

Nevertheless I would say forget that what the PIB says, we do what the
reality does now. (In my previous mail I was another opinion because the
current type is s8). I think we should not do that now, because we get
trouble later, this is what you mentioned now and I agree.


Plan to implement the mbm:

1. change current tx power to S32 instead s8.
   I gave it a try phy dump with iwpan still works, (not ends in a
   critical error), so I will change it.

2. the kernelside use mbm everywhere the userspace side kann convert the
   dbm values to mbm then with a calculation "dbm = mbm / 100" and
   "mbm = dbm * 100".

   Some helper marcos like:
   #define DBM_TO_MBM(gain) ((int)(((float)gain) * 100))
   #define MBM_TO_DBM(gain) ((float)(gain) / 100)

Examples
   MBM    | DBM
   +230   | +2.3
   -280   | -2.8
   ...    | ....

Thanks, for the review.

- Alex

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2015-04-29  9:07 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-23 16:47 [RFC bluetooth-next 00/15] ieee802154: add support for phy capabilities Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 01/15] nl802154: cleanup invalid argument handling Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 02/15] at86rf230: remove tabs after define Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 03/15] ieee802154: move validation check out of softmac Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 04/15] mac802154: check for really changes Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 05/15] mac802154: remove check if operation is supported Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 06/15] ieee802154: introduce wpan_phy_supported Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 07/15] ieee802154: add several phy supported handling Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 08/15] ieee802154: add iftypes capability Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 09/15] ieee802154: add support for get tx powers Alexander Aring
2015-04-27 11:49   ` Phoebe Buckheister
2015-04-29  9:07     ` Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 10/15] ieee802154: add support for get cca ed levels Alexander Aring
2015-04-27 11:50   ` Phoebe Buckheister
2015-04-23 16:47 ` [RFC bluetooth-next 11/15] at86rf230: set cca_modes supported flags Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 12/15] at86rf230: add reset states of tx power level Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 13/15] at86rf230: rework tx power support Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 14/15] at86rf230: rework tx cca energy detection level Alexander Aring
2015-04-23 16:47 ` [RFC bluetooth-next 15/15] nl802154: add support for dump phy capabilities Alexander Aring
2015-04-24  4:43   ` Varka Bhadram
2015-04-25  6:47     ` Alexander Aring
2015-04-24  3:38 ` [RFC bluetooth-next 00/15] ieee802154: add support for " Varka Bhadram
2015-04-24  5:11   ` Varka Bhadram
2015-04-25 10:06     ` Alexander Aring
2015-04-27  6:51       ` Varka Bhadram
2015-04-25  6:48   ` Alexander Aring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.