Commit 948f2df9 authored by calvin wang's avatar calvin wang

modify BSR code according comments

parent 8ce73e5a
...@@ -233,7 +233,7 @@ rrc_mac_config_req( ...@@ -233,7 +233,7 @@ rrc_mac_config_req(
if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) { if (mac_MainConfig->ext1 && mac_MainConfig->ext1->sr_ProhibitTimer_r9) {
UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9; UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) *mac_MainConfig->ext1->sr_ProhibitTimer_r9;
} else { } else {
UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = 0;
} }
if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) { if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) {
......
...@@ -941,7 +941,7 @@ typedef enum { ...@@ -941,7 +941,7 @@ typedef enum {
typedef struct { typedef struct {
/// buffer status for each lcgid /// buffer status for each lcgid
uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology
/// keep the number of bytes in rlc buffer for each lcid /// keep the number of bytes in rlc buffer for each lcgid
uint16_t BSR_bytes[MAX_NUM_LCGID]; uint16_t BSR_bytes[MAX_NUM_LCGID];
/// buffer status for each lcid /// buffer status for each lcid
uint8_t LCID_status[MAX_NUM_LCID]; uint8_t LCID_status[MAX_NUM_LCID];
......
...@@ -548,7 +548,7 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 ...@@ -548,7 +548,7 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8
\param[in] Mod_id instance of the UE \param[in] Mod_id instance of the UE
\param[out] lcgid \param[out] lcgid
*/ */
int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid); int get_bsr_lcgid (module_id_t module_idP);
/*! \fn uint8_t get_bsr_len (module_id_t module_idP,uint16_t bufflen); /*! \fn uint8_t get_bsr_len (module_id_t module_idP,uint16_t bufflen);
\brief determine whether the bsr is short or long assuming that the MAC pdu is built \brief determine whether the bsr is short or long assuming that the MAC pdu is built
...@@ -556,7 +556,7 @@ int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid); ...@@ -556,7 +556,7 @@ int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid);
\param[in] bufflen size of phy transport block \param[in] bufflen size of phy transport block
\param[out] bsr_len size of bsr control element \param[out] bsr_len size of bsr control element
*/ */
uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen); uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen);
/*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len) /*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len)
\brief get short bsr level \brief get short bsr level
......
...@@ -399,7 +399,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP, ...@@ -399,7 +399,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,int CC_id,frame_t frameP,
1); //post_padding 1); //post_padding
return(&UE_mac_inst[module_idP].RA_prach_resources); return(&UE_mac_inst[module_idP].RA_prach_resources);
} else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { } else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]] > 0) {
// This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example)
dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element
rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, rlc_status = mac_rlc_status_ind(module_idP,UE_mac_inst[module_idP].crnti, eNB_indexP,frameP,ENB_FLAG_NO,MBMS_FLAG_NO,
......
...@@ -133,7 +133,7 @@ void ue_init_mac(module_id_t module_idP) ...@@ -133,7 +133,7 @@ void ue_init_mac(module_id_t module_idP)
UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1;
} }
UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=LCID_EMPTY;
} }
#ifdef CBA #ifdef CBA
...@@ -1202,10 +1202,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1202,10 +1202,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
uint8_t payload_offset=0,num_sdus=0; uint8_t payload_offset=0,num_sdus=0;
uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
uint16_t sdu_length_total=0; uint16_t sdu_length_total=0;
BSR_SHORT bsr_short,bsr_truncated; BSR_SHORT bsr_short;
BSR_LONG bsr_long; BSR_LONG bsr_long;
BSR_SHORT *bsr_s=&bsr_short; BSR_SHORT *bsr_s=&bsr_short;
BSR_SHORT *bsr_t=&bsr_truncated;
BSR_LONG *bsr_l=&bsr_long; BSR_LONG *bsr_l=&bsr_long;
POWER_HEADROOM_CMD phr; POWER_HEADROOM_CMD phr;
POWER_HEADROOM_CMD *phr_p=&phr; POWER_HEADROOM_CMD *phr_p=&phr;
...@@ -1214,7 +1213,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1214,7 +1213,6 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
int j; // used for padding int j; // used for padding
// Compute header length // Compute header length
int all_pdu_len; int all_pdu_len;
int num_lcgid=0;
if (CC_id>0) { if (CC_id>0) {
LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n"); LOG_E(MAC,"Transmission on secondary CCs is not supported yet\n");
...@@ -1249,18 +1247,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1249,18 +1247,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT);
bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED);
phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED);
phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0;
if (phr_ce_len > 0) {
phr_len = phr_ce_len + phr_header_len;
LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n",
module_idP, phr_len, phr_ce_len, phr_header_len, buflen);
} else {
phr_len=0;
}
bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); bsr_ce_len = get_bsr_len (module_idP, eNB_index, frameP, buflen);
// retxBSR-Timer expires or periodicBSR-Timer expires and UE has data available for transmission // retxBSR-Timer expires or periodicBSR-Timer expires and Regular BSR trigger
if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) { if ((bsr_ce_len > 0 ) && (UE_mac_inst[module_idP].BSR_reporting_active > 0)) {
bsr_len = bsr_ce_len + bsr_header_len; bsr_len = bsr_ce_len + bsr_header_len;
LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n",
...@@ -1272,6 +1261,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1272,6 +1261,15 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
//bsr_len = bsr_ce_len + bsr_header_len; //bsr_len = bsr_ce_len + bsr_header_len;
} }
phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0;
if (phr_ce_len > 0) {
phr_len = phr_ce_len + phr_header_len;
LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n",
module_idP, phr_len, phr_ce_len, phr_header_len, buflen);
} else {
phr_len=0;
}
// check for UL bandwidth requests and add SR control element // check for UL bandwidth requests and add SR control element
// check for UL bandwidth requests and add SR control element // check for UL bandwidth requests and add SR control element
...@@ -1305,8 +1303,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1305,8 +1303,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
sdu_lcids[0] = DCCH; sdu_lcids[0] = DCCH;
LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]);
num_sdus = 1; num_sdus = 1;
update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); //update_bsr(module_idP, frameP, eNB_index, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]);
//header_len +=2; //header_len +=2;
UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] = LCID_EMPTY;
} else { } else {
dcch_header_len=0; dcch_header_len=0;
num_sdus = 0; num_sdus = 0;
...@@ -1345,6 +1344,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1345,6 +1344,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
num_sdus++; num_sdus++;
//update_bsr(module_idP, frameP, DCCH1); //update_bsr(module_idP, frameP, DCCH1);
//dcch_header_len +=2; // include dcch1 //dcch_header_len +=2; // include dcch1
UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] = LCID_EMPTY;
} else { } else {
dcch1_header_len =0; dcch1_header_len =0;
} }
...@@ -1379,7 +1379,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1379,7 +1379,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n", LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH%d, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[%d] %d)\n",
module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len, module_idP,frameP, lcid, rlc_status.bytes_in_buffer,buflen,dtch_header_len,
lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcid]); lcid, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]);
if (rlc_status.bytes_in_buffer > 0) { if (rlc_status.bytes_in_buffer > 0) {
sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
...@@ -1400,62 +1400,54 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1400,62 +1400,54 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
dtch_header_len_last --; dtch_header_len_last --;
} }
num_sdus++; num_sdus++;
UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]); //UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frameP, eNB_index,lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]);
} else { } else {
dtch_header_len -= 3; dtch_header_len -= 3;
} }
UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_EMPTY;
} else { // no rlc pdu : generate the dummy header } else { // no rlc pdu : generate the dummy header
dtch_header_len -= 3; dtch_header_len -= 3;
} }
} }
lcgid= get_bsr_lcgid(module_idP, &num_lcgid); lcgid= get_bsr_lcgid(module_idP);
if (num_lcgid == 0 ) { if (lcgid < 0 ) {
bsr_s = NULL;
bsr_t = NULL;
bsr_l = NULL;
} else if (num_lcgid == 1){
if (bsr_ce_len == sizeof(BSR_SHORT)){
bsr_l = NULL;
bsr_t = NULL;
bsr_s->LCGID = lcgid;
bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid];
LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n",
module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid);
} else {
bsr_s = NULL; bsr_s = NULL;
bsr_t = NULL; bsr_l = NULL ;
bsr_l = NULL; } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_ce_len == sizeof(BSR_LONG))) {
}
} else if (num_lcgid > 1) {
if (bsr_ce_len == sizeof(BSR_LONG)){
bsr_t = NULL;
bsr_s = NULL; bsr_s = NULL;
bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0];
bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1];
bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2];
bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3];
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID0] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID1] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID2] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[LCGID3] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] = 0;
LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP, LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frameP,
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0],
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1],
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2],
UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]);
} else if (bsr_ce_len == sizeof(BSR_SHORT)){ } else if (bsr_ce_len == sizeof(BSR_SHORT)) {
bsr_l = NULL; bsr_l = NULL;
bsr_s = NULL; bsr_s->LCGID = lcgid;
bsr_t->LCGID = lcgid;
bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid];
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] = 0;
UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] = 0;
LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n",
module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); module_idP, frameP, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid);
} else { } else {
bsr_s = NULL; bsr_s = NULL;
bsr_t = NULL;
bsr_l = NULL;
}
} else {
bsr_s = NULL;
bsr_t = NULL;
bsr_l = NULL; bsr_l = NULL;
} }
...@@ -1517,7 +1509,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1517,7 +1509,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
sdu_lcids, // sdu lcid sdu_lcids, // sdu lcid
phr_p, // power headroom phr_p, // power headroom
NULL, // crnti NULL, // crnti
bsr_t, // truncated bsr NULL, // truncated bsr
bsr_s, // short bsr bsr_s, // short bsr
bsr_l, bsr_l,
post_padding); // long_bsr post_padding); // long_bsr
...@@ -1719,7 +1711,7 @@ ue_scheduler( ...@@ -1719,7 +1711,7 @@ ue_scheduler(
} }
// Get RLC status info and update Bj for all lcids that are active // Get RLC status info and update Bj for all lcids that are active
for (lcid=DCCH; lcid <= DTCH; lcid++ ) { for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++ ) {
if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) { if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) {
// meausre the Bj // meausre the Bj
if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) { if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) {
...@@ -1740,6 +1732,8 @@ ue_scheduler( ...@@ -1740,6 +1732,8 @@ ue_scheduler(
if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { if (update_bsr(module_idP,frameP, eNB_indexP, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) {
UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; UE_mac_inst[module_idP].scheduling_info.SR_pending= 1;
// Regular BSR trigger
UE_mac_inst[module_idP].BSR_reporting_active = 1;
LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n",
module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid],
UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]],
...@@ -1960,75 +1954,49 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 ...@@ -1960,75 +1954,49 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8
} }
#endif #endif
int get_bsr_lcgid (module_id_t module_idP, int *num_lcgid) int get_bsr_lcgid (module_id_t module_idP)
{ {
int lcgid, lcgid_tmp=-1; int lcgid, lcgid_tmp=-1;
int num_active_lcgid = 0; int num_active_lcgid = 0;
for (lcgid = 0 ; lcgid < MAX_NUM_LCGID; lcgid++) { for (lcgid = 0 ; lcgid < MAX_NUM_LCGID; lcgid++) {
if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ) { if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ) {
if (lcgid_tmp == -1){
// first priority lcgid
lcgid_tmp = lcgid; lcgid_tmp = lcgid;
}
num_active_lcgid+=1; num_active_lcgid+=1;
} }
} }
*num_lcgid = num_active_lcgid;
if (num_active_lcgid == 0) { if (num_active_lcgid == 0) {
return -1; // no data return -1;
} else if (num_active_lcgid == 1) {
return lcgid_tmp;
} else { } else {
return lcgid_tmp;//only one lcgid, report short bsr return MAX_NUM_LCGID;
} }
} }
uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) uint8_t get_bsr_len (module_id_t module_idP, uint8_t eNB_index,frame_t frameP,uint16_t buflen)
{ {
int lcgid=0; int lcid;
uint8_t bsr_len=0, num_lcgid=0; uint8_t bsr_len=0, num_lcid=0;
int pdu = 0; int pdu = 0;
int long_bsr_plus_subheader_length = sizeof(BSR_LONG)+sizeof(SCH_SUBHEADER_FIXED); mac_rlc_status_resp_t rlc_status;
int short_bsr_plus_subheader_length = sizeof(BSR_SHORT)+sizeof(SCH_SUBHEADER_FIXED);
// check how many lcg have data to report for (lcid=DCCH; lcid<NB_RB_MAX ; lcid++){
for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,eNB_index,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, lcid, 0);
if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) { if (rlc_status.bytes_in_buffer > 0 ) {
num_lcgid ++; pdu += rlc_status.bytes_in_buffer + sizeof(SCH_SUBHEADER_SHORT) + bsr_len;
pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + sizeof(SCH_SUBHEADER_SHORT)); if (rlc_status.bytes_in_buffer > 128 ) {
} pdu += 1; //sizeof(SCH_SUBHEADER_LONG)
if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size
pdu += 1;
}
LOG_D(MAC,"BSR Bytes %d for lcgid %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, num_lcgid);
}
// current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid
if (buflen < pdu) {
if (num_lcgid > 0) {
bsr_len = sizeof(BSR_SHORT);
} else {
bsr_len = 0;
}
}
// padding larger then long bsr
if (buflen > (pdu + long_bsr_plus_subheader_length)) {
if (num_lcgid > 1) {
bsr_len = sizeof(BSR_LONG);
} else if (num_lcgid > 0) {
bsr_len = sizeof(BSR_SHORT);
} else {
bsr_len = 0;
} }
} }
// padding larger then short bsr and shorter then long bsr if ( (pdu > buflen) && (rlc_status.bytes_in_buffer > 0 ) ) {
if ((buflen < (pdu + long_bsr_plus_subheader_length)) && num_lcid +=1;
(buflen > (pdu + short_bsr_plus_subheader_length))) { bsr_len = (num_lcid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ;
if (num_lcgid > 0) {
bsr_len = sizeof(BSR_SHORT);
} else {
bsr_len = 0;
} }
LOG_D(MAC,"LC buffer Bytes %d for lcid %d bsr len %d num lcid %d\n", rlc_status.bytes_in_buffer, lcid, bsr_len, num_lcid);
} }
if ( bsr_len > 0 ) if ( bsr_len > 0 )
LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n",
module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu);
...@@ -2036,16 +2004,15 @@ uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) ...@@ -2036,16 +2004,15 @@ uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen)
return bsr_len; return bsr_len;
} }
boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcg_id) boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcg_id)
{ {
mac_rlc_status_resp_t rlc_status; mac_rlc_status_resp_t rlc_status;
boolean_t Bsr_pending = FALSE; boolean_t sr_pending = FALSE;
if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) { if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) {
return Bsr_pending; return sr_pending;
} }
// fixme: need a better way to reset // fixme: need a better way to reset
...@@ -2062,14 +2029,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in ...@@ -2062,14 +2029,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in
if (rlc_status.bytes_in_buffer > 0 ) { if (rlc_status.bytes_in_buffer > 0 ) {
//BSR trigger SR //BSR trigger SR
Bsr_pending = TRUE; sr_pending = TRUE;
UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY;
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] = rlc_status.bytes_in_buffer; // sum lcid buffer which has same lcgid
if (UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 == TRUE){ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer;
UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(Extended_BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]);
} else {
UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] = locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]);
}
// UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr
LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n",
module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]);
...@@ -2079,7 +2043,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in ...@@ -2079,7 +2043,7 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in
} }
//} //}
return Bsr_pending; return sr_pending;
} }
uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value) uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value)
......
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