nr_fill_indication(): protect with mutex
nr_fill_indication() fills CRC and RX requests, to be sent from L1 to L2. Before this commit, nr_fill_indication() is called when - we finally decoded LDPC (or not) - low signal on PUSCH This might happen at the same time, i.e., nr_fill_indication() might try to fill both CRC and RX, in the same list, from different threads. This can lead to this assertion: Assertion (crc->rnti == rx->rnti) failed! In handle_nr_ulsch() ../../../openair2/NR_PHY_INTERFACE/NR_IF_Module.c:190 mis-match between CRC RNTI e071 and RX RNTI 5e3b e.g., e071 is low energy, and while 5e3b related message are filled in one thread, e071 is being put into the message structure as well. At least that is my understanding. I could not actually reproduce this assertion; to be seen if it still happens.
This commit is contained in:
@@ -135,6 +135,8 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB)
|
||||
|
||||
load_LDPClib(NULL, &ldpc_interface);
|
||||
|
||||
pthread_mutex_init(&gNB->UL_INFO.crc_rx_mutex, NULL);
|
||||
|
||||
if (gNB->ldpc_offload_flag)
|
||||
load_LDPClib("_t2", &ldpc_interface_offload);
|
||||
gNB->max_nb_pdsch = MAX_MOBILES_PER_GNB;
|
||||
@@ -331,6 +333,8 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB)
|
||||
const int max_ul_mimo_layers = 4; // taken from phy_init_nr_gNB()
|
||||
const int n_buf = Prx * max_ul_mimo_layers;
|
||||
|
||||
pthread_mutex_destroy(&gNB->UL_INFO.crc_rx_mutex);
|
||||
|
||||
PHY_MEASUREMENTS_gNB *meas = &gNB->measurements;
|
||||
free_and_zero(meas->n0_subband_power);
|
||||
free_and_zero(meas->n0_subband_power_dB);
|
||||
|
||||
@@ -471,6 +471,14 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,
|
||||
else if (SNRtimes10 > 635) cqi=255;
|
||||
else cqi=(640+SNRtimes10)/5;
|
||||
|
||||
// multiple threads might call this function at the same time, or while the
|
||||
// L2 reads the messages. Hence, if not protected, crc and rx indications
|
||||
// might not appear pairwise (in the same order) in the same slot, or even in
|
||||
// separate slots. The L2 does not support this; hence, use the crc_rx_mutex
|
||||
// to ensure that messages are pairwise.
|
||||
int rc = pthread_mutex_lock(&gNB->UL_INFO.crc_rx_mutex);
|
||||
DevAssert(rc == 0);
|
||||
|
||||
// crc indication
|
||||
uint16_t num_crc = gNB->UL_INFO.crc_ind.number_crcs;
|
||||
gNB->UL_INFO.crc_ind.crc_list = &gNB->crc_pdu_list[0];
|
||||
@@ -507,8 +515,10 @@ void nr_fill_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int ULSCH_id,
|
||||
gNB->rx_pdu_list[num_rx].pdu_length = harq_process->TBS;
|
||||
gNB->rx_pdu_list[num_rx].pdu = harq_process->b;
|
||||
}
|
||||
|
||||
gNB->UL_INFO.rx_ind.number_of_pdus++;
|
||||
|
||||
rc = pthread_mutex_unlock(&gNB->UL_INFO.crc_rx_mutex);
|
||||
DevAssert(rc == 0);
|
||||
}
|
||||
|
||||
// Function to fill UL RB mask to be used for N0 measurements
|
||||
|
||||
Reference in New Issue
Block a user