Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
* [RFC bluetooth-next] nl802154: export supported commands
@ 2015-06-02  5:39 Varka Bhadram
  2015-06-02  6:49 ` Alexander Aring
  0 siblings, 1 reply; 2+ messages in thread
From: Varka Bhadram @ 2015-06-02  5:39 UTC (permalink / raw)
  To: linux-wpan; +Cc: alex.aring, Varka Bhadram

This patch will export the supported commands by the devices
to the user. This is required because user should know supported
commands by the IEEE-802.15.4 devices. Drivers that are there in
the mainline are not supporting all the functionalities that the
core is providing to us.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
Hi,

I am looking for the way to export the following commands
	o NL802154_CMD_SET_MAX_FRAME_RETRIES
        o NL802154_CMD_SET_BACKOFF_EXPONENT
        o NL802154_CMD_SET_MAX_CSMA_BACKOFFS

Any inputs..?

Thanks,
Varka Bhadram.

 include/net/nl802154.h    |    2 ++
 net/ieee802154/nl802154.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/net/nl802154.h b/include/net/nl802154.h
index 0badebd..6fc231e 100644
--- a/include/net/nl802154.h
+++ b/include/net/nl802154.h
@@ -102,6 +102,8 @@ enum nl802154_attrs {
 
 	NL802154_ATTR_WPAN_PHY_CAPS,
 
+	NL802154_ATTR_SUPPORTED_COMMANDS,
+
 	/* add attributes here, update the policy in nl802154.c */
 
 	__NL802154_ATTR_AFTER_LAST,
diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index 7dbb1f4..29e1ecd 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -372,7 +372,9 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,
 				  struct sk_buff *msg, u32 portid, u32 seq,
 				  int flags)
 {
+	struct nlattr *nl_cmds;
 	void *hdr;
+	int i;
 
 	hdr = nl802154hdr_put(msg, portid, seq, flags, cmd);
 	if (!hdr)
@@ -431,6 +433,37 @@ static int nl802154_send_wpan_phy(struct cfg802154_registered_device *rdev,
 	if (nl802154_put_capabilities(msg, rdev))
 		goto nla_put_failure;
 
+	nl_cmds = nla_nest_start(msg, NL802154_ATTR_SUPPORTED_COMMANDS);
+	if (!nl_cmds)
+		goto nla_put_failure;
+
+	i = 0;
+#define CMD(op, n)							\
+	do {								\
+		if (rdev->ops->op) {					\
+			i++;						\
+			if (nla_put_u32(msg, i, NL802154_CMD_ ## n))	\
+				goto nla_put_failure;			\
+		}							\
+	} while (0)
+
+	CMD(add_virtual_intf, NEW_INTERFACE);
+	CMD(del_virtual_intf, DEL_INTERFACE);
+	CMD(set_channel, SET_CHANNEL);
+	CMD(set_pan_id, SET_PAN_ID);
+	CMD(set_short_addr, SET_SHORT_ADDR);
+
+	if (rdev->wpan_phy.flags & WPAN_PHY_FLAG_TXPOWER)
+		CMD(set_tx_power, SET_TX_POWER);
+
+	if (rdev->wpan_phy.flags & WPAN_PHY_FLAG_CCA_ED_LEVEL)
+		CMD(set_cca_ed_level, SET_CCA_ED_LEVEL);
+
+	if (rdev->wpan_phy.flags & WPAN_PHY_FLAG_CCA_MODE)
+		CMD(set_cca_mode, SET_CCA_MODE);
+#undef CMD
+	nla_nest_end(msg, nl_cmds);
+
 finish:
 	genlmsg_end(msg, hdr);
 	return 0;
-- 
1.7.9.5


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

* Re: [RFC bluetooth-next] nl802154: export supported commands
  2015-06-02  5:39 [RFC bluetooth-next] nl802154: export supported commands Varka Bhadram
@ 2015-06-02  6:49 ` Alexander Aring
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Aring @ 2015-06-02  6:49 UTC (permalink / raw)
  To: Varka Bhadram; +Cc: linux-wpan, Varka Bhadram

On Tue, Jun 02, 2015 at 11:09:59AM +0530, Varka Bhadram wrote:
> This patch will export the supported commands by the devices
> to the user. This is required because user should know supported
> commands by the IEEE-802.15.4 devices. Drivers that are there in
> the mainline are not supporting all the functionalities that the
> core is providing to us.
> 
> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> ---
> Hi,
> 
> I am looking for the way to export the following commands
> 	o NL802154_CMD_SET_MAX_FRAME_RETRIES
>         o NL802154_CMD_SET_BACKOFF_EXPONENT
>         o NL802154_CMD_SET_MAX_CSMA_BACKOFFS
> 
> Any inputs..?
> 

These commands are always supported. If a driver doesn't support it,
indicated by the hw flags, then we assume 802.15.4 defaults.

If you driver doesn't fit to the 802.15.4 you need to change it,
otherwise it's a bug in your driver.

It's a little bit more complex, the backoffs and backoffs exponent depends
if max frame retries supports values above or equal 0. But then you should
assume the 802.15.4 defaults for these values if your transceiver supports
"-1" only.

These parameters above are for the MAC settings of 802.15.4 and the
802.15.4 standard describes for each a "default parameter". It's very
simple, if the driver doesn't tell anything we assume these defaults
parameters and you can't set your transceiver outside of this parameter
via nl802154.


PHY settings are different, because 802.15.4 describes no default
settings for PIB attributes. We don't assume nothing here, but is also a
bug inside your driver because you don't support WPAN_PHY_FLAG for e.g.
tx power, because sending without any tx power makes no sense.
Nevertheless the driver doesn't support to ask which one.

The same for CCA handling (when max frame retries are 0 or above, that
actually means CSMA-CA handling).



Now:

On MIB values the 802.15.4 describes default setting, if the driver
doesn't support it we assume "defaults". On PIB values the standard
describes no default values and we assume nothing, it's indicated by the
WPAN_PHY_FLAG if the driver supports to ask the current setting or not.

But also on phy settings (TX_POWER, CCA_MODE (CCA_ED_LEVEL depends if
the right CCA_MODE is supported)), but this _sometimes_ (in case of tx
power _always_) doesn't represent the reality. A phy which transmit has
always some tx power setting.

- Alex

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

end of thread, other threads:[~2015-06-02  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02  5:39 [RFC bluetooth-next] nl802154: export supported commands Varka Bhadram
2015-06-02  6:49 ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox