Commit 8ce73e5a authored by calvin wang's avatar calvin wang

L2 stabilization BSR fertilization

parent 12a304e6
...@@ -76,6 +76,7 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index) ...@@ -76,6 +76,7 @@ void ue_mac_reset(module_id_t module_idP,uint8_t eNB_index)
// cancel all pending SRs // cancel all pending SRs
UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_pending=0;
UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0;
UE_mac_inst[module_idP].BSR_reporting_active=0;
// stop ongoing RACH procedure // stop ongoing RACH procedure
...@@ -235,9 +236,30 @@ rrc_mac_config_req( ...@@ -235,9 +236,30 @@ rrc_mac_config_req(
UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0; UE_mac_inst[Mod_idP].scheduling_info.sr_ProhibitTimer = (uint16_t) 0;
} }
if (mac_MainConfig->ext2 && mac_MainConfig->ext2->mac_MainConfig_v1020) {
if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10) {
UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedBSR_Sizes_r10;
} else {
UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0;
}
if (mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10) {
UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t) *mac_MainConfig->ext2->mac_MainConfig_v1020->extendedPHR_r10;
} else {
UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0;
}
} else {
UE_mac_inst[Mod_idP].scheduling_info.extendedBSR_Sizes_r10 = (uint16_t)0;
UE_mac_inst[Mod_idP].scheduling_info.extendedPHR_r10 = (uint16_t)0;
}
#endif #endif
UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer);
UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer); UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer);
UE_mac_inst[Mod_idP].BSR_reporting_active = 0;
LOG_D(MAC,"[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n",
Mod_idP,
UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF,
UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF);
UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config; UE_mac_inst[Mod_idP].scheduling_info.drx_config = mac_MainConfig->drx_Config;
UE_mac_inst[Mod_idP].scheduling_info.phr_config = mac_MainConfig->phr_Config; UE_mac_inst[Mod_idP].scheduling_info.phr_config = mac_MainConfig->phr_Config;
...@@ -259,6 +281,7 @@ rrc_mac_config_req( ...@@ -259,6 +281,7 @@ rrc_mac_config_req(
UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer);
UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer);
UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange); UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_idP].scheduling_info.PathlossChange);
UE_mac_inst[Mod_idP].PHR_reporting_active = 0;
LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n",
Mod_idP, Mod_idP,
(mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1, (mac_MainConfig->phr_Config)?mac_MainConfig->phr_Config->present:-1,
......
...@@ -983,6 +983,12 @@ typedef struct { ...@@ -983,6 +983,12 @@ 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;
//Bj bucket usage per lcid //Bj bucket usage per lcid
int16_t Bj[MAX_NUM_LCID]; int16_t Bj[MAX_NUM_LCID];
// Bucket size per lcid // Bucket size per lcid
...@@ -1070,6 +1076,8 @@ typedef struct { ...@@ -1070,6 +1076,8 @@ typedef struct {
uint8_t PHR_reporting_active; uint8_t PHR_reporting_active;
/// power backoff due to power management (as allowed by P-MPRc) for this cell /// power backoff due to power management (as allowed by P-MPRc) for this cell
uint8_t power_backoff_db[NUMBER_OF_eNB_MAX]; uint8_t power_backoff_db[NUMBER_OF_eNB_MAX];
/// BSR report falg management
uint8_t BSR_reporting_active;
/// MBSFN_Subframe Configuration /// MBSFN_Subframe Configuration
struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA? struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA?
/// number of subframe allocation pattern available for MBSFN sync area /// number of subframe allocation pattern available for MBSFN sync area
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE]; extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE];
//extern uint32_t EBSR_Level[63]; //extern uint32_t EBSR_Level[63];
extern const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE];
//extern uint32_t Extended_BSR_TABLE[63]; ----currently not used
extern UE_MAC_INST *UE_mac_inst; extern UE_MAC_INST *UE_mac_inst;
extern eNB_MAC_INST *eNB_mac_inst; extern eNB_MAC_INST *eNB_mac_inst;
......
...@@ -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 get_bsr_lcgid (module_id_t module_idP, int *num_lcgid);
/*! \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
...@@ -582,14 +582,14 @@ BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len); ...@@ -582,14 +582,14 @@ BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len);
*/ */
boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcgid); boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_index, uint8_t lcid, uint8_t lcgid);
/*! \fn locate (int *table, int size, int value) /*! \fn locate_BsrIndexByBufferSize (int *table, int size, int value)
\brief locate the BSR level in the table as defined in 36.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. \brief locate the BSR level in the table as defined in 36.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] *table Pointer to BSR table
\param[in] size Size of the table \param[in] size Size of the table
\param[in] value Value of the buffer \param[in] value Value of the buffer
\return the index in the BSR_LEVEL table \return the index in the BSR_LEVEL table
*/ */
uint8_t locate (const uint32_t *table, int size, int value); uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value);
/*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer) /*! \fn int get_sf_periodicBSRTimer(uint8_t periodicBSR_Timer)
......
...@@ -110,13 +110,17 @@ void ue_init_mac(module_id_t module_idP) ...@@ -110,13 +110,17 @@ void ue_init_mac(module_id_t module_idP)
UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0;
UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; UE_mac_inst[module_idP].scheduling_info.ttiBundling=0;
UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10=0;
UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10=0;
UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; UE_mac_inst[module_idP].scheduling_info.drx_config=NULL;
UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; UE_mac_inst[module_idP].scheduling_info.phr_config=NULL;
UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer);
UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer);
UE_mac_inst[module_idP].BSR_reporting_active = 0;
UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer);
UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer);
UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange); UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].scheduling_info.PathlossChange);
UE_mac_inst[module_idP].PHR_reporting_active = 0;
for (i=0; i < MAX_NUM_LCID; i++) { for (i=0; i < MAX_NUM_LCID; i++) {
LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i);
...@@ -296,18 +300,28 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i ...@@ -296,18 +300,28 @@ uint32_t ue_get_SR(module_id_t module_idP,int CC_id,frame_t frameP,uint8_t eNB_i
// initiate RA // initiate RA
UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_pending=0;
UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0;
// release all pucch resource
UE_mac_inst[module_idP].physicalConfigDedicated = NULL;
UE_mac_inst[module_idP].ul_active=0;
UE_mac_inst[module_idP].BSR_reporting_active=0;
LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP);
return(0); return(0);
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void void
ue_send_sdu(module_id_t module_idP, ue_send_sdu(
module_id_t module_idP,
uint8_t CC_id, uint8_t CC_id,
frame_t frameP, frame_t frameP,
uint8_t* sdu, uint8_t* sdu,
uint16_t sdu_len, uint16_t sdu_len,
uint8_t eNB_index) { uint8_t eNB_index
)
//------------------------------------------------------------------------------
{
unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr;
unsigned char rx_lcids[NB_RB_MAX]; unsigned char rx_lcids[NB_RB_MAX];
...@@ -1188,16 +1202,19 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1188,16 +1202,19 @@ 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_SHORT bsr_short,bsr_truncated;
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;
unsigned short short_padding=0, post_padding=0; unsigned short short_padding=0, post_padding=0, padding_len=0;
int lcgid; int lcgid;
int j; // used for padding int j; // used for padding
// Compute header length // Compute header length
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");
...@@ -1243,8 +1260,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1243,8 +1260,8 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
} }
bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len);
// retxBSR-Timer expires or periodicBSR-Timer expires and UE has data available for transmission
if (bsr_ce_len > 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",
module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen);
...@@ -1338,8 +1355,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1338,8 +1355,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
dtch_header_len+=3; dtch_header_len+=3;
dtch_header_len_last=3; dtch_header_len_last=3;
all_pdu_len = bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total;
if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) && if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] == LCID_NOT_EMPTY) &&
((bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total) <= buflen)) { (all_pdu_len <= buflen)) {
// optimize the dtch header lenght // optimize the dtch header lenght
//if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) &&
...@@ -1357,7 +1375,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1357,7 +1375,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
ENB_FLAG_NO, ENB_FLAG_NO,
MBMS_FLAG_NO, // eNB_index MBMS_FLAG_NO, // eNB_index
lcid, lcid,
buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); buflen-all_pdu_len);
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,
...@@ -1391,12 +1409,28 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1391,12 +1409,28 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
} }
} }
lcgid= get_bsr_lcgid(module_idP); lcgid= get_bsr_lcgid(module_idP, &num_lcgid);
if (lcgid < 0 ) { if (num_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_l = NULL ; bsr_t = NULL;
} else if ((lcgid ==MAX_NUM_LCGID) && (bsr_ce_len == sizeof(BSR_LONG))) { bsr_l = NULL;
}
} 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];
...@@ -1407,14 +1441,21 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1407,14 +1441,21 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
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->LCGID = lcgid; bsr_s = NULL;
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];
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;
} }
...@@ -1444,12 +1485,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1444,12 +1485,14 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
dtch_header_len_last-=1; dtch_header_len_last-=1;
dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len; dtch_header_len= (dtch_header_len >0)? dtch_header_len - dtch_header_len_last : dtch_header_len;
} }
// 1-bit padding or 2-bit padding special padding subheader
if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { padding_len = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total;
short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; if (padding_len <= 2) {
short_padding = padding_len;
// only add padding header
post_padding = 0; post_padding = 0;
} else { } else {
if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { if (padding_len == buflen) {// nona mac pdu
*access_mode=CANCELED_ACCESS; *access_mode=CANCELED_ACCESS;
} }
...@@ -1474,7 +1517,7 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1474,7 +1517,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
NULL, // truncated bsr bsr_t, // truncated bsr
bsr_s, // short bsr bsr_s, // short bsr
bsr_l, bsr_l,
post_padding); // long_bsr post_padding); // long_bsr
...@@ -1494,6 +1537,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf ...@@ -1494,6 +1537,9 @@ void ue_get_sdu(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subf
module_idP,payload_offset, sdu_length_total); module_idP,payload_offset, sdu_length_total);
UE_mac_inst[module_idP].scheduling_info.SR_pending=0; UE_mac_inst[module_idP].scheduling_info.SR_pending=0;
UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0;
UE_mac_inst[module_idP].BSR_reporting_active=0;
UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer);
UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu); stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu);
...@@ -1655,7 +1701,22 @@ ue_scheduler( ...@@ -1655,7 +1701,22 @@ ue_scheduler(
// call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures
// outlined in Sections 5.4.4 an 5.4.5 of 36.321 // outlined in Sections 5.4.4 an 5.4.5 of 36.321
// Put this in another function // Call BSR procedure as described in Section 5.4.5 in 36.321
if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == get_sf_periodicBSRTimer(MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity)) {
UE_mac_inst[module_idP].BSR_reporting_active = 1;
} else if (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF <= 0 ){
// trigger BSR and reset the timer later when the BSR report is sent
UE_mac_inst[module_idP].BSR_reporting_active = 1;
} else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) {
UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--;
}
if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF <= 0){
// trigger BSR and reset the timer later when the BSR report is sent
UE_mac_inst[module_idP].BSR_reporting_active = 1;
} else if (UE_mac_inst[module_idP].BSR_reporting_active == 0 ) {
UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--;
}
// 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 <= DTCH; lcid++ ) {
...@@ -1899,54 +1960,75 @@ int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8 ...@@ -1899,54 +1960,75 @@ 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 get_bsr_lcgid (module_id_t module_idP, int *num_lcgid)
{ {
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; return -1; // no data
} else if (num_active_lcgid == 1) {
return lcgid_tmp;
} else { } else {
return MAX_NUM_LCGID; return lcgid_tmp;//only one lcgid, report short bsr
} }
} }
uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen) uint8_t get_bsr_len (module_id_t module_idP, uint16_t buflen)
{ {
int lcgid=0; int lcgid=0;
uint8_t bsr_len=0, num_lcgid=0; uint8_t bsr_len=0, num_lcgid=0;
int pdu = 0; int pdu = 0;
int long_bsr_plus_subheader_length = sizeof(BSR_LONG)+sizeof(SCH_SUBHEADER_FIXED);
int short_bsr_plus_subheader_length = sizeof(BSR_SHORT)+sizeof(SCH_SUBHEADER_FIXED);
// check how many lcg have data to report
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_bytes[lcgid] > 0 ) { if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) {
pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) num_lcgid ++;
pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + sizeof(SCH_SUBHEADER_SHORT));
} }
if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) { // long header size: adjust the header size
pdu += 1; 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 // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid
if (buflen < pdu) {
if ( (pdu > buflen) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) ) { if (num_lcgid > 0) {
num_lcgid +=1; bsr_len = sizeof(BSR_SHORT);
bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : 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 ((buflen < (pdu + long_bsr_plus_subheader_length)) &&
(buflen > (pdu + short_bsr_plus_subheader_length))) {
if (num_lcgid > 0) {
bsr_len = sizeof(BSR_SHORT);
} else {
bsr_len = 0;
} }
LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid);
} }
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);
...@@ -1959,11 +2041,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in ...@@ -1959,11 +2041,11 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in
{ {
mac_rlc_status_resp_t rlc_status; mac_rlc_status_resp_t rlc_status;
boolean_t sr_pending = FALSE; boolean_t Bsr_pending = FALSE;
if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) { if ((lcg_id < 0) || (lcg_id >= MAX_NUM_LCGID) ) {
return sr_pending; return Bsr_pending;
} }
// fixme: need a better way to reset // fixme: need a better way to reset
...@@ -1979,10 +2061,15 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in ...@@ -1979,10 +2061,15 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in
0); 0);
if (rlc_status.bytes_in_buffer > 0 ) { if (rlc_status.bytes_in_buffer > 0 ) {
sr_pending = TRUE; //BSR trigger SR
Bsr_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[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer); UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] = rlc_status.bytes_in_buffer;
UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; if (UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 == TRUE){
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_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]);
...@@ -1992,10 +2079,10 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in ...@@ -1992,10 +2079,10 @@ boolean_t update_bsr(module_id_t module_idP, frame_t frameP, eNB_index_t eNB_in
} }
//} //}
return sr_pending; return Bsr_pending;
} }
uint8_t locate (const uint32_t *table, int size, int value) uint8_t locate_BsrIndexByBufferSize (const uint32_t *table, int size, int value)
{ {
uint8_t ju, jm, jl; uint8_t ju, jm, jl;
......
...@@ -52,6 +52,15 @@ const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57 ...@@ -52,6 +52,15 @@ const uint32_t BSR_TABLE[BSR_TABLE_SIZE]= {0,10,12,14,17,19,22,26,31,36,42,49,57
1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099, 1326,1552,1817,2127,2490,2915,3413,3995,4677,5467,6411,7505,8787,10287,12043,14099,
16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000 16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000
}; };
// extended bsr table--currently not used
const uint32_t Extended_BSR_TABLE[BSR_TABLE_SIZE] = {0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,
181,223,274,337,414,509,625,769,945,1162,1429,
1757,2161,2657,3267,4017,4940,6074,7469,9185,
11294,13888,17077,20999,25822,31752,39045,48012,
59039,72598,89272,109774,134986,165989,204111,
250990,308634,379519,466683,573866,705666,867737,
1067031,1312097,1613447,1984009,2439678,3000000,
6000000};
//uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181}; //uint32_t EBSR_Level[63]={0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181};
......
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