[riot-notifications] [RIOT-OS/RIOT] ieee802154/radio_hal: detach hal descriptor from driver (#16534)

José Alamos notifications at github.com
Mon Jun 7 15:26:17 CEST 2021


<!--
The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.
-->

### Contribution description
This PR re-arranges the Radio HAL descriptor to be allocated outside of the private descriptor of radios.

In our current scheme, we usually allocate the upper layer descritptor (netdev, hal, etc) inside the private descriptor of the driver.
Therefore we assume it's possible to cast the private descriptor to the interface (and back). However, this approach has some disadvantages:

1. It requires more RAM than allocating the HAL descriptor close to the network stack. The upper layer descriptor requires a pointer to the "context" of the upper layer (e.g the radio HAL context points to the SubMAC if used within GNRC). At the same time, the network stack require to store pointers to the HAL descriptor, because the network stack descriptors and the HAL don't share the same location. If the HAL is allocated closed to the network stack (e.g in the SubMAC), only a pointer to the private descriptor is needed. After all, all `ieee802154_rf_ops` functions simply use the HAL descriptor (`ieee802154_dev_t`) to fetch the private descriptor. The upper layer can always retrieve the network stack descriptor if they were allocated together (e.g `container_of(...)`).
2. The relation of HAL <-> descriptor is not one to one. E.g there are devices that implement 2 radios (at86rf215). Therefore we can simplify a lot the code if we allocate one private descriptor and point it from 2 HAL instances.

>From now on, `ieee802154_dev_t`'s `ctx` was renamed to `priv` in order to store the private descriptor of the radios. All Radio HAL functions can access the private descriptor simply following the pointer. Radio events must be boostrapped in order to pass the pointer to the HAL on ISR (this is already done in the current Radio HAL implementations, but it will require to pass the HAL pointer to the args of the ISR in SPI radios).

A follow-up PR with the WIP HAL implementation of at86rf2xx will show this mechanism.
<!--
Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes
-->


### Testing procedure
Make sure all radio HAL radios still work properly (cc2538, nrf52840). Use e.g `examples/gnrc_networking`.
<!--
Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output
-->


### Issues/PRs references
Depends on https://github.com/RIOT-OS/RIOT/pull/16533
<!--
Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
-->

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/16534

-- Commit Summary --

  * ieee802154/submac: fix default SubGHz page
  * ieee802154/submac: call confirm_set_trx_state after initialization
  * netdev_ieee802154_submac: fix initialization code
  * ieee802154/radio_hal: detach hal descriptor from driver

-- File Changes --

    M drivers/include/net/netdev/ieee802154_submac.h (5)
    M drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c (44)
    M sys/include/net/ieee802154/radio.h (4)
    M sys/include/net/ieee802154/submac.h (12)
    M sys/net/link_layer/ieee802154/submac.c (38)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/16534.patch
https://github.com/RIOT-OS/RIOT/pull/16534.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16534
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210607/4a5d597a/attachment-0001.htm>


More information about the notifications mailing list