Commit 5e1c6029 authored by Calvin's avatar Calvin

Add nr_rrc_mac_config_req_ue function

parent 42afd545
......@@ -35,451 +35,47 @@ nr_rrc_mac_config_req_ue(
module_id_t Mod_idP,
int CC_idP,
uint8_t eNB_index,
){
MAC_CellGroupConfig_t *mac_cell_group_config,
PhysicalCellGroupConfig_t *phy_cell_group_config,
SpCellConfig_t *spcell_config){
// TODO do something FAPI-like P5 L1/L2 config interface in config_si, config_mib, etc.
int i;
if(mac_cell_group_config != (MAC_CellGroupConfig_t *)0){
if(mac_cell_group_config->drx_Config != (drx_Config_t *)0 ){
NR_UE_mac_inst->drx_Config = mac_cell_group_config->drx_Config;
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN);
if(mac_cell_group_config->SchedulingRequestConfig != (SchedulingRequestConfig_t *)0 ){
NR_UE_mac_inst->SchedulingRequestConfig = mac_cell_group_config->SchedulingRequestConfig;
}
LOG_I(MAC, "[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",
Mod_idP, eNB_index);
if(mac_cell_group_config->BSR_Config != (BSR_Config_t *)0 ){
NR_UE_mac_inst->BSR_Config = mac_cell_group_config->BSR_Config;
}
if (tdd_Config != NULL) {
UE_mac_inst[Mod_idP].tdd_Config = tdd_Config;
}
if(mac_cell_group_config->TAG_Config != (TAG_Config_t *)0 ){
NR_UE_mac_inst->TAG_Config = mac_cell_group_config->TAG_Config;
}
if(mac_cell_group_config->phr_Config != (phr_Config_t *)0 ){
NR_UE_mac_inst->phr_Config = mac_cell_group_config->phr_Config;
}
if (tdd_Config && SIwindowsize && SIperiod) {
phy_config_sib1_ue(Mod_idP, 0, eNB_index, tdd_Config,
*SIwindowsize, *SIperiod);
}
if(mac_cell_group_config->cs_RNTI != (cs_RNTI_t *)0 ){
NR_UE_mac_inst->cs_RNTI = mac_cell_group_config->cs_RNTI;
}
if (radioResourceConfigCommon != NULL) {
UE_mac_inst[Mod_idP].radioResourceConfigCommon =
radioResourceConfigCommon;
phy_config_sib2_ue(Mod_idP, 0, eNB_index,
radioResourceConfigCommon, ul_CarrierFreq,
ul_Bandwidth, additionalSpectrumEmission,
mbsfn_SubframeConfigList);
}
// SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup
if (logicalChannelConfig != NULL) {
LOG_I(MAC,
"[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n",
Mod_idP, eNB_index);
UE_mac_inst[Mod_idP].logicalChannelConfig[logicalChannelIdentity] =
logicalChannelConfig;
UE_mac_inst[Mod_idP].scheduling_info.Bj[logicalChannelIdentity] = 0; // initilize the bucket for this lcid
AssertFatal(logicalChannelConfig->ul_SpecificParameters != NULL,
"[UE %d] LCID %ld NULL ul_SpecificParameters\n",
Mod_idP, logicalChannelIdentity);
UE_mac_inst[Mod_idP].scheduling_info.bucket_size[logicalChannelIdentity] = logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate * logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size
if (logicalChannelConfig->ul_SpecificParameters->
logicalChannelGroup != NULL) {
UE_mac_inst[Mod_idP].scheduling_info.
LCGID[logicalChannelIdentity] =
*logicalChannelConfig->ul_SpecificParameters->
logicalChannelGroup;
LOG_D(MAC,
"[CONFIG][UE %d] LCID %ld is attached to the LCGID %ld\n",
Mod_idP, logicalChannelIdentity,
*logicalChannelConfig->
ul_SpecificParameters->logicalChannelGroup);
} else {
UE_mac_inst[Mod_idP].scheduling_info.
LCGID[logicalChannelIdentity] = MAX_NUM_LCGID;
}
UE_mac_inst[Mod_idP].
scheduling_info.LCID_buffer_remain[logicalChannelIdentity] = 0;
}
if (mac_MainConfig != NULL) {
LOG_I(MAC,
"[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n",
Mod_idP, eNB_index);
UE_mac_inst[Mod_idP].macConfig = mac_MainConfig;
UE_mac_inst[Mod_idP].measGapConfig = measGapConfig;
if (mac_MainConfig->ul_SCH_Config) {
if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) {
UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer =
(uint16_t) *
mac_MainConfig->ul_SCH_Config->periodicBSR_Timer;
} else {
UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_Timer =
#ifndef Rel14
(uint16_t)
MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity
#else
(uint16_t) PeriodicBSR_Timer_r12_infinity;
#endif
;
}
if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) {
UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx =
(uint16_t) * mac_MainConfig->ul_SCH_Config->maxHARQ_Tx;
} else {
UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx =
(uint16_t)
MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
}
phy_config_harq_ue(Mod_idP, 0, eNB_index,
UE_mac_inst[Mod_idP].
scheduling_info.maxHARQ_Tx);
if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) {
UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer =
(uint16_t) mac_MainConfig->ul_SCH_Config->
retxBSR_Timer;
} else {
#ifndef Rel14
UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer =
(uint16_t)
MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560;
#else
UE_mac_inst[Mod_idP].scheduling_info.retxBSR_Timer =
(uint16_t) RetxBSR_Timer_r12_sf2560;
#endif
}
}
#if defined(Rel10) || defined(Rel14)
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;
} else {
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_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
UE_mac_inst[Mod_idP].scheduling_info.periodicBSR_SF =
MAC_UE_BSR_TIMER_NOT_RUNNING;
UE_mac_inst[Mod_idP].scheduling_info.retxBSR_SF =
MAC_UE_BSR_TIMER_NOT_RUNNING;
UE_mac_inst[Mod_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
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.phr_config =
mac_MainConfig->phr_Config;
if (mac_MainConfig->phr_Config) {
UE_mac_inst[Mod_idP].PHR_state =
mac_MainConfig->phr_Config->present;
UE_mac_inst[Mod_idP].PHR_reconfigured = 1;
UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer =
mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer;
UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer =
mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer;
UE_mac_inst[Mod_idP].scheduling_info.PathlossChange =
mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange;
} else {
UE_mac_inst[Mod_idP].PHR_reconfigured = 0;
UE_mac_inst[Mod_idP].PHR_state =
MAC_MainConfig__phr_Config_PR_setup;
UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_Timer =
MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_Timer =
MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
UE_mac_inst[Mod_idP].scheduling_info.PathlossChange =
MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
}
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.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",
Mod_idP,
(mac_MainConfig->phr_Config) ? mac_MainConfig->
phr_Config->present : -1,
UE_mac_inst[Mod_idP].scheduling_info.periodicPHR_SF,
UE_mac_inst[Mod_idP].scheduling_info.prohibitPHR_SF,
UE_mac_inst[Mod_idP].scheduling_info.PathlossChange_db);
}
if (physicalConfigDedicated != NULL) {
phy_config_dedicated_ue(Mod_idP, 0, eNB_index,
physicalConfigDedicated);
UE_mac_inst[Mod_idP].physicalConfigDedicated = physicalConfigDedicated; // for SR proc
}
#if defined(Rel10) || defined(Rel14)
if (sCellToAddMod_r10 != NULL) {
phy_config_dedicated_scell_ue(Mod_idP, eNB_index,
sCellToAddMod_r10, 1);
UE_mac_inst[Mod_idP].physicalConfigDedicatedSCell_r10 = sCellToAddMod_r10->radioResourceConfigDedicatedSCell_r10->physicalConfigDedicatedSCell_r10; // using SCell index 0
}
#endif
if (measObj != NULL) {
if (measObj[0] != NULL) {
UE_mac_inst[Mod_idP].n_adj_cells =
measObj[0]->measObject.choice.
measObjectEUTRA.cellsToAddModList->list.count;
LOG_I(MAC, "Number of adjacent cells %d\n",
UE_mac_inst[Mod_idP].n_adj_cells);
for (i = 0; i < UE_mac_inst[Mod_idP].n_adj_cells; i++) {
UE_mac_inst[Mod_idP].adj_cell_id[i] =
measObj[0]->measObject.choice.
measObjectEUTRA.cellsToAddModList->list.array[i]->
physCellId;
LOG_I(MAC, "Cell %d : Nid_cell %d\n", i,
UE_mac_inst[Mod_idP].adj_cell_id[i]);
}
phy_config_meas_ue(Mod_idP, 0, eNB_index,
UE_mac_inst[Mod_idP].n_adj_cells,
UE_mac_inst[Mod_idP].adj_cell_id);
}
}
if (mobilityControlInfo != NULL) {
LOG_D(MAC, "[UE%d] MAC Reset procedure triggered by RRC eNB %d \n",
Mod_idP, eNB_index);
ue_mac_reset(Mod_idP, eNB_index);
if (mobilityControlInfo->radioResourceConfigCommon.
rach_ConfigCommon) {
memcpy((void *)
&UE_mac_inst[Mod_idP].radioResourceConfigCommon->
rach_ConfigCommon,
(void *) mobilityControlInfo->
radioResourceConfigCommon.rach_ConfigCommon,
sizeof(RACH_ConfigCommon_t));
}
memcpy((void *) &UE_mac_inst[Mod_idP].
radioResourceConfigCommon->prach_Config.prach_ConfigInfo,
(void *) mobilityControlInfo->
radioResourceConfigCommon.prach_Config.prach_ConfigInfo,
sizeof(PRACH_ConfigInfo_t));
UE_mac_inst[Mod_idP].radioResourceConfigCommon->
prach_Config.rootSequenceIndex =
mobilityControlInfo->radioResourceConfigCommon.
prach_Config.rootSequenceIndex;
if (mobilityControlInfo->radioResourceConfigCommon.
pdsch_ConfigCommon) {
memcpy((void *)
&UE_mac_inst[Mod_idP].radioResourceConfigCommon->
pdsch_ConfigCommon,
(void *) mobilityControlInfo->
radioResourceConfigCommon.pdsch_ConfigCommon,
sizeof(PDSCH_ConfigCommon_t));
}
// not a pointer: mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon
memcpy((void *) &UE_mac_inst[Mod_idP].
radioResourceConfigCommon->pusch_ConfigCommon,
(void *) &mobilityControlInfo->
radioResourceConfigCommon.pusch_ConfigCommon,
sizeof(PUSCH_ConfigCommon_t));
if (mobilityControlInfo->radioResourceConfigCommon.phich_Config) {
/* memcpy((void *)&UE_mac_inst[Mod_idP].radioResourceConfigCommon->phich_Config,
(void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config,
sizeof(PHICH_Config_t)); */
}
if (mobilityControlInfo->radioResourceConfigCommon.
pucch_ConfigCommon) {
memcpy((void *)
&UE_mac_inst[Mod_idP].radioResourceConfigCommon->
pucch_ConfigCommon,
(void *) mobilityControlInfo->
radioResourceConfigCommon.pucch_ConfigCommon,
sizeof(PUCCH_ConfigCommon_t));
}
if (mobilityControlInfo->
radioResourceConfigCommon.soundingRS_UL_ConfigCommon) {
memcpy((void *)
&UE_mac_inst[Mod_idP].radioResourceConfigCommon->
soundingRS_UL_ConfigCommon,
(void *) mobilityControlInfo->
radioResourceConfigCommon.soundingRS_UL_ConfigCommon,
sizeof(SoundingRS_UL_ConfigCommon_t));
}
if (mobilityControlInfo->
radioResourceConfigCommon.uplinkPowerControlCommon) {
memcpy((void *)
&UE_mac_inst[Mod_idP].radioResourceConfigCommon->
uplinkPowerControlCommon,
(void *) mobilityControlInfo->
radioResourceConfigCommon.uplinkPowerControlCommon,
sizeof(UplinkPowerControlCommon_t));
}
//configure antennaInfoCommon somewhere here..
if (mobilityControlInfo->radioResourceConfigCommon.p_Max) {
//to be configured
}
if (mobilityControlInfo->radioResourceConfigCommon.tdd_Config) {
UE_mac_inst[Mod_idP].tdd_Config =
mobilityControlInfo->radioResourceConfigCommon.tdd_Config;
}
if (mobilityControlInfo->
radioResourceConfigCommon.ul_CyclicPrefixLength) {
memcpy((void *)
&UE_mac_inst[Mod_idP].radioResourceConfigCommon->
ul_CyclicPrefixLength,
(void *) mobilityControlInfo->
radioResourceConfigCommon.ul_CyclicPrefixLength,
sizeof(UL_CyclicPrefixLength_t));
if(phy_cell_group_config != (PhysicalCellGroupConfig_t *)0){
}
// store the previous rnti in case of failure, and set thenew rnti
UE_mac_inst[Mod_idP].crnti_before_ho = UE_mac_inst[Mod_idP].crnti;
UE_mac_inst[Mod_idP].crnti =
((mobilityControlInfo->
newUE_Identity.buf[0]) | (mobilityControlInfo->
newUE_Identity.buf[1] << 8));
LOG_I(MAC, "[UE %d] Received new identity %x from %d\n", Mod_idP,
UE_mac_inst[Mod_idP].crnti, eNB_index);
UE_mac_inst[Mod_idP].rach_ConfigDedicated =
malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated));
if (mobilityControlInfo->rach_ConfigDedicated) {
memcpy((void *) UE_mac_inst[Mod_idP].rach_ConfigDedicated,
(void *) mobilityControlInfo->rach_ConfigDedicated,
sizeof(*mobilityControlInfo->rach_ConfigDedicated));
if(spcell_config != (SpCellConfig_t *)0){
}
phy_config_afterHO_ue(Mod_idP, 0, eNB_index, mobilityControlInfo,
0);
}
if (mbsfn_SubframeConfigList != NULL) {
LOG_I(MAC,
"[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n",
Mod_idP, mbsfn_SubframeConfigList->list.count);
UE_mac_inst[Mod_idP].num_sf_allocation_pattern =
mbsfn_SubframeConfigList->list.count;
for (i = 0; i < mbsfn_SubframeConfigList->list.count; i++) {
LOG_I(MAC,
"[UE %d] Configuring MBSFN_SubframeConfig %d from received SIB2 \n",
Mod_idP, i);
UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i] =
mbsfn_SubframeConfigList->list.array[i];
// LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is %ld\n", Mod_idP,
// UE_mac_inst[Mod_idP].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]);
}
}
#if defined(Rel10) || defined(Rel14)
if (mbsfn_AreaInfoList != NULL) {
LOG_I(MAC, "[UE %d][CONFIG] Received %d MBSFN Area Info\n",
Mod_idP, mbsfn_AreaInfoList->list.count);
UE_mac_inst[Mod_idP].num_active_mbsfn_area =
mbsfn_AreaInfoList->list.count;
for (i = 0; i < mbsfn_AreaInfoList->list.count; i++) {
UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i] =
mbsfn_AreaInfoList->list.array[i];
LOG_I(MAC,
"[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n",
Mod_idP, i,
UE_mac_inst[Mod_idP].mbsfn_AreaInfo[i]->
mcch_Config_r9.mcch_RepetitionPeriod_r9);
phy_config_sib13_ue(Mod_idP, 0, eNB_index, i,
UE_mac_inst[Mod_idP].
mbsfn_AreaInfo[i]->mbsfn_AreaId_r9);
}
}
if (pmch_InfoList != NULL) {
// LOG_I(MAC,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9));
LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n",
Mod_idP);
for (i = 0; i < pmch_InfoList->list.count; i++) {
UE_mac_inst[Mod_idP].pmch_Config[i] =
&pmch_InfoList->list.array[i]->pmch_Config_r9;
LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n",
Mod_idP, i,
UE_mac_inst[Mod_idP].
pmch_Config[i]->mch_SchedulingPeriod_r9);
}
UE_mac_inst[Mod_idP].mcch_status = 1;
}
#endif
#ifdef CBA
if (cba_rnti) {
UE_mac_inst[Mod_idP].cba_rnti[num_active_cba_groups - 1] =
cba_rnti;
LOG_D(MAC,
"[UE %d] configure CBA group %d RNTI %x for eNB %d (total active cba group %d)\n",
Mod_idP, Mod_idP % num_active_cba_groups, cba_rnti,
eNB_index, num_active_cba_groups);
phy_config_cba_rnti(Mod_idP, CC_idP, eNB_flagP, eNB_index,
cba_rnti, num_active_cba_groups - 1,
num_active_cba_groups);
}
#endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_OUT);
return (0);
return (0);
}
......@@ -68,1293 +68,18 @@
#include "nfapi_interface.h"
#include "PHY_INTERFACE/IF_Module.h"
/** @defgroup _mac MAC
* @ingroup _oai2
* @{
*/
#define BCCH_PAYLOAD_SIZE_MAX 128
#define CCCH_PAYLOAD_SIZE_MAX 128
#define PCCH_PAYLOAD_SIZE_MAX 128
#define RAR_PAYLOAD_SIZE_MAX 128
#define SCH_PAYLOAD_SIZE_MAX 4096
/// Logical channel ids from 36-311 (Note BCCH is not specified in 36-311, uses the same as first DRB)
#if defined(Rel10) || defined(Rel14)
// Mask for identifying subframe for MBMS
#define MBSFN_TDD_SF3 0x80 // for TDD
#define MBSFN_TDD_SF4 0x40
#define MBSFN_TDD_SF7 0x20
#define MBSFN_TDD_SF8 0x10
#define MBSFN_TDD_SF9 0x08
#define MBSFN_FDD_SF1 0x80 // for FDD
#define MBSFN_FDD_SF2 0x40
#define MBSFN_FDD_SF3 0x20
#define MBSFN_FDD_SF6 0x10
#define MBSFN_FDD_SF7 0x08
#define MBSFN_FDD_SF8 0x04
#define MAX_MBSFN_AREA 8
#define MAX_PMCH_perMBSFN 15
/*!\brief MAX MCCH payload size */
#define MCCH_PAYLOAD_SIZE_MAX 128
//#define MCH_PAYLOAD_SIZE_MAX 16384// this value is using in case mcs and TBS index are high
#endif
#define printk printf
/*!\brief Maximum number of logical channl group IDs */
#define MAX_NUM_LCGID 4
/*!\brief logical channl group ID 0 */
#define LCGID0 0
/*!\brief logical channl group ID 1 */
#define LCGID1 1
/*!\brief logical channl group ID 2 */
#define LCGID2 2
/*!\brief logical channl group ID 3 */
#define LCGID3 3
/*!\brief Maximum number of logical chanels */
#define MAX_NUM_LCID 11
/*!\brief Maximum number od control elemenets */
#define MAX_NUM_CE 5
/*!\brief Maximum number of random access process */
#if defined(USRP_REC_PLAY)
#define NB_RA_PROC_MAX 1
#else
#define NB_RA_PROC_MAX 4
#endif
/*!\brief size of buffer status report table */
#define BSR_TABLE_SIZE 64
/*!\brief The power headroom reporting range is from -23 ...+40 dB and beyond, with step 1 */
#define PHR_MAPPING_OFFSET 23 // if ( x>= -23 ) val = floor (x + 23)
/*!\brief maximum number of resource block groups */
#define N_RBG_MAX 25 // for 20MHz channel BW
/*!\brief minimum value for channel quality indicator */
#define MIN_CQI_VALUE 0
/*!\brief maximum value for channel quality indicator */
#define MAX_CQI_VALUE 15
/*!\briefmaximum number of supported bandwidth (1.4, 5, 10, 20 MHz) */
#define MAX_SUPPORTED_BW 4
/*!\brief CQI values range from 1 to 15 (4 bits) */
#define CQI_VALUE_RANGE 16
/*!\brief value for indicating BSR Timer is not running */
#define MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF)
#define LCID_EMPTY 0
#define LCID_NOT_EMPTY 1
/*!\brief minimum RLC PDU size to be transmitted = min RLC Status PDU or RLC UM PDU SN 5 bits */
#define MIN_RLC_PDU_SIZE (2)
/*!\brief minimum MAC data needed for transmitting 1 min RLC PDU size + 1 byte MAC subHeader */
#define MIN_MAC_HDR_RLC_SIZE (1 + MIN_RLC_PDU_SIZE)
/*!\brief maximum number of slices / groups */
#define MAX_NUM_SLICES 4
#define U_PLANE_INACTIVITY_VALUE 6000
/*
* eNB part
*/
/*
* UE/ENB common part
*/
/*!\brief MAC header of Random Access Response for Random access preamble identifier (RAPID) */
typedef struct {
uint8_t RAPID:6;
uint8_t T:1;
uint8_t E:1;
} __attribute__ ((__packed__)) RA_HEADER_RAPID;
/*!\brief MAC header of Random Access Response for backoff indicator (BI)*/
typedef struct {
uint8_t BI:4;
uint8_t R:2;
uint8_t T:1;
uint8_t E:1;
} __attribute__ ((__packed__)) RA_HEADER_BI;
/*
typedef struct {
uint64_t padding:16;
uint64_t t_crnti:16;
uint64_t hopping_flag:1;
uint64_t rb_alloc:10;
uint64_t mcs:4;
uint64_t TPC:3;
uint64_t UL_delay:1;
uint64_t cqi_req:1;
uint64_t Timing_Advance_Command:11; // first/2nd octet LSB
uint64_t R:1; // octet MSB
} __attribute__((__packed__))RAR_PDU;
typedef struct {
uint64_t padding:16;
uint64_t R:1; // octet MSB
uint64_t Timing_Advance_Command:11; // first/2nd octet LSB
uint64_t cqi_req:1;
uint64_t UL_delay:1;
uint64_t TPC:3;
uint64_t mcs:4;
uint64_t rb_alloc:10;
uint64_t hopping_flag:1;
uint64_t t_crnti:16;
} __attribute__((__packed__))RAR_PDU;
#define sizeof_RAR_PDU 6
*/
/*!\brief MAC subheader short with 7bit Length field */
typedef struct {
uint8_t LCID:5; // octet 1 LSB
uint8_t E:1;
uint8_t R:2; // octet 1 MSB
uint8_t L:7; // octet 2 LSB
uint8_t F:1; // octet 2 MSB
} __attribute__ ((__packed__)) SCH_SUBHEADER_SHORT;
/*!\brief MAC subheader long with 15bit Length field */
typedef struct {
uint8_t LCID:5; // octet 1 LSB
uint8_t E:1;
uint8_t R:2; // octet 1 MSB
uint8_t L_MSB:7;
uint8_t F:1; // octet 2 MSB
uint8_t L_LSB:8;
uint8_t padding;
} __attribute__ ((__packed__)) SCH_SUBHEADER_LONG;
/*!\brief MAC subheader short without length field */
typedef struct {
uint8_t LCID:5;
uint8_t E:1;
uint8_t R:2;
} __attribute__ ((__packed__)) SCH_SUBHEADER_FIXED;
/*!\brief mac control element: short buffer status report for a specific logical channel group ID*/
typedef struct {
uint8_t Buffer_size:6; // octet 1 LSB
uint8_t LCGID:2; // octet 1 MSB
} __attribute__ ((__packed__)) BSR_SHORT;
typedef BSR_SHORT BSR_TRUNCATED;
/*!\brief mac control element: long buffer status report for all logical channel group ID*/
typedef struct {
uint8_t Buffer_size3:6;
uint8_t Buffer_size2:6;
uint8_t Buffer_size1:6;
uint8_t Buffer_size0:6;
} __attribute__ ((__packed__)) BSR_LONG;
#define BSR_LONG_SIZE (sizeof(BSR_LONG))
/*!\brief mac control element: timing advance */
typedef struct {
uint8_t TA:6;
uint8_t R:2;
} __attribute__ ((__packed__)) TIMING_ADVANCE_CMD;
/*!\brief mac control element: power headroom report */
typedef struct {
uint8_t PH:6;
uint8_t R:2;
} __attribute__ ((__packed__)) POWER_HEADROOM_CMD;
/*! \brief MIB payload */
typedef struct {
uint8_t payload[3];
} __attribute__ ((__packed__)) MIB_PDU;
/*! \brief CCCH payload */
typedef struct {
uint8_t payload[CCCH_PAYLOAD_SIZE_MAX];
} __attribute__ ((__packed__)) CCCH_PDU;
/*! \brief BCCH payload */
typedef struct {
uint8_t payload[BCCH_PAYLOAD_SIZE_MAX];
} __attribute__ ((__packed__)) BCCH_PDU;
/*! \brief RAR payload */
typedef struct {
uint8_t payload[RAR_PAYLOAD_SIZE_MAX];
} __attribute__ ((__packed__)) RAR_PDU;
/*! \brief BCCH payload */
typedef struct {
uint8_t payload[PCCH_PAYLOAD_SIZE_MAX];
} __attribute__ ((__packed__)) PCCH_PDU;
#if defined(Rel10) || defined(Rel14)
/*! \brief MCCH payload */
typedef struct {
uint8_t payload[MCCH_PAYLOAD_SIZE_MAX];
} __attribute__ ((__packed__)) MCCH_PDU;
/*!< \brief MAC control element for activation and deactivation of component carriers */
typedef struct {
uint8_t C7:1; /*!< \brief Component carrier 7 */
uint8_t C6:1; /*!< \brief Component carrier 6 */
uint8_t C5:1; /*!< \brief Component carrier 5 */
uint8_t C4:1; /*!< \brief Component carrier 4 */
uint8_t C3:1; /*!< \brief Component carrier 3 */
uint8_t C2:1; /*!< \brief Component carrier 2 */
uint8_t C1:1; /*!< \brief Component carrier 1 */
uint8_t R:1; /*!< \brief Reserved */
} __attribute__ ((__packed__)) CC_ELEMENT;
/*! \brief MAC control element: MCH Scheduling Information */
typedef struct {
uint8_t stop_sf_MSB:3; // octet 1 LSB
uint8_t lcid:5; // octet 2 MSB
uint8_t stop_sf_LSB:8;
} __attribute__ ((__packed__)) MSI_ELEMENT;
#endif
/*! \brief Values of CCCH LCID for DLSCH */
#define CCCH_LCHANID 0
/*!\brief Values of BCCH logical channel (fake)*/
#define BCCH 3 // SI
/*!\brief Values of PCCH logical channel (fake)*/
#define PCCH 4 // Paging
/*!\brief Values of PCCH logical channel (fake) */
#define MIBCH 5 // MIB
/*!\brief Values of BCCH SIB1_BR logical channel (fake) */
#define BCCH_SIB1_BR 6 // SIB1_BR
/*!\brief Values of BCCH SIB_BR logical channel (fake) */
#define BCCH_SI_BR 7 // SI-BR
/*!\brief Value of CCCH / SRB0 logical channel */
#define CCCH 0 // srb0
/*!\brief DCCH / SRB1 logical channel */
#define DCCH 1 // srb1
/*!\brief DCCH1 / SRB2 logical channel */
#define DCCH1 2 // srb2
/*!\brief DTCH DRB1 logical channel */
#define DTCH 3 // LCID
/*!\brief MCCH logical channel */
#define MCCH 4
/*!\brief MTCH logical channel */
#define MTCH 1
// DLSCH LCHAN ID
/*!\brief LCID of UE contention resolution identity for DLSCH*/
#define UE_CONT_RES 28
/*!\brief LCID of timing advance for DLSCH */
#define TIMING_ADV_CMD 29
/*!\brief LCID of discontinous reception mode for DLSCH */
#define DRX_CMD 30
/*!\brief LCID of padding LCID for DLSCH */
#define SHORT_PADDING 31
#if defined(Rel10) || defined(Rel14)
// MCH LCHAN IDs (table6.2.1-4 TS36.321)
/*!\brief LCID of MCCH for DL */
#define MCCH_LCHANID 0
/*!\brief LCID of MCH scheduling info for DL */
#define MCH_SCHDL_INFO 3
/*!\brief LCID of Carrier component activation/deactivation */
#define CC_ACT_DEACT 27
#endif
// ULSCH LCHAN IDs
/*!\brief LCID of extended power headroom for ULSCH */
#define EXTENDED_POWER_HEADROOM 25
/*!\brief LCID of power headroom for ULSCH */
#define POWER_HEADROOM 26
/*!\brief LCID of CRNTI for ULSCH */
#define CRNTI 27
/*!\brief LCID of truncated BSR for ULSCH */
#define TRUNCATED_BSR 28
/*!\brief LCID of short BSR for ULSCH */
#define SHORT_BSR 29
/*!\brief LCID of long BSR for ULSCH */
#define LONG_BSR 30
/*!\bitmaps for BSR Triggers */
#define BSR_TRIGGER_NONE (0) /* No BSR Trigger */
#define BSR_TRIGGER_REGULAR (1) /* For Regular and ReTxBSR Expiry Triggers */
#define BSR_TRIGGER_PERIODIC (2) /* For BSR Periodic Timer Expiry Trigger */
#define BSR_TRIGGER_PADDING (4) /* For Padding BSR Trigger */
/*! \brief Downlink SCH PDU Structure */
typedef struct {
uint8_t payload[8][SCH_PAYLOAD_SIZE_MAX];
uint16_t Pdu_size[8];
} __attribute__ ((__packed__)) DLSCH_PDU;
/*! \brief MCH PDU Structure */
typedef struct {
int8_t payload[SCH_PAYLOAD_SIZE_MAX];
uint16_t Pdu_size;
uint8_t mcs;
uint8_t sync_area;
uint8_t msi_active;
uint8_t mcch_active;
uint8_t mtch_active;
} __attribute__ ((__packed__)) MCH_PDU;
/*! \brief Uplink SCH PDU Structure */
typedef struct {
int8_t payload[SCH_PAYLOAD_SIZE_MAX]; /*!< \brief SACH payload */
uint16_t Pdu_size;
} __attribute__ ((__packed__)) ULSCH_PDU;
#include "PHY/impl_defs_top.h"
/*!\brief RA process state*/
typedef enum {
IDLE = 0,
MSG2,
WAITMSG3,
MSG4,
WAITMSG4ACK
} RA_state;
/*!\brief UE ULSCH scheduling states*/
typedef enum {
S_UL_NONE = 0,
S_UL_WAITING,
S_UL_SCHEDULED,
S_UL_BUFFERED,
S_UL_NUM_STATUS
} UE_ULSCH_STATUS;
/*!\brief UE DLSCH scheduling states*/
typedef enum {
S_DL_NONE = 0,
S_DL_WAITING,
S_DL_SCHEDULED,
S_DL_BUFFERED,
S_DL_NUM_STATUS
} UE_DLSCH_STATUS;
/*!\brief scheduling policy for the contention-based access */
typedef enum {
CBA_ES = 0, /// equal share of RB among groups w
CBA_ES_S, /// equal share of RB among groups with small allocation
CBA_PF, /// proportional fair (kind of)
CBA_PF_S, /// proportional fair (kind of) with small RB allocation
CBA_RS /// random allocation
} CBA_POLICY;
/*! \brief temporary struct for ULSCH sched */
typedef struct {
rnti_t rnti;
uint16_t subframe;
uint16_t serving_num;
UE_ULSCH_STATUS status;
} eNB_ULSCH_INFO;
/*! \brief temp struct for DLSCH sched */
typedef struct {
rnti_t rnti;
uint16_t weight;
uint16_t subframe;
uint16_t serving_num;
UE_DLSCH_STATUS status;
} eNB_DLSCH_INFO;
/*! \brief eNB overall statistics */
typedef struct {
/// num BCCH PDU per CC
uint32_t total_num_bcch_pdu;
/// BCCH buffer size
uint32_t bcch_buffer;
/// total BCCH buffer size
uint32_t total_bcch_buffer;
/// BCCH MCS
uint32_t bcch_mcs;
/// num CCCH PDU per CC
uint32_t total_num_ccch_pdu;
/// BCCH buffer size
uint32_t ccch_buffer;
/// total BCCH buffer size
uint32_t total_ccch_buffer;
/// BCCH MCS
uint32_t ccch_mcs;
/// num PCCH PDU per CC
uint32_t total_num_pcch_pdu;
/// PCCH buffer size
uint32_t pcch_buffer;
/// total PCCH buffer size
uint32_t total_pcch_buffer;
/// BCCH MCS
uint32_t pcch_mcs;
/// num active users
uint16_t num_dlactive_UEs;
/// available number of PRBs for a give SF
uint16_t available_prbs;
/// total number of PRB available for the user plane
uint32_t total_available_prbs;
/// aggregation
/// total avilable nccc : num control channel element
uint16_t available_ncces;
// only for a new transmission, should be extended for retransmission
// current dlsch bit rate for all transport channels
uint32_t dlsch_bitrate;
//
uint32_t dlsch_bytes_tx;
//
uint32_t dlsch_pdus_tx;
//
uint32_t total_dlsch_bitrate;
//
uint32_t total_dlsch_bytes_tx;
//
uint32_t total_dlsch_pdus_tx;
// here for RX
//
uint32_t ulsch_bitrate;
//
uint32_t ulsch_bytes_rx;
//
uint64_t ulsch_pdus_rx;
uint32_t total_ulsch_bitrate;
//
uint32_t total_ulsch_bytes_rx;
//
uint32_t total_ulsch_pdus_rx;
/// MAC agent-related stats
/// total number of scheduling decisions
int sched_decisions;
/// missed deadlines
int missed_deadlines;
} eNB_STATS;
/*! \brief eNB statistics for the connected UEs*/
typedef struct {
/// CRNTI of UE
rnti_t crnti; ///user id (rnti) of connected UEs
// rrc status
uint8_t rrc_status;
/// harq pid
uint8_t harq_pid;
/// harq rounf
uint8_t harq_round;
/// total available number of PRBs for a new transmission
uint16_t rbs_used;
/// total available number of PRBs for a retransmission
uint16_t rbs_used_retx;
/// total nccc used for a new transmission: num control channel element
uint16_t ncce_used;
/// total avilable nccc for a retransmission: num control channel element
uint16_t ncce_used_retx;
// mcs1 before the rate adaptaion
uint8_t dlsch_mcs1;
/// Target mcs2 after rate-adaptation
uint8_t dlsch_mcs2;
// current TBS with mcs2
uint32_t TBS;
// total TBS with mcs2
// uint32_t total_TBS;
// total rb used for a new transmission
uint32_t total_rbs_used;
// total rb used for retransmission
uint32_t total_rbs_used_retx;
/// TX
/// Num pkt
uint32_t num_pdu_tx[NB_RB_MAX];
/// num bytes
uint32_t num_bytes_tx[NB_RB_MAX];
/// num retransmission / harq
uint32_t num_retransmission;
/// instantaneous tx throughput for each TTI
// uint32_t tti_throughput[NB_RB_MAX];
// Number of received MAC SDU
uint32_t num_mac_sdu_tx;
// LCID related to SDU
unsigned char lcid_sdu[NB_RB_MAX];
// Length of SDU Got from LC DL
uint32_t sdu_length_tx[NB_RB_MAX];
/// overall
//
uint32_t dlsch_bitrate;
//total
uint32_t total_dlsch_bitrate;
/// headers+ CE + padding bytes for a MAC PDU
uint64_t overhead_bytes;
/// headers+ CE + padding bytes for a MAC PDU
uint64_t total_overhead_bytes;
/// headers+ CE + padding bytes for a MAC PDU
uint64_t avg_overhead_bytes;
// MAC multiplexed payload
uint64_t total_sdu_bytes;
// total MAC pdu bytes
uint64_t total_pdu_bytes;
// total num pdu
uint32_t total_num_pdus;
//
// uint32_t avg_pdu_size;
/// RX
/// PUCCH1a/b power (dBm)
int32_t Po_PUCCH_dBm;
/// Indicator that Po_PUCCH has been updated by PHY
int32_t Po_PUCCH_update;
/// Uplink measured RSSI
int32_t UL_rssi;
/// preassigned mcs after rate adaptation
uint8_t ulsch_mcs1;
/// adjusted mcs
uint8_t ulsch_mcs2;
/// estimated average pdu inter-departure time
uint32_t avg_pdu_idt;
/// estimated average pdu size
uint32_t avg_pdu_ps;
///
uint32_t aggregated_pdu_size;
uint32_t aggregated_pdu_arrival;
/// uplink transport block size
uint32_t ulsch_TBS;
uint32_t total_ulsch_TBS;
/// total rb used for a new uplink transmission
uint32_t num_retransmission_rx;
/// total rb used for a new uplink transmission
uint32_t rbs_used_rx;
/// total rb used for a new uplink retransmission
uint32_t rbs_used_retx_rx;
/// total rb used for a new uplink transmission
uint32_t total_rbs_used_rx;
/// normalized rx power
int32_t normalized_rx_power;
/// target rx power
int32_t target_rx_power;
/// num rx pdu
uint32_t num_pdu_rx[NB_RB_MAX];
/// num bytes rx
uint32_t num_bytes_rx[NB_RB_MAX];
/// instantaneous rx throughput for each TTI
// uint32_t tti_goodput[NB_RB_MAX];
/// errors
uint32_t num_errors_rx;
uint64_t overhead_bytes_rx;
/// headers+ CE + padding bytes for a MAC PDU
uint64_t total_overhead_bytes_rx;
/// headers+ CE + padding bytes for a MAC PDU
uint64_t avg_overhead_bytes_rx;
//
uint32_t ulsch_bitrate;
//total
uint32_t total_ulsch_bitrate;
/// overall
/// MAC pdu bytes
uint64_t pdu_bytes_rx;
/// total MAC pdu bytes
uint64_t total_pdu_bytes_rx;
/// total num pdu
uint32_t total_num_pdus_rx;
/// num of error pdus
uint32_t total_num_errors_rx;
// Number of error PDUS
uint32_t num_mac_sdu_rx;
// Length of SDU Got from LC UL - Size array can be refined
uint32_t sdu_length_rx[NB_RB_MAX];
} eNB_UE_STATS;
/*! \brief eNB template for UE context information */
typedef struct {
/// C-RNTI of UE
rnti_t rnti;
/// NDI from last scheduling
uint8_t oldNDI[8];
/// mcs1 from last scheduling
uint8_t oldmcs1[8];
/// mcs2 from last scheduling
uint8_t oldmcs2[8];
/// NDI from last UL scheduling
uint8_t oldNDI_UL[8];
/// mcs from last UL scheduling
uint8_t mcs_UL[8];
/// TBS from last UL scheduling
int TBS_UL[8];
/// Flag to indicate UL has been scheduled at least once
boolean_t ul_active;
/// Flag to indicate UE has been configured (ACK from RRCConnectionSetup received)
boolean_t configured;
/// MCS from last scheduling
uint8_t mcs[8];
/// TPC from last scheduling
uint8_t oldTPC[8];
// PHY interface info
/// Number of Allocated RBs for DL after scheduling (prior to frequency allocation)
uint16_t nb_rb[8]; // num_max_harq
/// Number of Allocated RBs for UL after scheduling
uint16_t nb_rb_ul[8]; // num_max_harq
/// Number of Allocated RBs for UL after scheduling
uint16_t first_rb_ul[8]; // num_max_harq
/// Cyclic shift for DMRS after scheduling
uint16_t cshift[8]; // num_max_harq
/// Number of Allocated RBs by the ulsch preprocessor
uint8_t pre_allocated_nb_rb_ul[MAX_NUM_SLICES];
/// index of Allocated RBs by the ulsch preprocessor
int8_t pre_allocated_rb_table_index_ul;
/// total allocated RBs
int8_t total_allocated_rbs;
/// pre-assigned MCS by the ulsch preprocessor
uint8_t pre_assigned_mcs_ul;
/// assigned MCS by the ulsch scheduler
uint8_t assigned_mcs_ul;
/// DL DAI
uint8_t DAI;
/// UL DAI
uint8_t DAI_ul[10];
/// UL Scheduling Request Received
uint8_t ul_SR;
///Resource Block indication for each sub-band in MU-MIMO
uint8_t rballoc_subband[8][50];
// Logical channel info for link with RLC
/// LCGID mapping
long lcgidmap[11];
/// phr information
int8_t phr_info;
/// phr information
int8_t phr_info_configured;
///dl buffer info
uint32_t dl_buffer_info[MAX_NUM_LCID];
/// total downlink buffer info
uint32_t dl_buffer_total;
/// total downlink pdus
uint32_t dl_pdus_total;
/// downlink pdus for each LCID
uint32_t dl_pdus_in_buffer[MAX_NUM_LCID];
/// creation time of the downlink buffer head for each LCID
uint32_t dl_buffer_head_sdu_creation_time[MAX_NUM_LCID];
/// maximum creation time of the downlink buffer head across all LCID
uint32_t dl_buffer_head_sdu_creation_time_max;
/// a flag indicating that the downlink head SDU is segmented
uint8_t dl_buffer_head_sdu_is_segmented[MAX_NUM_LCID];
/// size of remaining size to send for the downlink head SDU
uint32_t dl_buffer_head_sdu_remaining_size_to_send[MAX_NUM_LCID];
/// uplink buffer creation time for each LCID
uint32_t ul_buffer_creation_time[MAX_NUM_LCGID];
/// maximum uplink buffer creation time across all the LCIDs
uint32_t ul_buffer_creation_time_max;
/// uplink buffer size per LCID
uint32_t ul_buffer_info[MAX_NUM_LCGID];
/// uplink bytes that are currently scheduled
int scheduled_ul_bytes;
/// estimation of the UL buffer size
int estimated_ul_buffer;
/// UE tx power
int32_t ue_tx_power;
/// stores the frame where the last TPC was transmitted
uint32_t pusch_tpc_tx_frame;
uint32_t pusch_tpc_tx_subframe;
uint32_t pucch_tpc_tx_frame;
uint32_t pucch_tpc_tx_subframe;
#ifdef LOCALIZATION
eNB_UE_estimated_distances distance;
#endif
#ifdef Rel14
uint8_t rach_resource_type;
uint16_t mpdcch_repetition_cnt;
frame_t Msg2_frame;
#endif
sub_frame_t Msg2_subframe;
PhysicalConfigDedicated_t *physicalConfigDedicated;
} UE_TEMPLATE;
/*! \brief scheduling control information set through an API (not used)*/
typedef struct {
///UL transmission bandwidth in RBs
uint8_t ul_bandwidth[MAX_NUM_LCID];
///DL transmission bandwidth in RBs
uint8_t dl_bandwidth[MAX_NUM_LCID];
//To do GBR bearer
uint8_t min_ul_bandwidth[MAX_NUM_LCID];
uint8_t min_dl_bandwidth[MAX_NUM_LCID];
///aggregated bit rate of non-gbr bearer per UE
uint64_t ue_AggregatedMaximumBitrateDL;
///aggregated bit rate of non-gbr bearer per UE
uint64_t ue_AggregatedMaximumBitrateUL;
///CQI scheduling interval in subframes.
uint16_t cqiSchedInterval;
///Contention resolution timer used during random access
uint8_t mac_ContentionResolutionTimer;
uint16_t max_rbs_allowed_slice[MAX_NUM_CCs][MAX_NUM_SLICES];
uint16_t max_rbs_allowed_slice_uplink[MAX_NUM_CCs][MAX_NUM_SLICES];
uint8_t max_mcs[MAX_NUM_LCID];
uint16_t priority[MAX_NUM_LCID];
// resource scheduling information
/// Current DL harq round per harq_pid on each CC
uint8_t round[MAX_NUM_CCs][10];
/// Current Active TBs per harq_pid on each CC
uint8_t tbcnt[MAX_NUM_CCs][10];
/// Current UL harq round per harq_pid on each CC
uint8_t round_UL[MAX_NUM_CCs][8];
uint8_t dl_pow_off[MAX_NUM_CCs];
uint16_t pre_nb_available_rbs[MAX_NUM_CCs];
unsigned char rballoc_sub_UE[MAX_NUM_CCs][N_RBG_MAX];
uint16_t ta_timer;
int16_t ta_update;
uint16_t ul_consecutive_errors;
int32_t context_active_timer;
int32_t cqi_req_timer;
int32_t ul_inactivity_timer;
int32_t ul_failure_timer;
uint32_t ue_reestablishment_reject_timer;
uint32_t ue_reestablishment_reject_timer_thres;
int32_t ul_scheduled;
int32_t ra_pdcch_order_sent;
int32_t ul_out_of_sync;
int32_t phr_received;
uint8_t periodic_ri_received[NFAPI_CC_MAX];
uint8_t aperiodic_ri_received[NFAPI_CC_MAX];
uint8_t pucch1_cqi_update[NFAPI_CC_MAX];
uint8_t pucch1_snr[NFAPI_CC_MAX];
uint8_t pucch2_cqi_update[NFAPI_CC_MAX];
uint8_t pucch2_snr[NFAPI_CC_MAX];
uint8_t pucch3_cqi_update[NFAPI_CC_MAX];
uint8_t pucch3_snr[NFAPI_CC_MAX];
uint8_t pusch_snr[NFAPI_CC_MAX];
uint16_t feedback_cnt[NFAPI_CC_MAX];
uint16_t timing_advance;
uint16_t timing_advance_r9;
uint8_t periodic_wideband_cqi[NFAPI_CC_MAX];
uint8_t periodic_wideband_spatial_diffcqi[NFAPI_CC_MAX];
uint8_t periodic_wideband_pmi[NFAPI_CC_MAX];
uint8_t periodic_subband_cqi[NFAPI_CC_MAX][16];
uint8_t periodic_subband_spatial_diffcqi[NFAPI_CC_MAX][16];
uint8_t aperiodic_subband_cqi0[NFAPI_CC_MAX][25];
uint8_t aperiodic_subband_pmi[NFAPI_CC_MAX][25];
uint8_t aperiodic_subband_diffcqi0[NFAPI_CC_MAX][25];
uint8_t aperiodic_subband_cqi1[NFAPI_CC_MAX][25];
uint8_t aperiodic_subband_diffcqi1[NFAPI_CC_MAX][25];
uint8_t aperiodic_wideband_cqi0[NFAPI_CC_MAX];
uint8_t aperiodic_wideband_pmi[NFAPI_CC_MAX];
uint8_t aperiodic_wideband_cqi1[NFAPI_CC_MAX];
uint8_t aperiodic_wideband_pmi1[NFAPI_CC_MAX];
uint8_t dl_cqi[NFAPI_CC_MAX];
int32_t uplane_inactivity_timer;
} UE_sched_ctrl;
/*! \brief eNB template for the Random access information */
typedef struct {
/// Flag to indicate this process is active
RA_state state;
/// Subframe where preamble was received
uint8_t preamble_subframe;
/// Subframe where Msg2 is to be sent
uint8_t Msg2_subframe;
/// Frame where Msg2 is to be sent
frame_t Msg2_frame;
/// Subframe where Msg3 is to be sent
sub_frame_t Msg3_subframe;
/// Frame where Msg3 is to be sent
frame_t Msg3_frame;
/// Subframe where Msg4 is to be sent
sub_frame_t Msg4_subframe;
/// Frame where Msg4 is to be sent
frame_t Msg4_frame;
/// harq_pid used for Msg4 transmission
uint8_t harq_pid;
/// UE RNTI allocated during RAR
rnti_t rnti;
/// RA RNTI allocated from received PRACH
uint16_t RA_rnti;
/// Received preamble_index
uint8_t preamble_index;
/// Received UE Contention Resolution Identifier
uint8_t cont_res_id[6];
/// Timing offset indicated by PHY
int16_t timing_offset;
/// Timeout for RRC connection
int16_t RRC_timer;
/// Msg3 first RB
uint8_t msg3_first_rb;
/// Msg3 number of RB
uint8_t msg3_nb_rb;
/// Msg3 MCS
uint8_t msg3_mcs;
/// Msg3 TPC command
uint8_t msg3_TPC;
/// Msg3 ULdelay command
uint8_t msg3_ULdelay;
/// Msg3 cqireq command
uint8_t msg3_cqireq;
/// Round of Msg3 HARQ
uint8_t msg3_round;
/// TBS used for Msg4
int msg4_TBsize;
/// MCS used for Msg4
int msg4_mcs;
#ifdef Rel14
uint8_t rach_resource_type;
uint8_t msg2_mpdcch_repetition_cnt;
uint8_t msg4_mpdcch_repetition_cnt;
uint8_t msg2_narrowband;
uint8_t msg34_narrowband;
#endif
} RA_t;
/*! \brief subband bitmap confguration (for ALU icic algo purpose), in test phase */
typedef struct {
uint8_t sbmap[NUMBER_OF_SUBBANDS_MAX]; //13 = number of SB MAX for 100 PRB
uint8_t periodicity;
uint8_t first_subframe;
uint8_t sb_size;
uint8_t nb_active_sb;
} SBMAP_CONF;
/*! \brief UE list used by eNB to order UEs/CC for scheduling*/
typedef struct {
/// Dedicated information for UEs
struct PhysicalConfigDedicated
*physicalConfigDedicated[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
/// DLSCH pdu
DLSCH_PDU DLSCH_pdu[MAX_NUM_CCs][2][NUMBER_OF_UE_MAX];
/// DCI template and MAC connection parameters for UEs
UE_TEMPLATE UE_template[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
/// DCI template and MAC connection for RA processes
int pCC_id[NUMBER_OF_UE_MAX];
/// sorted downlink component carrier for the scheduler
int ordered_CCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
/// number of downlink active component carrier
int numactiveCCs[NUMBER_OF_UE_MAX];
/// sorted uplink component carrier for the scheduler
int ordered_ULCCids[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
/// number of uplink active component carrier
int numactiveULCCs[NUMBER_OF_UE_MAX];
/// number of downlink active component carrier
uint8_t dl_CC_bitmap[NUMBER_OF_UE_MAX];
/// eNB to UE statistics
eNB_UE_STATS eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
/// scheduling control info
UE_sched_ctrl UE_sched_ctrl[NUMBER_OF_UE_MAX];
int next[NUMBER_OF_UE_MAX];
int head;
int next_ul[NUMBER_OF_UE_MAX];
int head_ul;
int avail;
int num_UEs;
boolean_t active[NUMBER_OF_UE_MAX];
/// Sorting criteria for the UE list in the MAC preprocessor
uint16_t sorting_criteria[MAX_NUM_SLICES][CR_NUM];
} UE_list_t;
/*! \brief eNB common channels */
typedef struct {
int physCellId;
int p_eNB;
int Ncp;
int eutra_band;
uint32_t dl_CarrierFreq;
BCCH_BCH_Message_t *mib;
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon;
#ifdef Rel14
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon_BR;
#endif
TDD_Config_t *tdd_Config;
SchedulingInfoList_t *schedulingInfoList;
ARFCN_ValueEUTRA_t ul_CarrierFreq;
long ul_Bandwidth;
/// Outgoing MIB PDU for PHY
MIB_PDU MIB_pdu;
/// Outgoing BCCH pdu for PHY
BCCH_PDU BCCH_pdu;
/// Outgoing BCCH DCI allocation
uint32_t BCCH_alloc_pdu;
/// Outgoing CCCH pdu for PHY
CCCH_PDU CCCH_pdu;
/// Outgoing PCCH DCI allocation
uint32_t PCCH_alloc_pdu;
/// Outgoing PCCH pdu for PHY
PCCH_PDU PCCH_pdu;
/// Outgoing RAR pdu for PHY
RAR_PDU RAR_pdu;
/// Template for RA computations
RA_t ra[NB_RA_PROC_MAX];
/// VRB map for common channels
uint8_t vrb_map[100];
/// VRB map for common channels and retransmissions by PHICH
uint8_t vrb_map_UL[100];
/// MBSFN SubframeConfig
struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8];
/// number of subframe allocation pattern available for MBSFN sync area
uint8_t num_sf_allocation_pattern;
#if defined(Rel10) || defined(Rel14)
/// MBMS Flag
uint8_t MBMS_flag;
/// Outgoing MCCH pdu for PHY
MCCH_PDU MCCH_pdu;
/// MCCH active flag
uint8_t msi_active;
/// MCCH active flag
uint8_t mcch_active;
/// MTCH active flag
uint8_t mtch_active;
/// number of active MBSFN area
uint8_t num_active_mbsfn_area;
/// MBSFN Area Info
struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA];
/// PMCH Config
struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN];
/// MBMS session info list
struct MBMS_SessionInfoList_r9 *mbms_SessionList[MAX_PMCH_perMBSFN];
/// Outgoing MCH pdu for PHY
MCH_PDU MCH_pdu;
#endif
#ifdef Rel14
/// Rel13 parameters from SIB1
SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext;
/// Counter for SIB1-BR scheduling
int SIB1_BR_cnt;
/// Outgoing BCCH-BR pdu for PHY
BCCH_PDU BCCH_BR_pdu[20];
#endif
} COMMON_channels_t;
/*! \brief top level eNB MAC structure */
typedef struct eNB_MAC_INST_s {
/// Ethernet parameters for northbound midhaul interface
eth_params_t eth_params_n;
/// Ethernet parameters for fronthaul interface
eth_params_t eth_params_s;
///
module_id_t Mod_id;
/// frame counter
frame_t frame;
/// subframe counter
sub_frame_t subframe;
/// Pointer to IF module instance for PHY
IF_Module_t *if_inst;
/// Common cell resources
COMMON_channels_t common_channels[MAX_NUM_CCs];
/// current PDU index (BCH,MCH,DLSCH)
uint16_t pdu_index[MAX_NUM_CCs];
/// NFAPI Config Request Structure
nfapi_config_request_t config[MAX_NUM_CCs];
/// Preallocated DL pdu list
nfapi_dl_config_request_pdu_t
dl_config_pdu_list[MAX_NUM_CCs][MAX_NUM_DL_PDU];
/// NFAPI DL Config Request Structure
nfapi_dl_config_request_t DL_req[MAX_NUM_CCs];
/// Preallocated UL pdu list
nfapi_ul_config_request_pdu_t
ul_config_pdu_list[MAX_NUM_CCs][MAX_NUM_UL_PDU];
/// Preallocated UL pdu list for ULSCH (n+k delay)
nfapi_ul_config_request_pdu_t
ul_config_pdu_list_tmp[MAX_NUM_CCs][10][MAX_NUM_UL_PDU];
/// NFAPI UL Config Request Structure, send to L1 4 subframes before processing takes place
nfapi_ul_config_request_t UL_req[MAX_NUM_CCs];
/// NFAPI "Temporary" UL Config Request Structure, holds future UL_config requests
nfapi_ul_config_request_t UL_req_tmp[MAX_NUM_CCs][10];
/// Preallocated HI_DCI0 pdu list
nfapi_hi_dci0_request_pdu_t
hi_dci0_pdu_list[MAX_NUM_CCs][MAX_NUM_HI_DCI0_PDU];
/// NFAPI HI/DCI0 Config Request Structure
nfapi_hi_dci0_request_t HI_DCI0_req[MAX_NUM_CCs];
/// Prealocated TX pdu list
nfapi_tx_request_pdu_t
tx_request_pdu[MAX_NUM_CCs][MAX_NUM_TX_REQUEST_PDU];
/// NFAPI DL PDU structure
nfapi_tx_request_t TX_req[MAX_NUM_CCs];
/// UL handle
uint32_t ul_handle;
UE_list_t UE_list;
///subband bitmap configuration
SBMAP_CONF sbmap_conf;
/// CCE table used to build DCI scheduling information
int CCE_table[MAX_NUM_CCs][800];
/// active flag for Other lcid
uint8_t lcid_active[NB_RB_MAX];
/// eNB stats
eNB_STATS eNB_stats[MAX_NUM_CCs];
// MAC function execution peformance profiler
/// processing time of eNB scheduler
time_stats_t eNB_scheduler;
/// processing time of eNB scheduler for SI
time_stats_t schedule_si;
/// processing time of eNB scheduler for Random access
time_stats_t schedule_ra;
/// processing time of eNB ULSCH scheduler
time_stats_t schedule_ulsch;
/// processing time of eNB DCI generation
time_stats_t fill_DLSCH_dci;
/// processing time of eNB MAC preprocessor
time_stats_t schedule_dlsch_preprocessor;
/// processing time of eNB DLSCH scheduler
time_stats_t schedule_dlsch; // include rlc_data_req + MAC header + preprocessor
/// processing time of eNB MCH scheduler
time_stats_t schedule_mch;
/// processing time of eNB ULSCH reception
time_stats_t rx_ulsch_sdu; // include rlc_data_ind
/// processing time of eNB PCH scheduler
time_stats_t schedule_pch;
} eNB_MAC_INST;
/*
* UE part
*/
typedef enum {
TYPE0,
TYPE1,
TYPE1A,
TYPE2,
TYPE2A,
TYPEUESPEC
} MPDCCH_TYPES_t;
/*!\brief UE layer 2 status */
typedef enum {
CONNECTION_OK = 0,
CONNECTION_LOST,
PHY_RESYNCH,
PHY_HO_PRACH
} UE_L2_STATE_t;
/*!\brief UE scheduling info */
typedef struct {
/// buffer status for each lcgid
uint8_t BSR[MAX_NUM_LCGID]; // should be more for mesh topology
/// keep the number of bytes in rlc buffer for each lcgid
int32_t BSR_bytes[MAX_NUM_LCGID];
/// after multiplexing buffer remain for each lcid
int32_t LCID_buffer_remain[MAX_NUM_LCID];
/// sum of all lcid buffer size
uint16_t All_lcid_buffer_size_lastTTI;
/// buffer status for each lcid
uint8_t LCID_status[MAX_NUM_LCID];
/// SR pending as defined in 36.321
uint8_t SR_pending;
/// SR_COUNTER as defined in 36.321
uint16_t SR_COUNTER;
/// logical channel group ide for each LCID
uint8_t LCGID[MAX_NUM_LCID];
/// retxBSR-Timer, default value is sf2560
uint16_t retxBSR_Timer;
/// retxBSR_SF, number of subframe before triggering a regular BSR
uint16_t retxBSR_SF;
/// periodicBSR-Timer, default to infinity
uint16_t periodicBSR_Timer;
/// periodicBSR_SF, number of subframe before triggering a periodic BSR
uint16_t periodicBSR_SF;
/// default value is 0: not configured
uint16_t sr_ProhibitTimer;
/// sr ProhibitTime running
uint8_t sr_ProhibitTimer_Running;
/// default value to n5
uint16_t maxHARQ_Tx;
/// default value is false
uint16_t ttiBundling;
/// default value is release
struct DRX_Config *drx_config;
/// default value is release
struct MAC_MainConfig__phr_Config *phr_config;
///timer before triggering a periodic PHR
uint16_t periodicPHR_Timer;
///timer before triggering a prohibit PHR
uint16_t prohibitPHR_Timer;
///DL Pathloss change value
uint16_t PathlossChange;
///number of subframe before triggering a periodic PHR
int16_t periodicPHR_SF;
///number of subframe before triggering a prohibit PHR
int16_t prohibitPHR_SF;
///DL Pathloss Change in 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
int16_t Bj[MAX_NUM_LCID];
// Bucket size per lcid
int16_t bucket_size[MAX_NUM_LCID];
} UE_SCHEDULING_INFO;
/*!\brief Top level UE MAC structure */
typedef struct {
uint16_t Node_id;
/// RX frame counter
frame_t rxFrame;
/// RX subframe counter
sub_frame_t rxSubframe;
/// TX frame counter
frame_t txFrame;
/// TX subframe counter
sub_frame_t txSubframe;
/// C-RNTI of UE
uint16_t crnti;
/// C-RNTI of UE before HO
rnti_t crnti_before_ho; ///user id (rnti) of connected UEs
/// uplink active flag
uint8_t ul_active;
/// pointer to RRC PHY configuration
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon;
/// pointer to RACH_ConfigDedicated (NULL when not active, i.e. upon HO completion or T304 expiry)
struct RACH_ConfigDedicated *rach_ConfigDedicated;
/// pointer to RRC PHY configuration
struct PhysicalConfigDedicated *physicalConfigDedicated;
#if defined(Rel10) || defined(Rel14)
/// pointer to RRC PHY configuration SCEll
struct PhysicalConfigDedicatedSCell_r10
*physicalConfigDedicatedSCell_r10;
#endif
/// pointer to TDD Configuration (NULL for FDD)
TDD_Config_t *tdd_Config;
/// Number of adjacent cells to measure
uint8_t n_adj_cells;
/// Array of adjacent physical cell ids
uint32_t adj_cell_id[6];
/// Pointer to RRC MAC configuration
MAC_MainConfig_t *macConfig;
/// Pointer to RRC Measurement gap configuration
MeasGapConfig_t *measGapConfig;
/// Pointers to LogicalChannelConfig indexed by LogicalChannelIdentity. Note NULL means LCHAN is inactive.
LogicalChannelConfig_t *logicalChannelConfig[MAX_NUM_LCID];
/// Scheduling Information
UE_SCHEDULING_INFO scheduling_info;
/// Outgoing CCCH pdu for PHY
CCCH_PDU CCCH_pdu;
/// Outgoing RAR pdu for PHY
RAR_PDU RAR_pdu;
/// Incoming DLSCH pdu for PHY
DLSCH_PDU DLSCH_pdu[NUMBER_OF_UE_MAX][2];
/// number of attempt for rach
uint8_t RA_attempt_number;
/// Random-access procedure flag
uint8_t RA_active;
/// Random-access window counter
int8_t RA_window_cnt;
/// Random-access Msg3 size in bytes
uint8_t RA_Msg3_size;
/// Random-access prachMaskIndex
uint8_t RA_prachMaskIndex;
/// Flag indicating Preamble set (A,B) used for first Msg3 transmission
uint8_t RA_usedGroupA;
/// Random-access Resources
PRACH_RESOURCES_t RA_prach_resources;
/// Random-access PREAMBLE_TRANSMISSION_COUNTER
uint8_t RA_PREAMBLE_TRANSMISSION_COUNTER;
/// Random-access backoff counter
int16_t RA_backoff_cnt;
/// Random-access variable for window calculation (frame of last change in window counter)
uint32_t RA_tx_frame;
/// Random-access variable for window calculation (subframe of last change in window counter)
uint8_t RA_tx_subframe;
/// Random-access Group B maximum path-loss
/// Random-access variable for backoff (frame of last change in backoff counter)
uint32_t RA_backoff_frame;
/// Random-access variable for backoff (subframe of last change in backoff counter)
uint8_t RA_backoff_subframe;
/// Random-access Group B maximum path-loss
uint16_t RA_maxPL;
/// Random-access Contention Resolution Timer active flag
uint8_t RA_contention_resolution_timer_active;
/// Random-access Contention Resolution Timer count value
uint8_t RA_contention_resolution_cnt;
/// power headroom reporitng reconfigured
uint8_t PHR_reconfigured;
/// power headroom state as configured by the higher layers
uint8_t PHR_state;
/// power backoff due to power management (as allowed by P-MPRc) for this cell
uint8_t PHR_reporting_active;
/// power backoff due to power management (as allowed by P-MPRc) for this cell
uint8_t power_backoff_db[NUMBER_OF_eNB_MAX];
/// BSR report falg management
uint8_t BSR_reporting_active;
/// retxBSR-Timer expires flag
uint8_t retxBSRTimer_expires_flag;
/// periodBSR-Timer expires flag
uint8_t periodBSRTimer_expires_flag;
drx_Config_t *drx_config;
SchedulingRequestConfig_t *SchedulingRequestConfig;
BSR_Config_t *BSR_Config;
TAG_Config_t *TAG_Config;
phr_Config_t *phr_Config;
cs_RNTI_t *cs_RNTI;
/// MBSFN_Subframe Configuration
struct MBSFN_SubframeConfig *mbsfn_SubframeConfig[8]; // FIXME replace 8 by MAX_MBSFN_AREA?
/// number of subframe allocation pattern available for MBSFN sync area
uint8_t num_sf_allocation_pattern;
#if defined(Rel10) || defined(Rel14)
/// number of active MBSFN area
uint8_t num_active_mbsfn_area;
/// MBSFN Area Info
struct MBSFN_AreaInfo_r9 *mbsfn_AreaInfo[MAX_MBSFN_AREA];
/// PMCH Config
struct PMCH_Config_r9 *pmch_Config[MAX_PMCH_perMBSFN];
/// MCCH status
uint8_t mcch_status;
/// MSI status
uint8_t msi_status; // could be an array if there are >1 MCH in one MBSFN area
#endif
//#ifdef CBA
/// CBA RNTI for each group
uint16_t cba_rnti[NUM_MAX_CBA_GROUP];
/// last SFN for CBA channel access
uint8_t cba_last_access[NUM_MAX_CBA_GROUP];
//#endif
/// total UE scheduler processing time
time_stats_t ue_scheduler; // total
/// UE ULSCH tx processing time inlcuding RLC interface (rlc_data_req) and mac header generation
time_stats_t tx_ulsch_sdu;
/// UE DLSCH rx processing time inlcuding RLC interface (mac_rrc_data_ind or mac_rlc_status_ind+mac_rlc_data_ind) and mac header parser
time_stats_t rx_dlsch_sdu;
/// UE query for MCH subframe processing time
time_stats_t ue_query_mch;
/// UE MCH rx processing time
time_stats_t rx_mch_sdu;
/// UE BCCH rx processing time including RLC interface (mac_rrc_data_ind)
time_stats_t rx_si;
/// UE PCCH rx processing time including RLC interface (mac_rrc_data_ind)
time_stats_t rx_p;
} UE_MAC_INST;
/*! \brief ID of the neighboring cells used for HO*/
typedef struct {
uint16_t cell_ids[6];
uint8_t n_adj_cells;
} neigh_cell_id_t;
#include "proto.h"
/*@}*/
#endif /*__LAYER2_MAC_DEFS_H__ */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file extern.h
* \brief mac externs
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \version 1.0
* \email navid.nikaein@eurecom.fr
* @ingroup _mac
*/
#ifndef __MAC_EXTERN_H__
#define __MAC_EXTERN_H__
#include "PHY/defs.h"
#include "defs.h"
#include "RRC/LITE/defs.h"
extern const uint32_t BSR_TABLE[BSR_TABLE_SIZE];
//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 const uint8_t cqi2fmt0_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE];
extern const uint8_t cqi2fmt1x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE];
extern const uint8_t cqi2fmt2x_agg[MAX_SUPPORTED_BW][CQI_VALUE_RANGE];
extern UE_RRC_INST *UE_rrc_inst;
extern UE_MAC_INST *UE_mac_inst;
extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8
extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8
#ifndef PHYSIM
#define NB_INST 1
#else
extern unsigned char NB_INST;
#endif
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
extern unsigned char NB_RN_INST;
extern unsigned short NODE_ID[1];
extern int cqi_to_mcs[16];
extern uint32_t RRC_CONNECTION_FLAG;
extern uint8_t rb_table[34];
extern DCI0_5MHz_TDD_1_6_t UL_alloc_pdu;
extern DCI1A_5MHz_TDD_1_6_t RA_alloc_pdu;
extern DCI1A_5MHz_TDD_1_6_t DLSCH_alloc_pdu1A;
extern DCI1A_5MHz_TDD_1_6_t BCCH_alloc_pdu;
extern DCI1A_5MHz_TDD_1_6_t CCCH_alloc_pdu;
extern DCI1_5MHz_TDD_t DLSCH_alloc_pdu;
extern DCI0_5MHz_FDD_t UL_alloc_pdu_fdd;
extern DCI1A_5MHz_FDD_t DLSCH_alloc_pdu1A_fdd;
extern DCI1A_5MHz_FDD_t RA_alloc_pdu_fdd;
extern DCI1A_5MHz_FDD_t BCCH_alloc_pdu_fdd;
extern DCI1A_5MHz_FDD_t CCCH_alloc_pdu_fdd;
extern DCI1_5MHz_FDD_t DLSCH_alloc_pdu_fdd;
extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu1;
extern DCI2_5MHz_2A_TDD_t DLSCH_alloc_pdu2;
extern DCI1E_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu1E;
#endif //DEF_H
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file LAYER2/MAC/proto.h
* \brief MAC functions prototypes for eNB and UE
* \author Navid Nikaein and Raymond Knopp
* \date 2010 - 2014
* \email navid.nikaein@eurecom.fr
* \version 1.0
*/
#ifndef __LAYER2_MAC_PROTO_H__
#define __LAYER2_MAC_PROTO_H__
#include "LAYER2/MAC/defs.h"
/** \addtogroup _mac
* @{
*/
/**
* slice specific scheduler
*/
typedef void (*slice_scheduler_dl)(module_id_t mod_id,
slice_id_t slice_id,
frame_t frame,
sub_frame_t subframe,
int *mbsfn_flag);
typedef void (*slice_scheduler_ul)(module_id_t mod_id,
slice_id_t slice_id,
frame_t frame,
sub_frame_t subframe,
unsigned char sched_subframe,
uint16_t *first_rb);
/** \fn void schedule_mib(module_id_t module_idP,frame_t frameP,sub_frame_t subframe);
\brief MIB scheduling for PBCH. This function requests the MIB from RRC and provides it to L1.
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
*/
void schedule_mib(module_id_t module_idP,
frame_t frameP, sub_frame_t subframeP);
/** \fn void schedule_RA(module_id_t module_idP,frame_t frameP,sub_frame_t subframe);
\brief First stage of Random-Access Scheduling. Loops over the ras and checks if RAR, Msg3 or its retransmission are to be scheduled in the subframe. It returns the total number of PRB used for RA SDUs. For Msg3 it retrieves the L3msg from RRC and fills the appropriate buffers. For the others it just computes the number of PRBs. Each DCI uses 3 PRBs (format 1A)
for the message.
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
*/
void schedule_RA(module_id_t module_idP, frame_t frameP,
sub_frame_t subframe);
/** \brief First stage of SI Scheduling. Gets a SI SDU from RRC if available and computes the MCS required to transport it as a function of the SDU length. It assumes a length less than or equal to 64 bytes (MCS 6, 3 PRBs).
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
*/
void schedule_SI(module_id_t module_idP, frame_t frameP,
sub_frame_t subframeP);
/** \brief MBMS scheduling: Checking the position for MBSFN subframes. Create MSI, transfer MCCH from RRC to MAC, transfer MTCHs from RLC to MAC. Multiplexing MSI,MCCH&MTCHs. Return 1 if there are MBSFN data being allocated, otherwise return 0;
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
*/
int schedule_MBMS(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
sub_frame_t subframe);
/** \brief check the mapping between sf allocation and sync area, Currently only supports 1:1 mapping
@param Mod_id Instance ID of eNB
@param mbsfn_sync_area index of mbsfn sync area
@param[out] index of sf pattern
*/
int8_t get_mbsfn_sf_alloction(module_id_t module_idP, uint8_t CC_id,
uint8_t mbsfn_sync_area);
/** \brief check the mapping between sf allocation and sync area, Currently only supports 1:1 mapping
@param Mod_id Instance ID of eNB
@param mbsfn_sync_area index of mbsfn sync area
@param eNB_index index of eNB
@param[out] index of sf pattern
*/
int8_t ue_get_mbsfn_sf_alloction(module_id_t module_idP,
uint8_t mbsfn_sync_area,
unsigned char eNB_index);
/** \brief top ULSCH Scheduling for TDD (config 1-6).
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
*/
void schedule_ulsch(module_id_t module_idP, frame_t frameP,
sub_frame_t subframe);
/** \brief ULSCH Scheduling per RNTI
@param Mod_id Instance ID of eNB
@param slice_id Instance slice for this eNB
@param frame Frame index
@param subframe Subframe number on which to act
@param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup)
*/
void schedule_ulsch_rnti(module_id_t module_idP, slice_id_t slice_idP, frame_t frameP,
sub_frame_t subframe,
unsigned char sched_subframe,
uint16_t * first_rb);
/** \brief Second stage of DLSCH scheduling, after schedule_SI, schedule_RA and schedule_dlsch have been called. This routine first allocates random frequency assignments for SI and RA SDUs using distributed VRB allocations and adds the corresponding DCI SDU to the DCI buffer for PHY. It then loops over the UE specific DCIs previously allocated and fills in the remaining DCI fields related to frequency allocation. It assumes localized allocation of type 0 (DCI.rah=0). The allocation is done for tranmission modes 1,2,4.
@param Mod_id Instance of eNB
@param frame Frame index
@param subframe Index of subframe
@param mbsfn_flag Indicates that this subframe is for MCH/MCCH
*/
void fill_DLSCH_dci(module_id_t module_idP, frame_t frameP,
sub_frame_t subframe, int *mbsfn_flag);
/** \brief UE specific DLSCH scheduling. Retrieves next ue to be schduled from round-robin scheduler and gets the appropriate harq_pid for the subframe from PHY. If the process is active and requires a retransmission, it schedules the retransmission with the same PRB count and MCS as the first transmission. Otherwise it consults RLC for DCCH/DTCH SDUs (status with maximum number of available PRBS), builds the MAC header (timing advance sent by default) and copies
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe on which to act
@param mbsfn_flag Indicates that MCH/MCCH is in this subframe
*/
void schedule_dlsch(module_id_t module_idP, frame_t frameP,
sub_frame_t subframe, int *mbsfn_flag);
void schedule_ue_spec(module_id_t module_idP, slice_id_t slice_idP,
frame_t frameP,sub_frame_t subframe, int *mbsfn_flag);
/** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure.
@param Mod_id Module id of UE
@returns Po_NOMINAL_PUSCH (PREAMBLE_RECEIVED_TARGET_POWER+DELTA_PREAMBLE
*/
int8_t get_Po_NOMINAL_PUSCH(module_id_t module_idP, uint8_t CC_id);
/** \brief Function to compute DELTA_PREAMBLE from 36.321 (for RA power ramping procedure and Msg3 PUSCH power control policy)
@param Mod_id Module id of UE
@returns DELTA_PREAMBLE
*/
int8_t get_DELTA_PREAMBLE(module_id_t module_idP, int CC_id);
/** \brief Function for compute deltaP_rampup from 36.321 (for RA power ramping procedure and Msg3 PUSCH power control policy)
@param Mod_id Module id of UE
@param CC_id carrier component id of UE
@returns deltaP_rampup
*/
int8_t get_deltaP_rampup(module_id_t module_idP, uint8_t CC_id);
uint16_t mac_computeRIV(uint16_t N_RB_DL, uint16_t RBstart,
uint16_t Lcrbs);
void add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP,
sub_frame_t subframeP);
//main.c
int mac_top_init(int eMBMS_active, char *uecap_xer,
uint8_t cba_group_active, uint8_t HO_active);
void mac_top_init_eNB(void);
void mac_init_cell_params(int Mod_idP, int CC_idP);
char layer2_init_UE(module_id_t module_idP);
char layer2_init_eNB(module_id_t module_idP, uint8_t Free_ch_index);
void mac_switch_node_function(module_id_t module_idP);
int mac_init_global_param(void);
void mac_top_cleanup(void);
void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP,
uint16_t eNB_index);
void clear_nfapi_information(eNB_MAC_INST * eNB, int CC_idP,
frame_t frameP, sub_frame_t subframeP);
void dlsch_scheduler_pre_processor_reset(int module_idP, int UE_id,
uint8_t CC_id,
int frameP,
int subframeP,
int N_RBG,
uint16_t
nb_rbs_required[MAX_NUM_CCs]
[NUMBER_OF_UE_MAX],
unsigned char
rballoc_sub[MAX_NUM_CCs]
[N_RBG_MAX],
unsigned char
MIMO_mode_indicator[MAX_NUM_CCs]
[N_RBG_MAX]);
// eNB functions
/* \brief This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done
@param Mod_id Instance ID of eNB
@param frame Index of frame
@param subframe Index of current subframe
@param N_RBS Number of resource block groups
*/
void dlsch_scheduler_pre_processor(module_id_t module_idP,
slice_id_t slice_idP,
frame_t frameP,
sub_frame_t subframe,
int N_RBG[MAX_NUM_CCs],
int *mbsfn_flag);
void dlsch_scheduler_pre_processor_allocate(module_id_t Mod_id,
int UE_id,
uint8_t CC_id,
int N_RBG,
int transmission_mode,
int min_rb_unit,
uint8_t N_RB_DL,
uint16_t
nb_rbs_required[MAX_NUM_CCs]
[NUMBER_OF_UE_MAX],
uint16_t
nb_rbs_required_remaining
[MAX_NUM_CCs]
[NUMBER_OF_UE_MAX],
unsigned char
rballoc_sub[MAX_NUM_CCs]
[N_RBG_MAX],
unsigned char
MIMO_mode_indicator
[MAX_NUM_CCs][N_RBG_MAX]);
/* \brief Function to trigger the eNB scheduling procedure. It is called by PHY at the beginning of each subframe, \f$n$\f
and generates all DLSCH allocations for subframe \f$n\f$ and ULSCH allocations for subframe \f$n+k$\f.
@param Mod_id Instance ID of eNB
@param subframe Index of current subframe
@param calibration_flag Flag to indicate that eNB scheduler should schedule TDD auto-calibration PUSCH.
*/
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); //, int calibration_flag);
/* \brief Function to indicate a received preamble on PRACH. It initiates the RA procedure.
@param Mod_id Instance ID of eNB
@param preamble_index index of the received RA request
@param timing_offset Offset in samples of the received PRACH w.r.t. eNB timing. This is used to
@param rnti RA rnti corresponding to this PRACH preamble
@param rach_resource type (0=non BL/CE,1 CE level 0,2 CE level 1, 3 CE level 2,4 CE level 3)
*/
void initiate_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP,
sub_frame_t subframeP, uint16_t preamble_index,
int16_t timing_offset, uint16_t rnti
#ifdef Rel14
, uint8_t rach_resource_type
#endif
);
/* \brief Function in eNB to fill RAR pdu when requested by PHY. This provides a single RAR SDU for the moment and returns the t-CRNTI.
@param Mod_id Instance ID of eNB
@param dlsch_buffer Pointer to DLSCH input buffer
@param N_RB_UL Number of UL resource blocks
@returns t_CRNTI
*/
unsigned short fill_rar(const module_id_t module_idP,
const int CC_id,
RA_t *ra,
const frame_t frameP,
uint8_t * const dlsch_buffer,
const uint16_t N_RB_UL,
const uint8_t input_buffer_length);
#ifdef Rel14
unsigned short fill_rar_br(eNB_MAC_INST * eNB,
int CC_id,
RA_t * ra,
const frame_t frameP,
const sub_frame_t subframeP,
uint8_t * const dlsch_buffer,
const uint8_t ce_level);
#endif
/* \brief Function to indicate a failed RA response. It removes all temporary variables related to the initial connection of a UE
@param Mod_id Instance ID of eNB
@param preamble_index index of the received RA request.
*/
void cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP,
uint16_t preamble_index);
/* \brief Function used by PHY to inform MAC that an uplink is scheduled
for Msg3 in given subframe. This is used so that the MAC
scheduler marks as busy the RBs used by the Msg3.
@param Mod_id Instance ID of eNB
@param CC_id CC ID of eNB
@param frame current frame
@param subframe current subframe
@param rnti UE rnti concerned
@param Msg3_frame frame where scheduling takes place
@param Msg3_subframe subframe where scheduling takes place
*/
void set_msg3_subframe(module_id_t Mod_id,
int CC_id,
int frame,
int subframe,
int rnti, int Msg3_frame, int Msg3_subframe);
/* \brief Function to indicate a received SDU on ULSCH.
@param Mod_id Instance ID of eNB
@param CC_id Component carrier index
@param rnti RNTI of UE transmitting the SDU
@param sdu Pointer to received SDU
@param sdu_len Length of SDU
@param timing_advance timing advance adjustment after this pdu
@param ul_cqi Uplink CQI estimate after this pdu (SNR quantized to 8 bits, -64 ... 63.5 dB in .5dB steps)
*/
void rx_sdu(const module_id_t enb_mod_idP,
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP,
uint8_t * sduP,
const uint16_t sdu_lenP,
const uint16_t timing_advance, const uint8_t ul_cqi);
/* \brief Function to indicate a scheduled schduling request (SR) was received by eNB.
@param Mod_idP Instance ID of eNB
@param CC_idP CC_id of received SR
@param frameP of received SR
@param subframeP Index of subframe where SR was received
@param rnti RNTI of UE transmitting the SR
@param ul_cqi SNR measurement of PUCCH (SNR quantized to 8 bits, -64 ... 63.5 dB in .5dB steps)
*/
void SR_indication(module_id_t module_idP, int CC_id, frame_t frameP,
sub_frame_t subframe, rnti_t rnti, uint8_t ul_cqi);
/* \brief Function to indicate a UL failure was detected by eNB PHY.
@param Mod_id Instance ID of eNB
@param CC_id Component carrier
@param frameP Frame index
@param rnti RNTI of UE transmitting the SR
@param subframe Index of subframe where SR was received
*/
void UL_failure_indication(module_id_t Mod_id, int CC_id, frame_t frameP,
rnti_t rnti, sub_frame_t subframe);
/* \brief Function to indicate an HARQ ACK/NAK.
@param Mod_id Instance ID of eNB
@param CC_id Component carrier
@param frameP Frame index
@param subframeP subframe index
@param harq_pdu NFAPI HARQ PDU descriptor
*/
void harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP,
sub_frame_t subframeP,
nfapi_harq_indication_pdu_t * harq_pdu);
/* \brief Function to indicate a received CQI pdu
@param Mod_id Instance ID of eNB
@param CC_id Component carrier
@param frameP Frame index
@param subframeP subframe index
@param rntiP RNTI of incoming CQI information
@param ul_cqi_information NFAPI UL CQI measurement
*/
void cqi_indication(module_id_t mod_idP, int CC_idP, frame_t frameP,
sub_frame_t subframeP, rnti_t rntiP,
nfapi_cqi_indication_rel9_t * rel9, uint8_t * pdu,
nfapi_ul_cqi_information_t * ul_cqi_information);
uint8_t *get_dlsch_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
rnti_t rnti, uint8_t TBindex);
/* \brief Function to retrieve MCH transport block and MCS used for MCH in this MBSFN subframe. Returns null if no MCH is to be transmitted
@param Mod_id Instance ID of eNB
@param frame Index of frame
@param subframe Index of current subframe
@param mcs Pointer to mcs used by PHY (to be filled by MAC)
@returns Pointer to MCH transport block and mcs for subframe
*/
MCH_PDU *get_mch_sdu(module_id_t Mod_id, int CC_id, frame_t frame,
sub_frame_t subframe);
void ue_mac_reset(module_id_t module_idP, uint8_t eNB_index);
void ue_init_mac(module_id_t module_idP);
void init_ue_sched_info(void);
void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id,
sub_frame_t subframe, UE_ULSCH_STATUS status);
void add_ue_dlsch_info(module_id_t module_idP, int CC_id, int UE_id,
sub_frame_t subframe, UE_DLSCH_STATUS status);
int find_UE_id(module_id_t module_idP, rnti_t rnti);
int find_RA_id(module_id_t mod_idP, int CC_idP, rnti_t rntiP);
rnti_t UE_RNTI(module_id_t module_idP, int UE_id);
int UE_PCCID(module_id_t module_idP, int UE_id);
uint8_t find_active_UEs(module_id_t module_idP);
boolean_t is_UE_active(module_id_t module_idP, int UE_id);
uint8_t get_aggregation(uint8_t bw_index, uint8_t cqi, uint8_t dci_fmt);
int8_t find_active_UEs_with_traffic(module_id_t module_idP);
void init_CCE_table(int module_idP, int CC_idP);
int get_nCCE_offset(int *CCE_table,
const unsigned char L,
const int nCCE,
const int common_dci,
const unsigned short rnti,
const unsigned char subframe);
int allocate_CCEs(int module_idP, int CC_idP, int subframe, int test_only);
boolean_t CCE_allocation_infeasible(int module_idP,
int CC_idP,
int common_flag,
int subframe,
int aggregation, int rnti);
void set_ue_dai(sub_frame_t subframeP,
int UE_id,
uint8_t CC_id, uint8_t tdd_config, UE_list_t * UE_list);
/** \brief First stage of PCH Scheduling. Gets a PCH SDU from RRC if available and computes the MCS required to transport it as a function of the SDU length. It assumes a length less than or equal to 64 bytes (MCS 6, 3 PRBs).
@param Mod_id Instance ID of eNB
@param frame Frame index
@param subframe Subframe number on which to act
@param paging_ue_index
*/
void schedule_PCH(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP);
uint8_t find_num_active_UEs_in_cbagroup(module_id_t module_idP,
unsigned char group_id);
uint8_t UE_is_to_be_scheduled(module_id_t module_idP, int CC_id,
uint8_t UE_id);
/** \brief Round-robin scheduler for ULSCH traffic.
@param Mod_id Instance ID for eNB
@param subframe Subframe number on which to act
@returns UE index that is to be scheduled if needed/room
*/
module_id_t schedule_next_ulue(module_id_t module_idP, int UE_id,
sub_frame_t subframe);
/** \brief Round-robin scheduler for DLSCH traffic.
@param Mod_id Instance ID for eNB
@param subframe Subframe number on which to act
@returns UE index that is to be scheduled if needed/room
*/
int schedule_next_dlue(module_id_t module_idP, int CC_id,
sub_frame_t subframe);
/* \brief Allocates a set of PRBS for a particular UE. This is a simple function for the moment, later it should process frequency-domain CQI information and/or PMI information. Currently it just returns the first PRBS that are available in the subframe based on the number requested.
@param UE_id Index of UE on which to act
@param nb_rb Number of PRBs allocated to UE by scheduler
@param N_RB_DL Number of PRBs on DL
@param rballoc Pointer to bit-map of current PRB allocation given to previous users/control channels. This is updated for subsequent calls to the routine.
@returns an rballoc bitmap for resource type 0 allocation (DCI).
*/
uint32_t allocate_prbs(int UE_id, uint8_t nb_rb, int N_RB_DL,
uint32_t * rballoc);
/* \fn uint32_t req_new_ulsch(module_id_t module_idP)
\brief check for a new transmission in any drb
@param Mod_id Instance id of UE in machine
@returns 1 for new transmission, 0 for none
*/
uint32_t req_new_ulsch(module_id_t module_idP);
/* \brief Get SR payload (0,1) from UE MAC
@param Mod_id Instance id of UE in machine
@param CC_id Component Carrier index
@param eNB_id Index of eNB that UE is attached to
@param rnti C_RNTI of UE
@param subframe subframe number
@returns 0 for no SR, 1 for SR
*/
uint32_t ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP,
uint8_t eNB_id, rnti_t rnti, sub_frame_t subframe);
uint8_t get_ue_weight(module_id_t module_idP, int CC_id, int UE_id);
// UE functions
void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP,
uint16_t CH_index);
void ue_decode_si(module_id_t module_idP, int CC_id, frame_t frame,
uint8_t CH_index, void *pdu, uint16_t len);
void ue_decode_p(module_id_t module_idP, int CC_id, frame_t frame,
uint8_t CH_index, void *pdu, uint16_t len);
void ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frame,
sub_frame_t subframe, uint8_t * sdu, uint16_t sdu_len,
uint8_t CH_index);
#if defined(Rel10) || defined(Rel14)
/* \brief Called by PHY to transfer MCH transport block to ue MAC.
@param Mod_id Index of module instance
@param frame Frame index
@param sdu Pointer to transport block
@param sdu_len Length of transport block
@param eNB_index Index of attached eNB
@param sync_area the index of MBSFN sync area
*/
void ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index,
uint8_t sync_area);
/*\brief Function to check if UE PHY needs to decode MCH for MAC.
@param Mod_id Index of protocol instance
@param frame Index of frame
@param subframe Index of subframe
@param eNB_index index of eNB for this MCH
@param[out] sync_area return the sync area
@param[out] mcch_active flag indicating whether this MCCH is active in this SF
*/
int ue_query_mch(uint8_t Mod_id, uint8_t CC_id, uint32_t frame,
sub_frame_t subframe, uint8_t eNB_index,
uint8_t * sync_area, uint8_t * mcch_active);
#endif
/* \brief Called by PHY to get sdu for PUSCH transmission. It performs the following operations: Checks BSR for DCCH, DCCH1 and DTCH corresponding to previous values computed either in SR or BSR procedures. It gets rlc status indications on DCCH,DCCH1 and DTCH and forms BSR elements and PHR in MAC header. CRNTI element is not supported yet. It computes transport block for up to 3 SDUs and generates header and forms the complete MAC SDU.
@param Mod_id Instance id of UE in machine
@param eNB_id Index of eNB that UE is attached to
@param rnti C_RNTI of UE
@param subframe subframe number
@returns 0 for no SR, 1 for SR
*/
void ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
sub_frame_t subframe, uint8_t eNB_index,
uint8_t * ulsch_buffer, uint16_t buflen,
uint8_t * access_mode);
/* \brief Function called by PHY to retrieve information to be transmitted using the RA procedure. 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 random-access to transmit a BSR along with the C-RNTI control element (see 5.1.4 from 36.321)
@param Mod_id Index of UE instance
@param Mod_id Component Carrier Index
@param New_Msg3 Flag to indicate this call is for a new Msg3
@param subframe Index of subframe for PRACH transmission (0 ... 9)
@returns A pointer to a PRACH_RESOURCES_t */
PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id,
frame_t frameP, uint8_t new_Msg3,
sub_frame_t subframe);
/* \brief Function called by PHY to process the received RAR. It checks that the preamble matches what was sent by the eNB and provides the timing advance and t-CRNTI.
@param Mod_id Index of UE instance
@param CC_id Index to a component carrier
@param frame Frame index
@param ra_rnti RA_RNTI value
@param dlsch_buffer Pointer to dlsch_buffer containing RAR PDU
@param t_crnti Pointer to PHY variable containing the T_CRNTI
@param preamble_index Preamble Index used by PHY to transmit the PRACH. This should match the received RAR to trigger the rest of
random-access procedure
@param selected_rar_buffer the output buffer for storing the selected RAR header and RAR payload
@returns timing advance or 0xffff if preamble doesn't match
*/
uint16_t
ue_process_rar(const module_id_t module_idP,
const int CC_id,
const frame_t frameP,
const rnti_t ra_rnti,
uint8_t * const dlsch_buffer,
rnti_t * const t_crnti,
const uint8_t preamble_index,
uint8_t * selected_rar_buffer);
/* \brief Generate header for UL-SCH. This function parses the desired control elements and sdus and generates the header as described
in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload
in the ULSCH buffer.
@param mac_header Pointer to the first byte of the MAC header (UL-SCH buffer)
@param num_sdus Number of SDUs in the payload
@param short_padding Number of bytes for short padding (0,1,2)
@param sdu_lengths Pointer to array of SDU lengths
@param sdu_lcids Pointer to array of LCIDs (the order must be the same as the SDU length array)
@param power_headroom Pointer to power headroom command (NULL means not present in payload)
@param crnti Pointer to CRNTI command (NULL means not present in payload)
@param truncated_bsr Pointer to Truncated BSR command (NULL means not present in payload)
@param short_bsr Pointer to Short BSR command (NULL means not present in payload)
@param long_bsr Pointer to Long BSR command (NULL means not present in payload)
@param post_padding Number of bytes for padding at the end of MAC PDU
@returns Number of bytes used for header
*/
unsigned char generate_ulsch_header(uint8_t * mac_header,
uint8_t num_sdus,
uint8_t short_padding,
uint16_t * sdu_lengths,
uint8_t * sdu_lcids,
POWER_HEADROOM_CMD * power_headroom,
uint16_t * crnti,
BSR_SHORT * truncated_bsr,
BSR_SHORT * short_bsr,
BSR_LONG * long_bsr,
unsigned short post_padding);
/* \brief Parse header for UL-SCH. This function parses the received UL-SCH header as described
in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload
in the ULSCH buffer.
@param mac_header Pointer to the first byte of the MAC header (UL-SCH buffer)
@param num_ces Number of SDUs in the payload
@param num_sdu Number of SDUs in the payload
@param rx_ces Pointer to received CEs in the header
@param rx_lcids Pointer to array of LCIDs (the order must be the same as the SDU length array)
@param rx_lengths Pointer to array of SDU lengths
@returns Pointer to payload following header
*/
uint8_t *parse_ulsch_header(uint8_t * mac_header,
uint8_t * num_ce,
uint8_t * num_sdu,
uint8_t * rx_ces,
uint8_t * rx_lcids,
uint16_t * rx_lengths, uint16_t tx_lenght);
int to_prb(int);
int to_rbg(int);
int l2_init(LTE_DL_FRAME_PARMS * frame_parms, int eMBMS_active,
char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active);
int mac_init(void);
int add_new_ue(module_id_t Mod_id, int CC_id, rnti_t rnti, int harq_pid
#ifdef Rel14
, uint8_t rach_resource_type
#endif
);
int rrc_mac_remove_ue(module_id_t Mod_id, rnti_t rntiP);
int maxround(module_id_t Mod_id, uint16_t rnti, int frame,
sub_frame_t subframe, uint8_t ul_flag);
void swap_UEs(UE_list_t * listP, int nodeiP, int nodejP, int ul_flag);
int prev(UE_list_t * listP, int nodeP, int ul_flag);
void dump_ue_list(UE_list_t * listP, int ul_flag);
int UE_num_active_CC(UE_list_t * listP, int ue_idP);
int UE_PCCID(module_id_t mod_idP, int ue_idP);
rnti_t UE_RNTI(module_id_t mod_idP, int ue_idP);
void ulsch_scheduler_pre_processor(module_id_t module_idP, slice_id_t slice_id, int frameP,
sub_frame_t subframeP,
uint16_t * first_rb);
void store_ulsch_buffer(module_id_t module_idP, int frameP,
sub_frame_t subframeP);
void sort_ue_ul(module_id_t module_idP, int frameP, sub_frame_t subframeP);
void assign_max_mcs_min_rb(module_id_t module_idP, int slice_id, int frameP,
sub_frame_t subframeP, uint16_t * first_rb);
void adjust_bsr_info(int buffer_occupancy, uint16_t TBS,
UE_TEMPLATE * UE_template);
int phy_stats_exist(module_id_t Mod_id, int rnti);
void sort_UEs(module_id_t Mod_idP, slice_id_t slice_id, int frameP, sub_frame_t subframeP);
/*! \fn UE_L2_state_t ue_scheduler(const module_id_t module_idP,const frame_t frameP, const sub_frame_t subframe, const lte_subframe_t direction,const uint8_t eNB_index)
\brief UE scheduler where all the ue background tasks are done. This function performs the following: 1) Trigger PDCP every 5ms 2) Call RRC for link status return to PHY3) Perform SR/BSR procedures for scheduling feedback 4) Perform PHR procedures.
\param[in] module_idP instance of the UE
\param[in] rxFrame the RX frame number
\param[in] rxSubframe the RX subframe number
\param[in] txFrame the TX frame number
\param[in] txSubframe the TX subframe number
\param[in] direction subframe direction
\param[in] eNB_index instance of eNB
@returns L2 state (CONNETION_OK or CONNECTION_LOST or PHY_RESYNCH)
*/
UE_L2_STATE_t ue_scheduler(const module_id_t module_idP,
const frame_t rxFrameP,
const sub_frame_t rxSubframe,
const frame_t txFrameP,
const sub_frame_t txSubframe,
const lte_subframe_t direction,
const uint8_t eNB_index, const int CC_id);
/*! \fn int cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, uint8_t eNB_index,uint16_t buflen);
\brief determine whether to use cba resource to transmit or not
\param[in] Mod_id instance of the UE
\param[in] frame the frame number
\param[in] subframe the subframe number
\param[in] eNB_index instance of eNB
\param[out] access(1) or postpone (0)
*/
int cba_access(module_id_t module_idP, frame_t frameP,
sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen);
/*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, uint8_t bsr_len)
\brief get short bsr level
\param[in] Mod_id instance of the UE
\param[in] bsr_len indicator for no, short, or long bsr
\param[out] bsr_s pointer to short bsr
*/
BSR_SHORT *get_bsr_short(module_id_t module_idP, uint8_t bsr_len);
/*! \fn BSR_LONG * get_bsr_long(module_id_t module_idP, uint8_t bsr_len)
\brief get long bsr level
\param[in] Mod_id instance of the UE
\param[in] bsr_len indicator for no, short, or long bsr
\param[out] bsr_l pointer to long bsr
*/
BSR_LONG *get_bsr_long(module_id_t module_idP, uint8_t bsr_len);
/*! \fn boolean_t update_bsr(module_id_t module_idP, frame_t frameP,sub_frame_t subframeP)
\brief get the rlc stats and update the bsr level for each lcid
\param[in] Mod_id instance of the UE
\param[in] frame Frame index
*/
boolean_t update_bsr(module_id_t module_idP, frame_t frameP,
sub_frame_t subframeP, eNB_index_t eNB_index);
/*! \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.
\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 locate_BsrIndexByBufferSize(const uint32_t * table, int size,
int value);
/*! \fn int 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 get_sf_periodicBSRTimer(uint8_t bucketSize);
/*! \fn int get_ms_bucketsizeduration(uint8_t bucketSize)
\brief get the time in ms form the bucket size duration configured by the higher layer
\param[in] bucketSize the bucket size duration
\return the time in ms
*/
int get_ms_bucketsizeduration(uint8_t bucketsizeduration);
/*! \fn int 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 get_sf_retxBSRTimer(uint8_t retxBSR_Timer);
/*! \fn int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer){
\brief get the number of subframe form the periodic PHR timer configured by the higher layer
\param[in] perioidicPHR_Timer timer for reguluar PHR
\return the time in sf
*/
int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer);
/*! \fn int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer)
\brief get the number of subframe form the prohibit PHR duration configured by the higher layer
\param[in] prohibitPHR_Timer timer for PHR
\return the time in sf
*/
int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer);
/*! \fn int get_db_dl_PathlossChange(uint8_t dl_PathlossChange)
\brief get the db form the path loss change configured by the higher layer
\param[in] dl_PathlossChange path loss for PHR
\return the pathloss in db
*/
int get_db_dl_PathlossChange(uint8_t dl_PathlossChange);
/*! \fn uint8_t get_phr_mapping (module_id_t module_idP, int CC_id,uint8_t eNB_index)
\brief get phr mapping as described in 36.313
\param[in] Mod_id index of eNB
\param[in] CC_id Component Carrier Index
\return phr mapping
*/
uint8_t get_phr_mapping(module_id_t module_idP, int CC_id,
uint8_t eNB_index);
/*! \fn void update_phr (module_id_t module_idP)
\brief update/reset the phr timers
\param[in] Mod_id index of eNB
\param[in] CC_id Component carrier index
\return void
*/
void update_phr(module_id_t module_idP, int CC_id);
/*! \brief Function to indicate Msg3 transmission/retransmission which initiates/reset Contention Resolution Timer
\param[in] Mod_id Instance index of UE
\param[in] eNB_id Index of eNB
*/
void Msg3_tx(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
uint8_t eNB_id);
/*! \brief Function to indicate the transmission of msg1/rach
\param[in] Mod_id Instance index of UE
\param[in] eNB_id Index of eNB
*/
void Msg1_tx(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
uint8_t eNB_id);
void dl_phy_sync_success(module_id_t module_idP,
frame_t frameP,
unsigned char eNB_index, uint8_t first_sync);
int dump_eNB_l2_stats(char *buffer, int length);
double uniform_rngen(int min, int max);
/*
void add_common_dci(DCI_PDU *DCI_pdu,
void *pdu,
rnti_t rnti,
unsigned char dci_size_bytes,
unsigned char aggregation,
unsigned char dci_size_bits,
unsigned char dci_fmt,
uint8_t ra_flag);
*/
uint32_t allocate_prbs_sub(int nb_rb, int N_RB_DL, int N_RBG,
uint8_t * rballoc);
void update_ul_dci(module_id_t module_idP, uint8_t CC_id, rnti_t rnti,
uint8_t dai);
int get_bw_index(module_id_t module_id, uint8_t CC_id);
int get_min_rb_unit(module_id_t module_idP, uint8_t CC_id);
/* \brief Generate header for DL-SCH. This function parses the desired control elements and sdus and generates the header as described
in 36-321 MAC layer specifications. It returns the number of bytes used for the header to be used as an offset for the payload
in the DLSCH buffer.
@param mac_header Pointer to the first byte of the MAC header (DL-SCH buffer)
@param num_sdus Number of SDUs in the payload
@param sdu_lengths Pointer to array of SDU lengths
@param sdu_lcids Pointer to array of LCIDs (the order must be the same as the SDU length array)
@param drx_cmd dicontinous reception command
@param timing_advancd_cmd timing advanced command
@param ue_cont_res_id Pointer to contention resolution identifier (NULL means not present in payload)
@param short_padding Number of bytes for short padding (0,1,2)
@param post_padding number of bytes for padding at the end of MAC PDU
@returns Number of bytes used for header
*/
int generate_dlsch_header(unsigned char *mac_header,
unsigned char num_sdus,
unsigned short *sdu_lengths,
unsigned char *sdu_lcids,
unsigned char drx_cmd,
unsigned short timing_advance_cmd,
unsigned char *ue_cont_res_id,
unsigned char short_padding,
unsigned short post_padding);
/** \brief RRC eNB Configuration primitive for PHY/MAC. Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages.
@param Mod_id Instance ID of eNB
@param CC_id Component Carrier of the eNB
@param mib Pointer to MIB
@param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration)
@param physicalConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration)
@param measObj Structure from RRCConnectionReconfiguration for UE measurement procedures
@param mac_MainConfig Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated MAC parameters (if NULL keep existing configuration)
@param logicalChannelIdentity Logical channel identity index of corresponding logical channel config
@param logicalChannelConfig Pointer to logical channel configuration
@param measGapConfig Measurement Gap configuration for MAC (if NULL keep existing configuration)
@param tdd_Config TDD Configuration from SIB1 (if NULL keep existing configuration)
@param mobilityControlInfo mobility control info received for Handover
@param SchedInfoList SI Scheduling information
@param MBMS_Flag indicates MBMS transmission
@param mbsfn_SubframeConfigList pointer to mbsfn subframe configuration list from SIB2
@param mbsfn_AreaInfoList pointer to MBSFN Area Info list from SIB13
@param pmch_InfoList pointer to PMCH_InfoList from MBSFNAreaConfiguration Message (MCCH Message)
@param sib1_ext_r13 SI Scheduling information for SI-BR UEs
*/
int rrc_mac_config_req_eNB(module_id_t module_idP,
int CC_id,
int physCellId,
int p_eNB,
int Ncp,
int eutra_band, uint32_t dl_CarrierFreq,
#ifdef Rel14
int pbch_repetition,
#endif
rnti_t rntiP,
BCCH_BCH_Message_t * mib,
RadioResourceConfigCommonSIB_t *
radioResourceConfigCommon,
#ifdef Rel14
RadioResourceConfigCommonSIB_t *
radioResourceConfigCommon_BR,
#endif
struct PhysicalConfigDedicated
*physicalConfigDedicated,
#if defined(Rel10) || defined(Rel14)
SCellToAddMod_r10_t * sCellToAddMod_r10,
//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
#endif
MeasObjectToAddMod_t ** measObj,
MAC_MainConfig_t * mac_MainConfig,
long logicalChannelIdentity,
LogicalChannelConfig_t * logicalChannelConfig,
MeasGapConfig_t * measGapConfig,
TDD_Config_t * tdd_Config,
MobilityControlInfo_t * mobilityControlInfo,
SchedulingInfoList_t * schedulingInfoList,
uint32_t ul_CarrierFreq,
long *ul_Bandwidth,
AdditionalSpectrumEmission_t *
additionalSpectrumEmission,
struct MBSFN_SubframeConfigList
*mbsfn_SubframeConfigList
#if defined(Rel10) || defined(Rel14)
,
uint8_t MBMS_Flag,
MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList,
PMCH_InfoList_r9_t * pmch_InfoList
#endif
#ifdef Rel14
,
SystemInformationBlockType1_v1310_IEs_t *
sib1_ext_r13
#endif
);
/** \brief RRC eNB Configuration primitive for PHY/MAC. Allows configuration of PHY/MAC resources based on System Information (SI), RRCConnectionSetup and RRCConnectionReconfiguration messages.
@param Mod_id Instance ID of ue
@param CC_id Component Carrier of the ue
@param eNB_id Index of eNB
@param radioResourceConfigCommon Structure from SIB2 for common radio parameters (if NULL keep existing configuration)
@param physcialConfigDedicated Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated PHY parameters (if NULL keep existing configuration)
@param measObj Structure from RRCConnectionReconfiguration for UE measurement procedures
@param mac_MainConfig Structure from RRCConnectionSetup or RRCConnectionReconfiguration for dedicated MAC parameters (if NULL keep existing configuration)
@param logicalChannelIdentity Logical channel identity index of corresponding logical channel config
@param logicalChannelConfig Pointer to logical channel configuration
@param measGapConfig Measurement Gap configuration for MAC (if NULL keep existing configuration)
@param tdd_Config TDD Configuration from SIB1 (if NULL keep existing configuration)
@param mobilityControlInfo mobility control info received for Handover
@param SIwindowsize SI Windowsize from SIB1 (if NULL keep existing configuration)
@param SIperiod SI Period from SIB1 (if NULL keep existing configuration)
@param MBMS_Flag indicates MBMS transmission
@param mbsfn_SubframeConfigList pointer to mbsfn subframe configuration list from SIB2
@param mbsfn_AreaInfoList pointer to MBSFN Area Info list from SIB13
@param pmch_InfoList pointer to PMCH_InfoList from MBSFNAreaConfiguration Message (MCCH Message)
*/
int rrc_mac_config_req_ue(module_id_t module_idP,
int CC_id,
uint8_t eNB_index,
RadioResourceConfigCommonSIB_t *
radioResourceConfigCommon,
struct PhysicalConfigDedicated
*physicalConfigDedicated,
#if defined(Rel10) || defined(Rel14)
SCellToAddMod_r10_t * sCellToAddMod_r10,
//struct PhysicalConfigDedicatedSCell_r10 *physicalConfigDedicatedSCell_r10,
#endif
MeasObjectToAddMod_t ** measObj,
MAC_MainConfig_t * mac_MainConfig,
long logicalChannelIdentity,
LogicalChannelConfig_t * logicalChannelConfig,
MeasGapConfig_t * measGapConfig,
TDD_Config_t * tdd_Config,
MobilityControlInfo_t * mobilityControlInfo,
uint8_t * SIwindowsize,
uint16_t * SIperiod,
ARFCN_ValueEUTRA_t * ul_CarrierFreq,
long *ul_Bandwidth,
AdditionalSpectrumEmission_t *
additionalSpectrumEmission,
struct MBSFN_SubframeConfigList
*mbsfn_SubframeConfigList
#if defined(Rel10) || defined(Rel14)
,
uint8_t MBMS_Flag,
MBSFN_AreaInfoList_r9_t * mbsfn_AreaInfoList,
PMCH_InfoList_r9_t * pmch_InfoList
#endif
#ifdef CBA
,
uint8_t num_active_cba_groups, uint16_t cba_rnti
#endif
);
uint16_t getRIV(uint16_t N_RB_DL, uint16_t RBstart, uint16_t Lcrbs);
int get_subbandsize(uint8_t dl_bandwidth);
void get_Msg3allocret(COMMON_channels_t * cc,
sub_frame_t current_subframe,
frame_t current_frame,
frame_t * frame, sub_frame_t * subframe);
void get_Msg3alloc(COMMON_channels_t * cc,
sub_frame_t current_subframe,
frame_t current_frame,
frame_t * frame, sub_frame_t * subframe);
uint16_t mac_computeRIV(uint16_t N_RB_DL, uint16_t RBstart,
uint16_t Lcrbs);
int get_phich_resource_times6(COMMON_channels_t * cc);
int to_rbg(int dl_Bandwidth);
int to_prb(int dl_Bandwidth);
uint8_t get_Msg3harqpid(COMMON_channels_t * cc,
frame_t frame, sub_frame_t current_subframe);
uint32_t pdcchalloc2ulframe(COMMON_channels_t * ccP, uint32_t frame,
uint8_t n);
uint8_t pdcchalloc2ulsubframe(COMMON_channels_t * ccP, uint8_t n);
int is_UL_sf(COMMON_channels_t * ccP, sub_frame_t subframeP);
uint8_t getQm(uint8_t mcs);
uint8_t subframe2harqpid(COMMON_channels_t * cc, frame_t frame,
sub_frame_t subframe);
void get_srs_pos(COMMON_channels_t * cc, uint16_t isrs,
uint16_t * psrsPeriodicity, uint16_t * psrsOffset);
void get_csi_params(COMMON_channels_t * cc,
struct CQI_ReportPeriodic *cqi_PMI_ConfigIndex,
uint16_t * Npd, uint16_t * N_OFFSET_CQI, int *H);
uint8_t get_rel8_dl_cqi_pmi_size(UE_sched_ctrl * sched_ctl, int CC_idP,
COMMON_channels_t * cc, uint8_t tmode,
struct CQI_ReportPeriodic
*cqi_ReportPeriodic);
uint8_t get_dl_cqi_pmi_size_pusch(COMMON_channels_t * cc, uint8_t tmode,
uint8_t ri,
CQI_ReportModeAperiodic_t *
cqi_ReportModeAperiodic);
void extract_pucch_csi(module_id_t mod_idP, int CC_idP, int UE_id,
frame_t frameP, sub_frame_t subframeP,
uint8_t * pdu, uint8_t length);
void extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id,
frame_t frameP, sub_frame_t subframeP,
uint8_t * pdu, uint8_t length);
uint16_t fill_nfapi_tx_req(nfapi_tx_request_body_t * tx_req_body,
uint16_t absSF, uint16_t pdu_length,
uint16_t pdu_index, uint8_t * pdu);
void fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *
ul_config_pdu, uint8_t cqi_req,
COMMON_channels_t * cc,
struct PhysicalConfigDedicated
*physicalConfigDedicated,
uint8_t tmode, uint32_t handle,
uint16_t rnti,
uint8_t resource_block_start,
uint8_t
number_of_resource_blocks,
uint8_t mcs,
uint8_t cyclic_shift_2_for_drms,
uint8_t
frequency_hopping_enabled_flag,
uint8_t frequency_hopping_bits,
uint8_t new_data_indication,
uint8_t redundancy_version,
uint8_t harq_process_number,
uint8_t ul_tx_mode,
uint8_t current_tx_nb,
uint8_t n_srs, uint16_t size);
#ifdef Rel14
void fill_nfapi_ulsch_config_request_emtc(nfapi_ul_config_request_pdu_t *
ul_config_pdu, uint8_t ue_type,
uint16_t
total_number_of_repetitions,
uint16_t repetition_number,
uint16_t
initial_transmission_sf_io);
#endif
void program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP,
frame_t frameP, sub_frame_t subframeP,
uint8_t cce_idx);
void fill_nfapi_dlsch_config(eNB_MAC_INST * eNB,
nfapi_dl_config_request_body_t * dl_req,
uint16_t length, uint16_t pdu_index,
uint16_t rnti,
uint8_t resource_allocation_type,
uint8_t
virtual_resource_block_assignment_flag,
uint16_t resource_block_coding,
uint8_t modulation,
uint8_t redundancy_version,
uint8_t transport_blocks,
uint8_t transport_block_to_codeword_swap_flag,
uint8_t transmission_scheme,
uint8_t number_of_layers,
uint8_t number_of_subbands,
// uint8_t codebook_index,
uint8_t ue_category_capacity,
uint8_t pa,
uint8_t delta_power_offset_index,
uint8_t ngap,
uint8_t nprb,
uint8_t transmission_mode,
uint8_t num_bf_prb_per_subband,
uint8_t num_bf_vector);
void fill_nfapi_harq_information(module_id_t module_idP,
int CC_idP,
uint16_t rntiP,
uint16_t absSFP,
nfapi_ul_config_harq_information *
harq_information, uint8_t cce_idxP);
void fill_nfapi_ulsch_harq_information(module_id_t module_idP,
int CC_idP,
uint16_t rntiP,
nfapi_ul_config_ulsch_harq_information
* harq_information);
uint16_t fill_nfapi_uci_acknak(module_id_t module_idP,
int CC_idP,
uint16_t rntiP,
uint16_t absSFP, uint8_t cce_idxP);
void fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t * dl_config_pdu,
uint8_t aggregation_level,
uint16_t rnti,
uint8_t rnti_type,
uint8_t harq_process,
uint8_t tpc,
uint16_t resource_block_coding,
uint8_t mcs,
uint8_t ndi, uint8_t rv, uint8_t vrb_flag);
nfapi_ul_config_request_pdu_t *has_ul_grant(module_id_t module_idP,
int CC_idP, uint16_t subframeP,
uint16_t rnti);
uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP);
uint8_t get_ul_req_index(module_id_t module_idP, int CC_idP,
sub_frame_t subframeP);
#ifdef Rel14
int get_numnarrowbandbits(long dl_Bandwidth);
int mpdcch_sf_condition(eNB_MAC_INST * eNB, int CC_id, frame_t frameP,
sub_frame_t subframeP, int rmax,
MPDCCH_TYPES_t mpdcch_type, int UE_id);
int get_numnarrowbands(long dl_Bandwidth);
int narrowband_to_first_rb(COMMON_channels_t * cc, int nb_index);
#endif
int l2_init_eNB(void);
void Msg1_transmitted(module_id_t module_idP, uint8_t CC_id,
frame_t frameP, uint8_t eNB_id);
void Msg3_transmitted(module_id_t module_idP, uint8_t CC_id,
frame_t frameP, uint8_t eNB_id);
uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn);
int32_t get_uldl_offset(int eutra_bandP);
int l2_init_ue(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active,
uint8_t HO_active);
/*Slice related functions */
uint16_t flexran_nb_rbs_allowed_slice(float rb_percentage, int total_rbs);
int ue_slice_membership(int UE_id, int slice_id);
#endif
/** @}*/
......@@ -68,360 +68,6 @@
/* for ImsiMobileIdentity_t */
#include "MobileIdentity.h"
/* correct Rel(8|10)/Rel14 differences
* the code is in favor of Rel14, those defines do the translation
*/
#if !defined(Rel14)
# define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm
# define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0
# define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1
# define CipheringAlgorithm_r12_eea2 SecurityAlgorithmConfig__cipheringAlgorithm_eea2
# define CipheringAlgorithm_r12_spare1 SecurityAlgorithmConfig__cipheringAlgorithm_spare1
# define Alpha_r12_al0 UplinkPowerControlCommon__alpha_al0
# define Alpha_r12_al04 UplinkPowerControlCommon__alpha_al04
# define Alpha_r12_al05 UplinkPowerControlCommon__alpha_al05
# define Alpha_r12_al06 UplinkPowerControlCommon__alpha_al06
# define Alpha_r12_al07 UplinkPowerControlCommon__alpha_al07
# define Alpha_r12_al08 UplinkPowerControlCommon__alpha_al08
# define Alpha_r12_al09 UplinkPowerControlCommon__alpha_al09
# define Alpha_r12_al1 UplinkPowerControlCommon__alpha_al1
# define PreambleTransMax_n3 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3
# define PreambleTransMax_n4 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4
# define PreambleTransMax_n5 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5
# define PreambleTransMax_n6 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6
# define PreambleTransMax_n7 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7
# define PreambleTransMax_n8 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8
# define PreambleTransMax_n10 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10
# define PreambleTransMax_n20 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20
# define PreambleTransMax_n50 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50
# define PreambleTransMax_n100 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100
# define PreambleTransMax_n200 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200
# define PeriodicBSR_Timer_r12_sf5 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf5
# define PeriodicBSR_Timer_r12_sf10 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf10
# define PeriodicBSR_Timer_r12_sf16 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf16
# define PeriodicBSR_Timer_r12_sf20 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf20
# define PeriodicBSR_Timer_r12_sf32 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf32
# define PeriodicBSR_Timer_r12_sf40 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf40
# define PeriodicBSR_Timer_r12_sf64 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf64
# define PeriodicBSR_Timer_r12_sf80 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf80
# define PeriodicBSR_Timer_r12_sf128 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf128
# define PeriodicBSR_Timer_r12_sf160 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf160
# define PeriodicBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf320
# define PeriodicBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf640
# define PeriodicBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf1280
# define PeriodicBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf2560
# define PeriodicBSR_Timer_r12_infinity MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity
# define RetxBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf320
# define RetxBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf640
# define RetxBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf1280
# define RetxBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560
# define RetxBSR_Timer_r12_sf5120 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf5120
# define RetxBSR_Timer_r12_sf10240 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240
#endif
// This corrects something generated by asn1c which is different between Rel8 and Rel10
#if !defined(Rel10) && !defined(Rel14)
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11
#endif
#define NB_SIG_CNX_CH 1
#define NB_CNX_CH MAX_MOBILES_PER_ENB
#define NB_SIG_CNX_UE 2 //MAX_MANAGED_RG_PER_MOBILE
#define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE
/*
#if defined(Rel10) || defined(Rel14)
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib12_v920
#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib13_v920
#endif
*/
//#include "L3_rrc_defs.h"
#ifndef NO_RRM
#include "L3_rrc_interface.h"
#include "rrc_rrm_msg.h"
#include "rrc_rrm_interface.h"
#endif
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
#endif
/* TODO: be sure this include is correct.
* It solves a problem of compilation of the RRH GW,
* issue #186.
*/
#if !defined(ENABLE_ITTI)
# include "as_message.h"
#endif
#if defined(ENABLE_USE_MME)
# include "commonDef.h"
#endif
//--------
typedef unsigned int uid_t;
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1)
typedef struct uid_linear_allocator_s {
unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE];
} uid_allocator_t;
//--------
#define PROTOCOL_RRC_CTXT_UE_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_UE_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
#define PROTOCOL_RRC_CTXT_FMT PROTOCOL_CTXT_FMT
#define PROTOCOL_RRC_CTXT_ARGS(CTXT_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp)
/** @defgroup _rrc RRC
* @ingroup _oai2
* @{
*/
#define UE_MODULE_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!!
#define UE_INDEX_INVALID ((module_id_t) ~0) // FIXME attention! depends on type uint8_t!!! used to be -1
typedef enum {
RRC_OK=0,
RRC_ConnSetup_failed,
RRC_PHY_RESYNCH,
RRC_Handover_failed,
RRC_HO_STARTED
} RRC_status_t;
typedef enum UE_STATE_e {
RRC_INACTIVE=0,
RRC_IDLE,
RRC_SI_RECEIVED,
RRC_CONNECTED,
RRC_RECONFIGURED,
RRC_HO_EXECUTION
} UE_STATE_t;
typedef enum HO_STATE_e {
HO_IDLE=0,
HO_MEASURMENT,
HO_PREPARE,
HO_CMD, // initiated by the src eNB
HO_COMPLETE // initiated by the target eNB
} HO_STATE_t;
//#define NUMBER_OF_UE_MAX MAX_MOBILES_PER_RG
#define RRM_FREE(p) if ( (p) != NULL) { free(p) ; p=NULL ; }
#define RRM_MALLOC(t,n) (t *) malloc16( sizeof(t) * n )
#define RRM_CALLOC(t,n) (t *) malloc16( sizeof(t) * n)
#define RRM_CALLOC2(t,s) (t *) malloc16( s )
#define MAX_MEAS_OBJ 6
#define MAX_MEAS_CONFIG 6
#define MAX_MEAS_ID 6
#define PAYLOAD_SIZE_MAX 1024
#define RRC_BUF_SIZE 255
#define UNDEF_SECURITY_MODE 0xff
#define NO_SECURITY_MODE 0x20
#define CBA_OFFSET 0xfff4
// #define NUM_MAX_CBA_GROUP 4 // in the platform_constants
/* TS 36.331: RRC-TransactionIdentifier ::= INTEGER (0..3) */
#if defined(USRP_REC_PLAY)
#define RRC_TRANSACTION_IDENTIFIER_NUMBER 1
#else
#define RRC_TRANSACTION_IDENTIFIER_NUMBER 3
#endif
typedef struct {
unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */
unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */
unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/
unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/
uint8_t Delay_class; /*!< \brief Delay class offered by MAC layer scheduling*/
uint8_t Target_bler; /*!< \brief Target Average Transport Block Error rate*/
uint8_t Lchan_t; /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/
} __attribute__ ((__packed__)) LCHAN_DESC;
#define LCHAN_DESC_SIZE sizeof(LCHAN_DESC)
typedef struct UE_RRC_INFO_s {
UE_STATE_t State;
uint8_t SIB1systemInfoValueTag;
uint32_t SIStatus;
uint32_t SIcnt;
#if defined(Rel10) || defined(Rel14)
uint8_t MCCHStatus[8]; // MAX_MBSFN_AREA
#endif
uint8_t SIwindowsize; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40
uint8_t handoverTarget;
HO_STATE_t ho_state;
uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
unsigned short UE_index;
uint32_t T300_active;
uint32_t T300_cnt;
uint32_t T304_active;
uint32_t T304_cnt;
uint32_t T310_active;
uint32_t T310_cnt;
uint32_t N310_cnt;
uint32_t N311_cnt;
rnti_t rnti;
} __attribute__ ((__packed__)) UE_RRC_INFO;
typedef struct UE_S_TMSI_s {
boolean_t presence;
mme_code_t mme_code;
m_tmsi_t m_tmsi;
} __attribute__ ((__packed__)) UE_S_TMSI;
#if defined(ENABLE_ITTI)
typedef enum e_rab_satus_e {
E_RAB_STATUS_NEW,
E_RAB_STATUS_DONE, // from the eNB perspective
E_RAB_STATUS_ESTABLISHED, // get the reconfigurationcomplete form UE
E_RAB_STATUS_FAILED,
E_RAB_STATUS_TORELEASE // to release DRB between eNB and UE
} e_rab_status_t;
typedef struct e_rab_param_s {
e_rab_t param;
uint8_t status;
uint8_t xid; // transaction_id
s1ap_Cause_t cause;
uint8_t cause_value;
} __attribute__ ((__packed__)) e_rab_param_t;
#endif
/* Intermediate structure for Handover management. Associated per-UE in eNB_RRC_INST */
typedef struct HANDOVER_INFO_s {
uint8_t ho_prepare;
uint8_t ho_complete;
uint8_t modid_s; //module_idP of serving cell
uint8_t modid_t; //module_idP of target cell
uint8_t ueid_s; //UE index in serving cell
uint8_t ueid_t; //UE index in target cell
AS_Config_t as_config; /* these two parameters are taken from 36.331 section 10.2.2: HandoverPreparationInformation-r8-IEs */
AS_Context_t as_context; /* They are mandatory for HO */
uint8_t buf[RRC_BUF_SIZE]; /* ASN.1 encoded handoverCommandMessage */
int size; /* size of above message in bytes */
} HANDOVER_INFO;
#define RRC_HEADER_SIZE_MAX 64
#define RRC_BUFFER_SIZE_MAX 1024
typedef struct {
char Payload[RRC_BUFFER_SIZE_MAX];
char Header[RRC_HEADER_SIZE_MAX];
char payload_size;
} RRC_BUFFER;
#define RRC_BUFFER_SIZE sizeof(RRC_BUFFER)
typedef struct RB_INFO_s {
uint16_t Rb_id; //=Lchan_id
LCHAN_DESC Lchan_desc[2];
// MAC_MEAS_REQ_ENTRY *Meas_entry;
} RB_INFO;
typedef struct SRB_INFO_s {
uint16_t Srb_id; //=Lchan_id
RRC_BUFFER Rx_buffer;
RRC_BUFFER Tx_buffer;
LCHAN_DESC Lchan_desc[2];
unsigned int Trans_id;
uint8_t Active;
} SRB_INFO;
typedef struct RB_INFO_TABLE_ENTRY_s {
RB_INFO Rb_info;
uint8_t Active;
uint32_t Next_check_frame;
uint8_t Status;
} RB_INFO_TABLE_ENTRY;
typedef struct SRB_INFO_TABLE_ENTRY_s {
SRB_INFO Srb_info;
uint8_t Active;
uint8_t Status;
uint32_t Next_check_frame;
} SRB_INFO_TABLE_ENTRY;
typedef struct MEAS_REPORT_LIST_s {
MeasId_t measId;
uint32_t numberOfReportsSent;
} MEAS_REPORT_LIST;
typedef struct HANDOVER_INFO_UE_s {
PhysCellId_t targetCellId;
uint8_t measFlag;
} HANDOVER_INFO_UE;
typedef uid_t ue_uid_t;
typedef struct {
uint8_t *MIB;
uint8_t sizeof_MIB;
uint8_t *SIB1;
uint8_t sizeof_SIB1;
uint8_t *SIB23;
uint8_t sizeof_SIB23;
#ifdef Rel14
uint8_t *SIB1_BR;
uint8_t sizeof_SIB1_BR;
uint8_t *SIB23_BR;
uint8_t sizeof_SIB23_BR;
#endif
int physCellId;
int Ncp;
int p_eNB;
uint32_t dl_CarrierFreq;
uint32_t ul_CarrierFreq;
uint32_t pbch_repetition;
BCCH_BCH_Message_t mib;
BCCH_DL_SCH_Message_t siblock1;
BCCH_DL_SCH_Message_t systemInformation;
// SystemInformation_t systemInformation;
SystemInformationBlockType1_t *sib1;
SystemInformationBlockType2_t *sib2;
SystemInformationBlockType3_t *sib3;
#ifdef Rel14
SystemInformationBlockType1_t *sib1_BR;
SystemInformationBlockType2_t *sib2_BR;
SystemInformationBlockType2_t *sib3_BR;
#endif
#if defined(Rel10) || defined(Rel14)
SystemInformationBlockType13_r9_t *sib13;
uint8_t MBMS_flag;
uint8_t num_mbsfn_sync_area;
uint8_t **MCCH_MESSAGE; // MAX_MBSFN_AREA
uint8_t sizeof_MCCH_MESSAGE[8];// MAX_MBSFN_AREA
MCCH_Message_t mcch;
MBSFNAreaConfiguration_r9_t *mcch_message;
SRB_INFO MCCH_MESS[8];// MAX_MBSFN_AREA
#endif
SRB_INFO SI;
SRB_INFO Srb0;
uint8_t *paging[NUMBER_OF_UE_MAX];
uint32_t sizeof_paging[NUMBER_OF_UE_MAX];
} rrc_eNB_carrier_data_t;
#define MAX_UE_CAPABILITY_SIZE 255
typedef struct OAI_UECapability_s {
uint8_t sdu[MAX_UE_CAPABILITY_SIZE];
uint8_t sdu_size;
UE_EUTRA_Capability_t *UE_EUTRA_Capability;
} OAI_UECapability_t;
typedef struct NR_UE_RRC_INST_s {
nr_rrc_state_t rrc_state;
......@@ -502,20 +148,12 @@ typedef struct NR_UE_RRC_INST_s {
e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
#endif
MeasConfig_t meas_config;
CellGroupConfig_t cell_group_config;
RadioBearerConfig_t radio_bearer_config;
MeasConfig_t *meas_config;
CellGroupConfig_t *cell_group_config;
RadioBearerConfig_t *radio_bearer_config;
} NR_UE_RRC_INST_t;
typedef struct UE_PF_PO_s {
boolean_t enable_flag; /* flag indicate whether current object is used */
uint16_t ue_index_value; /* UE index value */
uint8_t PF_min; /* minimal value of Paging Frame (PF) */
uint8_t PO; /* Paging Occasion (PO) */
uint32_t T; /* DRX cycle */
} UE_PF_PO_t;
#include "proto.h"
#endif
......
......@@ -143,29 +143,7 @@ uint8_t nr_rrc_ue_decode_dcch(
}
// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
// TODO check to use this or downer one
uint8_t nr_rrc_ue_decode_rrcReconfiguration(
const uint8_t *buffer,
const uint32_t size
){
RRCReconfiguration_t *rrcReconfiguration;
// decoding
uper_decode(NULL,
&asn_DEF_RRCReconfiguration,
(void **)&rrcReconfiguration,
(uint8_t *)buffer,
size);
nr_rrc_ue_process_rrcReconfiguration(rrcReconfiguration); // after decoder
free(rrcReconfiguration);
}
// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
// TODO check to use this or upper one
uint8_t nr_rrc_ue_decode_secondary_cellgroup_config(
const uint8_t *buffer,
const uint32_t size
......@@ -178,9 +156,15 @@ uint8_t nr_rrc_ue_decode_secondary_cellgroup_config(
(uint8_t *)buffer,
size, 0, 0);
nr_rrc_ue_process_scg_config(cellGroupConfig);
if(NR_UE_rrc_inst->cell_group_config == (CellGroupConfig_t *)0){
NR_UE_rrc_inst->cell_group_config = cellGroupConfig;
nr_rrc_ue_process_scg_config(cellGroupConfig);
}else{
nr_rrc_ue_process_scg_config(cellGroupConfig);
asn_DEF_CellGroupConfig.free_struct(asn_DEF_CellGroupConfig, cellGroupConfig, 0);
}
free(cellGroupConfig);
nr_rrc_mac_config_req_ue();
}
......@@ -191,25 +175,41 @@ uint8_t nr_rrc_ue_process_rrcReconfiguration(RRCReconfiguration_t *rrcReconfigur
switch(rrcReconfiguration.criticalExtensions.present){
case RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration:
if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->radioBearerConfig != (RadioBearerConfig_t *)0){
nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->radioBearerConfig);
if(NR_UE_rrc_inst->radio_bearer_config == (RadioBearerConfig_t *)0){
NR_UE_rrc_inst->radio_bearer_config = rrcReconfiguration->radioBearerConfig;
}else{
nr_rrc_ue_process_radio_bearer_config(rrcReconfiguration->radioBearerConfig);
}
}
if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->secondaryCellGroup != (OCTET_STRING_t *)0){
CellGroupConfig_t *cellGroupConfig = (CellGroupConfig_t *)0;
// TODO check if this deocder is need for decode "SecondaryCellGroup" of use type "CellGroupConfig" directly
uper_decode(NULL,
&asn_DEF_CellGroupConfig, //might be added prefix later
(void **)&cellGroupConfig,
(uint8_t *)rrcReconfiguration->secondaryCellGroup->buffer,
rrcReconfiguration->secondaryCellGroup.size, 0, 0);
nr_rrc_ue_process_scg_config(cellGroupConfig);
free(cellGroupConfig);
if(NR_UE_rrc_inst->cell_group_config == (CellGroupConfig_t *)0){
// first time receive the configuration, just use the memory allocated from uper_decoder. TODO this is not good implementation, need to maintain RRC_INST own structure every time.
NR_UE_rrc_inst->cell_group_config = cellGroupConfig;
nr_rrc_ue_process_scg_config(cellGroupConfig);
}else{
// after first time, update it and free the memory after.
nr_rrc_ue_process_scg_config(cellGroupConfig);
asn_DEF_CellGroupConfig.free_struct(asn_DEF_CellGroupConfig, cellGroupConfig, 0);
}
}
if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->measConfig != (MeasConfig *)0){
nr_rrc_ue_process_meas_config(rrcReconfiguration.criticalExtensions.rrcReconfiguration->measConfig);
if(NR_UE_rrc_inst->meas_config == (MeasConfig_t *)0){
NR_UE_rrc_inst->meas_config = rrcReconfiguration->measConfig;
}else{
// if some element need to be updated
nr_rrc_ue_process_meas_config(rrcReconfiguration->measConfig);
}
}
if(rrcReconfiguration.criticalExtensions.rrcReconfiguration->lateNonCriticalExtension != (OCTET_STRING_t *)0){
......@@ -225,39 +225,18 @@ uint8_t nr_rrc_ue_process_rrcReconfiguration(RRCReconfiguration_t *rrcReconfigur
default:
break;
}
// process
nr_rrc_mac_config_req_ue();
}
uint8_t nr_rrc_ue_process_meas_config(MeasConfig_t *meas_config){
// copy into nr_rrc inst
memcpy( (void *)NR_UE_rrc_inst->measConfig,
(void *)meas_config,
sizeof(MeasConfig_t));
// process it
}
uint8_t nr_rrc_ue_process_scg_config(CellGroupConfig_t *cell_group_config){
// copy into nr_rrc inst
nr_ue_process_rlc_bearer_list();
nr_ue_process_mac_cell_group_config();
nr_ue_process_physical_cell_group_config();
nr_ue_process_spcell_config();
nr_ue_process_spcell_list();
memcpy( (void *)NR_UE_rrc_inst->cellGroupConfig,
(void *)cellGroupConfig,
sizeof(cellGroupConfig_t));
// process it
}
uint8_t nr_rrc_ue_process_radio_bearer_config(RadioBearerConfig_t *radio_bearer_config){
// copy into nr_rrc inst
memcpy( (void *)NR_UE_rrc_inst->radioBearerConfig,
(void *)radio_bearer_config,
sizeof(RadioBearerConfig_t));
// process it
}
......@@ -276,19 +255,22 @@ uint8_t openair_rrc_top_init_ue_nr(void){
}
uint8_t nr_ue_process_rlc_bearer_list(){
};
uint8_t nr_ue_process_rlc_bearer_list(CellGroupConfig_t *cell_group_config){
uint8_t nr_ue_process_mac_cell_group_config(){
};
uint8_t nr_ue_process_physical_cell_group_config(){
uint8_t nr_ue_process_secondary_cell_list(CellGroupConfig_t *cell_group_config){
};
uint8_t nr_ue_process_spcell_config(){
uint8_t nr_ue_process_mac_cell_group_config(MAC_CellGroupConfig_t *mac_cell_group_config){
};
uint8_t nr_ue_process_spcell_list(){
uint8_t nr_ue_process_physical_cell_group_config(PhysicalCellGroupConfig_t *phy_cell_group_config){
};
uint8_t nr_ue_process_spcell_config(SpCellConfig_t *spcell_config){
};
......@@ -37,212 +37,5 @@
#include "COMMON/mac_rrc_primitives.h"
#include "LAYER2/MAC/defs.h"
UE_PF_PO_t UE_PF_PO[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
pthread_mutex_t ue_pf_po_mutex;
NR_UE_RRC_INST_t *NR_UE_rrc_inst;
#include "LAYER2/MAC/extern.h"
#define MAX_U32 0xFFFFFFFF
uint8_t DRB2LCHAN[8];
long logicalChannelGroup0 = 0;
long logicalChannelSR_Mask_r9=0;
struct LogicalChannelConfig__ul_SpecificParameters LCSRB1 = {1,
LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity,
0,
&logicalChannelGroup0
};
struct LogicalChannelConfig__ul_SpecificParameters LCSRB2 = {3,
LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity,
0,
&logicalChannelGroup0
};
#if defined(Rel10) || defined(Rel14)
struct LogicalChannelConfig__ext1 logicalChannelSR_Mask_r9_ext1 = {
logicalChannelSR_Mask_r9: &logicalChannelSR_Mask_r9
};
#endif
// These are the default SRB configurations from 36.331 (Chapter 9, p. 176-179 in v8.6)
LogicalChannelConfig_t SRB1_logicalChannelConfig_defaultValue = {ul_SpecificParameters: &LCSRB1
#if defined(Rel10) || defined(Rel14)
,
ext1: &logicalChannelSR_Mask_r9_ext1
#endif
};
LogicalChannelConfig_t SRB2_logicalChannelConfig_defaultValue = {ul_SpecificParameters: &LCSRB2
#if defined(Rel10) || defined(Rel14)
,
ext1: &logicalChannelSR_Mask_r9_ext1
#endif
};
//CONSTANTS
rlc_info_t Rlc_info_um,Rlc_info_am_config;
uint16_t RACH_FREQ_ALLOC;
//uint8_t NB_RACH;
LCHAN_DESC BCCH_LCHAN_DESC,CCCH_LCHAN_DESC,DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC;
MAC_MEAS_T BCCH_MEAS_TRIGGER,CCCH_MEAS_TRIGGER,DCCH_MEAS_TRIGGER,DTCH_MEAS_TRIGGER;
MAC_AVG_T BCCH_MEAS_AVG, CCCH_MEAS_AVG,DCCH_MEAS_AVG, DTCH_MEAS_AVG;
// timers
uint16_t T300[8] = {100,200,300,400,600,1000,1500,2000};
uint16_t T310[8] = {0,50,100,200,500,1000,2000};
uint16_t N310[8] = {1,2,3,4,6,8,10,20};
uint16_t N311[8] = {1,2,3,4,6,8,10,20};
uint32_t T304[8] = {50,100,150,200,500,1000,2000,MAX_U32};
// TimeToTrigger enum mapping table (36.331 TimeToTrigger IE)
uint32_t timeToTrigger_ms[16] = {0,40,64,80,100,128,160,256,320,480,512,640,1024,1280,2560,5120};
/* 36.133 Section 9.1.4 RSRP Measurement Report Mapping, Table: 9.1.4-1 */
float RSRP_meas_mapping[98] = {
-140,
-139,
-138,
-137,
-136,
-135,
-134,
-133,
-132,
-131,
-130,
-129,
-128,
-127,
-126,
-125,
-124,
-123,
-122,
-121,
-120,
-119,
-118,
-117,
-116,
-115,
-114,
-113,
-112,
-111,
-110,
-109,
-108,
-107,
-106,
-105,
-104,
-103,
-102,
-101,
-100,
-99,
-98,
-97,
-96,
-95,
-94,
-93,
-92,
-91,
-90,
-89,
-88,
-87,
-86,
-85,
-84,
-83,
-82,
-81,
-80,
-79,
-78,
-77,
-76,
-75,
-74,
-73,
-72,
-71,
-70,
-69,
-68,
-67,
-66,
-65,
-64,
-63,
-62,
-61,
-60,
-59,
-58,
-57,
-56,
-55,
-54,
-53,
-52,
-51,
-50,
-49,
-48,
-47,
-46,
-45,
-44,
-43
};
float RSRQ_meas_mapping[35] = {
-19,
-18.5,
-18,
-17.5,
-17,
-16.5,
-16,
-15.5,
-15,
-14.5,
-14,
-13.5,
-13,
-12.5,
-12,
-11.5,
-11,
-10.5,
-10,
-9.5,
-9,
-8.5,
-8,
-7.5,
-7,
-6.5,
-6,
-5.5,
-5,
-4.5,
-4,
-3.5,
-3,
-2.5,
-2
};
// only used for RRC connection re-establishment procedure TS36.331 5.3.7
// [0]: current C-RNTI, [1]: prior C-RNTI
// insert one when eNB received RRCConnectionReestablishmentRequest message
// delete one when eNB received RRCConnectionReestablishmentComplete message
uint16_t reestablish_rnti_map[NUMBER_OF_UE_MAX][2] = {{0}};
#endif
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