linux-wpan.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC bluetooth-next 0/4] ieee802154: aret handling changes
@ 2015-07-26 21:17 Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 1/4] ieee802154: add helpers for frame control checks Alexander Aring
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Alexander Aring @ 2015-07-26 21:17 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

Hi,

this patch series contains a RFC for changing the max_frame_retries behaviour.
The current behaviour is that we allow a range from -1 until 7 (802.15.4
standard describes a range from 0 until 7 only). Nevertheless for historical
reason we have the "-1" value, which describes no aret handling.

The point is when the ack request bit is set inside the mac header the
transceiver need to handle the ack somehow, this is mostly the aret mode
which is done by hardware. Instead to having this as mac setting which doesn't
allow a change during interface up, we simple do this handling per frame
indicated by the ack request bit.

Instead of max_frame_retries "-1" value which could be useful for making a
default ack request bit handling if no information is given if it should be
set or not, we have now the ack request default entry inside the mib.

This could be useful for the 6LoWPAN stack which have this as default
behaviour for data frames.

- Alex

Alexander Aring (4):
  ieee802154: add helpers for frame control checks
  at86rf230: use aret mode if ackreq is set while xmit
  mac802154: change max_frame_retries behaviour
  ieee802154: add ack request default handling

 drivers/net/ieee802154/at86rf230.c | 11 +++++++----
 include/linux/ieee802154.h         | 31 +++++++++++++++++++++++++++++++
 include/net/cfg802154.h            |  5 +++++
 include/net/nl802154.h             |  4 ++++
 net/ieee802154/6lowpan/tx.c        |  2 +-
 net/ieee802154/nl802154.c          | 33 +++++++++++++++++++++++++++++++++
 net/ieee802154/rdev-ops.h          | 13 +++++++++++++
 net/ieee802154/trace.h             | 19 +++++++++++++++++++
 net/mac802154/cfg.c                | 14 ++++++++++++++
 net/mac802154/iface.c              |  3 +--
 net/mac802154/main.c               |  9 +++------
 11 files changed, 131 insertions(+), 13 deletions(-)

-- 
2.4.6


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

* [RFC bluetooth-next 1/4] ieee802154: add helpers for frame control checks
  2015-07-26 21:17 [RFC bluetooth-next 0/4] ieee802154: aret handling changes Alexander Aring
@ 2015-07-26 21:17 ` Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit Alexander Aring
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2015-07-26 21:17 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch introduce two static inline functions. The first to get the
frame control field from an sk_buff. The second is for checking on the
acknowledgment request bit on the frame control field. Later we can
introduce more functions to check on the frame control fields.

These will deprecate the current behaviour which requires a
host-byteorder conversion and manually bit handling.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/linux/ieee802154.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 1dc1f4e..a0b16a5 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -25,6 +25,7 @@
 
 #include <linux/types.h>
 #include <linux/random.h>
+#include <linux/skbuff.h>
 #include <asm/byteorder.h>
 
 #define IEEE802154_MTU			127
@@ -205,6 +206,36 @@ enum {
 	IEEE802154_SCAN_IN_PROGRESS = 0xfc,
 };
 
+/* frame control handling */
+#define IEEE802154_FCTL_ACKREQ	0x0020
+
+/**
+ * ieee802154_is_ackreq - check if acknowledgment request bit is set
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline bool ieee802154_is_ackreq(__le16 fc)
+{
+	return (fc & cpu_to_le16(IEEE802154_FCTL_ACKREQ));
+}
+
+/**
+ * ieee802154_get_fc_from_skb - get the frame control field from an skb
+ * @skb: skb where the frame control field will be get from
+ */
+static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
+{
+	__le16 fc;
+
+	/* return some invalid fc on failure */
+	if (unlikely(skb->mac_len < 2)) {
+		WARN_ON(1);
+		return cpu_to_le16(0);
+	}
+
+	memcpy(&fc, skb_mac_header(skb), sizeof(fc));
+	return fc;
+}
+
 /**
  * ieee802154_is_valid_psdu_len - check if psdu len is valid
  * available lengths:
-- 
2.4.6


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

* [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit
  2015-07-26 21:17 [RFC bluetooth-next 0/4] ieee802154: aret handling changes Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 1/4] ieee802154: add helpers for frame control checks Alexander Aring
@ 2015-07-26 21:17 ` Alexander Aring
  2015-07-26 21:27   ` Alexander Aring
  2015-07-26 21:57   ` Phoebe Buckheister
  2015-07-26 21:17 ` [RFC bluetooth-next 3/4] mac802154: change max_frame_retries behaviour Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 4/4] ieee802154: add ack request default handling Alexander Aring
  3 siblings, 2 replies; 8+ messages in thread
From: Alexander Aring @ 2015-07-26 21:17 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch does a different aret mode handling. We will drop the
max_frame_retries "-1" value and check on the ack request bit while
xmit. If it's set we doing transmit in aret mode. If it's not set we
doing a transmit in normal tx mode.

This allows a mixed aret and non aret mode while interface is up and
doesn't depends on the max_frame_retries value inside the mib.

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

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index f7bd9f3..3aac100 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -99,7 +99,6 @@ struct at86rf230_local {
 
 	bool tx_aret;
 	unsigned long cal_timeout;
-	s8 max_frame_retries;
 	bool is_tx;
 	bool is_tx_from_off;
 	u8 tx_retry;
@@ -900,10 +899,17 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
 {
 	struct at86rf230_local *lp = hw->priv;
 	struct at86rf230_state_change *ctx = &lp->tx;
+	__le16 fc;
 
 	lp->tx_skb = skb;
 	lp->tx_retry = 0;
 
+	fc = ieee802154_get_fc_from_skb(skb);
+	if (ieee802154_is_ackreq(fc))
+		lp->tx_aret = true;
+	else
+		lp->tx_aret = false;
+
 	/* After 5 minutes in PLL and the same frequency we run again the
 	 * calibration loops which is recommended by at86rf2xx datasheets.
 	 *
@@ -1267,9 +1273,6 @@ at86rf230_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
 	struct at86rf230_local *lp = hw->priv;
 	int rc = 0;
 
-	lp->tx_aret = retries >= 0;
-	lp->max_frame_retries = retries;
-
 	if (retries >= 0)
 		rc = at86rf230_write_subreg(lp, SR_MAX_FRAME_RETRIES, retries);
 
-- 
2.4.6


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

* [RFC bluetooth-next 3/4] mac802154: change max_frame_retries behaviour
  2015-07-26 21:17 [RFC bluetooth-next 0/4] ieee802154: aret handling changes Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 1/4] ieee802154: add helpers for frame control checks Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit Alexander Aring
@ 2015-07-26 21:17 ` Alexander Aring
  2015-07-26 21:17 ` [RFC bluetooth-next 4/4] ieee802154: add ack request default handling Alexander Aring
  3 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2015-07-26 21:17 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch changes the default min value of max_frame_retries to 0 and
changes the max_frame_retries default value to 3 which is also 802.15.4
default.

We don't use max_frame_retries "-1" as indicator for no-aret mode
anymore, instead we checking on the ack request bit inside the 802.15.4
frame control field.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 net/mac802154/iface.c | 3 +--
 net/mac802154/main.c  | 9 +++------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 416de90..8837c5a 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -483,8 +483,7 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
 	wpan_dev->min_be = 3;
 	wpan_dev->max_be = 5;
 	wpan_dev->csma_retries = 4;
-	/* for compatibility, actual default is 3 */
-	wpan_dev->frame_retries = -1;
+	wpan_dev->frame_retries = 3;
 
 	wpan_dev->pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
 	wpan_dev->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 91f1208..6e1764b 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -109,7 +109,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
 	phy->supported.max_minbe = 8;
 	phy->supported.min_maxbe = 3;
 	phy->supported.max_maxbe = 8;
-	phy->supported.min_frame_retries = -1;
+	phy->supported.min_frame_retries = 0;
 	phy->supported.max_frame_retries = 7;
 	phy->supported.max_csma_backoffs = 5;
 	phy->supported.lbt = NL802154_SUPPORTED_BOOL_FALSE;
@@ -175,11 +175,8 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
 	}
 
 	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;
+		local->phy->supported.min_frame_retries = 3;
+		local->phy->supported.max_frame_retries = 3;
 	}
 
 	if (hw->flags & IEEE802154_HW_PROMISCUOUS)
-- 
2.4.6


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

* [RFC bluetooth-next 4/4] ieee802154: add ack request default handling
  2015-07-26 21:17 [RFC bluetooth-next 0/4] ieee802154: aret handling changes Alexander Aring
                   ` (2 preceding siblings ...)
  2015-07-26 21:17 ` [RFC bluetooth-next 3/4] mac802154: change max_frame_retries behaviour Alexander Aring
@ 2015-07-26 21:17 ` Alexander Aring
  2015-07-26 22:01   ` Phoebe Buckheister
  3 siblings, 1 reply; 8+ messages in thread
From: Alexander Aring @ 2015-07-26 21:17 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch introduce a new mib entry which isn't part of 802.15.4 but
useful as default behaviour to set the ack request bit or not if we
don't know if the ack request bit should set. This is currently used for
stacks like IEEE 802.15.4 6LoWPAN.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/net/cfg802154.h     |  5 +++++
 include/net/nl802154.h      |  4 ++++
 net/ieee802154/6lowpan/tx.c |  2 +-
 net/ieee802154/nl802154.c   | 33 +++++++++++++++++++++++++++++++++
 net/ieee802154/rdev-ops.h   | 13 +++++++++++++
 net/ieee802154/trace.h      | 19 +++++++++++++++++++
 net/mac802154/cfg.c         | 14 ++++++++++++++
 7 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 382f94b..21353f8 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -63,6 +63,8 @@ struct cfg802154_ops {
 					 s8 max_frame_retries);
 	int	(*set_lbt_mode)(struct wpan_phy *wpan_phy,
 				struct wpan_dev *wpan_dev, bool mode);
+	int	(*set_ackreq_default)(struct wpan_phy *wpan_phy,
+				      struct wpan_dev *wpan_dev, bool ackreq);
 };
 
 static inline bool
@@ -193,6 +195,9 @@ struct wpan_dev {
 	bool lbt;
 
 	bool promiscuous_mode;
+
+	/* fallback for acknowledgment bit setting */
+	bool ackreq;
 };
 
 #define to_phy(_dev)	container_of(_dev, struct wpan_phy, dev)
diff --git a/include/net/nl802154.h b/include/net/nl802154.h
index b0ab530..cf2713d 100644
--- a/include/net/nl802154.h
+++ b/include/net/nl802154.h
@@ -52,6 +52,8 @@ enum nl802154_commands {
 
 	NL802154_CMD_SET_LBT_MODE,
 
+	NL802154_CMD_SET_ACKREQ_DEFAULT,
+
 	/* add new commands above here */
 
 	/* used to define NL802154_CMD_MAX below */
@@ -104,6 +106,8 @@ enum nl802154_attrs {
 
 	NL802154_ATTR_SUPPORTED_COMMANDS,
 
+	NL802154_ATTR_ACKREQ_DEFAULT,
+
 	/* add attributes here, update the policy in nl802154.c */
 
 	__NL802154_ATTR_AFTER_LAST,
diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
index 2597abb..1bf4a30 100644
--- a/net/ieee802154/6lowpan/tx.c
+++ b/net/ieee802154/6lowpan/tx.c
@@ -224,7 +224,7 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *dev)
 	} else {
 		da.mode = IEEE802154_ADDR_LONG;
 		da.extended_addr = ieee802154_devaddr_from_raw(daddr);
-		cb->ackreq = wpan_dev->frame_retries >= 0;
+		cb->ackreq = wpan_dev->ackreq;
 	}
 
 	return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 68f2401..1b00a14 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -230,6 +230,8 @@ static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX+1] = {
 	[NL802154_ATTR_WPAN_PHY_CAPS] = { .type = NLA_NESTED },
 
 	[NL802154_ATTR_SUPPORTED_COMMANDS] = { .type = NLA_NESTED },
+
+	[NL802154_ATTR_ACKREQ_DEFAULT] = { .type = NLA_U8 },
 };
 
 /* message building helper */
@@ -458,6 +460,7 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,
 	CMD(set_max_csma_backoffs, SET_MAX_CSMA_BACKOFFS);
 	CMD(set_max_frame_retries, SET_MAX_FRAME_RETRIES);
 	CMD(set_lbt_mode, SET_LBT_MODE);
+	CMD(set_ackreq_default, SET_ACKREQ_DEFAULT);
 
 	if (rdev->wpan_phy.flags & WPAN_PHY_FLAG_TXPOWER)
 		CMD(set_tx_power, SET_TX_POWER);
@@ -656,6 +659,10 @@ nl802154_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags,
 	if (nla_put_u8(msg, NL802154_ATTR_LBT_MODE, wpan_dev->lbt))
 		goto nla_put_failure;
 
+	/* ackreq default behaviour */
+	if (nla_put_u8(msg, NL802154_ATTR_ACKREQ_DEFAULT, wpan_dev->ackreq))
+		goto nla_put_failure;
+
 	genlmsg_end(msg, hdr);
 	return 0;
 
@@ -1042,6 +1049,24 @@ static int nl802154_set_lbt_mode(struct sk_buff *skb, struct genl_info *info)
 	return rdev_set_lbt_mode(rdev, wpan_dev, mode);
 }
 
+static int
+nl802154_set_ackreq_default(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg802154_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
+	bool ackreq;
+
+	if (netif_running(dev))
+		return -EBUSY;
+
+	if (!info->attrs[NL802154_ATTR_ACKREQ_DEFAULT])
+		return -EINVAL;
+
+	ackreq = !!nla_get_u8(info->attrs[NL802154_ATTR_ACKREQ_DEFAULT]);
+	return rdev_set_ackreq_default(rdev, wpan_dev, ackreq);
+}
+
 #define NL802154_FLAG_NEED_WPAN_PHY	0x01
 #define NL802154_FLAG_NEED_NETDEV	0x02
 #define NL802154_FLAG_NEED_RTNL		0x04
@@ -1248,6 +1273,14 @@ static const struct genl_ops nl802154_ops[] = {
 		.internal_flags = NL802154_FLAG_NEED_NETDEV |
 				  NL802154_FLAG_NEED_RTNL,
 	},
+	{
+		.cmd = NL802154_CMD_SET_ACKREQ_DEFAULT,
+		.doit = nl802154_set_ackreq_default,
+		.policy = nl802154_policy,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = NL802154_FLAG_NEED_NETDEV |
+				  NL802154_FLAG_NEED_RTNL,
+	},
 };
 
 /* initialisation/exit functions */
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
index 8d5960a..03b3575 100644
--- a/net/ieee802154/rdev-ops.h
+++ b/net/ieee802154/rdev-ops.h
@@ -195,4 +195,17 @@ rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
 	return ret;
 }
 
+static inline int
+rdev_set_ackreq_default(struct cfg802154_registered_device *rdev,
+			struct wpan_dev *wpan_dev, bool ackreq)
+{
+	int ret;
+
+	trace_802154_rdev_set_ackreq_default(&rdev->wpan_phy, wpan_dev,
+					     ackreq);
+	ret = rdev->ops->set_ackreq_default(&rdev->wpan_phy, wpan_dev, ackreq);
+	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
+	return ret;
+}
+
 #endif /* __CFG802154_RDEV_OPS */
diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
index 4399b7f..9a471e4 100644
--- a/net/ieee802154/trace.h
+++ b/net/ieee802154/trace.h
@@ -275,6 +275,25 @@ TRACE_EVENT(802154_rdev_set_lbt_mode,
 		WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode))
 );
 
+TRACE_EVENT(802154_rdev_set_ackreq_default,
+	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
+		 bool ackreq),
+	TP_ARGS(wpan_phy, wpan_dev, ackreq),
+	TP_STRUCT__entry(
+		WPAN_PHY_ENTRY
+		WPAN_DEV_ENTRY
+		__field(bool, ackreq)
+	),
+	TP_fast_assign(
+		WPAN_PHY_ASSIGN;
+		WPAN_DEV_ASSIGN;
+		__entry->ackreq = ackreq;
+	),
+	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
+		", ackreq default: %s", WPAN_PHY_PR_ARG,
+		WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->ackreq))
+);
+
 TRACE_EVENT(802154_rdev_return_int,
 	TP_PROTO(struct wpan_phy *wpan_phy, int ret),
 	TP_ARGS(wpan_phy, ret),
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index f7ba51e..5e419b3 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -272,6 +272,19 @@ ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
 	return 0;
 }
 
+static int
+ieee802154_set_ackreq_default(struct wpan_phy *wpan_phy,
+			      struct wpan_dev *wpan_dev, bool ackreq)
+{
+	ASSERT_RTNL();
+
+	if (wpan_dev->ackreq == ackreq)
+		return 0;
+
+	wpan_dev->ackreq = ackreq;
+	return 0;
+}
+
 const struct cfg802154_ops mac802154_config_ops = {
 	.add_virtual_intf_deprecated = ieee802154_add_iface_deprecated,
 	.del_virtual_intf_deprecated = ieee802154_del_iface_deprecated,
@@ -289,4 +302,5 @@ const struct cfg802154_ops mac802154_config_ops = {
 	.set_max_csma_backoffs = ieee802154_set_max_csma_backoffs,
 	.set_max_frame_retries = ieee802154_set_max_frame_retries,
 	.set_lbt_mode = ieee802154_set_lbt_mode,
+	.set_ackreq_default = ieee802154_set_ackreq_default,
 };
-- 
2.4.6


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

* Re: [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit
  2015-07-26 21:17 ` [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit Alexander Aring
@ 2015-07-26 21:27   ` Alexander Aring
  2015-07-26 21:57   ` Phoebe Buckheister
  1 sibling, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2015-07-26 21:27 UTC (permalink / raw)
  To: linux-wpan

On Sun, Jul 26, 2015 at 11:17:29PM +0200, Alexander Aring wrote:
> This patch does a different aret mode handling. We will drop the
> max_frame_retries "-1" value and check on the ack request bit while
> xmit. If it's set we doing transmit in aret mode. If it's not set we
> doing a transmit in normal tx mode.
> 
> This allows a mixed aret and non aret mode while interface is up and
> doesn't depends on the max_frame_retries value inside the mib.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  drivers/net/ieee802154/at86rf230.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
> index f7bd9f3..3aac100 100644
> --- a/drivers/net/ieee802154/at86rf230.c
> +++ b/drivers/net/ieee802154/at86rf230.c
> @@ -99,7 +99,6 @@ struct at86rf230_local {
>  
>  	bool tx_aret;
>  	unsigned long cal_timeout;
> -	s8 max_frame_retries;
>  	bool is_tx;
>  	bool is_tx_from_off;
>  	u8 tx_retry;
> @@ -900,10 +899,17 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
>  {
>  	struct at86rf230_local *lp = hw->priv;
>  	struct at86rf230_state_change *ctx = &lp->tx;
> +	__le16 fc;
>  
>  	lp->tx_skb = skb;
>  	lp->tx_retry = 0;
>  
> +	fc = ieee802154_get_fc_from_skb(skb);
> +	if (ieee802154_is_ackreq(fc))
> +		lp->tx_aret = true;
> +	else
> +		lp->tx_aret = false;

doh, I should use here:

lp->tx_aret = ieee802154_is_ackreq(fc);

Anyway it's a RFC only and comments are welcome. ;-)

- Alex

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

* Re: [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit
  2015-07-26 21:17 ` [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit Alexander Aring
  2015-07-26 21:27   ` Alexander Aring
@ 2015-07-26 21:57   ` Phoebe Buckheister
  1 sibling, 0 replies; 8+ messages in thread
From: Phoebe Buckheister @ 2015-07-26 21:57 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan

On Sun, July 26, 2015 11:17 pm, Alexander Aring wrote:
> This patch does a different aret mode handling. We will drop the
> max_frame_retries "-1" value and check on the ack request bit while
> xmit. If it's set we doing transmit in aret mode. If it's not set we
> doing a transmit in normal tx mode.
>
> This allows a mixed aret and non aret mode while interface is up and
> doesn't depends on the max_frame_retries value inside the mib.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  drivers/net/ieee802154/at86rf230.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ieee802154/at86rf230.c
> b/drivers/net/ieee802154/at86rf230.c
> index f7bd9f3..3aac100 100644
> --- a/drivers/net/ieee802154/at86rf230.c
> +++ b/drivers/net/ieee802154/at86rf230.c
> @@ -99,7 +99,6 @@ struct at86rf230_local {
>
>  	bool tx_aret;
>  	unsigned long cal_timeout;
> -	s8 max_frame_retries;
>  	bool is_tx;
>  	bool is_tx_from_off;
>  	u8 tx_retry;
> @@ -900,10 +899,17 @@ at86rf230_xmit(struct ieee802154_hw *hw, struct
> sk_buff *skb)
>  {
>  	struct at86rf230_local *lp = hw->priv;
>  	struct at86rf230_state_change *ctx = &lp->tx;
> +	__le16 fc;
>
>  	lp->tx_skb = skb;
>  	lp->tx_retry = 0;
>
> +	fc = ieee802154_get_fc_from_skb(skb);
> +	if (ieee802154_is_ackreq(fc))
> +		lp->tx_aret = true;
> +	else
> +		lp->tx_aret = false;
> +

ieee802154_get_fc_from_skb returns bool, the if isn't necessary.

>  	/* After 5 minutes in PLL and the same frequency we run again the
>  	 * calibration loops which is recommended by at86rf2xx datasheets.
>  	 *
> @@ -1267,9 +1273,6 @@ at86rf230_set_frame_retries(struct ieee802154_hw
> *hw, s8 retries)
>  	struct at86rf230_local *lp = hw->priv;
>  	int rc = 0;
>
> -	lp->tx_aret = retries >= 0;
> -	lp->max_frame_retries = retries;
> -
>  	if (retries >= 0)
>  		rc = at86rf230_write_subreg(lp, SR_MAX_FRAME_RETRIES, retries);
>
> --
> 2.4.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



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

* Re: [RFC bluetooth-next 4/4] ieee802154: add ack request default handling
  2015-07-26 21:17 ` [RFC bluetooth-next 4/4] ieee802154: add ack request default handling Alexander Aring
@ 2015-07-26 22:01   ` Phoebe Buckheister
  0 siblings, 0 replies; 8+ messages in thread
From: Phoebe Buckheister @ 2015-07-26 22:01 UTC (permalink / raw)
  To: Alexander Aring; +Cc: linux-wpan

On Sun, July 26, 2015 11:17 pm, Alexander Aring wrote:
> This patch introduce a new mib entry which isn't part of 802.15.4 but
> useful as default behaviour to set the ack request bit or not if we
> don't know if the ack request bit should set. This is currently used for
> stacks like IEEE 802.15.4 6LoWPAN.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  include/net/cfg802154.h     |  5 +++++
>  include/net/nl802154.h      |  4 ++++
>  net/ieee802154/6lowpan/tx.c |  2 +-
>  net/ieee802154/nl802154.c   | 33 +++++++++++++++++++++++++++++++++
>  net/ieee802154/rdev-ops.h   | 13 +++++++++++++
>  net/ieee802154/trace.h      | 19 +++++++++++++++++++
>  net/mac802154/cfg.c         | 14 ++++++++++++++
>  7 files changed, 89 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
> index 382f94b..21353f8 100644
> --- a/include/net/cfg802154.h
> +++ b/include/net/cfg802154.h
> @@ -63,6 +63,8 @@ struct cfg802154_ops {
>  					 s8 max_frame_retries);
>  	int	(*set_lbt_mode)(struct wpan_phy *wpan_phy,
>  				struct wpan_dev *wpan_dev, bool mode);
> +	int	(*set_ackreq_default)(struct wpan_phy *wpan_phy,
> +				      struct wpan_dev *wpan_dev, bool ackreq);
>  };
>
>  static inline bool
> @@ -193,6 +195,9 @@ struct wpan_dev {
>  	bool lbt;
>
>  	bool promiscuous_mode;
> +
> +	/* fallback for acknowledgment bit setting */
> +	bool ackreq;
>  };
>
>  #define to_phy(_dev)	container_of(_dev, struct wpan_phy, dev)
> diff --git a/include/net/nl802154.h b/include/net/nl802154.h
> index b0ab530..cf2713d 100644
> --- a/include/net/nl802154.h
> +++ b/include/net/nl802154.h
> @@ -52,6 +52,8 @@ enum nl802154_commands {
>
>  	NL802154_CMD_SET_LBT_MODE,
>
> +	NL802154_CMD_SET_ACKREQ_DEFAULT,
> +
>  	/* add new commands above here */
>
>  	/* used to define NL802154_CMD_MAX below */
> @@ -104,6 +106,8 @@ enum nl802154_attrs {
>
>  	NL802154_ATTR_SUPPORTED_COMMANDS,
>
> +	NL802154_ATTR_ACKREQ_DEFAULT,
> +
>  	/* add attributes here, update the policy in nl802154.c */
>
>  	__NL802154_ATTR_AFTER_LAST,
> diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
> index 2597abb..1bf4a30 100644
> --- a/net/ieee802154/6lowpan/tx.c
> +++ b/net/ieee802154/6lowpan/tx.c
> @@ -224,7 +224,7 @@ static int lowpan_header(struct sk_buff *skb, struct
> net_device *dev)
>  	} else {
>  		da.mode = IEEE802154_ADDR_LONG;
>  		da.extended_addr = ieee802154_devaddr_from_raw(daddr);
> -		cb->ackreq = wpan_dev->frame_retries >= 0;
> +		cb->ackreq = wpan_dev->ackreq;
>  	}
>
>  	return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
> diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
> index 68f2401..1b00a14 100644
> --- a/net/ieee802154/nl802154.c
> +++ b/net/ieee802154/nl802154.c
> @@ -230,6 +230,8 @@ static const struct nla_policy
> nl802154_policy[NL802154_ATTR_MAX+1] = {
>  	[NL802154_ATTR_WPAN_PHY_CAPS] = { .type = NLA_NESTED },
>
>  	[NL802154_ATTR_SUPPORTED_COMMANDS] = { .type = NLA_NESTED },
> +
> +	[NL802154_ATTR_ACKREQ_DEFAULT] = { .type = NLA_U8 },
>  };
>
>  /* message building helper */
> @@ -458,6 +460,7 @@ static int nl802154_send_wpan_phy(struct
> cfg802154_registered_device *rdev,
>  	CMD(set_max_csma_backoffs, SET_MAX_CSMA_BACKOFFS);
>  	CMD(set_max_frame_retries, SET_MAX_FRAME_RETRIES);
>  	CMD(set_lbt_mode, SET_LBT_MODE);
> +	CMD(set_ackreq_default, SET_ACKREQ_DEFAULT);
>
>  	if (rdev->wpan_phy.flags & WPAN_PHY_FLAG_TXPOWER)
>  		CMD(set_tx_power, SET_TX_POWER);
> @@ -656,6 +659,10 @@ nl802154_send_iface(struct sk_buff *msg, u32 portid,
> u32 seq, int flags,
>  	if (nla_put_u8(msg, NL802154_ATTR_LBT_MODE, wpan_dev->lbt))
>  		goto nla_put_failure;
>
> +	/* ackreq default behaviour */
> +	if (nla_put_u8(msg, NL802154_ATTR_ACKREQ_DEFAULT, wpan_dev->ackreq))
> +		goto nla_put_failure;
> +
>  	genlmsg_end(msg, hdr);
>  	return 0;
>
> @@ -1042,6 +1049,24 @@ static int nl802154_set_lbt_mode(struct sk_buff
> *skb, struct genl_info *info)
>  	return rdev_set_lbt_mode(rdev, wpan_dev, mode);
>  }
>
> +static int
> +nl802154_set_ackreq_default(struct sk_buff *skb, struct genl_info *info)
> +{
> +	struct cfg802154_registered_device *rdev = info->user_ptr[0];
> +	struct net_device *dev = info->user_ptr[1];
> +	struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
> +	bool ackreq;
> +
> +	if (netif_running(dev))
> +		return -EBUSY;
> +
> +	if (!info->attrs[NL802154_ATTR_ACKREQ_DEFAULT])
> +		return -EINVAL;
> +
> +	ackreq = !!nla_get_u8(info->attrs[NL802154_ATTR_ACKREQ_DEFAULT]);
> +	return rdev_set_ackreq_default(rdev, wpan_dev, ackreq);
> +}
> +
>  #define NL802154_FLAG_NEED_WPAN_PHY	0x01
>  #define NL802154_FLAG_NEED_NETDEV	0x02
>  #define NL802154_FLAG_NEED_RTNL		0x04
> @@ -1248,6 +1273,14 @@ static const struct genl_ops nl802154_ops[] = {
>  		.internal_flags = NL802154_FLAG_NEED_NETDEV |
>  				  NL802154_FLAG_NEED_RTNL,
>  	},
> +	{
> +		.cmd = NL802154_CMD_SET_ACKREQ_DEFAULT,
> +		.doit = nl802154_set_ackreq_default,
> +		.policy = nl802154_policy,
> +		.flags = GENL_ADMIN_PERM,
> +		.internal_flags = NL802154_FLAG_NEED_NETDEV |
> +				  NL802154_FLAG_NEED_RTNL,
> +	},
>  };
>
>  /* initialisation/exit functions */
> diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
> index 8d5960a..03b3575 100644
> --- a/net/ieee802154/rdev-ops.h
> +++ b/net/ieee802154/rdev-ops.h
> @@ -195,4 +195,17 @@ rdev_set_lbt_mode(struct cfg802154_registered_device
> *rdev,
>  	return ret;
>  }
>
> +static inline int
> +rdev_set_ackreq_default(struct cfg802154_registered_device *rdev,
> +			struct wpan_dev *wpan_dev, bool ackreq)
> +{
> +	int ret;
> +
> +	trace_802154_rdev_set_ackreq_default(&rdev->wpan_phy, wpan_dev,
> +					     ackreq);
> +	ret = rdev->ops->set_ackreq_default(&rdev->wpan_phy, wpan_dev, ackreq);
> +	trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
> +	return ret;
> +}
> +
>  #endif /* __CFG802154_RDEV_OPS */
> diff --git a/net/ieee802154/trace.h b/net/ieee802154/trace.h
> index 4399b7f..9a471e4 100644
> --- a/net/ieee802154/trace.h
> +++ b/net/ieee802154/trace.h
> @@ -275,6 +275,25 @@ TRACE_EVENT(802154_rdev_set_lbt_mode,
>  		WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->mode))
>  );
>
> +TRACE_EVENT(802154_rdev_set_ackreq_default,
> +	TP_PROTO(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
> +		 bool ackreq),
> +	TP_ARGS(wpan_phy, wpan_dev, ackreq),
> +	TP_STRUCT__entry(
> +		WPAN_PHY_ENTRY
> +		WPAN_DEV_ENTRY
> +		__field(bool, ackreq)
> +	),
> +	TP_fast_assign(
> +		WPAN_PHY_ASSIGN;
> +		WPAN_DEV_ASSIGN;
> +		__entry->ackreq = ackreq;
> +	),
> +	TP_printk(WPAN_PHY_PR_FMT ", " WPAN_DEV_PR_FMT
> +		", ackreq default: %s", WPAN_PHY_PR_ARG,
> +		WPAN_DEV_PR_ARG, BOOL_TO_STR(__entry->ackreq))
> +);
> +
>  TRACE_EVENT(802154_rdev_return_int,
>  	TP_PROTO(struct wpan_phy *wpan_phy, int ret),
>  	TP_ARGS(wpan_phy, ret),
> diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
> index f7ba51e..5e419b3 100644
> --- a/net/mac802154/cfg.c
> +++ b/net/mac802154/cfg.c
> @@ -272,6 +272,19 @@ ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy,
> struct wpan_dev *wpan_dev,
>  	return 0;
>  }
>
> +static int
> +ieee802154_set_ackreq_default(struct wpan_phy *wpan_phy,
> +			      struct wpan_dev *wpan_dev, bool ackreq)
> +{
> +	ASSERT_RTNL();
> +
> +	if (wpan_dev->ackreq == ackreq)
> +		return 0;
> +
> +	wpan_dev->ackreq = ackreq;
> +	return 0;

Again, can be a simple assignment.

> +}
> +
>  const struct cfg802154_ops mac802154_config_ops = {
>  	.add_virtual_intf_deprecated = ieee802154_add_iface_deprecated,
>  	.del_virtual_intf_deprecated = ieee802154_del_iface_deprecated,
> @@ -289,4 +302,5 @@ const struct cfg802154_ops mac802154_config_ops = {
>  	.set_max_csma_backoffs = ieee802154_set_max_csma_backoffs,
>  	.set_max_frame_retries = ieee802154_set_max_frame_retries,
>  	.set_lbt_mode = ieee802154_set_lbt_mode,
> +	.set_ackreq_default = ieee802154_set_ackreq_default,
>  };
> --
> 2.4.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



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

end of thread, other threads:[~2015-07-26 22:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-26 21:17 [RFC bluetooth-next 0/4] ieee802154: aret handling changes Alexander Aring
2015-07-26 21:17 ` [RFC bluetooth-next 1/4] ieee802154: add helpers for frame control checks Alexander Aring
2015-07-26 21:17 ` [RFC bluetooth-next 2/4] at86rf230: use aret mode if ackreq is set while xmit Alexander Aring
2015-07-26 21:27   ` Alexander Aring
2015-07-26 21:57   ` Phoebe Buckheister
2015-07-26 21:17 ` [RFC bluetooth-next 3/4] mac802154: change max_frame_retries behaviour Alexander Aring
2015-07-26 21:17 ` [RFC bluetooth-next 4/4] ieee802154: add ack request default handling Alexander Aring
2015-07-26 22:01   ` Phoebe Buckheister

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).