Commit eaff52f8 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/NR_UE_MAC_UL_improvements' into integration_2024_w12

parents 3042c70d c090b1f7
...@@ -1011,6 +1011,8 @@ bool nr_timer_tick(NR_timer_t *timer) ...@@ -1011,6 +1011,8 @@ bool nr_timer_tick(NR_timer_t *timer)
bool expired = false; bool expired = false;
if (timer->active) { if (timer->active) {
timer->counter += timer->step; timer->counter += timer->step;
if (timer->target == UINT_MAX) // infinite target, never expires
return false;
expired = nr_timer_expired(*timer); expired = nr_timer_expired(*timer);
if (expired) if (expired)
timer->active = false; timer->active = false;
...@@ -1020,9 +1022,16 @@ bool nr_timer_tick(NR_timer_t *timer) ...@@ -1020,9 +1022,16 @@ bool nr_timer_tick(NR_timer_t *timer)
bool nr_timer_expired(NR_timer_t timer) bool nr_timer_expired(NR_timer_t timer)
{ {
if (timer.target == UINT_MAX) // infinite target, never expires
return false;
return (timer.counter >= timer.target); return (timer.counter >= timer.target);
} }
uint32_t nr_timer_elapsed_time(NR_timer_t timer)
{
return timer.counter;
}
void nr_timer_setup(NR_timer_t *timer, const uint32_t target, const uint32_t step) void nr_timer_setup(NR_timer_t *timer, const uint32_t target, const uint32_t step)
{ {
timer->target = target; timer->target = target;
......
...@@ -158,6 +158,13 @@ bool nr_timer_expired(NR_timer_t timer); ...@@ -158,6 +158,13 @@ bool nr_timer_expired(NR_timer_t timer);
* @return Indication if the timer is active or not * @return Indication if the timer is active or not
*/ */
bool is_nr_timer_active(NR_timer_t timer); bool is_nr_timer_active(NR_timer_t timer);
/**
* @brief To return how much time has passed since start of timer
* @param timer Timer to be checked
* @return Time passed since start of timer
*/
uint32_t nr_timer_elapsed_time(NR_timer_t timer);
extern const nr_bandentry_t nr_bandtable[]; extern const nr_bandentry_t nr_bandtable[];
......
...@@ -63,11 +63,6 @@ ...@@ -63,11 +63,6 @@
#define RAR_PAYLOAD_SIZE_MAX 128 #define RAR_PAYLOAD_SIZE_MAX 128
#define MAX_CSI_REPORTCONFIG 48 #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 // For both DL/UL-SCH
// Except: // Except:
// - UL/DL-SCH: fixed-size MAC CE(known by LCID) // - UL/DL-SCH: fixed-size MAC CE(known by LCID)
......
This diff is collapsed.
...@@ -68,6 +68,13 @@ ...@@ -68,6 +68,13 @@
// NR UE defs // 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 MAX_NUM_BWP_UE 5
#define NUM_SLOT_FRAME 10 #define NUM_SLOT_FRAME 10
...@@ -185,6 +192,7 @@ typedef struct { ...@@ -185,6 +192,7 @@ typedef struct {
long LCGID; long LCGID;
// Bj bucket usage per lcid // Bj bucket usage per lcid
int32_t Bj; int32_t Bj;
NR_timer_t Bj_timer;
} NR_LC_SCHEDULING_INFO; } NR_LC_SCHEDULING_INFO;
typedef struct { typedef struct {
...@@ -200,18 +208,20 @@ typedef struct { ...@@ -200,18 +208,20 @@ typedef struct {
NR_LC_SCHEDULING_INFO lc_sched_info[NR_MAX_NUM_LCID]; NR_LC_SCHEDULING_INFO lc_sched_info[NR_MAX_NUM_LCID];
// lcg scheduling info // lcg scheduling info
NR_LCG_SCHEDULING_INFO lcg_sched_info[NR_MAX_NUM_LCGID]; NR_LCG_SCHEDULING_INFO lcg_sched_info[NR_MAX_NUM_LCGID];
/// BSR report flag management
uint8_t BSR_reporting_active;
// LCID triggering BSR
NR_LogicalChannelIdentity_t regularBSR_trigger_lcid;
/// SR pending as defined in 38.321 /// SR pending as defined in 38.321
uint8_t SR_pending; uint8_t SR_pending;
/// SR_COUNTER as defined in 38.321 /// SR_COUNTER as defined in 38.321
uint16_t SR_COUNTER; uint16_t SR_COUNTER;
/// retxBSR-Timer, default value is sf2560 // logicalChannelSR-DelayTimer
uint16_t retxBSR_Timer; NR_timer_t sr_DelayTimer;
/// retxBSR_SF, number of subframe before triggering a regular BSR /// retxBSR-Timer
uint16_t retxBSR_SF; NR_timer_t retxBSR_Timer;
/// periodicBSR-Timer, default to infinity /// periodicBSR-Timer
uint16_t periodicBSR_Timer; NR_timer_t periodicBSR_Timer;
/// periodicBSR_SF, number of subframe before triggering a periodic BSR
uint16_t periodicBSR_SF;
/// default value is 0: not configured /// default value is 0: not configured
uint16_t sr_ProhibitTimer; uint16_t sr_ProhibitTimer;
/// sr ProhibitTime running /// sr ProhibitTime running
...@@ -231,10 +241,6 @@ typedef struct { ...@@ -231,10 +241,6 @@ typedef struct {
int16_t prohibitPHR_SF; int16_t prohibitPHR_SF;
///DL Pathloss Change in db ///DL Pathloss Change in db
uint16_t PathlossChange_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; } NR_UE_SCHEDULING_INFO;
typedef enum { typedef enum {
...@@ -441,9 +447,11 @@ typedef struct nr_lcordered_info_s { ...@@ -441,9 +447,11 @@ typedef struct nr_lcordered_info_s {
// logical channels ids ordered as per priority // logical channels ids ordered as per priority
NR_LogicalChannelIdentity_t lcid; NR_LogicalChannelIdentity_t lcid;
long priority; long priority;
long prioritisedBitRate; uint32_t pbr; // in B/s (UINT_MAX = infinite)
// Bucket size per lcid // Bucket size per lcid
uint32_t bucket_size; uint32_t bucket_size;
bool sr_DelayTimerApplied;
bool lc_SRMask;
} nr_lcordered_info_t; } nr_lcordered_info_t;
...@@ -521,9 +529,6 @@ typedef struct NR_UE_MAC_INST_s { ...@@ -521,9 +529,6 @@ typedef struct NR_UE_MAC_INST_s {
nr_phy_config_t phy_config; nr_phy_config_t phy_config;
nr_synch_request_t synch_request; nr_synch_request_t synch_request;
/// BSR report flag management
uint8_t BSR_reporting_active;
// order lc info // order lc info
A_SEQUENCE_OF(nr_lcordered_info_t) lc_ordered_list; A_SEQUENCE_OF(nr_lcordered_info_t) lc_ordered_list;
......
...@@ -47,6 +47,7 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac); ...@@ -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 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); 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 /**\brief apply default configuration values in nr_mac instance
\param mac mac instance */ \param mac mac instance */
...@@ -119,46 +120,6 @@ subframe number \param[in] slotP slot number ...@@ -119,46 +120,6 @@ subframe number \param[in] slotP slot number
*/ */
int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP); int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP);
/*! \fn nr_update_bsr
\brief get the rlc stats and update the bsr level for each lcid
\param[in] mac pointer to UE MAC instance
\param[in] frameP Frame index
\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);
/*! \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.
\param[in] *table Pointer to BSR table
\param[in] size Size of the table
\param[in] value Value of the buffer
\return the index in the BSR_LEVEL table
*/
uint8_t nr_locate_BsrIndexByBufferSize(const uint32_t *table, int size,
int value);
/*! \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(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
\param[in] periodicBSR_Timer timer for periodic BSR
\return the number of subframe
*/
int nr_get_sf_periodicBSRTimer(uint8_t bucketSize);
/*! \fn int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer)
\brief get the number of subframe form the bucket size duration configured by the higher layer
\param[in] retxBSR_Timer timer for regular BSR
\return the time in sf
*/
int nr_get_sf_retxBSRTimer(uint8_t retxBSR_Timer);
int8_t nr_ue_process_dci(NR_UE_MAC_INST_t *mac, int8_t nr_ue_process_dci(NR_UE_MAC_INST_t *mac,
int cc_id, int cc_id,
frame_t frame, frame_t frame,
......
...@@ -72,6 +72,9 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac) ...@@ -72,6 +72,9 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac)
mac->p_Max_alt = INT_MIN; mac->p_Max_alt = INT_MIN;
reset_mac_inst(mac); 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->ssb_measurements, 0, sizeof(mac->ssb_measurements));
memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment)); memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment));
memset(mac->ssb_list, 0, sizeof(mac->ssb_list)); memset(mac->ssb_list, 0, sizeof(mac->ssb_list));
...@@ -81,8 +84,13 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac) ...@@ -81,8 +84,13 @@ void nr_ue_init_mac(NR_UE_MAC_INST_t *mac)
void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
{ {
// default values as defined in 38.331 sec 9.2.2 // default values as defined in 38.331 sec 9.2.2
mac->scheduling_info.retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80;
mac->scheduling_info.periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; // 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.periodicPHR_Timer = NR_PHR_Config__phr_PeriodicTimer_sf10; mac->scheduling_info.periodicPHR_Timer = NR_PHR_Config__phr_PeriodicTimer_sf10;
mac->scheduling_info.prohibitPHR_Timer = NR_PHR_Config__phr_ProhibitTimer_sf10; mac->scheduling_info.prohibitPHR_Timer = NR_PHR_Config__phr_ProhibitTimer_sf10;
} }
...@@ -144,13 +152,20 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) ...@@ -144,13 +152,20 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
// initialize Bj for each logical channel to zero // initialize Bj for each logical channel to zero
// TODO reset also other status variables of LC, is this ok? // TODO reset also other status variables of LC, is this ok?
for (int i = 0; i < NR_MAX_NUM_LCID; i++) { 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].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_with_data = false;
nr_mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0; nr_mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0;
} }
// TODO stop all running timers // 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->ra.contention_resolution_timer);
nr_timer_stop(&nr_mac->scheduling_info.sr_DelayTimer);
nr_timer_stop(&nr_mac->scheduling_info.retxBSR_Timer);
// consider all timeAlignmentTimers as expired and perform the corresponding actions in clause 5.2 // consider all timeAlignmentTimers as expired and perform the corresponding actions in clause 5.2
// TODO // TODO
...@@ -177,9 +192,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) ...@@ -177,9 +192,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
nr_mac->scheduling_info.sr_id = -1; // invalid init value nr_mac->scheduling_info.sr_id = -1; // invalid init value
// cancel any triggered Buffer Status Reporting procedure // cancel any triggered Buffer Status Reporting procedure
nr_mac->scheduling_info.periodicBSR_SF = NR_MAC_UE_BSR_TIMER_NOT_RUNNING; nr_mac->scheduling_info.BSR_reporting_active = NR_BSR_TRIGGER_NONE;
nr_mac->scheduling_info.retxBSR_SF = NR_MAC_UE_BSR_TIMER_NOT_RUNNING;
nr_mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE;
// cancel any triggered Power Headroom Reporting procedure // cancel any triggered Power Headroom Reporting procedure
// TODO PHR not implemented yet // TODO PHR not implemented yet
......
...@@ -2511,8 +2511,7 @@ int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slot) ...@@ -2511,8 +2511,7 @@ int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slot)
// release all pucch resource // release all pucch resource
//mac->physicalConfigDedicated = NULL; // todo //mac->physicalConfigDedicated = NULL; // todo
//mac->ul_active = 0; // todo //mac->ul_active = 0; // todo
mac->BSR_reporting_active = si->BSR_reporting_active = NR_BSR_TRIGGER_NONE;
NR_BSR_TRIGGER_NONE;
LOG_I(NR_MAC, "[UE %d] Release all SRs \n", mac->ue_id); LOG_I(NR_MAC, "[UE %d] Release all SRs \n", mac->ue_id);
} }
si->SR_pending = 0; si->SR_pending = 0;
......
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