Prevent infinite loop on HARQ PID=-1 and Single Entry PHR
When receiving single-entry PHR with HARQ PID -1
(nr_mac_process_mac_pdu() is called with such parameter in at least two
places), the error handling path calls continue skipping the accounting
of the current sub-pdu (pduP and pdu_len). This results in an infinite
loop. Fix by moving functionality into a separate function.
Fixes: 2e0493632d ("RLC data ind: single call for complete TB at gNB")
Signed-off-by: Robert Schmidt <robert.schmidt@openairinterface.org>
This commit is contained in:
@@ -226,6 +226,45 @@ static int estimate_ul_buffer_long_bsr(const NR_BSR_LONG *bsr)
|
||||
return estim_size;
|
||||
}
|
||||
|
||||
static void handle_single_entry_phr(const NR_UE_UL_BWP_t *ul_bwp,
|
||||
NR_UE_sched_ctrl_t *sched_ctrl,
|
||||
int harq_pid,
|
||||
const NR_SINGLE_ENTRY_PHR_MAC_CE *phr)
|
||||
{
|
||||
if (harq_pid < 0) {
|
||||
LOG_E(NR_MAC, "Invalid HARQ PID %d\n", harq_pid);
|
||||
return;
|
||||
}
|
||||
NR_sched_pusch_t *sched_pusch = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch;
|
||||
|
||||
/* Save the phr info */
|
||||
int PH;
|
||||
const int PCMAX = phr->PCMAX;
|
||||
/* 38.133 Table10.1.17.1-1 */
|
||||
if (phr->PH < 55) {
|
||||
PH = phr->PH - 32;
|
||||
} else if (phr->PH < 63) {
|
||||
PH = 24 + (phr->PH - 55) * 2;
|
||||
} else {
|
||||
PH = 38;
|
||||
}
|
||||
// in sched_ctrl we set normalized PH wrt MCS and PRBs
|
||||
sched_ctrl->ph = PH + compute_ph_rb_factor(ul_bwp->scs, sched_pusch->rbSize);
|
||||
bool hasDeltaMCS = ul_bwp->pusch_Config && ul_bwp->pusch_Config->pusch_PowerControl->deltaMCS;
|
||||
if (hasDeltaMCS)
|
||||
sched_ctrl->ph += compute_ph_mcs_factor(sched_pusch);
|
||||
/* 38.133 Table10.1.18.1-1 */
|
||||
sched_ctrl->pcmax = PCMAX - 29;
|
||||
LOG_D(NR_MAC,
|
||||
"SINGLE ENTRY PHR %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n",
|
||||
phr->R1,
|
||||
PH,
|
||||
sched_ctrl->ph,
|
||||
phr->R2,
|
||||
PCMAX,
|
||||
sched_ctrl->pcmax);
|
||||
}
|
||||
|
||||
// For both UL-SCH except:
|
||||
// - UL-SCH: fixed-size MAC CE(known by LCID)
|
||||
// - UL-SCH: padding
|
||||
@@ -510,43 +549,10 @@ static int nr_process_mac_pdu(instance_t module_idP,
|
||||
break;
|
||||
|
||||
case UL_SCH_LCID_SINGLE_ENTRY_PHR:
|
||||
if (harq_pid < 0) {
|
||||
LOG_E(NR_MAC, "Invalid HARQ PID %d\n", harq_pid);
|
||||
continue;
|
||||
}
|
||||
NR_sched_pusch_t *sched_pusch = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch;
|
||||
|
||||
/* Extract SINGLE ENTRY PHR elements for PHR calculation */
|
||||
ce_ptr = &pduP[mac_subheader_len];
|
||||
NR_SINGLE_ENTRY_PHR_MAC_CE *phr = (NR_SINGLE_ENTRY_PHR_MAC_CE *)ce_ptr;
|
||||
/* Save the phr info */
|
||||
int PH;
|
||||
const int PCMAX = phr->PCMAX;
|
||||
/* 38.133 Table10.1.17.1-1 */
|
||||
if (phr->PH < 55) {
|
||||
PH = phr->PH - 32;
|
||||
} else if (phr->PH < 63) {
|
||||
PH = 24 + (phr->PH - 55) * 2;
|
||||
} else {
|
||||
PH = 38;
|
||||
}
|
||||
// in sched_ctrl we set normalized PH wrt MCS and PRBs
|
||||
sched_ctrl->ph = PH + compute_ph_rb_factor(ul_bwp->scs, sched_pusch->rbSize);
|
||||
bool hasDeltaMCS = ul_bwp->pusch_Config && ul_bwp->pusch_Config->pusch_PowerControl->deltaMCS;
|
||||
if (hasDeltaMCS)
|
||||
sched_ctrl->ph += compute_ph_mcs_factor(sched_pusch);
|
||||
/* 38.133 Table10.1.18.1-1 */
|
||||
sched_ctrl->pcmax = PCMAX - 29;
|
||||
LOG_D(NR_MAC,
|
||||
"SINGLE ENTRY PHR %d.%d R1 %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n",
|
||||
frameP,
|
||||
slot,
|
||||
phr->R1,
|
||||
PH,
|
||||
sched_ctrl->ph,
|
||||
phr->R2,
|
||||
PCMAX,
|
||||
sched_ctrl->pcmax);
|
||||
handle_single_entry_phr(ul_bwp, sched_ctrl, harq_pid, phr);
|
||||
break;
|
||||
|
||||
case UL_SCH_LCID_C_RNTI:
|
||||
|
||||
Reference in New Issue
Block a user