drivers: ieee802154: nRF5: TX timestamp now refers to start of PHR
Based on the standard based definitions given in previous commits, the TX timestamp used for timed TX now refers to the start of PHR. As OT continues to calculate timestamps based on a "start of SHR" definition, the duration of the PHY specific SHR is added in the OT adaptation layer to make up for this OT quirk. Fixes: #59245 Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This commit is contained in:
parent
7db0184e1b
commit
137a7edd6e
|
@ -527,7 +527,12 @@ static bool nrf5_tx_at(struct nrf5_802154_data *nrf5_radio, struct net_pkt *pkt,
|
|||
.extra_cca_attempts = max_extra_cca_attempts,
|
||||
#endif
|
||||
};
|
||||
uint64_t tx_at = net_ptp_time_to_ns(net_pkt_timestamp(pkt)) / NSEC_PER_USEC;
|
||||
|
||||
/* The timestamp points to the start of PHR but `nrf_802154_transmit_raw_at`
|
||||
* expects a timestamp pointing to start of SHR.
|
||||
*/
|
||||
uint64_t tx_at = nrf_802154_timestamp_phr_to_shr_convert(
|
||||
net_ptp_time_to_ns(net_pkt_timestamp(pkt)) / NSEC_PER_USEC);
|
||||
|
||||
return nrf_802154_transmit_raw_at(payload, tx_at, &metadata);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ extern "C" {
|
|||
*/
|
||||
#define IEEE802154_PHY_SYMBOLS_PER_SECOND(symbol_period) (USEC_PER_SEC / symbol_period)
|
||||
|
||||
/* see section 19.2.4 */
|
||||
/* in bytes, see section 19.2.4 */
|
||||
#define IEEE802154_PHY_SUN_FSK_PHR_LEN 2
|
||||
|
||||
/* Default PHY PIB attribute aTurnaroundTime, in PHY symbols, see section 11.3, table 11-1. */
|
||||
|
|
|
@ -58,6 +58,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
|
|||
|
||||
#define CHANNEL_COUNT OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX - OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN + 1
|
||||
|
||||
#define PHY_SHR_DURATION 160 /* duration of SHR in us */
|
||||
|
||||
enum pending_events {
|
||||
PENDING_EVENT_FRAME_TO_SEND, /* There is a tx frame to send */
|
||||
PENDING_EVENT_FRAME_RECEIVED, /* Radio has received new frame */
|
||||
|
@ -395,7 +397,7 @@ void transmit_message(struct k_work *tx_job)
|
|||
(sTransmitFrame.mInfo.mTxInfo.mTxDelay != 0)) {
|
||||
#if defined(CONFIG_NET_PKT_TXTIME)
|
||||
uint32_t tx_at = sTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime +
|
||||
sTransmitFrame.mInfo.mTxInfo.mTxDelay;
|
||||
sTransmitFrame.mInfo.mTxInfo.mTxDelay + PHY_SHR_DURATION;
|
||||
struct net_ptp_time timestamp =
|
||||
ns_to_net_ptp_time(convert_32bit_us_wrapped_to_64bit_ns(tx_at));
|
||||
net_pkt_set_timestamp(tx_pkt, ×tamp);
|
||||
|
|
|
@ -30,6 +30,8 @@ DEFINE_FFF_GLOBALS;
|
|||
#define FRAME_TYPE_MASK 0x07
|
||||
#define FRAME_TYPE_ACK 0x02
|
||||
|
||||
#define PHY_SHR_DURATION 160
|
||||
|
||||
K_SEM_DEFINE(ot_sem, 0, 1);
|
||||
|
||||
/**
|
||||
|
@ -293,10 +295,10 @@ ZTEST(openthread_radio, test_tx_test)
|
|||
get_time_mock_fake.return_val = (int64_t)UINT32_MAX * NSEC_PER_USEC + 1000;
|
||||
frm->mInfo.mTxInfo.mTxDelayBaseTime = 3U;
|
||||
frm->mInfo.mTxInfo.mTxDelay = 5U;
|
||||
expected_target_time =
|
||||
get_time_mock_fake.return_val +
|
||||
(frm->mInfo.mTxInfo.mTxDelayBaseTime + frm->mInfo.mTxInfo.mTxDelay) *
|
||||
NSEC_PER_USEC;
|
||||
expected_target_time = get_time_mock_fake.return_val +
|
||||
(frm->mInfo.mTxInfo.mTxDelayBaseTime +
|
||||
frm->mInfo.mTxInfo.mTxDelay + PHY_SHR_DURATION) *
|
||||
NSEC_PER_USEC;
|
||||
}
|
||||
|
||||
/* ACKed frame */
|
||||
|
|
Loading…
Reference in a new issue