Commit 310f6260 authored by francescomani's avatar francescomani

improvements in periodicBSR_Timer implementation

parent e60af1c8
......@@ -1634,6 +1634,62 @@ static uint32_t nr_get_sf_retxBSRTimer(long retxBSR_Timer)
return timer;
}
static uint32_t nr_get_sf_periodicBSRTimer(long periodicBSR)
{
uint32_t timer = 0;
switch (periodicBSR) {
case NR_BSR_Config__periodicBSR_Timer_sf1:
timer = 1;
break;
case NR_BSR_Config__periodicBSR_Timer_sf5:
timer = 5;
break;
case NR_BSR_Config__periodicBSR_Timer_sf10:
timer = 10;
break;
case NR_BSR_Config__periodicBSR_Timer_sf16:
timer = 16;
break;
case NR_BSR_Config__periodicBSR_Timer_sf20:
timer = 20;
break;
case NR_BSR_Config__periodicBSR_Timer_sf32:
timer = 32;
break;
case NR_BSR_Config__periodicBSR_Timer_sf40:
timer = 40;
break;
case NR_BSR_Config__periodicBSR_Timer_sf64:
timer = 64;
break;
case NR_BSR_Config__periodicBSR_Timer_sf80:
timer = 80;
break;
case NR_BSR_Config__periodicBSR_Timer_sf128:
timer = 128;
break;
case NR_BSR_Config__periodicBSR_Timer_sf160:
timer = 160;
break;
case NR_BSR_Config__periodicBSR_Timer_sf320:
timer = 320;
break;
case NR_BSR_Config__periodicBSR_Timer_sf640:
timer = 640;
break;
case NR_BSR_Config__periodicBSR_Timer_sf1280:
timer = 1280;
break;
case NR_BSR_Config__periodicBSR_Timer_sf2560:
timer = 2560;
break;
case NR_BSR_Config__periodicBSR_Timer_infinity:
timer = UINT_MAX;
default:
AssertFatal(false, "Invalid periodicBSR_Timer %ld\n", periodicBSR);
}
return timer;
}
static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroupConfig_t *mcg)
{
......@@ -1669,7 +1725,10 @@ static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroup
}
if (mcg->bsr_Config) {
int subframes_per_slot = nr_slots_per_frame[mac->current_UL_BWP->scs] / 10;
si->periodicBSR_Timer = mcg->bsr_Config->periodicBSR_Timer;
uint32_t periodic_sf = nr_get_sf_periodicBSRTimer(mcg->bsr_Config->periodicBSR_Timer);
uint32_t target = periodic_sf < UINT_MAX ? periodic_sf * subframes_per_slot : periodic_sf;
nr_timer_setup(&si->periodicBSR_Timer, target, 1); // 1 slot update rate
nr_timer_start(&si->periodicBSR_Timer);
uint32_t retx_sf = nr_get_sf_retxBSRTimer(mcg->bsr_Config->retxBSR_Timer);
nr_timer_setup(&si->retxBSR_Timer, retx_sf * subframes_per_slot, 1); // 1 slot update rate
if (mcg->bsr_Config->logicalChannelSR_DelayTimer) {
......
......@@ -216,10 +216,8 @@ typedef struct {
NR_timer_t sr_DelayTimer;
/// retxBSR-Timer
NR_timer_t retxBSR_Timer;
/// periodicBSR-Timer, default to infinity
uint16_t periodicBSR_Timer;
/// periodicBSR_SF, number of subframe before triggering a periodic BSR
uint16_t periodicBSR_SF;
/// periodicBSR-Timer
NR_timer_t periodicBSR_Timer;
/// default value is 0: not configured
uint16_t sr_ProhibitTimer;
/// sr ProhibitTime running
......@@ -239,10 +237,6 @@ typedef struct {
int16_t prohibitPHR_SF;
///DL Pathloss Change in db
uint16_t PathlossChange_db;
/// default value is false
uint16_t extendedBSR_Sizes_r10;
/// default value is false
uint16_t extendedPHR_r10;
} NR_UE_SCHEDULING_INFO;
typedef enum {
......
......@@ -139,13 +139,6 @@ void nr_update_bsr(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP, uint8_t
uint8_t nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size,
int value);
/*! \fn int nr_get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer)
\brief get the number of subframe from the periodic BSR timer configured by the higher layers
\param[in] periodicBSR_Timer timer for periodic BSR
\return the number of subframe
*/
int nr_get_sf_periodicBSRTimer(uint8_t bucketSize);
int8_t nr_ue_process_dci(NR_UE_MAC_INST_t *mac,
int cc_id,
frame_t frame,
......
......@@ -85,12 +85,12 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
{
// default values as defined in 38.331 sec 9.2.2
// sf80 default for retxBSR_Timer
// sf80 default for retxBSR_Timer sf10 for periodicBSR_Timer
int mu = mac->current_UL_BWP ? mac->current_UL_BWP->scs : get_softmodem_params()->numerology;
int subframes_per_slot = nr_slots_per_frame[mu] / 10;
nr_timer_setup(&mac->scheduling_info.retxBSR_Timer, 80 * subframes_per_slot, 1); // 1 slot update rate
nr_timer_setup(&mac->scheduling_info.periodicBSR_Timer, 10 * subframes_per_slot, 1); // 1 slot update rate
mac->scheduling_info.periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10;
mac->scheduling_info.periodicPHR_Timer = NR_PHR_Config__phr_PeriodicTimer_sf10;
mac->scheduling_info.prohibitPHR_Timer = NR_PHR_Config__phr_ProhibitTimer_sf10;
}
......@@ -192,7 +192,6 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
nr_mac->scheduling_info.sr_id = -1; // invalid init value
// cancel any triggered Buffer Status Reporting procedure
nr_mac->scheduling_info.periodicBSR_SF = NR_MAC_UE_BSR_TIMER_NOT_RUNNING;
nr_mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE;
// cancel any triggered Power Headroom Reporting procedure
......
......@@ -149,6 +149,12 @@ void update_mac_timers(NR_UE_MAC_INST_t *mac)
}
}
}
bool periodicBSR_expired = nr_timer_tick(&mac->scheduling_info.periodicBSR_Timer);
if (periodicBSR_expired) {
// periodicBSR-Timer expires, trigger BSR
mac->BSR_reporting_active |= NR_BSR_TRIGGER_PERIODIC;
LOG_D(NR_MAC, "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry\n", mac->ue_id);
}
for (int i = 0; i < NR_MAX_NUM_LCID; i++)
AssertFatal(!nr_timer_tick(&mac->scheduling_info.lc_sched_info[i].Bj_timer),
"Bj timer for LCID %d expired! That should never happen\n",
......@@ -1214,11 +1220,6 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info)
// Call BSR procedure as described in Section 5.4.5 in 38.321
// Decrement Periodic Timer if it is running and not null
if ((mac->scheduling_info.periodicBSR_SF != NR_MAC_UE_BSR_TIMER_NOT_RUNNING) && (mac->scheduling_info.periodicBSR_SF != 0)) {
mac->scheduling_info.periodicBSR_SF--;
}
//Check whether BSR is triggered
nr_update_bsr(mac, frame_tx, slot_tx, gNB_index);
......@@ -1327,75 +1328,6 @@ uint8_t nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size, int valu
}
}
int nr_get_sf_periodicBSRTimer(uint8_t sf_offset) {
switch (sf_offset) {
case NR_BSR_Config__periodicBSR_Timer_sf1:
return 1;
break;
case NR_BSR_Config__periodicBSR_Timer_sf5:
return 5;
break;
case NR_BSR_Config__periodicBSR_Timer_sf10:
return 10;
break;
case NR_BSR_Config__periodicBSR_Timer_sf16:
return 16;
break;
case NR_BSR_Config__periodicBSR_Timer_sf20:
return 20;
break;
case NR_BSR_Config__periodicBSR_Timer_sf32:
return 32;
break;
case NR_BSR_Config__periodicBSR_Timer_sf40:
return 40;
break;
case NR_BSR_Config__periodicBSR_Timer_sf64:
return 64;
break;
case NR_BSR_Config__periodicBSR_Timer_sf80:
return 80;
break;
case NR_BSR_Config__periodicBSR_Timer_sf128:
return 128;
break;
case NR_BSR_Config__periodicBSR_Timer_sf160:
return 160;
break;
case NR_BSR_Config__periodicBSR_Timer_sf320:
return 320;
break;
case NR_BSR_Config__periodicBSR_Timer_sf640:
return 640;
break;
case NR_BSR_Config__periodicBSR_Timer_sf1280:
return 1280;
break;
case NR_BSR_Config__periodicBSR_Timer_sf2560:
return 2560;
break;
case NR_BSR_Config__periodicBSR_Timer_infinity:
default:
return 0xFFFF;
break;
}
}
// PUSCH scheduler:
// - Calculate the slot in which ULSCH should be scheduled. This is current slot + K2,
// - where K2 is the offset between the slot in which UL DCI is received and the slot
......@@ -2528,19 +2460,6 @@ static int nr_ue_get_sdu_mac_ce_pre(NR_UE_MAC_INST_t *mac,
lcg_id++;
}
// periodicBSR-Timer expires, trigger BSR
if ((mac->scheduling_info.periodicBSR_Timer != NR_BSR_Config__periodicBSR_Timer_infinity)
&& (mac->scheduling_info.periodicBSR_SF == 0)) {
// Trigger BSR Periodic
mac->BSR_reporting_active |= NR_BSR_TRIGGER_PERIODIC;
LOG_D(NR_MAC,
"[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n",
mac->ue_id,
frameP,
subframe,
buflen);
}
//Compute BSR Length if Regular or Periodic BSR is triggered
//WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx
if (mac->BSR_reporting_active) {
......@@ -2742,9 +2661,9 @@ static void nr_ue_get_sdu_mac_ce_post(NR_UE_MAC_INST_t *mac,
// Reset ReTx BSR Timer
nr_timer_start(&mac->scheduling_info.retxBSR_Timer);
// Reset Periodic Timer except when BSR is truncated
if ((mac_ce_p->bsr_t == NULL) && (mac->scheduling_info.periodicBSR_Timer != NR_BSR_Config__periodicBSR_Timer_infinity)) {
mac->scheduling_info.periodicBSR_SF = nr_get_sf_periodicBSRTimer(mac->scheduling_info.periodicBSR_Timer);
LOG_D(NR_MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n", mac->ue_id, mac->scheduling_info.periodicBSR_SF);
if (mac_ce_p->bsr_t == NULL) {
nr_timer_start(&mac->scheduling_info.periodicBSR_Timer);
LOG_D(NR_MAC, "[UE %d] MAC Periodic BSR Timer Reset\n", mac->ue_id);
}
// Reset BSR Trigger flags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment