Commit f18e4009 authored by nikaeinn's avatar nikaeinn

* merge/add handover procedure for the access stratum (enabled with the -H), status: experimental.

* fix a bug in BSR computation
* add a python script to launch meld if the diff3 in subvsersion/config file is set to the targets/SCRIPTS/svn-merge-meld.py
* pre-ci passed (100%) 


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4309 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 84fb51d8
......@@ -9,6 +9,7 @@
#include "RadioResourceConfigDedicated.h"
#include "TDD-Config.h"
#include "MBSFN-SubframeConfigList.h"
#include "MobilityControlInfo.h"
#else
/**
......@@ -121,6 +122,17 @@ void phy_config_sib2_ue(u8 Mod_id,u8 CH_index,
AdditionalSpectrumEmission_t *additionalSpectrumEmission,
struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList);
/*!
\fn phy_config_afterHO_ue
\brief Configure Common PHY parameters from mobilityControlInfo
@param Mod_id
@param eNB_index
@param mobilityControlInfo pointer to the mobility control information for handover
@param ho_failed flag to indicated whether the ho was successful or not
*/
void phy_config_afterHO_ue(u8 Mod_id,u8 eNB_index,
MobilityControlInfo_t *mobilityControlInfo,u8 ho_failed);
/*!
\fn void phy_config_sib2_eNB(u8 Mod_id,
RadioResourceConfigCommonSIB_t *radioResourceConfigCommon,
......
......@@ -428,6 +428,118 @@ void phy_config_dedicated_eNB_step2(PHY_VARS_eNB *phy_vars_eNB) {
}
}
/*
* Configures UE MAC and PHY with radioResourceCommon received in mobilityControlInfo IE during Handover
*/
void phy_config_afterHO_ue(u8 Mod_id,u8 eNB_id, MobilityControlInfo_t *mobilityControlInfo, u8 ho_failed) {
if(mobilityControlInfo!=NULL) {
RadioResourceConfigCommon_t *radioResourceConfigCommon = &mobilityControlInfo->radioResourceConfigCommon;
LOG_I(PHY,"radioResourceConfigCommon %p\n", radioResourceConfigCommon);
memcpy((void *)&PHY_vars_UE_g[Mod_id]->lte_frame_parms_before_ho,
(void *)&PHY_vars_UE_g[Mod_id]->lte_frame_parms,
sizeof(LTE_DL_FRAME_PARMS));
PHY_vars_UE_g[Mod_id]->ho_triggered = 1;
//PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH;
LTE_DL_FRAME_PARMS *lte_frame_parms = &PHY_vars_UE_g[Mod_id]->lte_frame_parms;
int N_ZC;
u8 prach_fmt;
int u;
LOG_I(PHY,"[UE%d] Frame %d: Handover triggered: Applying radioResourceConfigCommon from eNB %d\n",
Mod_id,PHY_vars_UE_g[Mod_id]->frame,eNB_id);
lte_frame_parms->prach_config_common.rootSequenceIndex =radioResourceConfigCommon->prach_Config.rootSequenceIndex;
lte_frame_parms->prach_config_common.prach_Config_enabled=1;
lte_frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex;
lte_frame_parms->prach_config_common.prach_ConfigInfo.highSpeedFlag =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->highSpeedFlag;
lte_frame_parms->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->zeroCorrelationZoneConfig;
lte_frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset =radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_FreqOffset;
prach_fmt = get_prach_fmt(radioResourceConfigCommon->prach_Config.prach_ConfigInfo->prach_ConfigIndex,lte_frame_parms->frame_type);
N_ZC = (prach_fmt <4)?839:139;
u = (prach_fmt < 4) ? prach_root_sequence_map0_3[lte_frame_parms->prach_config_common.rootSequenceIndex] :
prach_root_sequence_map4[lte_frame_parms->prach_config_common.rootSequenceIndex];
//compute_prach_seq(u,N_ZC, PHY_vars_UE_g[Mod_id]->X_u);
compute_prach_seq(&PHY_vars_UE_g[Mod_id]->lte_frame_parms.prach_config_common,
lte_frame_parms->frame_type,
PHY_vars_UE_g[Mod_id]->X_u);
lte_frame_parms->pucch_config_common.deltaPUCCH_Shift = 1+radioResourceConfigCommon->pucch_ConfigCommon->deltaPUCCH_Shift;
lte_frame_parms->pucch_config_common.nRB_CQI = radioResourceConfigCommon->pucch_ConfigCommon->nRB_CQI;
lte_frame_parms->pucch_config_common.nCS_AN = radioResourceConfigCommon->pucch_ConfigCommon->nCS_AN;
lte_frame_parms->pucch_config_common.n1PUCCH_AN = radioResourceConfigCommon->pucch_ConfigCommon->n1PUCCH_AN;
lte_frame_parms->pdsch_config_common.referenceSignalPower = radioResourceConfigCommon->pdsch_ConfigCommon->referenceSignalPower;
lte_frame_parms->pdsch_config_common.p_b = radioResourceConfigCommon->pdsch_ConfigCommon->p_b;
lte_frame_parms->pusch_config_common.n_SB = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB;
lte_frame_parms->pusch_config_common.hoppingMode = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode;
lte_frame_parms->pusch_config_common.pusch_HoppingOffset = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset;
lte_frame_parms->pusch_config_common.enable64QAM = radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM;
lte_frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled;
lte_frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH;
lte_frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled;
lte_frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift = radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift;
init_ul_hopping(lte_frame_parms);
lte_frame_parms->soundingrs_ul_config_common.enabled_flag = 0;
if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->present==SoundingRS_UL_ConfigCommon_PR_setup) {
lte_frame_parms->soundingrs_ul_config_common.enabled_flag = 1;
lte_frame_parms->soundingrs_ul_config_common.srs_BandwidthConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_BandwidthConfig;
lte_frame_parms->soundingrs_ul_config_common.srs_SubframeConfig = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_SubframeConfig;
lte_frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission = radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.ackNackSRS_SimultaneousTransmission;
if (radioResourceConfigCommon->soundingRS_UL_ConfigCommon->choice.setup.srs_MaxUpPts)
lte_frame_parms->soundingrs_ul_config_common.srs_MaxUpPts = 1;
else
lte_frame_parms->soundingrs_ul_config_common.srs_MaxUpPts = 0;
}
lte_frame_parms->ul_power_control_config_common.p0_NominalPUSCH = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUSCH;
lte_frame_parms->ul_power_control_config_common.alpha = radioResourceConfigCommon->uplinkPowerControlCommon->alpha;
lte_frame_parms->ul_power_control_config_common.p0_NominalPUCCH = radioResourceConfigCommon->uplinkPowerControlCommon->p0_NominalPUCCH;
lte_frame_parms->ul_power_control_config_common.deltaPreambleMsg3 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaPreambleMsg3;
lte_frame_parms->ul_power_control_config_common.deltaF_PUCCH_Format1 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1;
lte_frame_parms->ul_power_control_config_common.deltaF_PUCCH_Format1b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format1b;
lte_frame_parms->ul_power_control_config_common.deltaF_PUCCH_Format2 = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2;
lte_frame_parms->ul_power_control_config_common.deltaF_PUCCH_Format2a = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2a;
lte_frame_parms->ul_power_control_config_common.deltaF_PUCCH_Format2b = radioResourceConfigCommon->uplinkPowerControlCommon->deltaFList_PUCCH.deltaF_PUCCH_Format2b;
lte_frame_parms->maxHARQ_Msg3Tx = radioResourceConfigCommon->rach_ConfigCommon->maxHARQ_Msg3Tx;
// Now configure some of the Physical Channels
if (radioResourceConfigCommon->antennaInfoCommon)
lte_frame_parms->nb_antennas_tx = (1<<radioResourceConfigCommon->antennaInfoCommon->antennaPortsCount);
else
lte_frame_parms->nb_antennas_tx = 1;
//PHICH
if (radioResourceConfigCommon->antennaInfoCommon) {
lte_frame_parms->phich_config_common.phich_resource = radioResourceConfigCommon->phich_Config->phich_Resource;
lte_frame_parms->phich_config_common.phich_duration = radioResourceConfigCommon->phich_Config->phich_Duration;
}
//Target CellId
lte_frame_parms->Nid_cell = mobilityControlInfo->targetPhysCellId;
lte_frame_parms->nushift = lte_frame_parms->Nid_cell%6;
// PUCCH
init_ncs_cell(lte_frame_parms,PHY_vars_UE_g[Mod_id]->ncs_cell);
init_ul_hopping(lte_frame_parms);
// RNTI
PHY_vars_UE_g[Mod_id]->lte_ue_pdcch_vars[eNB_id]->crnti = mobilityControlInfo->newUE_Identity.buf[0]|(mobilityControlInfo->newUE_Identity.buf[1]<<8);
}
if(ho_failed) {
LOG_D(PHY,"[UE%d] Handover failed, triggering RACH procedure\n",Mod_id);
memcpy((void *)&PHY_vars_UE_g[Mod_id]->lte_frame_parms,(void *)&PHY_vars_UE_g[Mod_id]->lte_frame_parms_before_ho, sizeof(LTE_DL_FRAME_PARMS));
PHY_vars_UE_g[Mod_id]->UE_mode[eNB_id] = PRACH;
}
}
void phy_config_meas_ue(u8 Mod_id,u8 eNB_index,u8 n_adj_cells,unsigned int *adj_cell_id) {
......
......@@ -151,6 +151,13 @@ void lte_ue_measurements_emul(PHY_VARS_UE *phy_vars_ue,u8 last_slot,u8 eNB_id);
@returns Path loss in dB
*/
s16 get_PL(u8 Mod_id,u8 eNB_index);
u8 get_RSRP(u8 Mod_id,u8 eNB_index);
u8 get_RSRQ(u8 Mod_id,u8 eNB_index);
u8 get_n_adj_cells(u8 Mod_id);
s8 get_rx_total_gain_dB(u8 Mod_id);
s8 get_RSSI(u8 Mod_id);
s8 set_RSRP_filtered(u8 Mod_id,u8 eNB_index,float rsrp);
s8 set_RSRQ_filtered(u8 Mod_id,u8 eNB_index,float rstq);
//! Automatic gain control
void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue,
......
......@@ -68,6 +68,70 @@ s16 get_PL(u8 Mod_id,u8 eNB_index) {
phy_vars_ue->lte_frame_parms.pdsch_config_common.referenceSignalPower));
}
u8 get_n_adj_cells (u8 Mod_id){
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue)
return phy_vars_ue->PHY_measurements.n_adj_cells;
else
return 0;
}
s8 get_rx_total_gain_dB (u8 Mod_id){
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue)
return phy_vars_ue->rx_total_gain_dB;
else
return -1;
}
s8 get_RSSI (u8 Mod_id){
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue)
return phy_vars_ue->PHY_measurements.rssi;
else
return -1;
}
u8 get_RSRP(u8 Mod_id,u8 eNB_index) {
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue)
return phy_vars_ue->PHY_measurements.rsrp[eNB_index];
return 0;
}
u8 get_RSRQ(u8 Mod_id,u8 eNB_index) {
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue)
return phy_vars_ue->PHY_measurements.rsrq[eNB_index];
return 0;
}
s8 set_RSRP_filtered(u8 Mod_id,u8 eNB_index,float rsrp) {
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue){
phy_vars_ue->PHY_measurements.rsrp_filtered[eNB_index]=rsrp;
return 0;
}
LOG_W(PHY,"[UE%d] could not set the rsrp\n",Mod_id);
return -1;
}
s8 set_RSRQ_filtered(u8 Mod_id,u8 eNB_index,float rsrq) {
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
if (phy_vars_ue){
phy_vars_ue->PHY_measurements.rsrq_filtered[eNB_index]=rsrq;
return 0;
}
LOG_W(PHY,"[UE%d] could not set the rsrq\n",Mod_id);
return -1;
}
void ue_rrc_measurements(PHY_VARS_UE *phy_vars_ue,
u8 slot,
......@@ -202,21 +266,24 @@ void ue_rrc_measurements(PHY_VARS_UE *phy_vars_ue,
}
else { // Do abstraction of RSRP and RSRQ
phy_vars_ue->PHY_measurements.rssi = phy_vars_ue->PHY_measurements.rx_power_avg[0];
// dummay value for the moment
phy_vars_ue->PHY_measurements.rsrp[eNB_offset] = -93 ;
phy_vars_ue->PHY_measurements.rsrq[eNB_offset] = 3;
}
if (((phy_vars_ue->frame %10) == 0) && (slot == 1)) {
#ifdef DEBUG_MEAS
if (eNB_offset == 0)
if (eNB_offset == 0)
LOG_D(PHY,"[UE %d] Frame %d, slot %d RRC Measurements => rssi %3.1f dBm (digital: %3.1f dB)\n",phy_vars_ue->Mod_id,
phy_vars_ue->frame,slot,10*log10(phy_vars_ue->PHY_measurements.rssi)-phy_vars_ue->rx_total_gain_dB,
10*log10(phy_vars_ue->PHY_measurements.rssi));
LOG_D(PHY,"[UE %d] Frame %d, slot %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f (%3.1f) dBm, rsrq: %3.1f dB\n",
phy_vars_ue->Mod_id,
phy_vars_ue->frame,slot,eNB_offset,
(eNB_offset>0) ? phy_vars_ue->PHY_measurements.adj_cell_id[eNB_offset-1] : phy_vars_ue->lte_frame_parms.Nid_cell,
(dB_fixed_times10(phy_vars_ue->PHY_measurements.rsrp[eNB_offset])/10.0)-phy_vars_ue->rx_total_gain_dB-dB_fixed(phy_vars_ue->lte_frame_parms.N_RB_DL*12),
(10*log10(phy_vars_ue->PHY_measurements.rx_power_avg[0])/10.0)-phy_vars_ue->rx_total_gain_dB-dB_fixed(phy_vars_ue->lte_frame_parms.N_RB_DL*12),
(10*log10(phy_vars_ue->PHY_measurements.rsrq[eNB_offset]))-20);
LOG_D(PHY,"[UE %d] Frame %d, slot %d RRC Measurements (idx %d, Cell id %d) => rsrp: %3.1f (%3.1f) dBm, rsrq: %3.1f dB\n",
phy_vars_ue->Mod_id,
phy_vars_ue->frame,slot,eNB_offset,
(eNB_offset>0) ? phy_vars_ue->PHY_measurements.adj_cell_id[eNB_offset-1] : phy_vars_ue->lte_frame_parms.Nid_cell,
(dB_fixed_times10(phy_vars_ue->PHY_measurements.rsrp[eNB_offset])/10.0)-phy_vars_ue->rx_total_gain_dB-dB_fixed(phy_vars_ue->lte_frame_parms.N_RB_DL*12),
(10*log10(phy_vars_ue->PHY_measurements.rx_power_avg[0])/10.0)-phy_vars_ue->rx_total_gain_dB-dB_fixed(phy_vars_ue->lte_frame_parms.N_RB_DL*12),
(10*log10(phy_vars_ue->PHY_measurements.rsrq[eNB_offset]))-20);
#endif
......
......@@ -331,8 +331,11 @@ typedef struct
s8 tx_power_max_dBm;
u32 frame;
u8 n_connected_eNB;
u8 ho_initiated;
u8 ho_triggered;
PHY_MEASUREMENTS PHY_measurements; /// Measurement variables
LTE_DL_FRAME_PARMS lte_frame_parms;
LTE_DL_FRAME_PARMS lte_frame_parms_before_ho; // frame parame before ho used to recover if ho fails
LTE_UE_COMMON lte_ue_common_vars;
LTE_UE_PDSCH *lte_ue_pdsch_vars[NUMBER_OF_CONNECTED_eNB_MAX+1];
......
......@@ -350,6 +350,8 @@ typedef struct
unsigned int adj_cell_id[6];
int rsrq[7];
int rsrp[7];
float rsrp_filtered[7]; // after layer 3 filtering
float rsrq_filtered[7];
// common measurements
//! estimated noise power (linear)
unsigned int n0_power[NB_ANTENNAS_RX];
......
......@@ -401,6 +401,9 @@ s32 remove_ue(u16 rnti, PHY_VARS_eNB *phy_vars_eNB,u8 abstraction_flag);
void process_timing_advance(u8 Mod_id,s16 timing_advance);
void process_timing_advance_rar(PHY_VARS_UE *phy_vars_ue,u16 timing_advance);
unsigned int get_tx_amp(int gain_dBm, int gain_max_dBm);
void phy_reset_ue(u8 Mod_id,u8 eNB_index);
/** \brief This function retrives the resource (n1_pucch) corresponding to a PDSCH transmission in
subframe n-4 which is acknowledged in subframe n (for FDD) according to n1_pucch = Ncce + N1_pucch. For
......
......@@ -2829,9 +2829,11 @@ void phy_procedures_eNB_RX(unsigned char last_slot,PHY_VARS_eNB *phy_vars_eNB,u8
LOG_I(PHY,"[eNB] Frame %d, Subframe %d : ULSCH SDU (RX harq_pid %d) %d bytes:\n",phy_vars_eNB->frame,last_slot>>1,
harq_pid,phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->TBS>>3);
for (j=0;j<phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->TBS>>3;j++)
LOG_T(PHY,"%x.",phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->c[0][j]);
LOG_T(PHY,"\n");
if (phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->c[0]!=NULL){
for (j=0;j<phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->TBS>>3;j++)
LOG_T(PHY,"%x.",phy_vars_eNB->ulsch_eNB[i]->harq_processes[harq_pid]->c[0][j]);
LOG_T(PHY,"\n");
}
//dump_ulsch(phy_vars_eNB, last_slot>>1, i);
......
......@@ -248,6 +248,39 @@ void dump_dlsch_ra(PHY_VARS_UE *phy_vars_ue,u8 eNB_id,u8 subframe) {
}
#endif
void phy_reset_ue(u8 Mod_id,u8 eNB_index) {
// This flushes ALL DLSCH and ULSCH harq buffers of ALL connected eNBs...add the eNB_index later
// for more flexibility
u8 i,j,k;
PHY_VARS_UE *phy_vars_ue = PHY_vars_UE_g[Mod_id];
//[NUMBER_OF_CONNECTED_eNB_MAX][2];
for(i=0;i<NUMBER_OF_CONNECTED_eNB_MAX;i++) {
for(j=0;j<2;j++) {
//DL HARQ
if(phy_vars_ue->dlsch_ue[i][j]) {
for(k=0;k<NUMBER_OF_HARQ_PID_MAX && phy_vars_ue->dlsch_ue[i][j]->harq_processes[k];k++) {
phy_vars_ue->dlsch_ue[i][j]->harq_processes[k]->status = SCH_IDLE;
}
}
}
//UL HARQ
if(phy_vars_ue->ulsch_ue[i]) {
for(k=0;k<NUMBER_OF_HARQ_PID_MAX && phy_vars_ue->ulsch_ue[i]->harq_processes[k];k++) {
phy_vars_ue->ulsch_ue[i]->harq_processes[k]->status = SCH_IDLE;
//Set NDIs for all UL HARQs to 0
phy_vars_ue->ulsch_ue[i]->harq_processes[k]->Ndi = 0;
}
}
// flush Msg3 buffer
phy_vars_ue->ulsch_ue_Msg3_active[i] = 0;
}
}
void ra_failed(u8 Mod_id,u8 eNB_index) {
// if contention resolution fails, go back to PRACH
......@@ -3194,6 +3227,10 @@ int phy_procedures_RN_UE_RX(u8 last_slot, u8 next_slot, relaying_type_t r_type)
phy_vars_ue->UE_mode[eNB_id] = RESYNCH;
mac_xface->macphy_exit("Connection lost");
//exit(-1);
} else if (ret == PHY_HO_PRACH) {
LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n",
phy_vars_ue->Mod_id,phy_vars_ue->frame,next_slot>>1);
phy_vars_ue->UE_mode[eNB_id] = PRACH;
}
}
#endif
......
......@@ -81,7 +81,9 @@ result could be based on an event-driven measurement report.
typedef enum {
RRC_OK=0,
RRC_ConnSetup_failed,
RRC_PHY_RESYNCH
RRC_PHY_RESYNCH,
RRC_Handover_failed,
RRC_HO_STARTED
} RRC_status_t;
......
This diff is collapsed.
......@@ -59,6 +59,7 @@
#include "TDD-Config.h"
#include "RACH-ConfigCommon.h"
#include "MeasObjectToAddModList.h"
#include "MobilityControlInfo.h"
#ifdef Rel10
#include "MBSFN-AreaInfoList-r9.h"
#include "MBSFN-SubframeConfigList.h"
......@@ -139,7 +140,8 @@
typedef enum {
CONNECTION_OK=0,
CONNECTION_LOST,
PHY_RESYNCH
PHY_RESYNCH,
PHY_HO_PRACH
} UE_L2_STATE_t;
typedef struct {
......@@ -713,6 +715,8 @@ typedef struct{
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;
/// pointer to TDD Configuration (NULL for FDD)
......@@ -839,6 +843,7 @@ unsigned char generate_dlsch_header(unsigned char *mac_header,
@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
......@@ -855,6 +860,7 @@ int rrc_mac_config_req(u8 Mod_id,u8 eNB_flag,u8 UE_id,u8 eNB_index,
LogicalChannelConfig_t *logicalChannelConfig,
MeasGapConfig_t *measGapConfig,
TDD_Config_t *tdd_Config,
MobilityControlInfo_t *mobilityControlInfo,
u8 *SIwindowsize,
u16 *SIperiod,
ARFCN_ValueEUTRA_t *ul_CarrierFreq,
......@@ -985,11 +991,11 @@ s8 get_deltaP_rampup(u8 Mod_id);
//main.c
void chbch_phy_sync_success(u8 Mod_id,u32 frame,u8 CH_index);
void chbch_phy_sync_success(u8 Mod_id,u32 frame,u8 eNB_index);
void mrbch_phy_sync_failure(u8 Mod_id, u32 frame,u8 free_eNB_index);
int mac_top_init(int eMBMS_active, u8 cba_group_active);
int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active);
char layer2_init_UE(u8 Mod_id);
......@@ -1001,7 +1007,7 @@ int mac_init_global_param(void);
void mac_top_cleanup(void);
void mac_UE_out_of_sync_ind(u8 Mod_id,u32 frame, u16 CH_index);
void mac_UE_out_of_sync_ind(u8 Mod_id,u32 frame, u16 eNB_index);
// eNB functions
......@@ -1106,8 +1112,8 @@ void UpdateSBnumber(unsigned char Mod_id);
//end ALU's algo
void ue_mac_reset(u8 Mod_id,u8 eNB_index);
void ue_init_mac(u8 Mod_id);
void init_ue_sched_info(void);
void add_ue_ulsch_info(u8 Mod_id, u8 UE_id, u8 subframe,UE_ULSCH_STATUS status);
void add_ue_dlsch_info(u8 Mod_id, u8 UE_id, u8 subframe,UE_DLSCH_STATUS status);
......@@ -1270,9 +1276,8 @@ u8 *parse_ulsch_header(u8 *mac_header,
u16 tx_lenght);
int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_active);
int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_active, u8 HO_active);
int mac_init(void);
void ue_init_mac(void);
s8 add_new_ue(u8 Mod_id, u16 rnti);
s8 mac_remove_ue(u8 Mod_id, u8 UE_id);
......
......@@ -4296,6 +4296,12 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf
#endif
#ifdef CELLULAR
rrc_rx_tx(Mod_id, frame, 0, 0);
#else
// check HO
rrc_rx_tx(Mod_id,
frame,
1,
Mod_id);
#endif
#ifdef Rel10
......
......@@ -97,6 +97,9 @@ void mrbch_phy_sync_failure(u8 Mod_id, u32 frame, u8 free_eNB_index){//init as C
layer2_init_eNB(Mod_id, free_eNB_index);
openair_rrc_eNB_init(Mod_id);
}
char layer2_init_eNB(unsigned char Mod_id, unsigned char eNB_index){
......@@ -120,7 +123,7 @@ void mac_UE_out_of_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index){
/***********************************************************************/
int mac_top_init(int eMBMS_active, u8 cba_group_active){
int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active){
/***********************************************************************/
unsigned char Mod_id,i,j;
RA_TEMPLATE *RA_template;
......@@ -135,8 +138,11 @@ int mac_top_init(int eMBMS_active, u8 cba_group_active){
mac_xface->macphy_exit("[MAC][MAIN] not enough memory for UEs \n");
}
LOG_D(MAC,"[MAIN] ALLOCATE %d Bytes for %d UE_MAC_INST @ %p\n",NB_UE_INST*sizeof(UE_MAC_INST),NB_UE_INST,UE_mac_inst);
bzero(UE_mac_inst,NB_UE_INST*sizeof(UE_MAC_INST));
ue_init_mac();
for(i=0;i<NB_UE_INST; i++)
ue_init_mac(i);
}
else
UE_mac_inst = NULL;
......@@ -172,7 +178,7 @@ int mac_top_init(int eMBMS_active, u8 cba_group_active){
if (Is_rrc_registered == 1){
LOG_I(MAC,"[MAIN] calling RRC\n");
#ifndef CELLULAR //nothing to be done yet for cellular
openair_rrc_top_init(eMBMS_active, cba_group_active);
openair_rrc_top_init(eMBMS_active, cba_group_active,HO_active);
#endif
}
else {
......@@ -287,6 +293,7 @@ int mac_top_init(int eMBMS_active, u8 cba_group_active){
//ICIC init param
#ifdef ICIC
u8 SB_size;
SB_size=mac_xface->get_SB_size(mac_xface->lte_frame_parms->N_RB_DL);
srand (time(NULL));
......@@ -388,7 +395,7 @@ void mac_top_cleanup(void){
free( Mac_rlc_xface);
}
int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_active) {
int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_active, u8 HO_active) {
......@@ -447,6 +454,11 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_activ
mac_xface->get_ue_active_harq_pid = get_ue_active_harq_pid;
mac_xface->get_PL = get_PL;
mac_xface->get_RSRP = get_RSRP;
mac_xface->get_RSRQ = get_RSRQ;
mac_xface->get_RSSI = get_RSSI;
mac_xface->get_n_adj_cells = get_n_adj_cells;
mac_xface->get_rx_total_gain_dB = get_rx_total_gain_dB;
mac_xface->get_Po_NOMINAL_PUSCH = get_Po_NOMINAL_PUSCH;
mac_xface->get_num_prach_tdd = get_num_prach_tdd;
mac_xface->get_fid_prach_tdd = get_fid_prach_tdd;
......@@ -461,7 +473,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_activ
mac_xface->phy_config_sib2_eNB = phy_config_sib2_eNB;
mac_xface->phy_config_sib2_ue = phy_config_sib2_ue;
mac_xface->phy_config_afterHO_ue = phy_config_afterHO_ue;
#ifdef Rel10
mac_xface->phy_config_sib13_eNB = phy_config_sib13_eNB;
mac_xface->phy_config_sib13_ue = phy_config_sib13_ue;
......@@ -470,6 +482,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_activ
mac_xface->phy_config_cba_rnti = phy_config_cba_rnti ;
#endif
mac_xface->phy_config_meas_ue = phy_config_meas_ue;
mac_xface->phy_reset_ue = phy_reset_ue;
mac_xface->phy_config_dedicated_eNB = phy_config_dedicated_eNB;
mac_xface->phy_config_dedicated_ue = phy_config_dedicated_ue;
......@@ -481,7 +494,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_activ
mac_xface->get_PHR = get_PHR;
LOG_D(MAC,"[MAIN] ALL INIT OK\n");
mac_xface->macphy_init(eMBMS_active,cba_group_active);
mac_xface->macphy_init(eMBMS_active,cba_group_active,HO_active);
//Mac_rlc_xface->Is_cluster_head[0] = 1;
//Mac_rlc_xface->Is_cluster_head[1] = 0;
......
......@@ -89,43 +89,42 @@ mapping BSR_names[] = {
extern inline unsigned int taus(void);
void ue_init_mac(){
int i,j;
for (i=0 ; i < NB_UE_INST; i++){
// default values as deined in 36.331 sec 9.2.2
LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",i);
LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_UE][MOD %02d][]\n", i+NB_eNB_INST);
//UE_mac_inst[Mod_id].scheduling_info.macConfig=NULL;
UE_mac_inst[i].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560;
UE_mac_inst[i].scheduling_info.periodicBSR_Timer=MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity;
UE_mac_inst[i].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
UE_mac_inst[i].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
UE_mac_inst[i].scheduling_info.PathlossChange_db = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
UE_mac_inst[i].PHR_state = MAC_MainConfig__phr_Config_PR_setup;
UE_mac_inst[i].scheduling_info.SR_COUNTER=0;
UE_mac_inst[i].scheduling_info.sr_ProhibitTimer=0;
UE_mac_inst[i].scheduling_info.sr_ProhibitTimer_Running=0;
UE_mac_inst[i].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
UE_mac_inst[i].scheduling_info.ttiBundling=0;
UE_mac_inst[i].scheduling_info.drx_config=NULL;
UE_mac_inst[i].scheduling_info.phr_config=NULL;
UE_mac_inst[i].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[i].scheduling_info.periodicBSR_Timer);
UE_mac_inst[i].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[i].scheduling_info.retxBSR_Timer);
UE_mac_inst[i].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[i].scheduling_info.periodicPHR_Timer);
UE_mac_inst[i].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[i].scheduling_info.prohibitPHR_Timer);
UE_mac_inst[i].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[i].scheduling_info.PathlossChange);
for (j=0; j < MAX_NUM_LCID; j++){
LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",i,j);
UE_mac_inst[i].scheduling_info.Bj[j]=-1;
UE_mac_inst[i].scheduling_info.bucket_size[j]=-1;
if (j < DTCH) // initilize all control channels lcgid to 0
UE_mac_inst[i].scheduling_info.LCGID[j]=0;
else // initialize all the data channels lcgid to 1
UE_mac_inst[i].scheduling_info.LCGID[j]=1;
UE_mac_inst[i].scheduling_info.LCID_status[j]=0;
}
void ue_init_mac(u8 Mod_id){
int i;
// default values as deined in 36.331 sec 9.2.2
LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",Mod_id);
LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_UE][MOD %02d][]\n", Mod_id+NB_eNB_INST);
//UE_mac_inst[Mod_id].scheduling_info.macConfig=NULL;
UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560;
UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer=MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity;
UE_mac_inst[Mod_id].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
UE_mac_inst[Mod_id].scheduling_info.PathlossChange_db = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
UE_mac_inst[Mod_id].PHR_state = MAC_MainConfig__phr_Config_PR_setup;
UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER=0;
UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer=0;
UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer_Running=0;
UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
UE_mac_inst[Mod_id].scheduling_info.ttiBundling=0;
UE_mac_inst[Mod_id].scheduling_info.drx_config=NULL;
UE_mac_inst[Mod_id].scheduling_info.phr_config=NULL;
UE_mac_inst[Mod_id].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer);
UE_mac_inst[Mod_id].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer);
UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[Mod_id].scheduling_info.periodicPHR_Timer);
UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_Timer);
UE_mac_inst[Mod_id].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[Mod_id].scheduling_info.PathlossChange);
for (i=0; i < MAX_NUM_LCID; i++){
LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",Mod_id,i);
UE_mac_inst[Mod_id].scheduling_info.Bj[i]=-1;
UE_mac_inst[Mod_id].scheduling_info.bucket_size[i]=-1;
if (i < DTCH) // initilize all control channels lcgid to 0
UE_mac_inst[Mod_id].scheduling_info.LCGID[i]=0;
else // initialize all the data channels lcgid to 1
UE_mac_inst[Mod_id].scheduling_info.LCGID[i]=1;
UE_mac_inst[Mod_id].scheduling_info.LCID_status[i]=0;
}
}
......@@ -1366,6 +1365,15 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire
case RRC_PHY_RESYNCH:
LOG_E(MAC,"RRC Loss of synch, returning PHY_RESYNCH\n");
return(PHY_RESYNCH);
case RRC_Handover_failed:
LOG_D(MAC,"Handover failure for UE %d eNB_index %d\n",Mod_id,eNB_index);
//Invalid...need to add another MAC UE state for re-connection procedure
mac_xface->phy_config_afterHO_ue(Mod_id,eNB_index,(MobilityControlInfo_t *)NULL,1);
//return(3);
break;
case RRC_HO_STARTED:
LOG_I(MAC,"RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n");
return(PHY_HO_PRACH);
default:
break;
}
......@@ -1402,7 +1410,7 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire
// Put this in another function
// Get RLC status info and update Bj for all lcids that are active
for (lcid=CCCH; lcid <= DTCH; lcid++ ) {
for (lcid=DCCH; lcid <= DTCH; lcid++ ) {
if ((lcid == 0) ||(UE_mac_inst[Mod_id].logicalChannelConfig[lcid])) {
// meausre the Bj
if ((direction == SF_UL)&& (UE_mac_inst[Mod_id].scheduling_info.Bj[lcid] >= 0)){
......@@ -1573,9 +1581,11 @@ int update_bsr(u8 Mod_id, u32 frame, u8 lcid, u8 lcg_id){
u8 sr_pending = 0;
if ((lcg_id < 0) || (lcg_id > MAX_NUM_LCGID) )
return sr_pending;
UE_mac_inst[Mod_id].scheduling_info.BSR[lcg_id]=0;
UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcg_id]=0;
// fixme: need a better way to reset
if ((lcid == DCCH) || (lcid == DTCH)){
UE_mac_inst[Mod_id].scheduling_info.BSR[lcg_id]=0;
UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcg_id]=0;
}
// for (lcid =0 ; lcid < MAX_NUM_LCID; lcid++) {
if (UE_mac_inst[Mod_id].scheduling_info.LCGID[lcid] == lcg_id) {
rlc_status = mac_rlc_status_ind(Mod_id+NB_eNB_INST,frame,0,RLC_MBMS_NO,
......@@ -1587,13 +1597,13 @@ int update_bsr(u8 Mod_id, u32 frame, u8 lcid, u8 lcg_id){
UE_mac_inst[Mod_id].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer);
UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer;
// UE_mac_inst[Mod_id].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr