Commit 04ac336c authored by francescomani's avatar francescomani

improvements in function to update BSR status

parent 5df946fa
......@@ -63,11 +63,6 @@
#define RAR_PAYLOAD_SIZE_MAX 128
#define MAX_CSI_REPORTCONFIG 48
#define NR_BSR_TRIGGER_NONE (0) /* No BSR Trigger */
#define NR_BSR_TRIGGER_REGULAR (1) /* For Regular and ReTxBSR Expiry Triggers */
#define NR_BSR_TRIGGER_PERIODIC (2) /* For BSR Periodic Timer Expiry Trigger */
#define NR_BSR_TRIGGER_PADDING (4) /* For Padding BSR Trigger */
// For both DL/UL-SCH
// Except:
// - UL/DL-SCH: fixed-size MAC CE(known by LCID)
......
......@@ -744,21 +744,24 @@ static void nr_configure_lc_config(NR_UE_MAC_INST_t *mac,
NR_LogicalChannelConfig_t *mac_lc_config,
NR_SRB_Identity_t srb_id)
{
NR_LC_SCHEDULING_INFO *lc_sched_info = get_scheduling_info_from_lcid(mac, lc_info->lcid);
if (srb_id > 0 && !mac_lc_config->ul_SpecificParameters) {
// release configuration and reset to default
set_default_logicalchannelconfig(lc_info, srb_id);
mac->scheduling_info.lc_sched_info[lc_info->lcid - 1].LCGID = 0;
// invalid LCGID to signal it is absent in the configuration
lc_sched_info->LCGID = NR_INVALID_LCGID;
return;
}
AssertFatal(mac_lc_config->ul_SpecificParameters, "UL parameters shouldn't be NULL for DRBs\n");
struct NR_LogicalChannelConfig__ul_SpecificParameters *ul_parm = mac_lc_config->ul_SpecificParameters;
lc_info->priority = ul_parm->priority;
lc_info->sr_DelayTimerApplied = ul_parm->logicalChannelSR_DelayTimerApplied;
lc_info->pbr = nr_get_pbr(ul_parm->prioritisedBitRate);
// TODO Verify setting to 0 is ok, 331 just says need R (release if NULL)
mac->scheduling_info.lc_sched_info[lc_info->lcid - 1].LCGID = ul_parm->logicalChannelGroup ? *ul_parm->logicalChannelGroup : 0;
// if logicalChannelGroup we release LCGID and set it to invalid
lc_sched_info->LCGID = ul_parm->logicalChannelGroup ? *ul_parm->logicalChannelGroup : NR_INVALID_LCGID;
lc_info->bucket_size = get_lc_bucket_size(ul_parm->prioritisedBitRate, ul_parm->bucketSizeDuration);
// setup and start Bj timer for this LC
NR_timer_t *bjt = &mac->scheduling_info.lc_sched_info[lc_info->lcid - 1].Bj_timer;
NR_timer_t *bjt = &lc_sched_info->Bj_timer;
nr_timer_setup(bjt, UINT_MAX, 1); // this timer never expires in principle, counter incremented by number of slots
nr_timer_start(bjt);
}
......@@ -1557,6 +1560,37 @@ static void configure_physicalcellgroup(NR_UE_MAC_INST_t *mac,
*p_UE_FR1 : *p_NR_FR1);
}
static uint32_t get_sr_DelayTimer(long logicalChannelSR_DelayTimer)
{
uint32_t timer = 0;
switch (logicalChannelSR_DelayTimer) {
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf20 :
timer = 20;
break;
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf40 :
timer = 40;
break;
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf64 :
timer = 64;
break;
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf128 :
timer = 128;
break;
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf512 :
timer = 512;
break;
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf1024 :
timer = 1024;
break;
case NR_BSR_Config__logicalChannelSR_DelayTimer_sf2560 :
timer = 2560;
break;
default :
AssertFatal(false, "Invalid SR_DelayTimer %ld\n", logicalChannelSR_DelayTimer);
}
return timer;
}
static void configure_maccellgroup(NR_UE_MAC_INST_t *mac, const NR_MAC_CellGroupConfig_t *mcg)
{
NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info;
......@@ -1590,10 +1624,13 @@ 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;
si->retxBSR_Timer = mcg->bsr_Config->retxBSR_Timer;
if (mcg->bsr_Config->logicalChannelSR_DelayTimer)
LOG_E(NR_MAC, "Handling of logicalChannelSR_DelayTimer not implemented\n");
if (mcg->bsr_Config->logicalChannelSR_DelayTimer) {
uint32_t target_sf = get_sr_DelayTimer(*mcg->bsr_Config->logicalChannelSR_DelayTimer);
nr_timer_setup(&si->sr_DelayTimer, target_sf * subframes_per_slot, 1); // 1 slot update rate
}
}
if (mcg->tag_Config) {
// TODO TAG not handled
......@@ -2053,9 +2090,6 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id,
AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n");
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
if (cell_group_config->mac_CellGroupConfig)
configure_maccellgroup(mac, cell_group_config->mac_CellGroupConfig);
if (cell_group_config->physicalCellGroupConfig)
configure_physicalcellgroup(mac, cell_group_config->physicalCellGroupConfig);
......@@ -2073,6 +2107,9 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id,
}
}
if (cell_group_config->mac_CellGroupConfig)
configure_maccellgroup(mac, cell_group_config->mac_CellGroupConfig);
configure_logicalChannelBearer(mac,
cell_group_config->rlc_BearerToAddModList,
cell_group_config->rlc_BearerToReleaseList);
......
......@@ -68,6 +68,13 @@
// NR UE defs
// ==========
#define NR_BSR_TRIGGER_NONE (0) /* No BSR Trigger */
#define NR_BSR_TRIGGER_REGULAR (1) /* For Regular and ReTxBSR Expiry Triggers */
#define NR_BSR_TRIGGER_PERIODIC (2) /* For BSR Periodic Timer Expiry Trigger */
#define NR_BSR_TRIGGER_PADDING (4) /* For Padding BSR Trigger */
#define NR_INVALID_LCGID (NR_MAX_NUM_LCGID)
#define MAX_NUM_BWP_UE 5
#define NUM_SLOT_FRAME 10
......@@ -205,6 +212,8 @@ typedef struct {
uint8_t SR_pending;
/// SR_COUNTER as defined in 38.321
uint16_t SR_COUNTER;
// logicalChannelSR-DelayTimer
NR_timer_t sr_DelayTimer;
/// retxBSR-Timer, default value is sf2560
uint16_t retxBSR_Timer;
/// retxBSR_SF, number of subframe before triggering a regular BSR
......@@ -445,6 +454,7 @@ typedef struct nr_lcordered_info_s {
uint32_t pbr; // in B/s (UINT_MAX = infinite)
// Bucket size per lcid
uint32_t bucket_size;
bool sr_DelayTimerApplied;
} nr_lcordered_info_t;
......
......@@ -47,6 +47,7 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac);
void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data);
void update_mac_timers(NR_UE_MAC_INST_t *mac);
NR_LC_SCHEDULING_INFO *get_scheduling_info_from_lcid(NR_UE_MAC_INST_t *mac, NR_LogicalChannelIdentity_t lcid);
/**\brief apply default configuration values in nr_mac instance
\param mac mac instance */
......@@ -126,7 +127,7 @@ int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP);
\param[in] slotP number
\param[in] gNB_index
*/
bool nr_update_bsr(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP, uint8_t gNB_index);
void nr_update_bsr(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP, uint8_t gNB_index);
/*! \fn nr_locate_BsrIndexByBufferSize (int *table, int size, int value)
\brief locate the BSR level in the table as defined in 38.321. This function requires that he values in table to be monotonic, either increasing or decreasing. The returned value is not less than 0, nor greater than n-1, where n is the size of table.
......
......@@ -72,6 +72,9 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac)
mac->p_Max_alt = INT_MIN;
reset_mac_inst(mac);
// need to inizialize because might not been setup (optional timer)
nr_timer_stop(&mac->scheduling_info.sr_DelayTimer);
memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements));
memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment));
memset(mac->ssb_list, 0, sizeof(mac->ssb_list));
......@@ -144,13 +147,19 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
// initialize Bj for each logical channel to zero
// TODO reset also other status variables of LC, is this ok?
for (int i = 0; i < NR_MAX_NUM_LCID; i++) {
LOG_D(NR_MAC, "Applying default logical channel config for LCID %d\n", i);
nr_mac->scheduling_info.lc_sched_info[i].Bj = 0;
nr_mac->scheduling_info.lc_sched_info[i].LCID_buffer_with_data = false;
nr_mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0;
}
// TODO stop all running timers
for (int i = 0; i < NR_MAX_NUM_LCID; i++) {
nr_mac->scheduling_info.lc_sched_info[i].Bj = 0;
nr_timer_stop(&nr_mac->scheduling_info.lc_sched_info[i].Bj_timer);
}
nr_timer_stop(&nr_mac->ra.contention_resolution_timer);
nr_timer_stop(&nr_mac->scheduling_info.sr_DelayTimer);
// consider all timeAlignmentTimers as expired and perform the corresponding actions in clause 5.2
// TODO
......
This diff is collapsed.
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