drivers/netdev: adds crc_valid to radio_rx_info#13878
drivers/netdev: adds crc_valid to radio_rx_info#13878fjmolinas wants to merge 26 commits intoRIOT-OS:masterfrom
Conversation
|
Great! I have only one comment regarding the netif header. Do upper layers actually need the CRC flag? I know LQI and RSSI might be used by some routing protocols though, but I'm not aware of any use case for CRC there. Does any one know? @miri64 @roberthartung |
drivers/mrf24j40/mrf24j40_netdev.c
Outdated
| mrf24j40_rx_fifo_read(dev, phr + 1, &(radio_info->lqi), 1); | ||
| mrf24j40_rx_fifo_read(dev, phr + 2, &(rssi_scalar), 1); | ||
| radio_info->rssi = mrf24j40_dbm_from_reg(rssi_scalar); | ||
| /* the driver currently does not support Packet Error Mode |
There was a problem hiding this comment.
trailing whitespace
|
Aren't most radio drivers configuring the radio to discard frames with invalid CRC automatically? |
Yes, that's true. But some network stacks require the radios to be configured to always receive packets regardless the CRC (OpenWSN). We would probably need compile time flags and or radio caps for this |
Yep, and as stated in the original PR there was a use case for:
|
yep, there was a PR on this a while ago. But this is currently not the case for all drivers and not very clear either, for some radios it will depend on the operating mode or some netops. But it is true that most drivers either don't accept invalid CRC altogether, or out implementation does that. All the commits that say |
cf208c2 to
56b49b0
Compare
Hmm, is this likely to happen on the upper layers? E.g. the CC1101 can do FEC in hardware; also BLE since version 5 does so in hardware. And if I had to add FEC in software, I would try to do that within the netdev and try to disable the layer 2 FCS altogether, if the hardware does support this. That way every network stack could transparently benefit from this. (And by properly implementing this as a common module, a handful of lines would be needed to be added to the netdev code.) One use case that comes to my mind is UDP-Lite, but I never heard of someone using this in a real world scenario.
Interesting. Why so? |
maribu
left a comment
There was a problem hiding this comment.
I only had a brief look. But if I didn't miss anything, this would now pass corrupted frames to the upper layers (but marked a such) instead of dropping them. Wouldn't we need to add code that checks for the flag (or more precisely the lack of it) and drops corrupted frames in the layers above instead?
drivers/at86rf2xx/at86rf2xx_netdev.c
Outdated
| */ | ||
| if (info != NULL) { | ||
| uint8_t ed = 0; | ||
| uint8_t crc = 0; |
There was a problem hiding this comment.
| uint8_t crc = 0; | |
| uint8_t crc_valid = 0; |
Just crc is a misleading name. I'd assume it would contain the value of the CRC.
Yes you are right. |
IIRC this is not enabled yet (and shouldn't be enabled by default) |
OK, this is better! (And unless no one is using two or more distinct network stacks in the same firmware, there is no need to e.g. add dropping of corrupted frames e.g. to GNRC; it will just never enable passing corrupted frames upward.) |
Add CRC_VALID flag to the new option.
|
Rebased and addressed current comments. |
|
@fjmolinas you should test this on monday (not sure if a self tag notifies myself) |
ping @fjmolinas :D |
|
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. |
Contribution description
This PR takes over for the staled and closed #8276. It also adds
crc_validto all other 802.15.4 drivers (except forxbeeandnative/socket_zepunless I missed one).I think commits should be reviewed individually for each radio. I currently don't have access to all the radios, I should in 1 month (if everything goes well) have access to boards with the missing radios.
I could also split the untested radios out of this PR.
Testing procedure
Setup
I applied the following patch to the sniffer to print
crc_info, I also made thatNETDEV_CRC_ERRORevent still pass the packet. I'll PR thecrc_indoif this gets merged.git diff sys/
git diff sniffer/main.c
I also setup a
at86rf233withAUTOCRCdisabled, with this radio its easy since it will simply not fill the FCS, so it will be invalid. Any other radio transmitting normally should have valid CRC.git diff drivers/at86rf2xx/at86rf2xx
Testing
For
at86rf2xxit needs to be setup in basic mode or packets are always rejected.CFLAGS=-DAT86RF2XX_BASIC_MODE BOARD=iotlab-m3 make -C riot-applications/sniffer flash term
Invalid CRC are rejected.
BOARD=usbkw41z make -C riot-applications/sniffer flash term
Non valid CRC are rejected
BOARD=nrf52840-mdkmake -C riot-applications/sniffer flash term
Issues/PRs references
Takeover of #8276.