drivers/cc110x: Adapt cc110x netdev impl to changed rcv event handling#2177
drivers/cc110x: Adapt cc110x netdev impl to changed rcv event handling#2177fnack wants to merge 5 commits intoRIOT-OS:masterfrom
Conversation
…com/authmillenon/RIOT into authmillenon-netdev/api/driver-set_event_handler
There was a problem hiding this comment.
I honestly didn't know what to do with it. Simply check it with
if (dev != &cc110x_dev) {
return;
}
???
That's why I walked the easy way and did exactly the same you did in #1733 ;)
There was a problem hiding this comment.
I thought that, given that your it is the first driver post-introduction of netdev, your driver might support multiple instances of netdev. #1733 is just a wrapper for the old driver architecture (because I was lazy, yes ^^).
There was a problem hiding this comment.
I haven't really understood yet what the benefits of having multiple netdev "instances" are? Could you explain this with a proper use-case?
There was a problem hiding this comment.
Imagine a board with two cc110x interfaces on different frequencies or channels.
|
I took a slightly different approach than you (@authmillenon) did in #1733. I read the received packet already in the interrupt routine (as it was done before with the transceiver module) and afterwards notify the event handling thread. I think this is a better approach than to completely rely on the event handling thread for receiving the packet from the device (we cannot be sure that the event handling thread is the one taking over after the interrupt routine and the packet might get lost). This is something that should also be discussed with @haukepetersen (and maybe @thomaseichinger) because it looks like it differs from your basic flow description. Nevertheless, I think the slightly longer interrupt routine is justified by the gain of certainty that the packet is read from the device timely. |
|
@fnack how large are the packets / how large is the overhead? |
|
I'm not quite sure, but instinctively I would say that with this kind of implementation you would risk to be easily DoS'd since you basically would never leave the ISR when you are flooded. I think the risk of not being able to respond outweighs the risk of loosing data because the OS was not fast enough. Making sure everything is received that should be is the task of the Link Layer (aka MAC Layer sometimes in our lingo) or the Transport Layer, but should never be the task of the driver (except the SoC offers some kind of congestion/packet loss control, of course, which is not the case for the cc1100 iirc). |
|
+ You also loose data if you are in the ISR too long, because it can't react if it's working. |
|
Why wouldn't it leave the ISR? |
|
Scenario (copy in ISR): |
|
@fnack I'm undecided on this as different hardware provides different features.
I didn't really look into cc1100's features yet.
For this to work, at least for the cc2420, you'd have to disable radio interrupts, else, as mentioned above, when firing with minimal sized packets the notified thread could be outperformed by the number of interrupts. (And to assure the received data is valid) To sum up, in either case we could/will loose data but, although currently implemented differently for rf2xx, I tend to support the notify strategy since in the not "evil" case we can react to other events more promptly. |
To assess that is also the job of an upper layer IMHO. |
Also yes, the radio driver should assure to receive valid and complete 15.4 packets. |
|
The cc1100 is not a 15.4 transceiver ;-) |
|
@authmillenon Yes, came to my mind as I pressed the button. As stated above I'm not familiar with this device but shouldn't it still do some CRC checking etc? |
|
Yes, the CC110x does CRC checking. |
|
I thought about it again and in some cases multiple interrupts are preferable/needed to handle packet reception from the device (for example when the packet length exceeds the CCxxxx's RXFIFO). In these cases handling the reception in the link layer thread using notifications with different event-types is probably the better approach. I think I'll adapt my implementation, but nonetheless I'd really like to hear @haukepetersen's opinion on this topic as well. |
|
I have the same opinion: the (time consuming) data transfers should be done in the thread context. This way no other function with time critical operations will be disturbed by this long running interrupt. So the way I would imagine this is:
In case there are different events to be handled (receptions of data on multiple FIFOs...), the argument of the |
This PR adapts the CC110X netdev implementation to the updated receive event handling sequence for netdev (see description).
On packet reception, in the interrupt routine the packet is read from the CC110X and stored in the device driver's RX-Buffer. The event handler thread is notified of the receive event with a msg and the interrupt routine is left. The event handler thread then calls
_cc110x_eventwith the fitting event type. In the event function the packet is read from the device driver's RX-Buffer and the registered callback is executed. This sequence is needed to make sure that the callback execution is taking place in the event handler thread.The PR is depending on #2163.