Skip to content

Commit a8f3c1d

Browse files
lmaciejonczykcarlescufi
authored andcommitted
[nrf fromtree] drivers: ieee802154: propagate frame counter to upper layer
When frame counter is managed by the radio driver the upper layer needs to be informed about the frame counter changed. The upper layer looks for the most recent frame counter in the transmitted frame, this is why the tx_payload need to be updated after processed by the radio driver. Signed-off-by: Lukasz Maciejonczyk <[email protected]>
1 parent 9ba10ef commit a8f3c1d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,20 @@ static int nrf5_tx(const struct device *dev,
567567

568568
LOG_DBG("Result: %d", nrf5_data.tx_result);
569569

570+
#if NRF_802154_ENCRYPTION_ENABLED
571+
/*
572+
* When frame encryption by the radio driver is enabled, the frame stored in
573+
* the tx_psdu buffer is:
574+
* 1) authenticated and encrypted in place which causes that after an unsuccessful
575+
* TX attempt, this frame must be propagated back to the upper layer for retransmission.
576+
* The upper layer must ensure that the exact same secured frame is used for
577+
* retransmission
578+
* 2) frame counters are updated in place and for keeping the link frame counter up to date,
579+
* this information must be propagated back to the upper layer
580+
*/
581+
memcpy(payload, nrf5_radio->tx_psdu + 1, payload_len);
582+
#endif
583+
570584
switch (nrf5_radio->tx_result) {
571585
case NRF_802154_TX_ERROR_NONE:
572586
if (nrf5_radio->ack_frame.psdu == NULL) {
@@ -589,18 +603,6 @@ static int nrf5_tx(const struct device *dev,
589603
result = -EIO;
590604
}
591605

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-
604606
return result;
605607
}
606608

0 commit comments

Comments
 (0)