Skip to content

Conversation

bergzand
Copy link
Member

Contribution description

This PR adds a number of configuration flags to ieee802154.h similar to the current default PANID and CHANNEL define. This allows for configuring the AUTOACK, ACK_REQ and CSMA flag at compile time.

Except for Openthread, the current set of supported network stacks are updated to set these flags on interface initialization.

Issues/PRs references

  • None

Testing

samr21-xpro

Remove L81-L83 from the at86rf2xx driver to prevent it from setting its own default. Also keep in mind that there is the issue piggybacked with #9581 where modifying the AUTOACK flag influences the ACK_REQ flag.

Other radios

The other radios have different defaults enabled in their reset functions which should be removed to effectively test this PR.

Known issues

  • For some reason the AUTOACK flag is always enabled on the at86rf2xx independent of the settings provided in this PR, I haven't tested yet if the other radios are also affected, but it could be a default setting from the radio hardware itself.

  • I don't really like the code duplication between the stack initialization functions but at the moment I don't know a nice place to put a common settings init function

  • @jia200x Does OpenThread require any specific flags from the network interface to function, does it make sense to honor the settings provided at compile time as much as possible except for any flags strictly required?

@bergzand bergzand added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports GNRC labels Jul 18, 2018
@bergzand
Copy link
Member Author

As a follow up I'd like to extend this to also set the channel and PAN ID this way.

Copy link
Member

@jnohlgard jnohlgard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the general idea. Only checked the gnrc code change.
Maybe there should be some ifdef for removing the dead code if we are building an application without 802.15.4 (e.g. Ethernet only), to reduce the rom usage

@@ -1226,6 +1226,29 @@ static void _init_from_device(gnrc_netif_t *netif)
_update_l2addr_from_dev(netif);
}

static void _configure_netdev_802154(netdev_t *dev)
{
netopt_enable_t enable = NETOPT_ENABLE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this static const to reduce stack usage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

switch(dev_type) {
case NETDEV_TYPE_IEEE802154:
_configure_netdev_802154(dev);
break;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there should be some ifdef for removing the dead code if we are building an application without 802.15.4 (e.g. Ethernet only), to reduce the rom usage

I can put a #ifdef MODULE_NETDEV_IEEE802154 around the case here and the configuration function above.

@bergzand
Copy link
Member Author

@gebart fixed! I've also added an ifdef around the config in LwIP. I've used MODULE_LWIP_SIXLOWPAN there as it was already used as guards around 802.15.4 specific code

@miri64
Copy link
Member

miri64 commented Jul 18, 2018

I actually already dislike the ifdefing in the current gnrc_netif.c and will cause more problems for new device types with similar but not equal options. Maybe this can also be put into the init function of the netdev_data layer?

@bergzand
Copy link
Member Author

I actually already dislike the ifdefing in the current gnrc_netif.c

Yeah, I agree with this.

Maybe this can also be put into the init function of the netdev_data layer?

What exactly is the netdev_data layer here?

I strongly prefer to keep the initialization of the device settings outside of netdev. When we have the layered netdev approach, it can be dangerous to set netopt settings halfway the stack. Layers on top of the layer enabling settings might have to be aware of settings that get enabled/disabled or have to mask certain settings for lower layers.

For example a software "AUTOACK" layer would have to be aware of enabling or disabling the NETOPT_AUTOACK flag.

Maybe we can move this to the gnrc_netif_ieee802154.c somehow.

@miri64
Copy link
Member

miri64 commented Jul 18, 2018

Agreed :-/

@bergzand
Copy link
Member Author

@miri64 I've moved the flag setters for gnrc to a new (but already supported) init function for gnrc_netif_ieee802154.

@miri64
Copy link
Member

miri64 commented Aug 24, 2018

I just tested it. My expectation would be that if I set IEEE802154_DEFAULT_ENABLE_ACK_REQ=0 that ACK_REQ would be disabled on start-up. However, the current behavior seems to be "leave it to the device". Is that intended?

@miri64
Copy link
Member

miri64 commented Sep 25, 2018

However, the current behavior seems to be "leave it to the device". Is that intended?

@bergzand ping?

@miri64 miri64 self-assigned this Sep 25, 2018
@bergzand
Copy link
Member Author

I just tested it. My expectation would be that if I set IEEE802154_DEFAULT_ENABLE_ACK_REQ=0 that ACK_REQ would be disabled on start-up. However, the current behavior seems to be "leave it to the device". Is that intended?

It was originally intended. For now it is probably better to enable/disable every setting the way it is defined.

In the long I'd like to remove the mix of flag settings from each device and only enable the flags required/configured by the network stack.

@miri64
Copy link
Member

miri64 commented Sep 29, 2018

It was originally intended. For now it is probably better to enable/disable every setting the way it is defined.

In the long I'd like to remove the mix of flag settings from each device and only enable the flags required/configured by the network stack.

Ok. That should however be done ASAP after this PR was merged.

@miri64
Copy link
Member

miri64 commented Oct 8, 2018

Ok. That should however be done ASAP after this PR was merged.

Ping @bergzand?

@jia200x
Copy link
Member

jia200x commented Oct 8, 2018

@jia200x Does OpenThread require any specific flags from the network interface to function, does it make sense to honor the settings provided at compile time as much as possible except for any flags strictly required?

There is this function. It ask for the radio capabilities. So, up to a certain level we can specify some flags at compile time and report them to the stack with that function.

Concerning CHANNEL, PANID, etc we might need to think how to integrate them at compile time. We have our own init for OpenThread, so I guess it's possible ;)

@bergzand
Copy link
Member Author

bergzand commented Nov 8, 2018

@jia200x Does OpenThread require any specific flags from the network interface to function, does it make sense to honor the settings provided at compile time as much as possible except for any flags strictly required?

There is this function. It ask for the radio capabilities. So, up to a certain level we can specify some flags at compile time and report them to the stack with that function.

@jia200x But from the set of {ACK_REQ, AUTOACK, CSMA}, is there anything that should always be enable if possible for Openthread to function?

@jia200x
Copy link
Member

jia200x commented Nov 9, 2018

@jia200x But from the set of {ACK_REQ, AUTOACK, CSMA}, is there anything that should always be enable if possible for Openthread to function?

I will check this ASAP. At least I know the ACK_REQ and AUTOACK are required with the current implemetation.

Ping me during the next week if I don't reply :)

This adds support to GNRC for enabling radio flags on device
initialization
This adds support to LwIP for enabling radio flags on device
initialization
This adds support to emb6 for enabling radio flags on device
initialization
ACK_REQ and AUTOACK are always forced on independent of the settings as
Openthread requires that these are enabled.
@bergzand bergzand force-pushed the pr/netdev/default_flags branch from 61d5179 to 84e9b6d Compare November 9, 2018 11:27
@bergzand
Copy link
Member Author

bergzand commented Nov 9, 2018

Rebased and added openthread based on @jia200x current instructions.

@@ -74,6 +76,31 @@ static gnrc_pktsnip_t *_make_netif_hdr(uint8_t *mhr)
return snip;
}

static void _init(gnrc_netif_t *netif)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be called when a NETOPT_STATE_RESET set is done

@bergzand
Copy link
Member Author

bergzand commented Dec 3, 2018

@jia200x More ping!

@jia200x
Copy link
Member

jia200x commented Dec 10, 2018

@bergzand The current OpenThread port assumes:

  • Automatic Ack handling (with CSMA)
  • Ack Timeout event (e.g call to NOACK event)
  • ACK_REQ is enabled.

However most of these features are also implemented by OpenThread (but not used in the RIOT implementation). So, in theory there's no strict requirement on {ACK_REQ, AUTOACK, CSMA} set to make it work. But ACK_REQ should be enabled.

The thing is, otPlatRadioGetCaps should be implemented with netdev->driver->get calls (NETOPT_CSMA, NETOPT_AUTOACK, etc). I plan do it now-ish :)

TL;DR: Let's assume for now only AUTOACK and ACK_REQ are required (I guess it also calls NOACK if failed, doesn't?)

@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@stale stale bot closed this Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: pkg Area: External package ports State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants