Separate profile admission and standby costs in hardware timing captures
This commit is contained in:
1 parent
12b2a02f5b
commit
663312c820
3 files changed
+151
-16
No files matched your search
@@ -13,12 +13,12 @@ namespace mesh {
|
||||
namespace profiletiming {
|
||||
|
||||
enum Stage : uint32_t {
|
||||
BeginReconfigure = 0, Frequency, Modulation, Preamble, GuardMath,
|
||||
Admission = 0, Standby, PostStandby, Frequency, Modulation, Preamble, GuardMath,
|
||||
ProtocolAndCache, RxResume, Tail, Whole, StageCount
|
||||
};
|
||||
enum Result : uint32_t { Success = 0, Busy = 1, Failure = 2 };
|
||||
static constexpr uint32_t Magic = 0x4d435054; // MCPT
|
||||
static constexpr uint32_t Version = 2;
|
||||
static constexpr uint32_t Version = 3;
|
||||
static constexpr uint32_t HistogramCount = 16;
|
||||
static constexpr uint32_t HistogramWidthUs = 64;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
@@ -109,6 +109,32 @@ inline void mark(Stage stage, uint32_t now_ticks) {
|
||||
work.mask |= uint32_t(1) << stage;
|
||||
}
|
||||
|
||||
// Instrument beginReconfigure's existing operations without adding radio I/O.
|
||||
// Every exit records the admission and post-standby bookkeeping. If admission
|
||||
// defers or the receiver was idle, Standby is present with duration zero.
|
||||
class ReconfigureScope {
|
||||
bool admission_marked_ = false;
|
||||
bool standby_marked_ = false;
|
||||
public:
|
||||
void admissionComplete() {
|
||||
mark(Admission, readClock());
|
||||
admission_marked_ = true;
|
||||
}
|
||||
int16_t standbyResult(int16_t result) {
|
||||
mark(Standby, readClock());
|
||||
standby_marked_ = true;
|
||||
return result;
|
||||
}
|
||||
~ReconfigureScope() {
|
||||
auto& work = mesh_hil_profile_timing_work;
|
||||
if (!work.active) return;
|
||||
const uint32_t now_ticks = readClock();
|
||||
if (!admission_marked_) mark(Admission, now_ticks);
|
||||
if (!standby_marked_) mark(Standby, work.previous_ticks);
|
||||
mark(PostStandby, now_ticks);
|
||||
}
|
||||
};
|
||||
|
||||
inline void finish(Result result, uint32_t now_ticks) {
|
||||
auto& work = mesh_hil_profile_timing_work;
|
||||
if (!work.active) return;
|
||||
@@ -149,6 +175,8 @@ inline void finish(Result result, uint32_t now_ticks) {
|
||||
|
||||
static_assert(sizeof(Capture) == 40 + 2 * (20 + StageCount * (8 + 88)),
|
||||
"Unexpected profile timing ABI");
|
||||
static_assert(StageCount == 11 && sizeof(Capture) == 2192,
|
||||
"Profile timing version 3 requires eleven stages and 2192 bytes");
|
||||
|
||||
} // namespace profiletiming
|
||||
} // namespace mesh
|
||||
|
||||
@@ -368,6 +368,9 @@ bool RadioLibWrapper::setTxPower(int8_t dbm) {
|
||||
}
|
||||
|
||||
uint8_t RadioLibWrapper::beginReconfigure() {
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
mesh::profiletiming::ReconfigureScope profile_timing;
|
||||
#endif
|
||||
#if MESH_RADIO_TRACE_ENABLED
|
||||
mesh::radiotrace::trace().context(_radio, _active_profile, _profile_generation);
|
||||
#endif
|
||||
@@ -382,7 +385,16 @@ uint8_t RadioLibWrapper::beginReconfigure() {
|
||||
if (base_state == STATE_TX_WAIT || isChipBusy()) return 2;
|
||||
claimRadioInterrupt();
|
||||
_rx_hold_continuous = false;
|
||||
if (_radio->standby() != RADIOLIB_ERR_NONE) {
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
profile_timing.admissionComplete();
|
||||
#endif
|
||||
if (
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
profile_timing.standbyResult(_radio->standby())
|
||||
#else
|
||||
_radio->standby()
|
||||
#endif
|
||||
!= RADIOLIB_ERR_NONE) {
|
||||
state = STATE_IDLE;
|
||||
return 3;
|
||||
}
|
||||
@@ -399,9 +411,18 @@ uint8_t RadioLibWrapper::beginReconfigure() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
profile_timing.admissionComplete();
|
||||
#endif
|
||||
const bool resume_rx = base_state == STATE_RX;
|
||||
if (_rx_ps_armed || resume_rx) {
|
||||
if (_radio->standby() != RADIOLIB_ERR_NONE) {
|
||||
if (
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
profile_timing.standbyResult(_radio->standby())
|
||||
#else
|
||||
_radio->standby()
|
||||
#endif
|
||||
!= RADIOLIB_ERR_NONE) {
|
||||
state = STATE_IDLE;
|
||||
_profile_refresh_required = _profile_repair_required = true;
|
||||
return 3;
|
||||
@@ -617,9 +638,6 @@ mesh::RadioParamApplyResult RadioLibWrapper::tuneProfile(uint8_t profile) {
|
||||
#endif
|
||||
beginProfileRetune(isInRecvMode() && !_rx_ps_armed && !_rx_ps_enabled);
|
||||
const uint8_t resume = beginReconfigure();
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
mesh::profiletiming::mark(mesh::profiletiming::BeginReconfigure, mesh::profiletiming::readClock());
|
||||
#endif
|
||||
if (resume > 1) {
|
||||
endProfileRetune(resume == 2); // Only a BUSY guard deferred before changing hardware.
|
||||
#if MESH_HIL_PROFILE_TIMING
|
||||
|
||||
Reference in new issue
Block a user