diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 6537e4b840..cb2359c675 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -736,6 +736,24 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, } */ #endif + if (UEScopeHasTryLock(ue)) { + metadata mt = {.frame = proc->frame_rx, .slot = proc->nr_slot_rx }; + int total_valid_res = 0; + for (int i = startSymbIdx; i < startSymbIdx + nbSymb; i++) { + total_valid_res = dl_valid_re[i - 1]; + } + if (UETryLockScopeData(ue, pdschRxdataF_comp, sizeof(c16_t), 1, total_valid_res, &mt)) { + size_t offset = 0; + for (int i = startSymbIdx; i < startSymbIdx + nbSymb; i++) { + size_t data_size = sizeof(c16_t) * dl_valid_re[i - i]; + UEscopeCopyUnsafe(ue, pdschRxdataF_comp, &rxdataF_comp[0][0][rx_size_symbol * i], data_size, offset, i - startSymbIdx); + offset += data_size; + } + UEunlockScopeData(ue, pdschRxdataF_comp) + } + } else { + UEscopeCopy(ue, pdschRxdataF_comp, rxdataF_comp[0], sizeof(c16_t), nbRx, rx_size_symbol * NR_SYMBOLS_PER_SLOT, 0); + } } if (meas_enabled) { @@ -759,7 +777,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, T_INT(frame_parms->symbols_per_slot), T_BUFFER(&rxdataF_comp[gNB_id][0], 2 * /* ulsch[UE_id]->harq_processes[harq_pid]->nb_rb */ frame_parms->N_RB_UL * 12 * 2)); #endif - UEscopeCopy(ue, pdschRxdataF_comp, rxdataF_comp[0], sizeof(c16_t), nbRx, rx_size_symbol * NR_SYMBOLS_PER_SLOT, 0); if (ue->phy_sim_pdsch_rxdataF_comp) for (int a = 0; a < nbRx; a++) { diff --git a/openair1/PHY/TOOLS/imscope/imscope.cpp b/openair1/PHY/TOOLS/imscope/imscope.cpp index 687226940f..8205c85b9e 100644 --- a/openair1/PHY/TOOLS/imscope/imscope.cpp +++ b/openair1/PHY/TOOLS/imscope/imscope.cpp @@ -74,6 +74,7 @@ typedef struct ImScopeData { metadata meta; uint64_t time_taken_in_ns; uint64_t time_taken_in_ns_per_offset[MAX_OFFSETS]; + size_t data_copied_per_offset[MAX_OFFSETS]; } ImScopeData; typedef struct MovingAverageTimer { @@ -811,6 +812,7 @@ bool tryLockScopeData(enum scopeDataType type, int elementSz, int colSz, int lin scope_data.time_taken_in_ns = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start).count(); memset(scope_data.time_taken_in_ns_per_offset, 0, sizeof(scope_data.time_taken_in_ns_per_offset)); + memset(scope_data.data_copied_per_offset, 0, sizeof(scope_data.data_copied_per_offset)); return true; } return false; @@ -818,6 +820,7 @@ bool tryLockScopeData(enum scopeDataType type, int elementSz, int colSz, int lin void copyDataUnsafeWithOffset(enum scopeDataType type, void *dataIn, size_t size, size_t offset, int copy_index) { + AssertFatal(copy_index < MAX_OFFSETS, "Unexpected number of copies per sink. copy_index = %d\n", copy_index); ImScopeData &scope_data = scope_array[type]; auto start = std::chrono::high_resolution_clock::now(); scopeGraphData_t *data = scope_data.scope_graph_data; @@ -825,13 +828,19 @@ void copyDataUnsafeWithOffset(enum scopeDataType type, void *dataIn, size_t size memcpy(&outptr[offset], dataIn, size); scope_data.time_taken_in_ns_per_offset[copy_index] = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start).count(); + scope_data.data_copied_per_offset[copy_index] = size; } void unlockScopeData(enum scopeDataType type) { ImScopeData &scope_data = scope_array[type]; + size_t total_size = 0; for (auto i = 0; i < MAX_OFFSETS; i++) { scope_data.time_taken_in_ns += scope_data.time_taken_in_ns_per_offset[i]; + total_size += scope_data.data_copied_per_offset[i]; + } + if (total_size != (uint64_t)scope_data.scope_graph_data->dataSize) { + LOG_E(PHY, "Scope is missing data - not all data that was expected was copied - possibly missed copyDataUnsafeWithOffset call\n"); } scope_data.is_data_ready = true; scope_data.write_mutex.unlock(); diff --git a/openair1/PHY/TOOLS/phy_scope_interface.h b/openair1/PHY/TOOLS/phy_scope_interface.h index 2d44e0cf45..2f8378e7b7 100644 --- a/openair1/PHY/TOOLS/phy_scope_interface.h +++ b/openair1/PHY/TOOLS/phy_scope_interface.h @@ -154,6 +154,25 @@ void copyData(void *, enum scopeDataType type, void *dataIn, int elementSz, int scope_data->unlockScopeData(type); \ } +#define UEScopeHasTryLock(ue) \ + (ue->scopeData && ((scopeData_t *)ue->scopeData)->tryLockScopeData) + +#define UETryLockScopeData(ue, type, ...) \ + ue->scopeData && ((scopeData_t *)ue->scopeData)->tryLockScopeData \ + && ((scopeData_t *)ue->scopeData)->tryLockScopeData(type, ##__VA_ARGS__) + +#define UEscopeCopyUnsafe(ue, type, ...) \ + scopeData_t *scope_data = (scopeData_t *)ue->scopeData; \ + if (scope_data && scope_data->copyDataUnsafeWithOffset) { \ + scope_data->copyDataUnsafeWithOffset(type, ##__VA_ARGS__); \ + } + +#define UEunlockScopeData(ue, type) \ + scopeData_t *scope_data = (scopeData_t *)ue->scopeData; \ + if (scope_data && scope_data->unlockScopeData) { \ + scope_data->unlockScopeData(type); \ + } + extended_kpi_ue* getKPIUE(); #endif