drivers: ieee802154: gracefully handle invalid Ack timestamp
The nRF IEEE 802.15.4 driver might report a received Ack frame with invalid timestamp, if the timestamp could not have been taken. The upper layers are not prepared to handle such a case as they expect that for a received frame, the timestamp is always present and valid. This commit detects this situation and handles it gracefully by reporting the transmission as failed as if no Ack was received. Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
This commit is contained in:
parent
80a6a20628
commit
774dd16555
|
@ -398,6 +398,17 @@ static int handle_ack(struct nrf5_802154_data *nrf5_radio)
|
|||
struct net_pkt *ack_pkt;
|
||||
int err = 0;
|
||||
|
||||
#if defined(CONFIG_NET_PKT_TIMESTAMP)
|
||||
if (nrf5_radio->ack_frame.time == NRF_802154_NO_TIMESTAMP) {
|
||||
/* Ack timestamp is invalid and cannot be used by the upper layer.
|
||||
* Report the transmission as failed as if the Ack was not received at all.
|
||||
*/
|
||||
LOG_WRN("Invalid ACK timestamp.");
|
||||
err = -ENOMSG;
|
||||
goto free_nrf_ack;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
|
||||
ack_len = nrf5_radio->ack_frame.psdu[0];
|
||||
} else {
|
||||
|
@ -1140,8 +1151,14 @@ void nrf_802154_transmitted_raw(uint8_t *frame,
|
|||
nrf5_data.ack_frame.lqi = metadata->data.transmitted.lqi;
|
||||
|
||||
#if defined(CONFIG_NET_PKT_TIMESTAMP)
|
||||
if (metadata->data.transmitted.time == NRF_802154_NO_TIMESTAMP) {
|
||||
/* Ack timestamp is invalid. Keep this value to detect it when handling Ack
|
||||
*/
|
||||
nrf5_data.ack_frame.time = NRF_802154_NO_TIMESTAMP;
|
||||
} else {
|
||||
nrf5_data.ack_frame.time = nrf_802154_timestamp_end_to_phr_convert(
|
||||
metadata->data.transmitted.time, nrf5_data.ack_frame.psdu[0]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue