-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] at86rf2xx: implement radio HAL #16535
base: master
Are you sure you want to change the base?
Conversation
IIRC this isn't even implemented in current master, so do we have to wait for this additional feature before merging? |
It is :) :#13798 |
Just from a complexity stand-point option two seems more reasonable. From what I understand, option 1 needs (#network stacks ⨉ #network device drivers) abstraction layers and option 2 needs only #network device drivers abstraction layers. I am confused though, that you pointed this out as the drawback of option 2, so I am not sure I am seeing the whole picture. |
then nvm :-) |
Option 2 requires "device drivers ⨉ BH mechanisms". On one side, we are using 4 BH mechanisms (msg_t, event_thread, thread_flags, pure ISR), which is in order with the number of network stacks. On the other side, I think we should slowly try to unify the BH of the drivers to e.g thread_flags or event_thread. In order to be compliant with the IEEE 802.15.4 standard the radios need some kind of determinism, which is hard to achieve with e.g message queues. |
ping @miri64 @maribu @fjmolinas @benpicco regarding the ISR offloading discussion :) |
If it is all the same regarding number of adapter modules, I think from experience it is best to suit the driver side (so that least porting effort is needed for a device driver implementation). There are usually more device drivers incoming than network stacks, so we should keep the workload low there. |
So, this means going with the 2. approach? :) (e.g |
Yes. Maybe we can even simplify that approach for driver devs more by making the BH processor independent of the mechanism used (as I did e.g. for |
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. |
Would be really great to have this as it would allow to use the radio HAL for SPI based radios in addition to memory mapped ones. |
This one needs a rebase |
Contribution description
This (draft) PR implements the Radio HAL interface for
at86rf2xx
. This is the first SPI radio that runs the Radio HAL, so I had to adapt some stuff that I would like to discuss with the community (see Discussion).This port is resilient against #11256. After many debugging hours, forcing the radio to PLL_ON before a transition from RX_ON to TX_ON seems to be the only way to prevent the bug described there, since there's a small gap which makes it impossible to detect if there are incoming frames even when:
a) The transceiver state is checked before
request_set_trx_state
b) The function checks if there are pending interrupts for the radio
c) The SHR detection is disabled right before checking a) and b)
The port has been tested against other radio in stressful conditions and it seems to work. There are some pending stuff before it's mergeable:
And of course, it would nice to resolve the discussion presented above.
Discussion
Contrary to netdev, it was decided that the ISR offloading (a.k.a Bottom Half processing) would be independent of the upper layer, since not all radios require ISR processing or some might require a slightly different mechanism (e.g devices with 2 radios).
For radios that require ISR offloading, we need a Bottom Half Processing interface than can indicate there are pending IRQs and be able to process the events. I see 2 patterns that we might follow:
at86rf2xx_irq_handler
: To be implemented by the network stack. This function is called from ISR context and indicates the BH to process the radio events. The argument of this function (e.g pointer to the HAL) is assigned duringat86rf2xx_init
.at86rf2xx_task_handler
: This function process the pending IRQs and calls the Radio HAL CB functions.at86rf2xx_init_evq
or similar to setup the BH.The first approach has the advantage that it can be easily adapted to any network stack specific mechanism, with the cost of a BH implementation for every driver - network stack combination.
The second approach simplifies simplifies bootstrap code of the drivers. We could eventually decouple the initialization of the drivers from the initialization of the network stacks. The price to pay in this case is the fact he implementation of the drivers would be slightly more complex, since each driver has to implement variants of every mechanism. Also, the drivers would be hardcoded to a specific set of BH mechanisms
Opinions on this?
If there's a better way to process the events, please report it :)
Testing procedure
Try
tests/ieee802154_hal
andexamples/gnrc_networking
.I haven't configured the dependencies properly. Therefore it's required to manually include
gnrc_netif_events
andnetdev_ieee802154_submac
forexamples/gnrc_networking
Issues/PRs references
Depends on #16533 and #16534