Commit 9e59a261 authored by mjoang's avatar mjoang

1. Add nr_ue_init_mac() to initialize the fields in nr_mac instance. 2. Fix...

1. Add nr_ue_init_mac() to initialize the fields in nr_mac instance. 2. Fix bug on handling padding BSR.
parent 4db04d7b
......@@ -182,9 +182,9 @@ typedef struct {
uint16_t All_lcid_buffer_size_lastTTI;
/// buffer status for each lcid
uint8_t LCID_status[NR_MAX_NUM_LCID];
/// SR pending as defined in 36.321
/// SR pending as defined in 38.321
uint8_t SR_pending;
/// SR_COUNTER as defined in 36.321
/// SR_COUNTER as defined in 38.321
uint16_t SR_COUNTER;
/// logical channel group ide for each LCID
uint8_t LCGID[NR_MAX_NUM_LCID];
......
......@@ -40,6 +40,10 @@
#define NR_DL_MAX_DAI (4) /* TS 38.213 table 9.1.3-1 Value of counter DAI for DCI format 1_0 and 1_1 */
#define NR_DL_MAX_NB_CW (2) /* number of downlink code word */
/**\brief initialize the field in nr_mac instance
\param module_id module id */
void nr_ue_init_mac(module_id_t module_idP);
/**\brief decode mib pdu in NR_UE, from if_module ul_ind with P7 tx_ind message
\param module_id module id
\param cc_id component carrier id
......@@ -143,7 +147,7 @@ int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slotP);
boolean_t nr_update_bsr(module_id_t module_idP, 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 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 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
......@@ -374,7 +378,7 @@ void nr_ra_succeeded(module_id_t mod_id, frame_t frame, int slot);
If the UE is not in PUSCH mode for a particular eNB index, this is assumed to be an Msg3 and MAC
attempts to retrieves the CCCH message from RRC. If the UE is in PUSCH mode for a particular eNB
index and PUCCH format 0 (Scheduling Request) is not activated, the MAC may use this resource for
andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321)
andom-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 38.321)
@param mod_id Index of UE instance
@param CC_id Component Carrier Index
@param frame
......
......@@ -51,10 +51,11 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst)
//init mac here
nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST);
for (int j=0;j<NB_NR_UE_MAC_INST;j++)
for (int j=0;j<NB_NR_UE_MAC_INST;j++) {
nr_ue_init_mac(j);
for (int i=0;i<NR_MAX_HARQ_PROCESSES;i++)
nr_ue_mac_inst[j].first_ul_tx[i]=1;
}
if (rrc_inst && (rrc_inst->scell_group_config || rrc_inst->cell_group_config)) {
if(rrc_inst->scell_group_config) {
......
......@@ -135,6 +135,71 @@ const initial_pucch_resource_t initial_pucch_resource[16] = {
};
void nr_ue_init_mac(module_id_t module_idP) {
int i;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
// default values as deined in 38.331 sec 9.2.2
LOG_I(NR_MAC, "[UE%d] Applying default macMainConfig\n", module_idP);
//mac->scheduling_info.macConfig=NULL;
mac->scheduling_info.retxBSR_Timer =
NR_BSR_Config__retxBSR_Timer_sf10240;
mac->scheduling_info.periodicBSR_Timer =
NR_BSR_Config__periodicBSR_Timer_infinity;
// mac->scheduling_info.periodicPHR_Timer =
// NR_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
// mac->scheduling_info.prohibitPHR_Timer =
// NR_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
// mac->scheduling_info.PathlossChange_db =
// NR_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
// mac->PHR_state =
// NR_MAC_MainConfig__phr_Config_PR_setup;
mac->scheduling_info.SR_COUNTER = 0;
mac->scheduling_info.sr_ProhibitTimer = 0;
mac->scheduling_info.sr_ProhibitTimer_Running = 0;
// mac->scheduling_info.maxHARQ_Tx =
// NR_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
// mac->scheduling_info.ttiBundling = 0;
// mac->scheduling_info.extendedBSR_Sizes_r10 = 0;
// mac->scheduling_info.extendedPHR_r10 = 0;
// mac->scheduling_info.drx_config = NULL;
// mac->scheduling_info.phr_config = NULL;
// set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW.
mac->scheduling_info.periodicBSR_SF =
MAC_UE_BSR_TIMER_NOT_RUNNING;
mac->scheduling_info.retxBSR_SF =
MAC_UE_BSR_TIMER_NOT_RUNNING;
mac->BSR_reporting_active = BSR_TRIGGER_NONE;
// mac->scheduling_info.periodicPHR_SF =
// nr_get_sf_perioidicPHR_Timer(mac->
// scheduling_info.periodicPHR_Timer);
// mac->scheduling_info.prohibitPHR_SF =
// nr_get_sf_prohibitPHR_Timer(mac->
// scheduling_info.prohibitPHR_Timer);
// mac->scheduling_info.PathlossChange_db =
// nr_get_db_dl_PathlossChange(mac->
// scheduling_info.PathlossChange);
// mac->PHR_reporting_active = 0;
for (i = 0; i < NR_MAX_NUM_LCID; i++) {
LOG_D(NR_MAC,
"[UE%d] Applying default logical channel config for LCGID %d\n",
module_idP, i);
mac->scheduling_info.Bj[i] = -1;
mac->scheduling_info.bucket_size[i] = -1;
if (i < UL_SCH_LCID_DTCH) { // initialize all control channels lcgid to 0
mac->scheduling_info.LCGID[i] = 0;
} else { // initialize all the data channels lcgid to 1
mac->scheduling_info.LCGID[i] = 1;
}
mac->scheduling_info.LCID_status[i] =
LCID_EMPTY;
mac->scheduling_info.LCID_buffer_remain[i] = 0;
}
}
int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti){
RA_config_t *ra = &mac->ra;
......
......@@ -1202,7 +1202,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in
|| (mac->
physicalConfigDedicated->schedulingRequestConfig->present ==
LTE_SchedulingRequestConfig_PR_release)) {
// initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5
// initiate RA with CRNTI included in msg3 (no contention) as descibed in 38.321 sec 5.1.5
// cancel all pending SRs
mac->scheduling_info.SR_pending = 0;
mac->ul_active = 0;
......@@ -1298,7 +1298,7 @@ nr_update_bsr(module_id_t module_idP, frame_t frameP,
}
}
// Check whether a regular BSR can be triggered according to the first cases in 36.321
// Check whether a regular BSR can be triggered according to the first cases in 38.321
if (num_lcid_with_data) {
LOG_D(MAC,
"[UE %d] PDCCH Tick at frame %d slot %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n",
......@@ -2485,7 +2485,8 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
int16_t buflen_remain = 0;
uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0;
uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0;
//uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0;
uint8_t phr_len = 0;
uint8_t lcid = 0;
uint16_t sdu_length = 0;
uint16_t num_sdus = 0;
......@@ -2522,7 +2523,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
lcg_id++;
}
//Restart ReTxBSR Timer at new grant indication (36.321)
//Restart ReTxBSR Timer at new grant indication (38.321)
if (mac->scheduling_info.retxBSR_SF !=
MAC_UE_BSR_TIMER_NOT_RUNNING) {
mac->scheduling_info.retxBSR_SF =
......@@ -2554,18 +2555,18 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
if (num_lcg_id_with_data <= 1) {
if (buflen >= (sizeof(NR_BSR_SHORT)+sizeof(NR_MAC_SUBHEADER_FIXED)+1)) {
bsr_ce_len = sizeof(NR_BSR_SHORT); //1 byte
bsr_header_len = sizeof(NR_MAC_SUBHEADER_FIXED);
bsr_header_len = sizeof(NR_MAC_SUBHEADER_FIXED); //1 byte
}
} else {
if (buflen >= (num_lcg_id_with_data+1+sizeof(NR_MAC_SUBHEADER_SHORT)+1)) {
bsr_ce_len = num_lcg_id_with_data + 1; //variable size
bsr_header_len = sizeof(NR_MAC_SUBHEADER_SHORT);
bsr_ce_len = num_lcg_id_with_data + 1; //variable size
bsr_header_len = sizeof(NR_MAC_SUBHEADER_SHORT); //2 bytes
}
}
}
bsr_len = bsr_ce_len + bsr_header_len;
#if 0 // todo
phr_ce_len =
(mac->PHR_reporting_active ==
1) ? 1 /* sizeof(POWER_HEADROOM_CMD) */ : 0;
......@@ -2581,7 +2582,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
phr_header_len = 0;
phr_ce_len = 0;
}
#endif
int tot_mac_ce_len = bsr_len + phr_len;
uint8_t total_mac_pdu_header_len = tot_mac_ce_len;
......@@ -2669,7 +2670,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
mac->scheduling_info.LCID_buffer_remain[lcid] -= sdu_length;
mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]] -= sdu_length;
LOG_D(MAC,
"[UE %d] Update BSR Tx frame%d subframe %d nb LCG =%d Bytes for LCG%d=%d\n",
"[UE %d] Update BSR [%d.%d] num_lcg_id_with_data %d. BSR_bytes for LCG%d=%d\n",
module_idP, frameP, subframe, num_lcg_id_with_data, mac->scheduling_info.LCGID[lcid],
mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]]);
if (mac->scheduling_info.BSR_bytes[mac->scheduling_info.LCGID[lcid]] < 0)
......@@ -2682,7 +2683,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
scheduling_info.LCGID[lcid]]
== 0)) {
num_lcg_id_with_data--;
#if 0 // Disable the following to simplify the logic
// Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1
if (bsr_len) {
if (num_lcg_id_with_data == 1) {
......@@ -2700,6 +2701,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
tot_mac_ce_len = bsr_len + phr_len;
}
}
#endif
}
}
}
......@@ -2766,18 +2768,18 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
if ((padding_len) && (bsr_len == 0)) {
/* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */
if (padding_len >= (1 + num_lcg_id_with_data)) {
bsr_ce_len = 1 + num_lcg_id_with_data;
bsr_header_len = 1;
if (padding_len >= (num_lcg_id_with_data+1+sizeof(NR_MAC_SUBHEADER_SHORT))) {
bsr_ce_len = num_lcg_id_with_data + 1; //variable size
bsr_header_len = sizeof(NR_MAC_SUBHEADER_SHORT); //2 bytes
// Trigger BSR Padding
mac->BSR_reporting_active |=
NR_BSR_TRIGGER_PADDING;
} else if (padding_len >= (1 + sizeof(NR_BSR_SHORT))) {
bsr_ce_len = sizeof(NR_BSR_SHORT);
bsr_header_len = 1;
} else if (padding_len >= (sizeof(NR_BSR_SHORT)+sizeof(NR_MAC_SUBHEADER_FIXED))) {
bsr_ce_len = sizeof(NR_BSR_SHORT); //1 byte
bsr_header_len = sizeof(NR_MAC_SUBHEADER_FIXED); //1 byte
if (num_lcg_id_with_data > 1) {
// REPORT TRUNCATED BSR
// REPORT SHORT TRUNCATED BSR
//Get LCGID of highest priority LCID with data
for (lcid = DCCH; lcid < NR_MAX_NUM_LCID; lcid++) {
// if (mac->
......@@ -2814,7 +2816,8 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
}
bsr_len = bsr_header_len + bsr_ce_len;
tot_mac_ce_len = bsr_len + phr_len;
tot_mac_ce_len += bsr_len;
total_mac_pdu_header_len += bsr_len;
}
//Fill BSR Infos
......@@ -2822,7 +2825,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
bsr_s = NULL;
bsr_l = NULL;
bsr_t = NULL;
} else if (bsr_ce_len > sizeof(NR_BSR_SHORT)) {
} else if (bsr_header_len == sizeof(NR_MAC_SUBHEADER_SHORT)) {
bsr_s = NULL;
bsr_t = NULL;
bsr_l->Buffer_size0 =
......@@ -2841,9 +2844,8 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
mac->scheduling_info.BSR[6];
bsr_l->Buffer_size7 =
mac->scheduling_info.BSR[7];
/*
LOG_D(MAC,
"[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d level LCGID4 %d,level LCGID5 %d,level LCGID6 %d,level LCGID7 %d)\n",
"[UE %d] Frame %d subframe %d BSR Trig=%d report LONG BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d level LCGID4 %d,level LCGID5 %d,level LCGID6 %d,level LCGID7 %d)\n",
module_idP, frameP, subframe,
mac->BSR_reporting_active,
mac->scheduling_info.BSR[0],
......@@ -2854,8 +2856,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
mac->scheduling_info.BSR[5],
mac->scheduling_info.BSR[6],
mac->scheduling_info.BSR[7]);
*/
} else if (bsr_ce_len == sizeof(NR_BSR_SHORT)) {
} else if (bsr_header_len == sizeof(NR_MAC_SUBHEADER_FIXED)) {
bsr_l = NULL;
if ((bsr_t != NULL)
......@@ -2906,6 +2907,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
// Compute final offset for padding and fill remainder of ULSCH with 0
if (buflen_remain > 0) {
LOG_D(NR_MAC, "In %s filling remainder %d bytes to the UL PDU \n", __FUNCTION__, buflen_remain);
((NR_MAC_SUBHEADER_FIXED *) pdu)->R = 0;
((NR_MAC_SUBHEADER_FIXED *) pdu)->LCID = UL_SCH_LCID_PADDING;
......
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