From e1d7306a43d3ca53065a919e835c685fe603c8da Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Wed, 5 Feb 2025 10:43:03 +0100 Subject: [PATCH] Reduce indentation, add comment Reduce one level of indentation, and explain why we wait for physide_dl_tti callback. --- radio/fhi_72/oaioran.c | 61 ++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/radio/fhi_72/oaioran.c b/radio/fhi_72/oaioran.c index cbcc7346bf..65839fd5a0 100644 --- a/radio/fhi_72/oaioran.c +++ b/radio/fhi_72/oaioran.c @@ -112,39 +112,42 @@ void oai_xran_fh_rx_callback(void *pCallbackTag, xran_status_t status) } } #endif - if (first_call_set) { - slot2 = slot + (subframe * slots_per_subframe); - rx_RU[ru_id][slot2] = 1; - if (last_frame > 0 && frame > 0 - && ((slot2 > 0 && last_frame != frame) || (slot2 == 0 && last_frame != ((1024 + frame - 1) & 1023)))) - LOG_E(PHY, "Jump in frame counter last_frame %d => %d, slot %d\n", last_frame, frame, slot2); - for (int i = 0; i < num_ports; i++) { - if (rx_RU[i][slot2] == 0) - return; - } - for (int i = 0; i < num_ports; i++) - rx_RU[i][slot2] = 0; + // if xran did not call xran_physide_dl_tti callback, it's not ready yet. + // wait till first callback to advance counters, because otherwise users + // would see periodic output with only "0" in stats counters + if (!first_call_set) + return; + slot2 = slot + (subframe * slots_per_subframe); + rx_RU[ru_id][slot2] = 1; + if (last_frame > 0 && frame > 0 + && ((slot2 > 0 && last_frame != frame) || (slot2 == 0 && last_frame != ((1024 + frame - 1) & 1023)))) + LOG_E(PHY, "Jump in frame counter last_frame %d => %d, slot %d\n", last_frame, frame, slot2); + for (int i = 0; i < num_ports; i++) { + if (rx_RU[i][slot2] == 0) + return; + } + for (int i = 0; i < num_ports; i++) + rx_RU[i][slot2] = 0; - if (last_slot == -1 || slot2 != last_slot) { + if (last_slot == -1 || slot2 != last_slot) { #ifndef USE_POLLING - notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(oran_sync_info_t), 0, &oran_sync_fifo, NULL); - oran_sync_info_t *info = NotifiedFifoData(req); - info->tti = tti; - info->sl = slot2; - info->f = frame; - LOG_D(PHY, "Push %d.%d.%d (slot %d, subframe %d,last_slot %d)\n", frame, info->sl, slot, ru_id, subframe, last_slot); - pushNotifiedFIFO(&oran_sync_fifo, req); + notifiedFIFO_elt_t *req = newNotifiedFIFO_elt(sizeof(oran_sync_info_t), 0, &oran_sync_fifo, NULL); + oran_sync_info_t *info = NotifiedFifoData(req); + info->tti = tti; + info->sl = slot2; + info->f = frame; + LOG_D(PHY, "Push %d.%d.%d (slot %d, subframe %d,last_slot %d)\n", frame, info->sl, slot, ru_id, subframe, last_slot); + pushNotifiedFIFO(&oran_sync_fifo, req); #else - LOG_D(PHY, "Writing %d.%d.%d (slot %d, subframe %d,last_slot %d)\n", frame, slot2, ru_id, slot, subframe, last_slot); - oran_sync_info.tti = tti; - oran_sync_info.sl = slot2; - oran_sync_info.f = frame; + LOG_D(PHY, "Writing %d.%d.%d (slot %d, subframe %d,last_slot %d)\n", frame, slot2, ru_id, slot, subframe, last_slot); + oran_sync_info.tti = tti; + oran_sync_info.sl = slot2; + oran_sync_info.f = frame; #endif - } else - LOG_E(PHY, "Cannot Push %d.%d.%d (slot %d, subframe %d,last_slot %d)\n", frame, slot2, ru_id, slot, subframe, last_slot); - last_slot = slot2; - last_frame = frame; - } // first_call_set + } else + LOG_E(PHY, "Cannot Push %d.%d.%d (slot %d, subframe %d,last_slot %d)\n", frame, slot2, ru_id, slot, subframe, last_slot); + last_slot = slot2; + last_frame = frame; } // rx_sym == 7 } void oai_xran_fh_srs_callback(void *pCallbackTag, xran_status_t status)