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 <rafal.kuznia@nordicsemi.no>
This commit is contained in:
parent
24b2ef4590
commit
cab64a9c61
1 changed files with 19 additions and 5 deletions
|
@ -471,6 +471,7 @@ static int nrf5_tx(const struct device *dev,
|
|||
uint8_t payload_len = frag->len;
|
||||
uint8_t *payload = frag->data;
|
||||
bool ret = true;
|
||||
int result;
|
||||
|
||||
LOG_DBG("%p (%u)", payload, payload_len);
|
||||
|
||||
|
@ -528,19 +529,32 @@ static int nrf5_tx(const struct device *dev,
|
|||
/* Handle ACK packet. */
|
||||
return handle_ack(nrf5_radio);
|
||||
case NRF_802154_TX_ERROR_NO_MEM:
|
||||
return -ENOBUFS;
|
||||
result = -ENOBUFS;
|
||||
case NRF_802154_TX_ERROR_BUSY_CHANNEL:
|
||||
return -EBUSY;
|
||||
result = -EBUSY;
|
||||
case NRF_802154_TX_ERROR_INVALID_ACK:
|
||||
case NRF_802154_TX_ERROR_NO_ACK:
|
||||
return -ENOMSG;
|
||||
result = -ENOMSG;
|
||||
case NRF_802154_TX_ERROR_ABORTED:
|
||||
case NRF_802154_TX_ERROR_TIMESLOT_DENIED:
|
||||
case NRF_802154_TX_ERROR_TIMESLOT_ENDED:
|
||||
return -EIO;
|
||||
default:
|
||||
result = -EIO;
|
||||
}
|
||||
|
||||
return -EIO;
|
||||
#if NRF_802154_ENCRYPTION_ENABLED
|
||||
/*
|
||||
* When frame encryption by the radio driver is enabled,
|
||||
* the frame stored in the tx_psdu buffer is authenticated
|
||||
* and encrypted in place. After an unsuccessful TX attempt,
|
||||
* this frame must be propagated back to the upper layer
|
||||
* for retransmission. The upper layer must ensure that the
|
||||
* excact same secured frame is used for retransmission.
|
||||
*/
|
||||
memcpy(payload, nrf5_radio->tx_psdu + 1, payload_len);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint64_t nrf5_get_time(const struct device *dev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue