Commit f5b5c7d2 authored by francescomani's avatar francescomani

remove pointer to logicalChannelConfig in LC ordered info and store actual values in the list

parent 05281ded
......@@ -42,32 +42,6 @@
#include "SCHED_NR/phy_frame_config_nr.h"
#include "oai_asn1.h"
const long logicalChannelGroup0_NR = 0;
typedef struct NR_LogicalChannelConfig__ul_SpecificParameters LcConfig_UlParamas_t;
const LcConfig_UlParamas_t NR_LCSRB1 = {
.priority = 1,
.prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity,
.logicalChannelGroup = (long *)&logicalChannelGroup0_NR};
const LcConfig_UlParamas_t NR_LCSRB2 = {
.priority = 3,
.prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity,
.logicalChannelGroup = (long *)&logicalChannelGroup0_NR};
const LcConfig_UlParamas_t NR_LCSRB3 = {
.priority = 1,
.prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity,
.logicalChannelGroup = (long *)&logicalChannelGroup0_NR};
// these are the default values for SRB configurations(SRB1 and SRB2) as mentioned in 36.331 pg 258-259
const NR_LogicalChannelConfig_t NR_SRB1_logicalChannelConfig_defaultValue = {.ul_SpecificParameters =
(LcConfig_UlParamas_t *)&NR_LCSRB1};
const NR_LogicalChannelConfig_t NR_SRB2_logicalChannelConfig_defaultValue = {.ul_SpecificParameters =
(LcConfig_UlParamas_t *)&NR_LCSRB2};
const NR_LogicalChannelConfig_t NR_SRB3_logicalChannelConfig_defaultValue = {.ul_SpecificParameters =
(LcConfig_UlParamas_t *)&NR_LCSRB3};
void set_tdd_config_nr_ue(fapi_nr_tdd_table_t *tdd_table,
int mu,
NR_TDD_UL_DL_Pattern_t *pattern)
......@@ -650,14 +624,11 @@ static void configure_ss_coreset(NR_BWP_PDCCH_t *pdcch, NR_PDCCH_Config_t *pdcch
static int lcid_cmp(const void *a, const void *b)
{
long pa, pb;
memcpy(&pa, &((nr_lcordered_info_t*)a)->logicalChannelConfig->ul_SpecificParameters->priority, sizeof(pa));
memcpy(&pb, &((nr_lcordered_info_t*)b)->logicalChannelConfig->ul_SpecificParameters->priority, sizeof(pb));
if (pa < pb)
return -1;
else if (pa > pb)
return 1;
return 0;
long priority_a = (*((nr_lcordered_info_t**)a))->priority;
AssertFatal(priority_a > 0 && priority_a < 17, "Invalid priority value %ld\n", priority_a);
long priority_b = (*((nr_lcordered_info_t**)b))->priority;
AssertFatal(priority_b > 0 && priority_b < 17, "Invalid priority value %ld\n", priority_b);
return priority_a - priority_b;
}
static int nr_get_ms_bucketsizeduration(long bucketsizeduration)
......@@ -686,28 +657,47 @@ static int nr_get_ms_bucketsizeduration(long bucketsizeduration)
}
}
void nr_configure_sched_info(NR_UE_MAC_INST_t *mac, long channel_identity, NR_LogicalChannelConfig_t *lc_config)
static uint32_t get_lc_bucket_size(long prioritisedBitRate, long bucketSizeDuration)
{
LOG_D(NR_MAC, "Applying RRC Logical Channel Config to lcid %li\n", channel_identity);
int pbr = nr_get_pbr(prioritisedBitRate);
// in infinite pbr, the bucket is saturated by pbr
int bsd = 0;
if (prioritisedBitRate == NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity)
bsd = 1;
else
bsd = nr_get_ms_bucketsizeduration(bucketSizeDuration);
// initialize the variable Bj for every LCID
mac->scheduling_info.lc_sched_info[channel_identity - 1].Bj = 0;
return pbr * bsd;
}
// store the bucket size
int pbr = nr_get_pbr(lc_config->ul_SpecificParameters->prioritisedBitRate);
int bsd = nr_get_ms_bucketsizeduration(lc_config->ul_SpecificParameters->bucketSizeDuration);
static void set_default_logicalchannelconfig(nr_lcordered_info_t *lc_info, NR_SRB_Identity_t srb_id)
{
lc_info->lcid = srb_id;
lc_info->priority = srb_id == 2 ? 3 : 1;
lc_info->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
lc_info->bucket_size = get_lc_bucket_size(lc_info->prioritisedBitRate, 0);
lc_info->Bj = 0;
}
// in infinite pbr, the bucket is saturated by pbr
if (lc_config->ul_SpecificParameters->prioritisedBitRate
== NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity) {
bsd = 1;
static void nr_configure_lc_config(NR_UE_MAC_INST_t *mac,
nr_lcordered_info_t *lc_info,
NR_LogicalChannelConfig_t *mac_lc_config,
NR_SRB_Identity_t srb_id)
{
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;
return;
}
mac->scheduling_info.lc_sched_info[channel_identity - 1].bucket_size = pbr * bsd;
if (lc_config->ul_SpecificParameters->logicalChannelGroup != NULL)
mac->scheduling_info.lc_sched_info[channel_identity - 1].LCGID = *lc_config->ul_SpecificParameters->logicalChannelGroup;
else
mac->scheduling_info.lc_sched_info[channel_identity - 1].LCGID = 0;
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->prioritisedBitRate = 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;
lc_info->bucket_size = get_lc_bucket_size(ul_parm->prioritisedBitRate, ul_parm->bucketSizeDuration);
lc_info->Bj = 0;
}
static void configure_logicalChannelBearer(module_id_t module_id,
......@@ -726,7 +716,6 @@ static void configure_logicalChannelBearer(module_id_t module_id,
}
if (j < mac->lc_ordered_list.count) {
nr_lcordered_info_t *lc_info = mac->lc_ordered_list.array[j];
free(lc_info->logicalChannelConfig);
asn_sequence_del(&mac->lc_ordered_list, j, 0);
free(lc_info);
}
......@@ -748,10 +737,10 @@ static void configure_logicalChannelBearer(module_id_t module_id,
if (j < mac->lc_ordered_list.count) {
LOG_D(NR_MAC, "Logical channel %d is already established, Reconfiguring now\n", lc_identity);
if (mac_lc_config != NULL) {
nr_configure_sched_info(mac, lc_identity, mac_lc_config);
UPDATE_MAC_IE(mac->lc_ordered_list.array[j]->logicalChannelConfig,
rlc_bearer->mac_LogicalChannelConfig,
NR_LogicalChannelConfig_t);
NR_SRB_Identity_t srb_id = 0;
if (rlc_bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
srb_id = rlc_bearer->servedRadioBearer->choice.srb_Identity;
nr_configure_lc_config(mac, mac->lc_ordered_list.array[j], mac_lc_config, srb_id);
}
}
else {
......@@ -762,29 +751,14 @@ static void configure_logicalChannelBearer(module_id_t module_id,
AssertFatal(rlc_bearer->servedRadioBearer, "servedRadioBearer should be present for LCID establishment\n");
if (rlc_bearer->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity) { /* SRB */
NR_SRB_Identity_t srb_id = rlc_bearer->servedRadioBearer->choice.srb_Identity;
if (mac_lc_config != NULL) {
UPDATE_MAC_IE(lc_info->logicalChannelConfig, rlc_bearer->mac_LogicalChannelConfig, NR_LogicalChannelConfig_t);
} else {
LOG_D(NR_RRC, "Applying the default logicalChannelConfig for SRB\n");
switch (srb_id) {
case 1 :
lc_info->logicalChannelConfig = (NR_LogicalChannelConfig_t *)&NR_SRB1_logicalChannelConfig_defaultValue;
break;
case 2 :
lc_info->logicalChannelConfig = (NR_LogicalChannelConfig_t *)&NR_SRB2_logicalChannelConfig_defaultValue;
break;
case 3 :
lc_info->logicalChannelConfig = (NR_LogicalChannelConfig_t *)&NR_SRB3_logicalChannelConfig_defaultValue;
break;
default :
AssertFatal(false, "The logical id %d is not a valid SRB id %li\n", lc_identity, srb_id);
}
}
if (mac_lc_config != NULL)
nr_configure_lc_config(mac, lc_info, mac_lc_config, srb_id);
else
set_default_logicalchannelconfig(lc_info, srb_id);
} else { /* DRB */
AssertFatal(mac_lc_config, "When establishing a DRB, LogicalChannelConfig should be mandatorily present\n");
UPDATE_MAC_IE(lc_info->logicalChannelConfig, rlc_bearer->mac_LogicalChannelConfig, NR_LogicalChannelConfig_t);
nr_configure_lc_config(mac, lc_info, mac_lc_config, 0);
}
nr_configure_sched_info(mac, lc_identity, lc_info->logicalChannelConfig);
ASN_SEQUENCE_ADD(&mac->lc_ordered_list, lc_info);
}
}
......
......@@ -181,12 +181,8 @@ typedef struct {
int32_t LCID_buffer_remain;
// buffer status for each lcid
uint8_t LCID_status;
// Bj bucket usage per lcid
int32_t Bj;
// Bucket size per lcid
int32_t bucket_size;
// logical channel group id for each LCID
uint8_t LCGID;
// logical channel group id of this LCID
long LCGID;
} NR_LC_SCHEDULING_INFO;
typedef struct {
......@@ -433,8 +429,12 @@ typedef struct ssb_list_info {
typedef struct nr_lcordered_info_s {
// logical channels ids ordered as per priority
NR_LogicalChannelIdentity_t lcid;
// logical channel configurations reordered as per priority
NR_LogicalChannelConfig_t *logicalChannelConfig;
long priority;
long prioritisedBitRate;
// Bucket size per lcid
uint32_t bucket_size;
// Bj bucket usage per lcid
int32_t Bj;
} nr_lcordered_info_t;
typedef struct {
......
......@@ -239,12 +239,12 @@ bool nr_update_bsr(module_id_t module_idP, 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_pbr(uint8_t prioritizedbitrate)
/*! \fn int nr_get_pbr(long prioritizedbitrate)
\brief get the rate in kbps from the rate configured by the higher layer
\param[in] prioritizedbitrate
\return the rate in kbps
*/
uint32_t nr_get_pbr(uint8_t prioritizedbitrate);
uint32_t nr_get_pbr(long prioritizedbitrate);
/*! \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
......
......@@ -95,9 +95,6 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
for (int i = 0; i < NR_MAX_NUM_LCID; i++) {
LOG_D(NR_MAC, "Applying default logical channel config for LCGID %d\n", i);
mac->scheduling_info.lc_sched_info[i].Bj = -1;
mac->scheduling_info.lc_sched_info[i].bucket_size = -1;
mac->scheduling_info.lc_sched_info[i].LCGID = 0; // defaults to 0 irrespective of SRB or DRB
mac->scheduling_info.lc_sched_info[i].LCID_status = LCID_EMPTY;
mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0;
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++)
......@@ -143,7 +140,8 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
nr_ue_mac_default_configs(nr_mac);
// initialize Bj for each logical channel to zero
// Done in default config but to -1 (is that correct?)
for (int i = 0; i < nr_mac->lc_ordered_list.count; i++)
nr_mac->lc_ordered_list.array[i]->Bj = 0;
// stop all running timers
// TODO
......@@ -219,7 +217,6 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac)
for (int i = 0; i < mac->lc_ordered_list.count; i++) {
nr_lcordered_info_t *lc_info = mac->lc_ordered_list.array[i];
free(lc_info->logicalChannelConfig);
asn_sequence_del(&mac->lc_ordered_list, i, 0);
free(lc_info);
}
......
......@@ -1097,11 +1097,10 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
// update Bj for all active lcids before LCP procedure
LOG_D(NR_MAC, "====================[Frame %d][Slot %d]Logical Channel Prioritization===========\n", frame_tx, slot_tx);
for (int i = 0; i < mac->lc_ordered_list.count; i++) {
int lcid = mac->lc_ordered_list.array[i]->lcid;
NR_LogicalChannelConfig_t *lcconfig = mac->lc_ordered_list.array[i]->logicalChannelConfig;
NR_LC_SCHEDULING_INFO *sched_lc = &mac->scheduling_info.lc_sched_info[lcid - 1];
nr_lcordered_info_t *lc_info = mac->lc_ordered_list.array[i];
int lcid = lc_info->lcid;
// max amount of data that can be buffered/accumulated in a logical channel buffer
int32_t bucketSize_max = sched_lc->bucket_size;
int32_t bucketSize_max = lc_info->bucket_size;
AssertFatal(bucketSize_max >= 0, "negative bucketSize_max %d, will never schedule UE: lcid %d\n",bucketSize_max, lcid);
/*
......@@ -1109,15 +1108,13 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
increment the value of Bj by product PBR * T
*/
int T = 1; // time elapsed since Bj was last incremented
int32_t bj = sched_lc->Bj;
bj += nr_get_pbr(lcconfig->ul_SpecificParameters->prioritisedBitRate) * T;
if (lcconfig->ul_SpecificParameters->prioritisedBitRate
== NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity) {
bj = nr_get_pbr(lcconfig->ul_SpecificParameters->prioritisedBitRate);
}
int32_t bj = lc_info->Bj;
bj += nr_get_pbr(lc_info->prioritisedBitRate) * T;
if (lc_info->prioritisedBitRate == NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity)
bj = nr_get_pbr(lc_info->prioritisedBitRate);
// bj > max bucket size, set bj to max bucket size, as in ts38.321 5.4.3.1 Logical Channel Prioritization
sched_lc->Bj = min(bj, bucketSize_max);
lc_info->Bj = min(bj, bucketSize_max);
}
// Call BSR procedure as described in Section 5.4.5 in 38.321
......@@ -1253,7 +1250,7 @@ bool nr_update_bsr(module_id_t module_idP, frame_t frameP, slot_t slotP, uint8_t
{
bsr_regular_triggered = true;
LOG_D(NR_MAC,
"[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d slot %d\n",
"[UE %d] PDCCH Tick : MAC BSR Triggered LCID %d LCGID %ld data become available at frame %d slot %d\n",
module_idP,
lcid,
mac->scheduling_info.lc_sched_info[lcid - 1].LCGID,
......@@ -2901,8 +2898,7 @@ uint32_t get_count_lcids_same_priority(uint8_t start, uint8_t total_active_lcids
uint8_t same_priority_count = 0;
uint8_t curr_lcid = lcid_ordered_array[start].lcid;
for (uint8_t index = start; index < total_active_lcids; index++) {
if (lcid_ordered_array[start].logicalChannelConfig->ul_SpecificParameters->priority ==
lcid_ordered_array[index].logicalChannelConfig->ul_SpecificParameters->priority) {
if (lcid_ordered_array[start].priority == lcid_ordered_array[index].priority) {
same_priority_count++;
}
}
......@@ -2920,15 +2916,15 @@ long get_num_bytes_to_reqlc(NR_UE_MAC_INST_t *mac,
long *target)
{
/* Calculates the number of bytes the logical channel should request from the correcponding RLC buffer*/
NR_LogicalChannelConfig_t *lc_config = NULL;
long found_pbr = -1;
for (int i = 0; i < mac->lc_ordered_list.count; i++) {
if (mac->lc_ordered_list.array[i]->lcid == lc_num) {
lc_config = mac->lc_ordered_list.array[i]->logicalChannelConfig;
found_pbr = mac->lc_ordered_list.array[i]->prioritisedBitRate;
break;
}
}
AssertFatal(lc_config, "Couldn't find LC config for ID %d\n", lc_num);
long pbr = nr_get_pbr(lc_config->ul_SpecificParameters->prioritisedBitRate);
AssertFatal(found_pbr >= 0, "Couldn't find LC config for ID %d\n", lc_num);
uint32_t pbr = nr_get_pbr(found_pbr);
int32_t lcid_remain_buffer = mac->scheduling_info.lc_sched_info[lc_num - 1].LCID_buffer_remain;
*target = (same_priority_count > 1) ? min(buflen_remain_ep, pbr) : pbr;
......@@ -2974,10 +2970,8 @@ static void select_logical_channels(NR_UE_MAC_INST_t *mac, int *num_active_lcids
// selection of logical channels with Bj > 0
for (int i = 0; i < mac->lc_ordered_list.count; i++) {
int lcid = mac->lc_ordered_list.array[i]->lcid;
NR_LogicalChannelConfig_t *logicalChannelConfig = mac->lc_ordered_list.array[i]->logicalChannelConfig;
if (mac->scheduling_info.lc_sched_info[lcid - 1].Bj > 0) {
active_lcids[*num_active_lcids].lcid = lcid;
active_lcids[*num_active_lcids].logicalChannelConfig = logicalChannelConfig;
if (mac->lc_ordered_list.array[i]->Bj > 0) {
active_lcids[*num_active_lcids] = *mac->lc_ordered_list.array[i];
(*num_active_lcids)++;
LOG_D(NR_MAC, "The available lcid is %d with total active channels count = %d\n", lcid, *num_active_lcids);
}
......@@ -3051,13 +3045,21 @@ static bool fill_mac_sdu(module_id_t module_idP,
// currently the Bj is drecremented by size of MAC SDus everytime it is served to logical channel, so by this approach there
// will be more chance for lower priority logical channels to be served in the next TTI
// second approach can also be followed where Bj is decremented only in the first round but not in the subsequent rounds
sched_info->lc_sched_info[lcid - 1].Bj -= sdu_length;
bool found = false;
for (int i = 0; i < mac->lc_ordered_list.count; i++) {
if (lcid == mac->lc_ordered_list.array[i]->lcid) {
found = true;
mac->lc_ordered_list.array[i]->Bj -= sdu_length;
LOG_D(NR_MAC,
"decrement Bj of the lcid %d by size of sdu length = %d and new Bj for lcid %d is %d\n",
lcid,
sdu_length,
lcid,
sched_info->lc_sched_info[lcid - 1].Bj);
mac->lc_ordered_list.array[i]->Bj);
break;
}
}
AssertFatal(found, "Couldn't find LCID %d in lc_ordered_list\n", lcid);
if (sdu_length > 0) {
LOG_D(NR_MAC,
......@@ -3105,7 +3107,7 @@ static bool fill_mac_sdu(module_id_t module_idP,
lc_info->LCID_buffer_remain -= sdu_length;
(lcg_info + lc_info->LCGID)->BSR_bytes -= sdu_length;
LOG_D(NR_MAC,
"[UE %d] Update BSR [%d.%d] BSR_bytes for LCG%d = %d\n",
"[UE %d] Update BSR [%d.%d] BSR_bytes for LCG %ld = %d\n",
module_idP,
frameP,
subframe,
......@@ -3352,7 +3354,7 @@ void schedule_ta_command(fapi_nr_dl_config_request_t *dl_config, NR_UL_TIME_ALIG
ul_time_alignment->ta_apply = false;
}
uint32_t nr_get_pbr(uint8_t prioritizedbitrate)
uint32_t nr_get_pbr(long prioritizedbitrate)
{
int32_t pbr = -1;
switch (prioritizedbitrate) {
......
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