Skip to content

Commit 9ba10ef

Browse files
e-rkcarlescufi
authored andcommitted
[nrf fromtree] drivers: ieee802154: copy back the TX buffer into the upper
... layer Copy back the TX buffer content back into the upper layer in case of a TX failure. This is necessary in when frame encryption by the radio driver is used. The shim layer for the nRF5 driver has a buffer, that is used by the driver to authenticate and encrypt the frame in-place. In case of a TX failure, the buffer contents are propagated back to the upper layer. The upper layer must use the same secured frame for retransmission. Signed-off-by: Rafał Kuźnia <[email protected]>
1 parent af79106 commit 9ba10ef

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ static int nrf5_tx(const struct device *dev,
518518
uint8_t payload_len = frag->len;
519519
uint8_t *payload = frag->data;
520520
bool ret = true;
521+
int result;
521522

522523
LOG_DBG("%p (%u)", payload, payload_len);
523524

@@ -575,19 +576,32 @@ static int nrf5_tx(const struct device *dev,
575576
/* Handle ACK packet. */
576577
return handle_ack(nrf5_radio);
577578
case NRF_802154_TX_ERROR_NO_MEM:
578-
return -ENOBUFS;
579+
result = -ENOBUFS;
579580
case NRF_802154_TX_ERROR_BUSY_CHANNEL:
580-
return -EBUSY;
581+
result = -EBUSY;
581582
case NRF_802154_TX_ERROR_INVALID_ACK:
582583
case NRF_802154_TX_ERROR_NO_ACK:
583-
return -ENOMSG;
584+
result = -ENOMSG;
584585
case NRF_802154_TX_ERROR_ABORTED:
585586
case NRF_802154_TX_ERROR_TIMESLOT_DENIED:
586587
case NRF_802154_TX_ERROR_TIMESLOT_ENDED:
587-
return -EIO;
588+
default:
589+
result = -EIO;
588590
}
589591

590-
return -EIO;
592+
#if NRF_802154_ENCRYPTION_ENABLED
593+
/*
594+
* When frame encryption by the radio driver is enabled,
595+
* the frame stored in the tx_psdu buffer is authenticated
596+
* and encrypted in place. After an unsuccessful TX attempt,
597+
* this frame must be propagated back to the upper layer
598+
* for retransmission. The upper layer must ensure that the
599+
* excact same secured frame is used for retransmission.
600+
*/
601+
memcpy(payload, nrf5_radio->tx_psdu + 1, payload_len);
602+
#endif
603+
604+
return result;
591605
}
592606

593607
static uint64_t nrf5_get_time(const struct device *dev)

0 commit comments

Comments
 (0)